version 1.57, 2013/04/09 05:53:06
|
version 1.58, 2013/05/07 06:57:44
|
|
|
*/ | */ |
const char RepositoryUpgrade::_OPTION_HELP = 'h'; | const char RepositoryUpgrade::_OPTION_HELP = 'h'; |
| |
|
#ifdef NS_INTEROP |
|
/** |
|
The constant representing that interop option has been specified |
|
*/ |
|
const Uint32 RepositoryUpgrade::_OPTION_TYPE_INTEROP = 5; |
|
|
|
/** |
|
The option character used to change root/PG_Interop to interop. |
|
*/ |
|
const char RepositoryUpgrade::_OPTION_INTEROP = 'i'; |
|
#endif |
|
|
static const char LONG_HELP [] = "help"; | static const char LONG_HELP [] = "help"; |
| |
/** | /** |
|
|
_usage.append (" old_repository_path"); | _usage.append (" old_repository_path"); |
_usage.append (" -").append (_OPTION_NEW_REPOSITORY_PATH); | _usage.append (" -").append (_OPTION_NEW_REPOSITORY_PATH); |
_usage.append (" new_repository_path"); | _usage.append (" new_repository_path"); |
|
#ifdef NS_INTEROP |
|
_usage.append (" [-").append (_OPTION_INTEROP).append("]"); |
|
#endif |
#endif | #endif |
| |
_usage.append("\n"); | _usage.append("\n"); |
|
|
| |
_usage.append(" -n "); | _usage.append(" -n "); |
_usage.append("- Specify the fully qualified path of the new Repository\n"); | _usage.append("- Specify the fully qualified path of the new Repository\n"); |
|
|
|
#ifdef NS_INTEROP |
|
_usage.append(" -i - Change root/PG_InterOp to interop\n"); |
|
#endif |
#endif | #endif |
| |
_usage.append(" -h, --help - Display this help message\n"); | _usage.append(" -h, --help - Display this help message\n"); |
|
|
optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR); | optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR); |
optString.append (_OPTION_NEW_REPOSITORY_PATH); | optString.append (_OPTION_NEW_REPOSITORY_PATH); |
optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR); | optString.append (getoopt::GETOPT_ARGUMENT_DESIGNATOR); |
|
#ifdef NS_INTEROP |
|
optString.append (_OPTION_INTEROP); |
|
optString.append (getoopt::NOARG); |
|
#endif |
#endif | #endif |
| |
optString.append (_OPTION_HELP); | optString.append (_OPTION_HELP); |
|
|
_newRepositoryPathSet = true; | _newRepositoryPathSet = true; |
break; | break; |
} | } |
|
#ifdef NS_INTEROP |
|
case _OPTION_INTEROP: |
|
{ |
|
if (getOpts.isSet (_OPTION_INTEROP) > 1) |
|
{ |
|
// |
|
// More than one version option was found |
|
// |
|
throw DuplicateOptionException(_OPTION_INTEROP); |
|
} |
|
|
|
_optionType = _OPTION_TYPE_INTEROP; |
|
_optionInterop = true; |
|
break; |
|
} |
|
#endif |
#endif | #endif |
case _OPTION_HELP: | case _OPTION_HELP: |
{ | { |
|
|
_updateSystemNameKeyProperty(); | _updateSystemNameKeyProperty(); |
_removeInstances(); | _removeInstances(); |
| |
|
#ifdef NS_INTEROP |
|
// Change "root/PG_InterOp" to "interop" in the new repository |
|
if ( (_optionInterop == true ) && |
|
(_oldRepository->nameSpaceExists(PEGASUS_NAMESPACE_PGINTEROP))) |
|
{ |
|
#ifdef REPUPGRADE_DEBUG |
|
cout << "Changing namespace name from " << |
|
PEGASUS_NAMESPACE_PGINTEROP.getString() << " to " |
|
<< PEGASUS_NAMESPACENAME_INTEROP.getString() << endl; |
|
#endif |
|
_newRepository->modifyNameSpaceName(PEGASUS_NAMESPACE_PGINTEROP, |
|
PEGASUS_NAMESPACENAME_INTEROP); |
|
} |
|
#endif |
} | } |
| |
Array<CIMNamespaceName> RepositoryUpgrade::_compareNamespaces( | Array<CIMNamespaceName> RepositoryUpgrade::_compareNamespaces( |
|
|
<< (const char*)oldClassNames[ctr].getString().getCString() | << (const char*)oldClassNames[ctr].getString().getCString() |
<< endl; | << endl; |
#endif | #endif |
|
|
|
#ifdef NS_INTEROP |
|
CIMClass oldClass = _oldRepository->getClass( |
|
oldNamespaces[i], |
|
oldClassNames[ctr]); |
|
Uint32 pCnt = oldClass.getPropertyCount(); |
|
Boolean hasReference = false; |
|
Array<CIMName> refProp; |
|
for ( Uint32 j = 0; j < pCnt; j++) |
|
{ |
|
CIMProperty prop = oldClass.getProperty(j); |
|
if(prop.getType() == CIMTYPE_REFERENCE) |
|
{ |
|
refProp.append(prop.getName()); |
|
hasReference = true; |
|
} |
|
} |
|
#endif |
|
|
Array<CIMInstance> instances; | Array<CIMInstance> instances; |
Uint32 ictr = 0; | Uint32 ictr = 0; |
| |
|
|
#ifdef REPUPGRADE_DEBUG | #ifdef REPUPGRADE_DEBUG |
cout << "Creating instance" << endl; | cout << "Creating instance" << endl; |
#endif | #endif |
|
|
|
#ifdef NS_INTEROP |
|
if( hasReference == true) |
|
{ |
|
#ifdef REPUPGRADE_DEBUG |
|
cout << "Calling _processInstance()" << endl; |
|
#endif |
|
_processInstance(processedInstance, refProp); |
|
} |
|
#endif |
_newRepository->createInstance( | _newRepository->createInstance( |
oldNamespaces[i], | oldNamespaces[i], |
processedInstance); | processedInstance); |
|
|
} | } |
} | } |
| |
|
#ifdef NS_INTEROP |
|
void RepositoryUpgrade::_processInstance(CIMInstance& instance, |
|
Array<CIMName> a) |
|
{ |
|
for(Uint32 k = 0; k < a.size(); k++) |
|
{ |
|
try |
|
{ |
|
Uint32 propIndex = instance.findProperty(a[k]); |
|
CIMProperty prop = instance.getProperty(propIndex); |
|
CIMObjectPath objPath; |
|
prop.getValue().get(objPath); |
|
if ( objPath.getNameSpace() == PEGASUS_NAMESPACE_PGINTEROP ) |
|
{ |
|
objPath.setNameSpace(PEGASUS_NAMESPACENAME_INTEROP); |
|
instance.removeProperty(propIndex); |
|
prop.setValue(objPath); |
|
instance.addProperty(prop); |
|
} |
|
} |
|
catch(...) |
|
{ |
|
#ifdef REPUPGRADE_DEBUG |
|
cout << "Execption occured in _processInstance()" << endl; |
|
#endif |
|
throw; |
|
} |
|
} |
|
} |
|
#endif |
|
|
void RepositoryUpgrade::_removeInstances(void) | void RepositoryUpgrade::_removeInstances(void) |
{ | { |
Array<CIMInstance> instances; | Array<CIMInstance> instances; |