📄 repositoryupgrade.cpp
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author : Sushma Fernandes, Hewlett-Packard Company// (sushma_fernandes@hp.com)//// Modified By: David Dillard, VERITAS Software Corp.// (david.dillard@veritas.com)// Aruran, IBM (ashanmug@in.ibm.com) for Bug# 4114////%/////////////////////////////////////////////////////////////////////////////#include <iostream>#include <Pegasus/Common/Config.h>#include <Pegasus/Common/CIMName.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/XmlWriter.h>#include <Pegasus/Common/TimeValue.h>#include <Pegasus/Common/Exception.h>#include <Pegasus/Common/FileSystem.h>#include <Pegasus/Common/System.h>#include <Pegasus/getoopt/getoopt.h>#include <Clients/cliutils/CommandException.h>#ifdef PEGASUS_OS_OS400#include <Pegasus/Common/Logger.h>#endif#include "RepositoryUpgrade.h"#if defined(PEGASUS_USE_RELEASE_DIRS) && defined (PEGASUS_OVERRIDE_DEFAULT_RELEASE_DIRS)# include <Pegasus/Config/ProductDirectoryStructure.h>#endif// Enables debug information.// #define REPUPGRADE_DEBUG 1PEGASUS_NAMESPACE_BEGIN// Constant initializations.//l10n/** * The CLI message resource name */static const char MSG_PATH [] = "pegasus/pegasusCLI";/** The command name. */const char RepositoryUpgrade::COMMAND_NAME [] = "repupgrade";/** Label for the usage string for this command. */const char RepositoryUpgrade::_USAGE [] = "Usage: ";/** This constant signifies that an option has not been recorded*/const Uint32 RepositoryUpgrade::_OPTION_TYPE_UNINITIALIZED = 0;/** This constant signifies that an old repository path option has been been recorded*/const Uint32 RepositoryUpgrade::_OPTION_TYPE_OLD_REPOSITORY_PATH = 1;/** This constant signifies that an new repository path option has been been recorded*/const Uint32 RepositoryUpgrade::_OPTION_TYPE_NEW_REPOSITORY_PATH = 2;/** The constant representing a help operation*/const Uint32 RepositoryUpgrade::_OPTION_TYPE_HELP = 3;/** The constant representing a version display operation*/const Uint32 RepositoryUpgrade::_OPTION_TYPE_VERSION = 4;/** The option character used to specify the old Repository path. */const char RepositoryUpgrade::_OPTION_OLD_REPOSITORY_PATH = 'o';/** The option character used to specify the new Repository path. */const char RepositoryUpgrade::_OPTION_NEW_REPOSITORY_PATH = 'n';/** The option character used to display help info.*/const char RepositoryUpgrade::_OPTION_HELP = 'h';static const char LONG_HELP [] = "help";#ifdef PEGASUS_OS_OS400/** The option character used to suppress output.*/const char RepositoryUpgrade::_OPTION_QUIET = 'q';#endif/** The option character used to display version info.*/const char RepositoryUpgrade::_OPTION_VERSION = 'v';static const char LONG_VERSION [] = "version";/** Display messages.*/static const char REQUIRED_ARGS_MISSING [] = "Required arguments missing.";static const char REQUIRED_ARGS_MISSING_KEY [] = "Clients.repupgrade.RepositoryUpgrade.REQUIRED_ARGS_MISSING";static const char REPOSITORY_UPGRADE_FAILURE [] = "Failed to upgrade repository. ";static const char REPOSITORY_UPGRADE_FAILURE_KEY [] = "Clients.repupgrade.RepositoryUpgrade.REPOSITORY_UPGRADE_FAILURE";static const char REPOSITORY_UPGRADE_UNKNOWN_ERROR [] = "Unknown error encountered during upgrade. ";static const char REPOSITORY_UPGRADE_UNKNOWN_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.REPOSITORY_UPGRADE_UNKNOWN_ERROR";static const char REPOSITORY_DOES_NOT_EXIST [] = "The specified location $0 does not exist. ";static const char REPOSITORY_DOES_NOT_EXIST_KEY [] = "Clients.repupgrade.RepositoryUpgrade.REPOSITORY_DOES_NOT_EXIST";static const char NAMESPACE_CREATION_ERROR [] = "Error creating namespace $0.";static const char NAMESPACE_CREATION_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.NAMESPACE_CREATION_ERROR";static const char CLASS_CREATION_ERROR [] = "Error creating class $0 in namespace $1.";static const char CLASS_CREATION_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.CLASS_CREATION_ERROR";static const char INSTANCE_CREATION_ERROR [] = "Error creating instance in namespace $0. ";static const char INSTANCE_CREATION_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.INSTANCE_CREATION_ERROR";static const char QUALIFIER_CREATION_ERROR [] = "Error creating qualifier $0 in namespace $1.";static const char QUALIFIER_CREATION_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.QUALIFIER_CREATION_ERROR";static const char OLD_CLASS_RETRIEVAL_ERROR [] = "Error reading old repository class $0 in namespace $1.";static const char OLD_CLASS_RETRIEVAL_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.OLDCLASS_RETRIEVAL_ERROR";static const char OLD_DEPENDENT_CLASS_RETRIEVAL_ERROR [] = "Error reading old repository dependent class $0 in namespace $1.";static const char OLD_DEPENDENT_CLASS_RETRIEVAL_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.OLD_DEPENDENT_CLASS_RETRIEVAL_ERROR";static const char NEW_CLASS_RETRIEVAL_ERROR [] = "Error reading new repository class $0 in namespace $1.";static const char NEW_CLASS_RETRIEVAL_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.NEW_CLASS_RETRIEVAL_ERROR";static const char LIBRARY_LOAD_ERROR [] = "Error loading special handling library $0.";static const char LIBRARY_LOAD_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.LIBRARY_LOAD_ERROR";static const char LIBRARY_ENTRY_POINT_ERROR [] = "Error trying to get entry point symbol in library $0.";static const char LIBRARY_ENTRY_POINT_ERROR_KEY [] = "Clients.repupgrade.RepositoryUpgrade.LIBRARY_ENTRY_POINT_ERROR";static const char CLASS_XML_OUTPUT_FILE [] = "CIM/XML request for this class has been logged to file $0 ";static const char CLASS_XML_OUTPUT_FILE_KEY [] = "Clients.repupgrade.RepositoryUpgrade.CLASS_XML_OUTPUT_FILE";static const char INSTANCE_XML_OUTPUT_FILE [] = "CIM/XML request for this instance has been logged to file $0.";static const char INSTANCE_XML_OUTPUT_FILE_KEY [] = "Clients.repupgrade.RepositoryUpgrade.INSTANCE_XML_OUTPUT_FILE";static const char QUALIFIER_XML_OUTPUT_FILE [] = "CIM/XML request for this qualifier has been logged to file $0.";static const char QUALIFIER_XML_OUTPUT_FILE_KEY [] = "Clients.repupgrade.RepositoryUpgrade.QUALIFIER_XML_OUTPUT_FILE";static const char HIGHER_VERSION_OLD_CLASS [] = "Warning: The old repository contains a class $0 in namespace $1 that has a higher version number than the new repository class. This class may have to be manually imported.";static const char HIGHER_VERSION_OLD_CLASS_KEY [] = "Clients.repupgrade.RepositoryUpgrade.HIGHER_VERSION_OLD_CLASS";const String RepositoryUpgrade::_FILE_EXTENSION = ".xml";/** Constant representing the name of the Version Qualifier. */const String RepositoryUpgrade::_VERSION_QUALIFIER_NAME = "VERSION";#ifdef ENABLE_MODULE_PROCESSING/** Defines that the Special Processing Module is interested in processing classes.*/const char* RepositoryUpgrade::_CLASS_ONLY = "c";/** Defines that the Special Processing Module is interested in processing instances.*/const char* RepositoryUpgrade::_INSTANCE_ONLY = "i";/** Defines that the Special Processing Module is interested in processing qualifiers.*/const char* RepositoryUpgrade::_QUALIFIER_ONLY = "q";/** Defines that the Special Processing Module is interested in processing all types (includes class, instance and qualifier).*/const char* RepositoryUpgrade::_ALL = "a";#endif//// Make the repository paths fixed for HPUX, if PEGASUS_USE_RELEASE_DIRS is set.// Also defines the directory path to store CIMXML file for a failed request.//#ifdef PEGASUS_USE_RELEASE_DIRS# define REPUPGRADE_USE_RELEASE_DIRS true# ifdef PEGASUS_OVERRIDE_DEFAULT_RELEASE_DIRS const String OLD_REPOSITORY_PATH = PEGASUS_PREV_REPOSITORY_DIR; const String NEW_REPOSITORY_PATH = PEGASUS_REPOSITORY_DIR; const String RepositoryUpgrade::_LOG_PATH = PEGASUS_LOG_DIR"/upgrade";# elif defined(PEGASUS_OS_HPUX) const String OLD_REPOSITORY_PATH = "/var/opt/wbem/prev_repository"; const String NEW_REPOSITORY_PATH = "/var/opt/wbem/repository"; const String RepositoryUpgrade::_LOG_PATH = "/var/opt/wbem/upgrade";# elif defined(PEGASUS_OS_VMS) const String OLD_REPOSITORY_PATH = "/wbem_var/opt/wbem/prev_repository"; const String NEW_REPOSITORY_PATH = "/wbem_var/opt/wbem/repository"; const String RepositoryUpgrade::_LOG_PATH = "/wbem_var/opt/wbem/upgrade";# elif defined(PEGASUS_OS_LINUX) const String OLD_REPOSITORY_PATH = "/var/opt/tog-pegasus/prev_repository"; const String NEW_REPOSITORY_PATH = "/var/opt/tog-pegasus/repository"; const String RepositoryUpgrade::_LOG_PATH = "/var/opt/tog-pegasus/log/upgrade";# endif#else const String RepositoryUpgrade::_LOG_PATH = "./";#endifRepositoryUpgrade::RepositoryUpgrade () : MessageQueue(PEGASUS_QUEUENAME_INTERNALCLIENT), _requestEncoder(0){ // // Initialize data members. // _authenticator.clear(); _authenticator.setAuthType(ClientAuthenticator::NONE);#ifdef PEGASUS_OS_OS400 logFileName = "/QIBM/USERDATA/OS400/CIM/qycmRepositoryUpgrade.log";#endif // // Create request encoder: // _requestEncoder = new CIMOperationRequestEncoder( this, "localhost", &_authenticator, 0); instanceCount=0; qualifierCount=0; _modulesInitialized=false; // // Get environment variable PEGASUS_HOME //#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM#pragma convert(37) const char* tmp = getenv("PEGASUS_HOME");#pragma convert(0) // Set pegasusHome to the env var,if it is set. Otherwise, // use the OS/400 default path. if (tmp != NULL) { char home[256] = {0}; if (strlen(tmp) < 256) { strcpy(home, tmp); EtoA(home); _pegasusHome=home; } } else _pegasusHome = OS400_DEFAULT_PEGASUS_HOME;#else const char* tmp = getenv("PEGASUS_HOME");#endif if (tmp) { _pegasusHome = tmp; } FileSystem::translateSlashes(_pegasusHome);#ifdef REPUPGRADE_DEBUG cout << "Pegasus HOME : " << _pegasusHome << endl;#endif // // build Usage string. // _usage = String (_USAGE); _usage.append (COMMAND_NAME);#if !(defined(REPUPGRADE_USE_RELEASE_DIRS)) _usage.append (" -").append (_OPTION_OLD_REPOSITORY_PATH); _usage.append (" old_repository_path"); _usage.append (" -").append (_OPTION_NEW_REPOSITORY_PATH); _usage.append (" new_repository_path\n");#endif // // Version options // _usage.append(" ").append (COMMAND_NAME); _usage.append (" -").append (_OPTION_VERSION) .append(" |"); _usage.append (" --").append (LONG_VERSION) .append("\n"); // // Help option // _usage.append(" ").append (COMMAND_NAME);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -