summaryrefslogtreecommitdiffstats
path: root/src/software
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-07-06 21:17:35 +0200
committerMichal Minar <miminar@redhat.com>2013-07-23 13:52:34 +0200
commit0bc47663c050267d396472216b4b7ae53f840a9e (patch)
tree9396e894260aad4c5e8520c1acffdffb4f54d408 /src/software
parent3709d0107651af42a1e81505ed47244bb75033ae (diff)
downloadopenlmi-providers-0bc47663c050267d396472216b4b7ae53f840a9e.tar.gz
openlmi-providers-0bc47663c050267d396472216b4b7ae53f840a9e.tar.xz
openlmi-providers-0bc47663c050267d396472216b4b7ae53f840a9e.zip
software: be more tolerant when checking SystemName
Allow hostname aliases and fully qualified domain names in properties like SystemName. Modified tests accordingly.
Diffstat (limited to 'src/software')
-rw-r--r--src/software/lmi/software/core/ComputerSystem.py6
-rw-r--r--src/software/lmi/software/core/IdentityResource.py2
-rw-r--r--src/software/lmi/software/util/__init__.py11
-rwxr-xr-xsrc/software/test/test_hosted_software_collection.py2
-rwxr-xr-xsrc/software/test/test_hosted_software_identity_resource.py4
-rwxr-xr-xsrc/software/test/test_installed_software_identity.py2
-rwxr-xr-xsrc/software/test/test_resource_for_software_identity.py2
-rwxr-xr-xsrc/software/test/test_software_identity_file_check.py2
-rwxr-xr-xsrc/software/test/test_software_identity_resource.py2
9 files changed, 22 insertions, 11 deletions
diff --git a/src/software/lmi/software/core/ComputerSystem.py b/src/software/lmi/software/core/ComputerSystem.py
index fe341d7..22b66c7 100644
--- a/src/software/lmi/software/core/ComputerSystem.py
+++ b/src/software/lmi/software/core/ComputerSystem.py
@@ -69,10 +69,10 @@ def check_path(env, system, prop_name):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
"CreationClassName of \"%s\" must be a sublass of %s" % (
prop_name, our_system.classname))
- if system['Name'] != our_system['Name']:
+ if not util.is_this_system(system['Name']):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
- "Name of \"%s\" does not match \"%s\"" %
- prop_name, our_system['Name'])
+ "Name of \"%s\" does not match \"%s\"" % (
+ prop_name, our_system['Name']))
return True
@cmpi_logging.trace_function
diff --git a/src/software/lmi/software/core/IdentityResource.py b/src/software/lmi/software/core/IdentityResource.py
index 392dac7..cd7e481 100644
--- a/src/software/lmi/software/core/IdentityResource.py
+++ b/src/software/lmi/software/core/IdentityResource.py
@@ -517,7 +517,7 @@ def object_path2repo(env, op, kind='enabled'):
or not op["SystemCreationClassName"])
or (not "SystemName" in op or not op["SystemName"])):
raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, "Wrong keys.")
- if op["SystemName"] != util.Configuration().system_name:
+ if not util.is_this_system(op["SystemName"]):
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
'SystemName "%s" does not match "%s".' % (
op["SystemName"],
diff --git a/src/software/lmi/software/util/__init__.py b/src/software/lmi/software/util/__init__.py
index fad9bcd..43fd4ba 100644
--- a/src/software/lmi/software/util/__init__.py
+++ b/src/software/lmi/software/util/__init__.py
@@ -27,6 +27,8 @@ import platform
import pywbem
import re
import signal
+import socket
+
from lmi.software.util.SoftwareConfiguration \
import SoftwareConfiguration as Configuration
@@ -188,3 +190,12 @@ def new_instance_name(class_name, namespace=None, **kwargs):
host=Configuration.get_instance().system_name,
namespace=namespace,
keybindings=keybindings)
+
+def is_this_system(system_name):
+ """
+ Return True if given system_name matches the hostname of currently
+ running system.
+ """
+ return ( socket.gethostbyaddr(system_name)[0]
+ == socket.gethostbyaddr(
+ Configuration.get_instance().system_name)[0])
diff --git a/src/software/test/test_hosted_software_collection.py b/src/software/test/test_hosted_software_collection.py
index c260210..51abc9d 100755
--- a/src/software/test/test_hosted_software_collection.py
+++ b/src/software/test/test_hosted_software_collection.py
@@ -51,7 +51,7 @@ class TestHostedSoftwareCollection(base.SoftwareBaseTestCase):
namespace="root/cimv2",
keybindings=pywbem.NocaseDict({
"CreationClassName" : "Linux_ComputerSystem",
- "Name" : socket.gethostname()
+ "Name" : socket.getfqdn()
}))
objpath["Dependent"] = pywbem.CIMInstanceName(
classname="LMI_SystemSoftwareCollection",
diff --git a/src/software/test/test_hosted_software_identity_resource.py b/src/software/test/test_hosted_software_identity_resource.py
index 6a60e61..b931b31 100755
--- a/src/software/test/test_hosted_software_identity_resource.py
+++ b/src/software/test/test_hosted_software_identity_resource.py
@@ -54,7 +54,7 @@ class TestHostedSoftwareIdentityResource(base.SoftwareBaseTestCase):
namespace="root/cimv2",
keybindings=pywbem.NocaseDict({
"CreationClassName" : "Linux_ComputerSystem",
- "Name" : socket.gethostname()
+ "Name" : socket.getfqdn()
}))
objpath["Dependent"] = pywbem.CIMInstanceName(
classname="LMI_SoftwareIdentityResource",
@@ -62,7 +62,7 @@ class TestHostedSoftwareIdentityResource(base.SoftwareBaseTestCase):
keybindings=pywbem.NocaseDict({
"CreationClassName" : "LMI_SoftwareIdentityResource",
"SystemCreationClassName" : "Linux_ComputerSystem",
- "SystemName" : socket.gethostname(),
+ "SystemName" : socket.getfqdn(),
"Name" : repo.repoid
}))
return objpath
diff --git a/src/software/test/test_installed_software_identity.py b/src/software/test/test_installed_software_identity.py
index bf8fe2c..1a038c3 100755
--- a/src/software/test/test_installed_software_identity.py
+++ b/src/software/test/test_installed_software_identity.py
@@ -47,7 +47,7 @@ class TestInstalledSoftwareIdentity(base.SoftwareBaseTestCase):
namespace="root/cimv2",
keybindings=pywbem.NocaseDict({
"CreationClassName" : "Linux_ComputerSystem",
- "Name" : socket.gethostname()
+ "Name" : socket.getfqdn()
}))
objpath["InstalledSoftware"] = pywbem.CIMInstanceName(
classname="LMI_SoftwareIdentity",
diff --git a/src/software/test/test_resource_for_software_identity.py b/src/software/test/test_resource_for_software_identity.py
index d38da46..a9c2cf6 100755
--- a/src/software/test/test_resource_for_software_identity.py
+++ b/src/software/test/test_resource_for_software_identity.py
@@ -51,7 +51,7 @@ class TestResourceForSoftwareIdentity(base.SoftwareBaseTestCase):
keybindings=pywbem.NocaseDict({
"CreationClassName" : "LMI_SoftwareIdentityResource",
"SystemCreationClassName" : "Linux_ComputerSystem",
- "SystemName" : socket.gethostname()
+ "SystemName" : socket.getfqdn()
}))
if repo is not None:
objpath["AvailableSAP"]["Name"] = repo.repoid
diff --git a/src/software/test/test_software_identity_file_check.py b/src/software/test/test_software_identity_file_check.py
index 69c942a..027e17f 100755
--- a/src/software/test/test_software_identity_file_check.py
+++ b/src/software/test/test_software_identity_file_check.py
@@ -373,7 +373,7 @@ class TestSoftwareIdentityFileCheck(
classname="Linux_ComputerSystem",
keybindings=pywbem.NocaseDict({
"CreationClassName" : "Linux_ComputerSystem",
- "Name" : socket.gethostname()})))
+ "Name" : socket.getfqdn()})))
self.assertEqual(pywbem.Uint32(0), #Satisfied
rval, msg="InvokeOnSystem method should be successful"
diff --git a/src/software/test/test_software_identity_resource.py b/src/software/test/test_software_identity_resource.py
index ecdc263..5d4b5ab 100755
--- a/src/software/test/test_software_identity_resource.py
+++ b/src/software/test/test_software_identity_resource.py
@@ -61,7 +61,7 @@ class TestSoftwareIdentityResource(
repo = repo.repoid
objpath = self.objpath.copy()
objpath["Name"] = repo
- objpath["SystemName"] = socket.gethostname()
+ objpath["SystemName"] = socket.getfqdn()
return objpath
def tearDown(self):