Reviewed-by: Xu Wang <cngesaint@outlook.com>


Fedora changed the default device naming scheme, see
  http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming

So if we're running on Fedora, let's "default" to "em1" although that
doesn't guarantee that we will find what we're looking for.

This code probably needs some mechanism to detect with interfaces are
available, then query those interfaces to find one that supports the
feature we want.
---
 .../27_definesystem_macvtap_dev.py                    | 19 ++++++++++++++++++-
 .../28_definesystem_with_vsi_profile.py               | 15 +++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
index 8c20781..36bf52f 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/27_definesystem_macvtap_dev.py
@@ -32,6 +32,7 @@
 import sys
 from CimTest.Globals import logger
 from CimTest.ReturnCodes import FAIL, PASS, SKIP
+from VirtLib import utils
 from XenKvmLib.classes import get_typed_class, inst_to_mof
 from XenKvmLib.rasd import get_default_rasds
 from XenKvmLib.const import do_main, get_provider_version
@@ -101,6 +102,7 @@ def verify_net_rasd(ip, virt, target_dev, source_dev, guest_name):
 @do_main(sup_types)
 def main():
     options = main.options
+    server = options.ip
 
     status = FAIL
 
@@ -113,7 +115,22 @@ def main():
     cxml = get_class(options.virt)(test_dom)
 
     target_dev = "vepa"
-    source_dev = "eth1"
+
+    # Fedora changed the default device naming scheme, see
+    #  http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
+    #
+    # So if we're running on Fedora, let's "default" to "em1" although that
+    # doesn't guarantee that we will find what we're looking for.  This code
+    # probably needs some mechanism to detect with interfaces are available,
+    # then query those interfaces to find one that supports the feature we
+    # want.  If not are found and XFAIL could be generated indicating so.
+    #
+    cmd = 'cat /etc/issue | grep -v ^$ | egrep "Fedora"'
+    rc, out = utils.run_remote(server, cmd)
+    if rc == 0:
+        source_dev = "em1"
+    else:
+        source_dev = "eth1"
 
     guest_defined = False
 
diff --git a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
index d14dda3..2b108f9 100644
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/28_definesystem_with_vsi_profile.py
@@ -35,6 +35,7 @@
 import sys
 from CimTest.Globals import logger
 from CimTest.ReturnCodes import FAIL, PASS, SKIP, XFAIL_RC, XFAIL
+from VirtLib import utils
 from XenKvmLib.classes import get_typed_class, inst_to_mof
 from XenKvmLib.rasd import get_default_rasds
 from XenKvmLib.const import do_main, get_provider_version
@@ -173,6 +174,20 @@ def main():
                      'VSITypeIDVersion' : "1"
                    } 
 
+    # Fedora changed the default device naming scheme, see
+    #  http://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
+    #
+    # So if we're running on Fedora, let's "default" to "em1" although that
+    # doesn't guarantee that we will find what we're looking for.  This code
+    # probably needs some mechanism to detect with interfaces are available,
+    # then query those interfaces to find one that supports the feature we
+    # want.  If not are found and XFAIL could be generated indicating so.
+    #
+    cmd = 'cat /etc/issue | grep -v ^$ | egrep "Fedora"'
+    rc, out = utils.run_remote(server, cmd)
+    if rc == 0:
+        vsi_defaults['SourceDevice'] = "em1"
+
     nrasd_cn = get_typed_class(virt, 'NetResourceAllocationSettingData')
     status  = FAIL
     cxml = None
-- 
1.8.1.4