[Libvirt-cim] [PATCH 1/3] live.full_hostname: Adjust mechanism to get FQDN

John Ferlan jferlan at redhat.com
Tue May 20 18:26:26 UTC 2014


Use socket.getfqdn() rather than socket.gethostbyaddr(socket.gethostname())[0]
to return the fully qualified domain name. Also, since the input parameter
'server' was never used - just remove it

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 lib/VirtLib/live.py                                            | 6 +++---
 suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py | 2 +-
 suites/libvirt-cim/cimtest/HostSystem/01_enum.py               | 4 ++--
 suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py   | 2 +-
 suites/libvirt-cim/lib/XenKvmLib/vxml.py                       | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lib/VirtLib/live.py b/lib/VirtLib/live.py
index c929e71..45a6713 100644
--- a/lib/VirtLib/live.py
+++ b/lib/VirtLib/live.py
@@ -99,7 +99,7 @@ def hostname(server):
 
     return out
 
-def full_hostname(server):
-    """To return the fully qualifiec domain name(FQDN) of the system"""
+def full_hostname():
+    """To return the fully qualified domain name(FQDN) of the system"""
 
-    return socket.gethostbyaddr(socket.gethostname())[0]
+    return socket.getfqdn()
diff --git a/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py b/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
index fa92176..b724815 100644
--- a/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
+++ b/suites/libvirt-cim/cimtest/ElementConforms/04_ectp_rev_errs.py
@@ -155,7 +155,7 @@ def main():
 
     hs = get_typed_class(options.virt, "HostSystem")
     cs = get_typed_class(options.virt, "ComputerSystem")
-    host_name = full_hostname(options.ip)
+    host_name = full_hostname()
     host_name_val = [
                         'CreationClassName', hs,
                         'Name',              host_name
diff --git a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
index fd44b8b..75d6f5d 100644
--- a/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
+++ b/suites/libvirt-cim/cimtest/HostSystem/01_enum.py
@@ -40,8 +40,8 @@ SUPPORTED_TYPES = ['Xen', 'KVM', 'XenFV', 'LXC']
 @do_main(SUPPORTED_TYPES)
 def main():
     options = main.options
-    host = full_hostname(options.ip) 
-   
+    host = full_hostname()
+
     status = FAIL
     keys = ['Name', 'CreationClassName']
     name = get_typed_class(options.virt, 'HostSystem')
diff --git a/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py b/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py
index f960911..8bbe8c1 100644
--- a/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py
+++ b/suites/libvirt-cim/cimtest/HostSystem/03_hs_to_settdefcap.py
@@ -100,7 +100,7 @@ def get_inst_from_list(cn, qcn, list, filter, exp_val):
 
 def get_hostsys(server, virt="Xen"):
     status = PASS 
-    host = full_hostname(server)
+    host = full_hostname()
 
     try:
         status, host_inst = get_host_info(server, virt)
diff --git a/suites/libvirt-cim/lib/XenKvmLib/vxml.py b/suites/libvirt-cim/lib/XenKvmLib/vxml.py
index 3bea13c..c38b4dd 100644
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py
@@ -1109,7 +1109,7 @@ def get_class(virt):
 
 def set_default(server):
     dict = {}
-    dict['default_sysname'] = live.full_hostname(server)
+    dict['default_sysname'] = live.full_hostname()
     dict['default_port'] = CIM_PORT
     dict['default_url'] = "%s:%s" % (dict['default_sysname'],
                                      dict['default_port'])
-- 
1.9.0




More information about the Libvirt-cim mailing list