📄 cimprovidercommand.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: Yi Zhou, Hewlett Packard Company (yi_zhou@hp.com)//// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company// (carolann_graves@hp.com)// Amit K Arora, IBM (amita@in.ibm.com) for PEP-101// Alagaraja Ramasubramanian, IBM (alags_raj@in.ibm.com) - PEP-167// Amit K Arora, IBM (amita@in.ibm.com) Bug#2311,#2333,#2351// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) - Bug#2756, Bug#3032////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <iostream>#include <Clients/cliutils/Command.h>#include <Clients/cliutils/CommandException.h>#include <Pegasus/getoopt/getoopt.h>#include <Pegasus/Client/CIMClient.h>#include <Pegasus/Common/CIMProperty.h>#include <Pegasus/Common/CIMObjectPath.h>#include <Pegasus/Common/CIMStatusCode.h>#include <Pegasus/Common/Exception.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/System.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/PegasusVersion.h>#include <Pegasus/Common/AutoPtr.h>#ifdef PEGASUS_OS_OS400#include "qycmutiltyUtility.H"#include "qycmutilu2.H"#include "vfyptrs.cinc"#include <stdio.h>#include "OS400ConvertChar.h"#endif#define CIMPROVIDERCOMMAND_CLIENT_DEFAULTTIMEOUT 120000PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGIN//l10n/** * The CLI message resource name */static const char MSG_PATH [] = "pegasus/pegasusCLI";//l10n end/** The command name.*/static const char COMMAND_NAME [] = "cimprovider";/** The name of the provider module name property for PG_Provider class*/static const CIMName _PROPERTY_PROVIDERMODULENAME = CIMName ("ProviderModuleName");/** The name of the Name property for PG_Provider class*/static const CIMName _PROPERTY_PROVIDER_NAME = CIMName ("Name");/** The usage string for this command. This string is displayed when an error occurs in parsing or validating the command line.*/static const char USAGE [] = "Usage: ";/** This constant represents the getoopt argument designator*/static const char GETOPT_ARGUMENT_DESIGNATOR = ':';/* These constants represent the operation modes supported by the CLI. Any new operation should be added here.*//** This constant signifies that an operation option has not been recorded*/static const Uint32 OPERATION_TYPE_UNINITIALIZED = 0;/** This constant represents a disable provider operation*/static const Uint32 OPERATION_TYPE_DISABLE = 1;/** This constant represents a remove provider operation*/static const Uint32 OPERATION_TYPE_REMOVE = 2;/** This constant represents a enable provider operation*/static const Uint32 OPERATION_TYPE_ENABLE = 3;/** This constant represents a list operation*/static const Uint32 OPERATION_TYPE_LIST = 4;/** This constant represents a help operation*/static const Uint32 OPERATION_TYPE_HELP = 5;/** This constant represents a version display operation*/static const Uint32 OPERATION_TYPE_VERSION = 6;/** The constants representing the messages.*/static const char NOT_PRIVILEGED_USER [] = "Error, you must have superuser privilege to run cimprovider.";static const char NOT_PRIVILEGED_USER_KEY [] = "Clients.cimprovider.CIMProviderCommand.NOT_PRIVILEGED_USER";static const char CIMOM_NOT_RUNNING [] = "The CIM server may not be running.";static const char CIMOM_NOT_RUNNING_KEY [] = "Clients.cimprovider.CIMProviderCommand.CIMOM_NOT_RUNNING";static const char DELETE_PROVIDER_FAILURE [] = "Failed to delete...";static const char DELETE_PROVIDER_FAILURE_KEY [] = "Clients.cimprovider.CIMProviderCommand.DELETE_PROVIDER_FAILURE";static const char START_PROVIDER_FAILURE [] = "Failed to enable provider module.";static const char START_PROVIDER_FAILURE_KEY [] = "Clients.cimprovider.CIMProviderCommand.START_PROVIDER_FAILURE";static const char STOP_PROVIDER_FAILURE [] = "Failed to disable provider module.";static const char PENDING_REQUESTS_STOP_PROVIDER_FAILURE_KEY [] = "Clients.cimprovider.CIMProviderCommand." "PENDING_REQUESTS_STOP_PROVIDER_FAILURE";static const char PENDING_REQUESTS_STOP_PROVIDER_FAILURE [] = "Failed to disable provider module: Provider is busy.";static const char STOP_PROVIDER_FAILURE_KEY [] = "Clients.cimprovider.CIMProviderCommand.STOP_PROVIDER_FAILURE";static const char LIST_PROVIDERS_FAILURE [] = "Failed to list... ";static const char LIST_PROVIDERS_FAILURE_KEY [] = "Clients.cimprovider.CIMProviderCommand.LIST_PROVIDERS_FAILURE";static const char DELETE_PROVIDER_MODULE_SUCCESS [] = "Provider module deleted successfully.";static const char DELETE_PROVIDER_MODULE_SUCCESS_KEY [] = "Clients.cimprovider.CIMProviderCommand.DELETE_PROVIDER_SUCCESS";static const char DELETE_PROVIDER_SUCCESS [] = "Provider deleted successfully.";static const char DELETE_PROVIDER_SUCCESS_KEY [] = "Clients.cimprovider.CIMProviderCommand.DELETE_PROVIDER_SUCCESS";static const char START_PROVIDER_SUCCESS [] = "Provider module enabled successfully.";static const char START_PROVIDER_SUCCESS_KEY [] = "Clients.cimprovider.CIMProviderCommand.START_PROVIDER_SUCCESS";static const char STOP_PROVIDER_SUCCESS [] = "Provider module disabled successfully.";static const char STOP_PROVIDER_SUCCESS_KEY [] = "Clients.cimprovider.CIMProviderCommand.STOP_PROVIDER_SUCCESS";static const char PROVIDER_ALREADY_STOPPED [] = "Provider module already disabled.";static const char PROVIDER_ALREADY_STOPPED_KEY [] = "Clients.cimprovider.CIMProviderCommand.PROVIDER_ALREADY_STOPPED";static const char PROVIDER_ALREADY_STARTED [] = "Provider module already enabled.";static const char PROVIDER_ALREADY_STARTED_KEY [] = "Clients.cimprovider.CIMProviderCommand.PROVIDER_ALREADY_STARTED";static const char CANNOT_START_PROVIDER [] = "Provider module can not be enabled since it is disabling.";static const char CANNOT_START_PROVIDER_KEY [] = "Clients.cimprovider.CIMProviderCommand.CANNOT_START_PROVIDER";static const char PROVIDER_NOT_REGISTERED[] = "Specified provider was not registered.";static const char PROVIDER_NOT_REGISTERED_KEY [] = "Clients.cimprovider.CIMProviderCommand.PROVIDER_NOT_REGISTERED";static const char DELETEING_PROVIDER_MODULE[] = "Deleting provider module...";static const char DELETEING_PROVIDER_MODULE_KEY [] = "Clients.cimprovider.CIMProviderCommand.DELETEING_PROVIDER_MODULE";static const char DELETEING_PROVIDER[] = "Deleting provider...";static const char DELETEING_PROVIDER_KEY[] = "Clients.cimprovider.CIMProviderCommand.DELETEING_PROVIDER";static const char STARTING_PROVIDER_MODULE[] = "Enabling provider module...";static const char STARTING_PROVIDER_MODULE_KEY[] = "Clients.cimprovider.CIMProviderCommand.STARTING_PROVIDER_MODULE";static const char STOPING_PROVIDER_MODULE[] = "Disabling provider module...";static const char STOPING_PROVIDER_MODULE_KEY[] = "Clients.cimprovider.CIMProviderCommand.STOPING_PROVIDER_MODULE";static const char NO_MODULE_REGISTERED[] = "No modules registered for listing.";static const char NO_MODULE_REGISTERED_KEY[] = "Clients.cimprovider.CIMProviderCommand.NO_MODULE_REGISTERED";static const char ERR_OPTION_NOT_SUPPORTED[] = "Invalid option. Use '--help' to obtain command syntax.";static const char ERR_OPTION_NOT_SUPPORTED_KEY[] = "Clients.cimprovider.CIMProviderCommand.ERR_OPTION_NOT_SUPPORTED";static const char ERR_MODULE_NOT_REGISTERED[] = "Specified provider module was not registered.";static const char ERR_MODULE_NOT_REGISTERED_KEY[] = "Clients.cimprovider.CIMProviderCommand.ERR_MODULE_NOT_REGISTERED";static const char ERR_PROVIDER_NOT_REGISTERED[] = "Specified provider was not registered.";static const char ERR_PROVIDER_NOT_REGISTERED_KEY[] = "Clients.cimprovider.CIMProviderCommand.ERR_PROVIDER_NOT_REGISTERED";static const char PG_PROVIDER_SCHEMA_NOT_LOADED [] = "Please make sure that the registration schema is loaded on the CIMOM.";static const char PG_PROVIDER_SCHEMA_NOT_LOADED_KEY [] = "Clients.cimprovider.CIMProviderCommand.PG_PROVIDER_SCHEMA_NOT_LOADED";static const char REQUIRED_ARGS_MISSING [] = "Required arguments missing.";static const char REQUIRED_ARGS_MISSING_KEY [] = "Clients.cimprovider.CIMProviderCommand.REQUIRED_ARGS_MISSING";static const char INVALID_ARGS [] = "Invalid arguments.";static const char INVALID_ARGS_KEY [] = "Clients.cimprovider.CIMProviderCommand.INVALID_ARGS";static const char UNEXPECTED_OPTION [] = "Unexpected Option.";static const char UNEXPECTED_OPTION_KEY [] = "Clients.cimprovider.CIMProviderCommand.UNEXPECTED_OPTION";static const char ERR_USAGE_KEY [] = "Clients.cimprovider.CIMProviderCommand.ERR_USAGE";static const char ERR_USAGE [] = "Incorrect usage. Use '--help' to obtain command syntax.";static const char LONG_HELP [] = "help";static const char LONG_VERSION [] = "version";/** The option character used to specify disable a provider module.*/static const char OPTION_DISABLE = 'd';/** The option character used to specify remove a provider or module.*/static const char OPTION_REMOVE = 'r';/** The option character used to specify enable a provider module.*/static const char OPTION_ENABLE = 'e';/** The option character used to specify a module.*/static const char OPTION_MODULE = 'm';/** The option character used to specify a provider.*/static const char OPTION_PROVIDER = 'p';/** The option character used to specify listing of providers or provider modules.*/static const char OPTION_LIST = 'l';/** The option character used to specify get module status.*/static const char OPTION_STATUS = 's';/** The option character used to display help info.*/static const char OPTION_HELP = 'h';/** The option character used to display version info.*/static const char OPTION_VERSION = 'v';#ifdef PEGASUS_OS_OS400/** The option character used to specify no output to stdout or stderr.*/static const char OPTION_QUIET_VALUE = 'q';#endif/** The name of the Method that implements stop provider or module*/static const CIMName STOP_METHOD = CIMName ("stop");/** The name of the Method that implements start provider or module*/static const CIMName START_METHOD = CIMName ("start");/**This is a CLI used to update providers of the CIM Server. This command supportsoperations to stop, start, list and delete provider or module.@author Yi Zhou, Hewlett-Packard Company*/class CIMProviderCommand : public Command{public: /** Constructs a CIMProviderCommand and initializes instance variables. */ CIMProviderCommand (); // // Overrides the virtual function setCommand from Command class // This is defined as an empty function. // void setCommand ( Uint32 argc, char* argv []) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -