diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-10-02 12:36:43 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-10-02 13:26:23 +0200 |
commit | 4460e06726d069d4db7dd35a557be911864a4823 (patch) | |
tree | fbd6ea2a285eaa3478f51f0f7d3707fc9406e5ac /src/logicalfile | |
parent | 97057c2681746ad93c3627c5eedc8385c162c032 (diff) | |
download | openlmi-providers-4460e06726d069d4db7dd35a557be911864a4823.tar.gz openlmi-providers-4460e06726d069d4db7dd35a557be911864a4823.tar.xz openlmi-providers-4460e06726d069d4db7dd35a557be911864a4823.zip |
logicalfile: correctly ignore creation class name
Diffstat (limited to 'src/logicalfile')
-rw-r--r-- | src/logicalfile/LMI_DirectoryContainsFileProvider.c | 16 | ||||
-rw-r--r-- | src/logicalfile/LMI_FileIdentityProvider.c | 50 | ||||
-rw-r--r-- | src/logicalfile/LMI_RootDirectoryProvider.c | 3 | ||||
-rw-r--r-- | src/logicalfile/test/test_basic.py | 9 |
4 files changed, 36 insertions, 42 deletions
diff --git a/src/logicalfile/LMI_DirectoryContainsFileProvider.c b/src/logicalfile/LMI_DirectoryContainsFileProvider.c index 1be5eb2..20f2376 100644 --- a/src/logicalfile/LMI_DirectoryContainsFileProvider.c +++ b/src/logicalfile/LMI_DirectoryContainsFileProvider.c @@ -133,6 +133,9 @@ static CMPIStatus associators( CMPIInstance *ci; CMPIStatus st; const char *ns = KNameSpace(cop); + const char *path; + CMPIObjectPath *refs[MAX_REFS]; + unsigned int count = 0; int group = -1; int rgroup = -1; @@ -167,10 +170,7 @@ static CMPIStatus associators( CMReturn(CMPI_RC_OK); } - const char *path = get_string_property_from_op(cop, "Name"); - - CMPIObjectPath *refs[MAX_REFS]; - unsigned int count = 0; + path = get_string_property_from_op(cop, "Name"); if (CMClassPathIsA(_cb, cop, LMI_UnixDirectory_ClassName, &st)) { /* got UnixDirectory - GroupComponent */ @@ -241,6 +241,9 @@ static CMPIStatus references( LMI_DirectoryContainsFile lmi_dcf; CMPIStatus st; const char *ns = KNameSpace(cop); + const char *path; + char *fsname; + char ccname[BUFLEN]; /* GroupComponent */ CIM_DirectoryRef lmi_dr; @@ -268,9 +271,8 @@ static CMPIStatus references( CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns); LMI_DirectoryContainsFile_Init(&lmi_dcf, _cb, ns); - const char *ccname = get_string_property_from_op(cop, "CreationClassName"); - const char *path = get_string_property_from_op(cop, "Name"); - char *fsname; + path = get_string_property_from_op(cop, "Name"); + get_class_from_path(path, ccname); st = get_fsname_from_path(_cb, path, &fsname); check_status(st); diff --git a/src/logicalfile/LMI_FileIdentityProvider.c b/src/logicalfile/LMI_FileIdentityProvider.c index 4d85f3c..cf47d17 100644 --- a/src/logicalfile/LMI_FileIdentityProvider.c +++ b/src/logicalfile/LMI_FileIdentityProvider.c @@ -43,6 +43,7 @@ static CMPIStatus associators( CMPIInstance *ci; CMPIObjectPath *o; const char *ns = KNameSpace(cop); + const char *path; char fileclass[BUFLEN]; char *fsname; @@ -52,14 +53,14 @@ static CMPIStatus associators( if (CMClassPathIsA(_cb, cop, LMI_UnixFile_ClassName, &st)) { /* got UnixFile - SameElement */ st = lmi_check_required(_cb, cop); - if (st.rc != CMPI_RC_OK) { - return st; - } + check_status(st); - const char *path = get_string_property_from_op(cop, "LFName"); - const char *ccname = get_string_property_from_op(cop, "LFCreationClassName"); + path = get_string_property_from_op(cop, "LFName"); + get_class_from_path(path, fileclass); + st = get_fsname_from_path(_cb, path, &fsname); + check_status(st); - st = check_assoc_class(_cb, ns, resultClass, ccname); + st = check_assoc_class(_cb, ns, resultClass, fileclass); check_class_check_status(st); if (role && strcmp(role, SAME_ELEMENT) != 0) { CMReturn(CMPI_RC_OK); @@ -68,23 +69,17 @@ static CMPIStatus associators( CMReturn(CMPI_RC_OK); } - get_class_from_path(path, fileclass); - st = get_fsname_from_path(_cb, path, &fsname); - check_status(st); - CIM_LogicalFileRef cim_lfr; CIM_LogicalFileRef_Init(&cim_lfr, _cb, ns); - fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, fsname, ccname); + fill_logicalfile(CIM_LogicalFileRef, &cim_lfr, path, fsname, fileclass); o = CIM_LogicalFileRef_ToObjectPath(&cim_lfr, &st); CMSetClassName(o, fileclass); } else { /* got LogicalFile - SystemElement */ st = lmi_check_required(_cb, cop); - if (st.rc != CMPI_RC_OK) { - return st; - } + check_status(st); - const char *path = get_string_property_from_op(cop, "Name"); + path = get_string_property_from_op(cop, "Name"); st = check_assoc_class(_cb, ns, resultClass, LMI_UnixFile_ClassName); check_class_check_status(st); @@ -135,6 +130,7 @@ static CMPIStatus references( const char *ns = KNameSpace(cop); CMPIInstance *ci; CMPIObjectPath *o; + const char *path; char fileclass[BUFLEN]; char *fsname; @@ -152,27 +148,20 @@ static CMPIStatus references( return st; } - const char *path = get_string_property_from_op(cop, "LFName"); - const char *ccname = get_string_property_from_op(cop, "LFCreationClassName"); - - if (role && strcmp(role, SAME_ELEMENT) != 0) { - CMReturn(CMPI_RC_OK); - } - + path = get_string_property_from_op(cop, "LFName"); get_class_from_path(path, fileclass); st = get_fsname_from_path(_cb, path, &fsname); check_status(st); - /* TODO is this error necessary? */ - if (strcmp(fileclass, ccname) != 0) { - CMReturnWithChars(_cb, CMPI_RC_ERR_NOT_FOUND, - "LFCreationClassName is not correct"); + if (role && strcmp(role, SAME_ELEMENT) != 0) { + CMReturn(CMPI_RC_OK); } /* SystemElement */ CIM_LogicalFileRef lmi_lfr; CIM_LogicalFileRef_Init(&lmi_lfr, _cb, ns); - fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsname, ccname); + fill_logicalfile(CIM_LogicalFileRef, &lmi_lfr, path, fsname, fileclass); + o = CIM_LogicalFileRef_ToObjectPath(&lmi_lfr, &st); CMSetClassName(o, fileclass); LMI_FileIdentity_SetObjectPath_SystemElement(&lmi_fi, o); @@ -185,12 +174,11 @@ static CMPIStatus references( return st; } - const char *path = get_string_property_from_op(cop, "Name"); - const char *ccname = get_string_property_from_op(cop, "CreationClassName"); - if (role && strcmp(role, SYSTEM_ELEMENT) != 0) { CMReturn(CMPI_RC_OK); } + path = get_string_property_from_op(cop, "Name"); + get_class_from_path(path, fileclass); st = get_fsname_from_path(_cb, path, &fsname); check_status(st); @@ -202,7 +190,7 @@ static CMPIStatus references( LMI_UnixFile_Set_CSName(&lmi_uf, get_system_name()); LMI_UnixFile_Set_FSCreationClassName(&lmi_uf, FSCREATIONCLASSNAME); LMI_UnixFile_Set_FSName(&lmi_uf, fsname); - LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, ccname); + LMI_UnixFile_Set_LFCreationClassName(&lmi_uf, fileclass); o = LMI_UnixFile_ToObjectPath(&lmi_uf, &st); LMI_FileIdentity_SetObjectPath_SameElement(&lmi_fi, o); } diff --git a/src/logicalfile/LMI_RootDirectoryProvider.c b/src/logicalfile/LMI_RootDirectoryProvider.c index fb012d6..b798d86 100644 --- a/src/logicalfile/LMI_RootDirectoryProvider.c +++ b/src/logicalfile/LMI_RootDirectoryProvider.c @@ -120,7 +120,8 @@ static CMPIStatus references( const char *comp_ccname = get_system_creation_class_name(); const char *ns = KNameSpace(cop); const char *path = get_string_property_from_op(cop, "Name"); - const char *ccname = get_string_property_from_op(cop, "CreationClassName"); + char ccname[BUFLEN]; + get_class_from_path(path, ccname); st = check_assoc_class(_cb, ns, assocClass, LMI_RootDirectory_ClassName); check_class_check_status(st); diff --git a/src/logicalfile/test/test_basic.py b/src/logicalfile/test/test_basic.py index 4c210f9..8426ea3 100644 --- a/src/logicalfile/test/test_basic.py +++ b/src/logicalfile/test/test_basic.py @@ -419,6 +419,9 @@ class TestLogicalFile(LogicalFileTestBase): rmdir, '/cant/remove/me') + # for now, this test just checks if FSName, FSCreationClassName, + # CreationClassName and LFCreationClassName are properly ignored; empty + # strings are used, since they should represent "ignored" pretty well def _test_missing_or_wrong_properties(self, is_unixfile): testfile = self.files['data'] if is_unixfile: @@ -432,12 +435,12 @@ class TestLogicalFile(LogicalFileTestBase): keybindings={ 'CSCreationClassName':self.SYSTEM_CLASS_NAME, 'CSName':self.SYSTEM_NAME, - 'FSCreationClassName':'LMI_LocalFileSystem', - 'FSName':self.fsname, + 'FSCreationClassName':'', + 'FSName':'', }) - cop.keybindings[prefix+'CreationClassName'] = testfile['class'] cop.keybindings[prefix+'Name'] = testfile['path'] + cop.keybindings[prefix+'CreationClassName'] = '' try: self.wbemconnection.GetInstance(cop) |