1 //%LICENSE////////////////////////////////////////////////////////////////
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //////////////////////////////////////////////////////////////////////////
30 //%/////////////////////////////////////////////////////////////////////////////
33 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/Constants.h>
35 #include <Pegasus/Common/System.h>
36 #include <Pegasus/Common/FileSystem.h>
37 #include <Pegasus/Common/CIMProperty.h>
38 #include <Pegasus/Common/CIMObjectPath.h>
39 #include <Pegasus/Common/CIMStatusCode.h>
40 #include <Pegasus/Common/Exception.h>
41 #include <Pegasus/Common/PegasusVersion.h>
42 #include <Pegasus/Common/StringConversion.h>
43 #include <Pegasus/getoopt/getoopt.h>
45 #include <Pegasus/Client/CIMClient.h>
46 #include <Pegasus/Config/ConfigFileHandler.h>
47 #include "CIMConfigCommand.h"
49 #ifdef PEGASUS_OS_PASE
50 # include <ILEWrapper/ILEUtilities.h>
54 #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
57 PEGASUS_NAMESPACE_BEGIN
61 * The CLI message resource name
64 static const char MSG_PATH [] = "pegasus/pegasusCLI";
71 static const char COMMAND_NAME [] = "cimconfig";
74 The usage string for this command. This string is displayed
75 when an error occurs in parsing or validating the command line.
77 static const char USAGE [] = "Usage: ";
80 This constant represents the getoopt argument designator
82 static const char GETOPT_ARGUMENT_DESIGNATOR = ':';
85 These constants represent the operation modes supported by the CLI.
86 Any new operation should be added here.
90 This constant signifies that an operation option has not been recorded
92 static const Uint32 OPERATION_TYPE_UNINITIALIZED = 0;
95 This constant represents a property get operation
97 static const Uint32 OPERATION_TYPE_GET = 1;
100 This constant represents a property set operation
102 static const Uint32 OPERATION_TYPE_SET = 2;
105 This constant represents a property unset operation
107 static const Uint32 OPERATION_TYPE_UNSET = 3;
110 This constant represents a property list operation
112 static const Uint32 OPERATION_TYPE_LIST = 4;
115 This constant represents a help operation
117 static const Uint32 OPERATION_TYPE_HELP = 5;
120 This constant represents a version display operation
122 static const Uint32 OPERATION_TYPE_VERSION = 6;
125 The constants representing the string literals.
127 static const CIMName PROPERTY_NAME = CIMName ("PropertyName");
129 static const CIMName DEFAULT_VALUE = CIMName ("DefaultValue");
131 static const CIMName CURRENT_VALUE = CIMName ("CurrentValue");
133 static const CIMName PLANNED_VALUE = CIMName ("PlannedValue");
135 static const CIMName DYNAMIC_PROPERTY = CIMName ("DynamicProperty");
138 The name of the method that implements the property value update using the
141 static const CIMName METHOD_UPDATE_PROPERTY_VALUE =
142 CIMName("UpdatePropertyValue");
145 The input parameter names for the UpdatePropertyValue() method.
147 static const String PARAM_PROPERTYVALUE = String("PropertyValue");
148 static const String PARAM_RESETVALUE = String("ResetValue");
149 static const String PARAM_UPDATEPLANNEDVALUE = String("SetPlannedValue");
150 static const String PARAM_UPDATECURRENTVALUE = String("SetCurrentValue");
151 static const String PARAM_TIMEOUTPERIOD = String("TimeoutPeriod");
154 The constants representing the messages.
156 static const char FILE_NOT_READABLE [] =
157 "Configuration file not readable.";
159 static const char FAILED_TO_GET_PROPERTY [] =
160 "Failed to get the config property.";
162 static const char FAILED_TO_SET_PROPERTY [] =
163 "Failed to set the config property.";
165 static const char FAILED_TO_UNSET_PROPERTY [] =
166 "Failed to unset the config property.";
168 static const char FAILED_TO_LIST_PROPERTIES [] =
169 "Failed to list the config properties. ";
171 static const char CONFIG_SCHEMA_NOT_LOADED [] =
172 "Please restore the internal repository on the CIM Server.";
174 static const char PROPERTY_NOT_FOUND [] =
175 "Specified property name was not found.";
177 static const char INVALID_PROPERTY_VALUE [] =
178 "Specified property value is not valid.";
180 static const char PROPERTY_NOT_MODIFIED [] =
181 "Specified property can not be modified.";
183 //l10n default messages and resource keys
185 static const char OPTION_INVALID_CIM_RUNNING [] =
186 "Option -$0 is not valid for this command when CIM server is not running.";
188 static const char OPTION_INVALID_CIM_RUNNING_KEY [] =
189 "Clients.CIMConfig.CIMConfigCommand.OPTION_INVALID_CIM_RUNNING";
191 static const char FILE_NOT_READABLE_KEY [] =
192 "Clients.CIMConfig.CIMConfigCommand.FILE_NOT_READABLE";
194 static const char FAILED_TO_GET_PROPERTY_KEY [] =
195 "Clients.CIMConfig.CIMConfigCommand.FAILED_TO_GET_PROPERTY";
197 static const char FAILED_TO_SET_PROPERTY_KEY [] =
198 "Clients.CIMConfig.CIMConfigCommand.FAILED_TO_SET_PROPERTY";
200 static const char FAILED_TO_UNSET_PROPERTY_KEY [] =
201 "Clients.CIMConfig.CIMConfigCommand.FAILED_TO_UNSET_PROPERTY";
203 static const char FAILED_TO_LIST_PROPERTIES_KEY [] =
204 "Clients.CIMConfig.CIMConfigCommand.FAILED_TO_LIST_PROPERTIES";
206 static const char CONFIG_SCHEMA_NOT_LOADED_KEY [] =
207 "Clients.CIMConfig.CIMConfigCommand.CONFIG_SCHEMA_NOT_LOADED";
209 static const char PROPERTY_NOT_FOUND_KEY [] =
210 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_NOT_FOUND";
212 static const char INVALID_PROPERTY_VALUE_KEY [] =
213 "Clients.CIMConfig.CIMConfigCommand.INVALID_PROPERTY_VALUE";
215 static const char PROPERTY_NOT_MODIFIED_KEY [] =
216 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_NOT_MODIFIED";
218 static const char PLANNED_VALUE_OF_PROPERTY_IS [] =
219 "Planned value for the property $0 is set to \"$1\" in CIMServer.";
220 static const char PLANNED_VALUE_OF_PROPERTY_IS_KEY [] =
221 "Clients.CIMConfig.CIMConfigCommand.PLANNED_VALUE_OF_PROPERTY_IS";
223 static const char CURRENT_VALUE_OF_PROPERTY_IS [] =
224 "Current value for the property $0 is set to \"$1\" in CIMServer.";
225 static const char CURRENT_VALUE_OF_PROPERTY_IS_KEY [] =
226 "Clients.CIMConfig.CIMConfigCommand.CURRENT_VALUE_OF_PROPERTY_IS";
228 static const char CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET [] =
229 "Current value for the property '$0' can not be set because the"
230 " CIM server is not running.";
231 static const char CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET_KEY [] =
232 "Clients.CIMConfig.CIMConfigCommand."
233 "CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET";
235 static const char FAILED_UPDATE_OF_PLANNED_VALUE_IN_FILE [] =
236 "Failed to update the planned value of the Property '$0' in"
237 " configuration file.";
238 static const char FAILED_UPDATE_OF_PLANNED_VALUE_IN_FILE_KEY [] =
239 "Clients.CIMConfig.CIMConfigCommand."
240 "FAILED_UPDATE_OF_PLANNED_VALUE_IN_FILE";
242 static const char PROPERTY_UPDATED_IN_FILE [] =
243 "Property '$0' updated in configuration file.";
245 static const char PROPERTY_UPDATED_IN_FILE_KEY [] =
246 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_UPDATED_IN_FILE";
248 static const char PLANNED_VALUE_IS [] = "Planned value: $0";
249 static const char PLANNED_VALUE_IS_KEY [] =
250 "Clients.CIMConfig.CIMConfigCommand.PLANNED_VALUE_IS";
252 static const char CURRENT_VALUE_IS [] = "Current value: $0";
253 static const char CURRENT_VALUE_IS_KEY [] =
254 "Clients.CIMConfig.CIMConfigCommand.CURRENT_VALUE_IS";
257 static const char DEFAULT_VALUE_IS [] = "Default value: $0";
258 static const char DEFAULT_VALUE_IS_KEY [] =
259 "Clients.CIMConfig.CIMConfigCommand.DEFAULT_VALUE_IS";
261 static const char CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING [] =
262 "Planned value can not be determined because the CIM server is not"
264 static const char CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING_KEY [] =
265 "Clients.CIMConfig.CIMConfigCommand."
266 "CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING";
268 static const char CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING [] =
269 "Current value can not be determined because the CIM server is"
271 static const char CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING_KEY [] =
272 "Clients.CIMConfig.CIMConfigCommand."
273 "CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING";
275 static const char PROPERTY_VALUE_ALREADY_SET_TO [] =
276 "The property '$0' value is already set to '$1'.";
278 static const char PROPERTY_VALUE_ALREADY_SET_TO_KEY [] =
279 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_VALUE_ALREADY_SET_TO";
281 static const char CURRENT_PROPERTY_SET_TO_DEFAULT [] =
282 "Current value for the property '$0' is set to default value in CIMServer.";
283 static const char CURRENT_PROPERTY_SET_TO_DEFAULT_KEY [] =
284 "Clients.CIMConfig.CIMConfigCommand.CURRENT_PROPERTY_SET_TO_DEFAULT";
286 static const char PROPERTY_UNSET_IN_FILE [] =
287 "Property '$0' is unset in the configuration file.";
289 static const char PROPERTY_UNSET_IN_FILE_KEY [] =
290 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_UNSET_IN_FILE";
292 static const char CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING [] =
293 "Current value for the property '$0' can not be unset because the"
294 " CIM server is not running.";
295 static const char CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY [] =
296 "Clients.CIMConfig.CIMConfigCommand."
297 "CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING";
299 static const char PROPERTY_VALUE_ALREADY_UNSET [] =
300 "The property '$0' value is already unset.";
302 static const char PROPERTY_VALUE_ALREADY_UNSET_KEY [] =
303 "Clients.CIMConfig.CIMConfigCommand.PROPERTY_VALUE_ALREADY_UNSET";
305 static const char CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING [] =
306 "Current value of properties can not be listed because the CIM server"
308 static const char CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING_KEY [] =
309 "Clients.CIMConfig.CIMConfigCommand."
310 "CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING";
312 static const char NO_PROPERTIES_FOUND_IN_FILE [] =
313 "No configuration properties found in the configuration file.";
315 static const char NO_PROPERTIES_FOUND_IN_FILE_KEY [] =
316 "Clients.CIMConfig.CIMConfigCommand.NO_PROPERTIES_FOUND_IN_FILE";
318 static const char REQUIRED_ARGS_MISSING [] =
319 "Required arguments missing.";
321 static const char REQUIRED_ARGS_MISSING_KEY [] =
322 "Clients.cimuser.CIMUserCommand.REQUIRED_ARGS_MISSING";
324 static const char ERR_USAGE [] =
325 "Use '--help' to obtain command syntax.";
327 static const char ERR_USAGE_KEY [] =
328 "Clients.CIMConfig.CIMConfigCommand.ERR_USAGE";
331 //l10n end default messages and keys
334 The option character used to specify get config property.
336 static const char OPTION_GET = 'g';
339 The option character used to specify set config property.
341 static const char OPTION_SET = 's';
343 #ifdef PEGASUS_OS_PASE
345 The option character used to specify no output to stdout or stderr.
347 static const char OPTION_QUIET_VALUE = 'q';
351 The option character used to specify unset config property.
353 static const char OPTION_UNSET = 'u';
356 The option character used to specify listing of config properties.
358 static const char OPTION_LIST = 'l';
361 The option character used to specify the current config value.
363 static const char OPTION_CURRENT_VALUE = 'c';
366 The option character used to specify the planned config value.
368 static const char OPTION_PLANNED_VALUE = 'p';
371 The option character used to specify the default config value.
373 static const char OPTION_DEFAULT_VALUE = 'd';
376 The option character used to specify the timeout value.
378 static const char OPTION_TIMEOUT_VALUE = 't';
381 The option character used to display help info.
383 static const char OPTION_HELP = 'h';
386 The option character used to display version info.
388 static const char OPTION_VERSION = 'v';
390 static const char LONG_HELP [] = "help";
392 static const char LONG_VERSION [] = "version";
395 Constructs a CIMConfigCommand and initializes instance variables.
397 CIMConfigCommand::CIMConfigCommand ()
400 Initialize the instance variables.
402 _operationType = OPERATION_TYPE_UNINITIALIZED;
403 _propertyName = CIMName ();
404 _currentValueSet = false;
405 _plannedValueSet = false;
406 _defaultValueSet = false;
407 #ifdef PEGASUS_OS_PASE
408 _defaultQuietSet = false;
412 Build the usage string for the config command.
414 usage.reserveCapacity(200);
417 usage.append(COMMAND_NAME);
419 usage.append(" -").append(OPTION_GET).append(" name");
420 usage.append(" [ -").append(OPTION_CURRENT_VALUE);
421 usage.append(" ] [ -").append(OPTION_DEFAULT_VALUE);
422 usage.append(" ] [ -").append(OPTION_PLANNED_VALUE).append(" ]\n");
423 #ifdef PEGASUS_OS_PASE
424 usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n");
427 usage.append(" -").append(OPTION_SET).append(" name=value");
428 usage.append(" [ -").append(OPTION_CURRENT_VALUE);
429 usage.append(" ] [ -").append(OPTION_PLANNED_VALUE);
430 usage.append(" ] [ -").append(OPTION_TIMEOUT_VALUE).append(" ]\n");
431 #ifdef PEGASUS_OS_PASE
432 usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n");
435 usage.append(" -").append(OPTION_UNSET).append(" name");
436 usage.append(" [ -").append(OPTION_CURRENT_VALUE);
437 usage.append(" ] [ -").append(OPTION_PLANNED_VALUE);
438 usage.append(" ] [ -").append(OPTION_TIMEOUT_VALUE).append(" ]\n");
439 #ifdef PEGASUS_OS_PASE
440 usage.append(" ] [ -").append(OPTION_QUIET_VALUE).append(" ]\n");
443 usage.append(" -").append(OPTION_LIST);
444 usage.append(" [ -").append(OPTION_CURRENT_VALUE);
445 usage.append(" | -").append(OPTION_PLANNED_VALUE).append(" ]\n");
447 usage.append(" -").append(OPTION_HELP).append("\n");
448 usage.append(" --").append(LONG_HELP).append("\n");
449 usage.append(" --").append(LONG_VERSION).append("\n");
451 usage.append("Options : \n");
452 usage.append(" -c - Use current configuration\n");
453 usage.append(" -d - Use default configuration\n");
454 usage.append(" -g - Get the value of specified configuration"
456 usage.append(" -h, --help - Display this help message\n");
457 usage.append(" -l - Display all the configuration properties\n");
458 usage.append(" -p - Configuration used on next CIM Server"
460 #ifdef PEGASUS_OS_PASE
461 usage.append(" -q - Specify quiet mode,"
462 "avoiding output to stdout or stderr\n");
464 usage.append(" -s - Add or Update configuration property"
466 usage.append(" -u - Reset configuration property to its"
468 usage.append(" -t - Timeout value in seconds for updating the"
469 " current or planned value\n");
470 usage.append(" --version - Display CIM Server version number\n");
472 usage.append("\nUsage note: The cimconfig command can be used to update"
473 " the next planned\n");
474 usage.append( "configuration without having the CIM Server running."
475 " All other options \n");
476 usage.append("of the cimconfig command require that the CIM Server"
479 //l10n localize usage
480 #ifdef PEGASUS_HAS_ICU
481 MessageLoaderParms menuparms(
482 "Clients.CIMConfig.CIMConfigCommand.MENU.STANDARD",usage);
483 menuparms.msg_src_path = MSG_PATH;
484 usage = MessageLoader::getMessage(menuparms);
490 Parses the command line, validates the options, and sets instance
491 variables based on the option arguments.
493 void CIMConfigCommand::setCommand (Uint32 argc, char* argv [])
497 String property = String ();
498 String badOptionString = String ();
499 String optString = String ();
500 Uint32 equalsIndex = 0;
503 // Construct optString
505 optString.append(OPTION_GET);
506 optString.append(GETOPT_ARGUMENT_DESIGNATOR);
508 optString.append(OPTION_SET);
509 optString.append(GETOPT_ARGUMENT_DESIGNATOR);
511 optString.append(OPTION_UNSET);
512 optString.append(GETOPT_ARGUMENT_DESIGNATOR);
514 optString.append(OPTION_TIMEOUT_VALUE);
515 optString.append(GETOPT_ARGUMENT_DESIGNATOR);
518 optString.append(OPTION_LIST);
519 optString.append(OPTION_CURRENT_VALUE);
520 optString.append(OPTION_PLANNED_VALUE);
521 optString.append(OPTION_DEFAULT_VALUE);
522 #ifdef PEGASUS_OS_PASE
523 optString.append(OPTION_QUIET_VALUE);
525 optString.append(OPTION_HELP);
528 // Initialize and parse options
530 getoopt options ("");
531 options.addFlagspec(optString);
532 //PEP#167 - adding long flag for options : 'help' and 'version'
533 options.addLongFlagspec(LONG_HELP,getoopt::NOARG);
534 options.addLongFlagspec(LONG_VERSION,getoopt::NOARG);
536 options.parse (argc, argv);
538 if (options.hasErrors ())
540 throw CommandFormatException(options.getErrorStrings()[0]);
543 _operationType = OPERATION_TYPE_UNINITIALIZED;
547 // Get options and arguments from the command line
549 for (i = options.first (); i < options.last (); i++)
551 if (options[i].getType () == Optarg::LONGFLAG)
553 if (options[i].getopt () == LONG_HELP)
555 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
558 // More than one operation option was found
560 throw UnexpectedOptionException(String(LONG_HELP));
563 _operationType = OPERATION_TYPE_HELP;
565 else if (options[i].getopt () == LONG_VERSION)
567 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
570 // More than one operation option was found
572 throw UnexpectedOptionException(String(LONG_VERSION));
575 _operationType = OPERATION_TYPE_VERSION;
578 else if (options [i].getType () == Optarg::REGULAR)
581 // The cimconfig command has no non-option argument options
583 throw UnexpectedArgumentException(options[i].Value());
585 else /* if (options [i].getType () == Optarg::FLAG) */
588 c = options [i].getopt () [0];
594 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
597 // More than one operation option was found
599 throw UnexpectedOptionException(OPTION_GET);
602 if (options.isSet (OPTION_GET) > 1)
605 // More than one get option was found
607 throw DuplicateOptionException(OPTION_GET);
612 _propertyName = options [i].Value ();
614 catch (const InvalidNameException&)
616 throw InvalidOptionArgumentException(
617 options[i].Value(), OPTION_GET);
620 _operationType = OPERATION_TYPE_GET;
627 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
630 // More than one operation option was found
632 throw UnexpectedOptionException(OPTION_SET);
635 if (options.isSet (OPTION_SET) > 1)
638 // More than one set option was found
640 throw DuplicateOptionException(OPTION_SET);
643 _operationType = OPERATION_TYPE_SET;
645 property = options [i].Value ();
647 equalsIndex = property.find ('=');
649 if ( equalsIndex == PEG_NOT_FOUND )
652 // The property value was not specified
654 throw InvalidOptionArgumentException(
661 _propertyName = CIMName (property.subString
664 catch (const InvalidNameException&)
666 throw InvalidOptionArgumentException(
667 property, OPTION_SET);
670 _propertyValue = property.subString( equalsIndex + 1 );
675 case OPTION_TIMEOUT_VALUE:
677 if (options.isSet (OPTION_TIMEOUT_VALUE) > 1)
679 throw DuplicateOptionException(OPTION_TIMEOUT_VALUE);
682 property = options [i].Value ();
684 if (!StringConversion::decimalStringToUint64(
685 property.getCString(), value) || !value)
687 throw InvalidOptionArgumentException(
688 property, OPTION_TIMEOUT_VALUE);
690 _timeoutSeconds = (Uint32)value;
696 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
699 // More than one operation option was found
701 throw UnexpectedOptionException(OPTION_UNSET);
704 if (options.isSet (OPTION_UNSET) > 1)
707 // More than one unset option was found
709 throw DuplicateOptionException(OPTION_UNSET);
714 _propertyName = options [i].Value ();
716 catch (const InvalidNameException&)
718 throw InvalidOptionArgumentException(
719 options[i].Value(), OPTION_UNSET);
722 _operationType = OPERATION_TYPE_UNSET;
729 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
732 // More than one operation option was found
734 throw UnexpectedOptionException(OPTION_LIST);
737 if (options.isSet (OPTION_LIST) > 1)
740 // More than one list option was found
742 throw DuplicateOptionException(OPTION_LIST);
744 _operationType = OPERATION_TYPE_LIST;
748 case OPTION_CURRENT_VALUE:
750 if (options.isSet (OPTION_CURRENT_VALUE) > 1)
753 // More than one current value option was found
755 throw DuplicateOptionException(OPTION_CURRENT_VALUE);
758 _currentValueSet = true;
762 case OPTION_PLANNED_VALUE:
764 if (options.isSet (OPTION_PLANNED_VALUE) > 1)
767 // More than one planned value option was found
769 throw DuplicateOptionException(OPTION_PLANNED_VALUE);
772 _plannedValueSet = true;
776 case OPTION_DEFAULT_VALUE:
778 if (options.isSet (OPTION_DEFAULT_VALUE) > 1)
781 // More than one default value option was found
783 throw DuplicateOptionException(OPTION_DEFAULT_VALUE);
786 _defaultValueSet = true;
790 //PEP#167 - 2 new cases added below for HELP and VERSION
793 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
796 // More than one operation option was found
798 throw UnexpectedOptionException(OPTION_HELP);
801 if (options.isSet (OPTION_HELP) > 1)
804 // More than one list option was found
806 throw DuplicateOptionException(OPTION_HELP);
808 _operationType = OPERATION_TYPE_HELP;
813 if (_operationType != OPERATION_TYPE_UNINITIALIZED)
816 // More than one operation option was found
818 throw UnexpectedOptionException(OPTION_VERSION);
821 if (options.isSet (OPTION_VERSION) > 1)
824 // More than one list option was found
826 throw DuplicateOptionException(OPTION_VERSION);
828 _operationType = OPERATION_TYPE_VERSION;
832 #ifdef PEGASUS_OS_PASE
833 // check for quiet option
834 // before processing the rest of the options
835 case OPTION_QUIET_VALUE:
837 _defaultQuietSet = true;
838 freopen("/dev/null","w",stdout);
839 freopen("/dev/null","w",stderr);
846 // Should never get here
853 if ( _operationType == OPERATION_TYPE_UNINITIALIZED )
856 // No operation type was specified; throw exception
857 // so that usage can be displayed.
859 throw CommandFormatException(localizeMessage(
860 MSG_PATH, REQUIRED_ARGS_MISSING_KEY, REQUIRED_ARGS_MISSING));
863 if ( ( _operationType != OPERATION_TYPE_GET ) && ( _defaultValueSet ) )
866 // An invalid option was encountered
868 throw InvalidOptionException(OPTION_DEFAULT_VALUE);
871 if (_operationType != OPERATION_TYPE_SET &&
872 _operationType != OPERATION_TYPE_UNSET && _timeoutSeconds != 0)
875 // An invalid option was encountered
877 throw InvalidOptionException(OPTION_TIMEOUT_VALUE);
880 if (_operationType == OPERATION_TYPE_LIST)
882 if ( _currentValueSet && _plannedValueSet )
885 // An invalid option was encountered
887 throw InvalidOptionException(OPTION_CURRENT_VALUE);
889 #ifdef PEGASUS_OS_PASE
890 if( _defaultQuietSet )
893 // An invalid option was encountered
895 throw InvalidOptionException(OPTION_QUIET_VALUE);
902 // if no options specified for get, set or unset operations
903 // then set option as _currentValueSet
905 if ( !_currentValueSet && !_plannedValueSet && !_defaultValueSet )
907 _currentValueSet = true;
914 Executes the command and writes the results to the PrintWriters.
916 Uint32 CIMConfigCommand::execute(
917 ostream& outPrintWriter,
918 ostream& errPrintWriter)
920 Boolean connected = false;
925 Boolean gotCurrentValue = false;
926 Boolean gotPlannedValue = false;
928 if (_operationType == OPERATION_TYPE_UNINITIALIZED)
931 // The command was not initialized
935 else if (_operationType == OPERATION_TYPE_HELP)
937 cerr << usage << endl;
940 else if (_operationType == OPERATION_TYPE_VERSION)
942 cerr << "Version " << PEGASUS_PRODUCT_VERSION << endl;
947 // Get local host name
949 _hostName.assign(System::getHostName());
953 // Construct the CIMClient and set to request server messages
954 // in the default language of this client process.
955 _client.reset(new CIMClient);
956 _client->setRequestDefaultLanguages();
958 catch (const Exception& e)
960 errPrintWriter << e.getMessage() << endl;
967 // Open connection with CIMSever
969 _client->connectLocal();
973 catch (const Exception&)
976 // Failed to connect, so process the request offline.
984 // Locate the config files
986 const char* env = getenv("PEGASUS_HOME");
989 FileSystem::getAbsolutePath(env, PEGASUS_CURRENT_CONFIG_FILE_PATH);
991 FileSystem::getAbsolutePath(env, PEGASUS_PLANNED_CONFIG_FILE_PATH);
996 // Open default config files and load current config properties
998 _configFileHandler.reset(
999 new ConfigFileHandler(currentFile, plannedFile, true));;
1001 catch (const NoSuchFile&)
1004 catch (const FileNotReadable& fnr)
1008 MSG_PATH, FILE_NOT_READABLE_KEY, FILE_NOT_READABLE)
1009 << fnr.getMessage() << endl;
1012 catch (const ConfigFileSyntaxError& cfse)
1014 errPrintWriter << cfse.getMessage() << endl;
1019 // When the CIM Server is not running, cimconfig only updates the
1020 // planned config properties.
1022 _configFileHandler->loadPlannedConfigProperties();
1026 // Perform the requested operation
1028 switch (_operationType)
1030 case OPERATION_TYPE_GET:
1035 Array<String> propertyValues;
1037 _getPropertiesFromCIMServer( outPrintWriter,
1038 errPrintWriter, _propertyName, propertyValues);
1040 defaultValue = propertyValues[1];
1041 currentValue = propertyValues[2];
1042 gotCurrentValue = true;
1043 plannedValue = propertyValues[3];
1044 gotPlannedValue = true;
1048 if (_defaultValueSet)
1050 errPrintWriter << localizeMessage(MSG_PATH,
1051 OPTION_INVALID_CIM_RUNNING_KEY,
1052 OPTION_INVALID_CIM_RUNNING,
1053 String(&OPTION_DEFAULT_VALUE,1))
1055 return ( RC_ERROR );
1059 gotCurrentValue = _configFileHandler->getCurrentValue (
1060 _propertyName, currentValue );
1061 gotPlannedValue = _configFileHandler->getPlannedValue (
1062 _propertyName, plannedValue );
1066 catch (const CIMException& e)
1068 CIMStatusCode code = e.getCode();
1070 if (code == CIM_ERR_NOT_FOUND ||
1071 code == CIM_ERR_FAILED)
1073 outPrintWriter << localizeMessage(MSG_PATH,
1074 PROPERTY_NOT_FOUND_KEY,
1078 errPrintWriter << e.getMessage() << endl;
1080 else if (code == CIM_ERR_INVALID_CLASS)
1082 outPrintWriter << localizeMessage(MSG_PATH,
1083 FAILED_TO_GET_PROPERTY_KEY,
1084 FAILED_TO_GET_PROPERTY)
1086 localizeMessage(MSG_PATH,
1087 CONFIG_SCHEMA_NOT_LOADED_KEY,
1088 CONFIG_SCHEMA_NOT_LOADED)
1096 FAILED_TO_GET_PROPERTY_KEY,
1097 FAILED_TO_GET_PROPERTY)
1098 << e.getMessage() << endl;
1101 return ( RC_ERROR );
1103 catch (const Exception& e)
1106 << localizeMessage(MSG_PATH,FAILED_TO_GET_PROPERTY_KEY,
1107 FAILED_TO_GET_PROPERTY) << endl
1108 << e.getMessage() << endl;
1109 return ( RC_ERROR );
1112 if( _currentValueSet || ( !_plannedValueSet && !_defaultValueSet ))
1114 if (gotCurrentValue)
1116 outPrintWriter << localizeMessage(MSG_PATH,
1117 CURRENT_VALUE_IS_KEY,
1119 currentValue) << endl;
1124 << localizeMessage(MSG_PATH,
1125 CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING_KEY,
1126 CANNOT_DETERMINE_CURRENT_VALUE_CIM_RUNNING)
1132 if( _plannedValueSet )
1134 if (gotPlannedValue)
1136 outPrintWriter << localizeMessage(MSG_PATH,
1137 PLANNED_VALUE_IS_KEY,
1139 plannedValue) << endl;
1144 << localizeMessage(MSG_PATH,
1145 CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING_KEY,
1146 CANNOT_DETERMINE_PLANNED_VALUE_CIM_RUNNING)
1152 if( _defaultValueSet )
1154 outPrintWriter << localizeMessage(MSG_PATH,
1155 DEFAULT_VALUE_IS_KEY,
1157 defaultValue) << endl;
1161 case OPERATION_TYPE_SET:
1163 // send changes to CIMOM if running, else send to config file
1169 _updatePropertyInCIMServer( outPrintWriter,
1170 errPrintWriter, _propertyName, _propertyValue, false);
1172 if ( _currentValueSet )
1175 << localizeMessage(MSG_PATH,
1176 CURRENT_VALUE_OF_PROPERTY_IS_KEY,
1177 CURRENT_VALUE_OF_PROPERTY_IS,
1178 _propertyName.getString(),
1183 if ( _plannedValueSet )
1186 << localizeMessage(MSG_PATH,
1187 PLANNED_VALUE_OF_PROPERTY_IS_KEY,
1188 PLANNED_VALUE_OF_PROPERTY_IS,
1189 _propertyName.getString(),
1196 if (_currentValueSet)
1199 << localizeMessage(MSG_PATH,
1200 CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET_KEY,
1201 CURRENT_VALUE_OF_PROPERTY_CANNOT_BE_SET,
1202 _propertyName.getString()) << endl;
1204 return ( RC_ERROR );
1206 else if (_plannedValueSet)
1208 if ( !_configFileHandler->updatePlannedValue(
1209 _propertyName, _propertyValue, false ) )
1212 << localizeMessage(MSG_PATH,
1213 FAILED_UPDATE_OF_PLANNED_VALUE_IN_FILE_KEY,
1214 FAILED_UPDATE_OF_PLANNED_VALUE_IN_FILE,
1215 _propertyName.getString())
1217 return ( RC_ERROR );
1221 << localizeMessage(MSG_PATH,
1222 PROPERTY_UPDATED_IN_FILE_KEY,
1223 PROPERTY_UPDATED_IN_FILE,
1224 _propertyName.getString()) << endl;
1228 catch (const CIMException& e)
1230 CIMStatusCode code = e.getCode();
1232 if (code == CIM_ERR_TYPE_MISMATCH)
1234 outPrintWriter << localizeMessage(MSG_PATH,
1235 INVALID_PROPERTY_VALUE_KEY,
1236 INVALID_PROPERTY_VALUE) << endl;
1238 errPrintWriter << e.getMessage() << endl;
1240 else if (code == CIM_ERR_NOT_FOUND)
1242 outPrintWriter << localizeMessage(MSG_PATH,
1243 PROPERTY_NOT_FOUND_KEY,
1244 PROPERTY_NOT_FOUND) << endl;
1246 errPrintWriter << e.getMessage() << endl;
1248 else if (code == CIM_ERR_NOT_SUPPORTED)
1250 outPrintWriter << localizeMessage(MSG_PATH,
1251 PROPERTY_NOT_MODIFIED_KEY,
1252 PROPERTY_NOT_MODIFIED) << endl;
1254 errPrintWriter << e.getMessage() << endl;
1256 else if (code == CIM_ERR_FAILED)
1258 outPrintWriter << localizeMessage(MSG_PATH,
1259 FAILED_TO_SET_PROPERTY_KEY,
1260 FAILED_TO_SET_PROPERTY)
1261 << e.getMessage() << endl;
1263 else if (code == CIM_ERR_ALREADY_EXISTS)
1265 outPrintWriter << localizeMessage(MSG_PATH,
1266 PROPERTY_VALUE_ALREADY_SET_TO_KEY,
1267 PROPERTY_VALUE_ALREADY_SET_TO,
1268 _propertyName.getString(),
1269 _propertyValue) << endl;
1271 errPrintWriter << e.getMessage() << endl;
1273 else if (code == CIM_ERR_INVALID_CLASS)
1275 outPrintWriter << localizeMessage(MSG_PATH,
1276 FAILED_TO_SET_PROPERTY_KEY,
1277 FAILED_TO_SET_PROPERTY)
1279 localizeMessage(MSG_PATH,
1280 CONFIG_SCHEMA_NOT_LOADED_KEY,
1281 CONFIG_SCHEMA_NOT_LOADED)
1286 errPrintWriter << e.getMessage() << endl;
1288 return ( RC_ERROR );
1290 catch (const Exception& e)
1292 outPrintWriter << localizeMessage(MSG_PATH,
1293 FAILED_TO_SET_PROPERTY_KEY,
1294 FAILED_TO_SET_PROPERTY)
1296 << e.getMessage() << endl;
1297 return ( RC_ERROR );
1301 case OPERATION_TYPE_UNSET:
1303 // send changes to CIMOM if running, else send to config file
1309 _propertyValue = String::EMPTY;
1311 _updatePropertyInCIMServer( outPrintWriter,
1312 errPrintWriter, _propertyName, _propertyValue, true);
1314 if ( _currentValueSet )
1316 outPrintWriter << localizeMessage(MSG_PATH,
1317 CURRENT_PROPERTY_SET_TO_DEFAULT_KEY,
1318 CURRENT_PROPERTY_SET_TO_DEFAULT,
1319 _propertyName.getString())
1324 if ( _plannedValueSet )
1326 outPrintWriter << localizeMessage(MSG_PATH,
1327 PROPERTY_UNSET_IN_FILE_KEY,
1328 PROPERTY_UNSET_IN_FILE,
1329 _propertyName.getString())
1335 if (_currentValueSet)
1337 outPrintWriter << localizeMessage(MSG_PATH,
1338 CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING_KEY,
1339 CURRENT_PROPERTY_CANNOT_BE_UNSET_CIM_NOT_RUNNING,
1340 _propertyName.getString())
1344 return ( RC_ERROR );
1347 if ( !_configFileHandler->updatePlannedValue(
1348 _propertyName, _propertyValue, true ) )
1350 return ( RC_ERROR );
1352 outPrintWriter << localizeMessage(MSG_PATH,
1353 PROPERTY_UNSET_IN_FILE_KEY,
1354 PROPERTY_UNSET_IN_FILE,
1355 _propertyName.getString())
1360 catch (const CIMException& e)
1362 CIMStatusCode code = e.getCode();
1364 if (code == CIM_ERR_TYPE_MISMATCH)
1366 outPrintWriter << localizeMessage(MSG_PATH,
1367 INVALID_PROPERTY_VALUE_KEY,
1368 INVALID_PROPERTY_VALUE)
1371 errPrintWriter << e.getMessage() << endl;
1373 else if (code == CIM_ERR_NOT_FOUND)
1375 outPrintWriter << localizeMessage(MSG_PATH,
1376 PROPERTY_NOT_FOUND_KEY,
1380 errPrintWriter << e.getMessage() << endl;
1382 else if (code == CIM_ERR_NOT_SUPPORTED)
1384 outPrintWriter << localizeMessage(MSG_PATH,
1385 PROPERTY_NOT_MODIFIED_KEY,
1386 PROPERTY_NOT_MODIFIED)
1389 errPrintWriter << e.getMessage() << endl;
1391 else if (code == CIM_ERR_FAILED)
1393 outPrintWriter << localizeMessage(MSG_PATH,
1394 FAILED_TO_UNSET_PROPERTY_KEY,
1395 FAILED_TO_UNSET_PROPERTY)
1396 << e.getMessage() << endl;
1398 else if (code == CIM_ERR_ALREADY_EXISTS)
1400 outPrintWriter << localizeMessage(MSG_PATH,
1401 PROPERTY_VALUE_ALREADY_UNSET_KEY,
1402 PROPERTY_VALUE_ALREADY_UNSET,
1403 _propertyName.getString())
1406 errPrintWriter << e.getMessage() << endl;
1408 else if (code == CIM_ERR_INVALID_CLASS)
1410 outPrintWriter << localizeMessage(MSG_PATH,
1411 FAILED_TO_UNSET_PROPERTY_KEY,
1412 FAILED_TO_UNSET_PROPERTY)
1414 localizeMessage(MSG_PATH,
1415 CONFIG_SCHEMA_NOT_LOADED_KEY,
1416 CONFIG_SCHEMA_NOT_LOADED)
1421 errPrintWriter << e.getMessage() << endl;
1423 return ( RC_ERROR );
1425 catch (const Exception& e)
1427 outPrintWriter << localizeMessage(MSG_PATH,
1428 FAILED_TO_UNSET_PROPERTY_KEY,
1429 FAILED_TO_UNSET_PROPERTY)
1430 << endl << e.getMessage() << endl;
1431 return ( RC_ERROR );
1435 case OPERATION_TYPE_LIST:
1437 // send request to CIMOM if running, else send to config file
1441 Array<CIMName> propertyNames;
1442 Array<String> propertyValues;
1446 _listAllPropertiesInCIMServer(outPrintWriter,
1447 errPrintWriter, propertyNames, propertyValues);
1452 if (_plannedValueSet)
1454 _configFileHandler->getAllPlannedProperties(
1455 propertyNames, propertyValues);
1460 << localizeMessage(MSG_PATH,
1461 CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING_KEY,
1462 CURRENT_VALUES_CANNOT_BE_LISTED_CIM_NOT_RUNNING)
1468 Uint32 valuesSize = propertyValues.size();
1469 Uint32 namesSize = propertyNames.size();
1473 outPrintWriter << localizeMessage(MSG_PATH,
1474 NO_PROPERTIES_FOUND_IN_FILE_KEY,
1475 NO_PROPERTIES_FOUND_IN_FILE)
1480 for ( Uint32 i = 0; i < namesSize; i++ )
1482 outPrintWriter << propertyNames[i].getString();
1483 if ( ( _currentValueSet || _plannedValueSet ) &&
1484 ( valuesSize == namesSize) )
1486 outPrintWriter << "=" << propertyValues[i];
1488 outPrintWriter << endl;
1492 catch (const CIMException& e)
1494 CIMStatusCode code = e.getCode();
1496 if (code == CIM_ERR_NOT_FOUND || code == CIM_ERR_INVALID_CLASS)
1498 outPrintWriter << localizeMessage(MSG_PATH,
1499 FAILED_TO_LIST_PROPERTIES_KEY,
1500 FAILED_TO_LIST_PROPERTIES)
1502 localizeMessage(MSG_PATH,
1503 CONFIG_SCHEMA_NOT_LOADED_KEY,
1504 CONFIG_SCHEMA_NOT_LOADED)
1507 else if (code == CIM_ERR_FAILED)
1509 outPrintWriter << localizeMessage(MSG_PATH,
1510 FAILED_TO_LIST_PROPERTIES_KEY,
1511 FAILED_TO_LIST_PROPERTIES)
1512 << e.getMessage() << endl;
1516 errPrintWriter << e.getMessage() << endl;
1519 return ( RC_ERROR );
1521 catch (const Exception& e)
1523 outPrintWriter << localizeMessage(MSG_PATH,
1524 FAILED_TO_LIST_PROPERTIES_KEY,
1525 FAILED_TO_LIST_PROPERTIES)
1526 << endl << e.getMessage() << endl;
1527 return ( RC_ERROR );
1532 // Should never get here
1537 return (RC_SUCCESS);
1541 Get property values for the specified property from the CIM Server.
1543 void CIMConfigCommand::_getPropertiesFromCIMServer
1545 ostream& outPrintWriter,
1546 ostream& errPrintWriter,
1547 const CIMName& propName,
1548 Array <String>& propValues
1553 Array<CIMKeyBinding> kbArray;
1556 kb.setName(PROPERTY_NAME);
1557 kb.setValue(propName.getString());
1558 kb.setType(CIMKeyBinding::STRING);
1562 CIMObjectPath reference(
1563 _hostName, PEGASUS_NAMESPACENAME_CONFIG,
1564 PEGASUS_CLASSNAME_CONFIGSETTING, kbArray);
1566 CIMInstance cimInstance =
1567 _client->getInstance(PEGASUS_NAMESPACENAME_CONFIG, reference);
1569 Uint32 pos = cimInstance.findProperty(PROPERTY_NAME);
1570 prop = (CIMProperty)cimInstance.getProperty(pos);
1571 propValues.append(prop.getValue().toString());
1573 pos = cimInstance.findProperty(DEFAULT_VALUE);
1574 prop = (CIMProperty)cimInstance.getProperty(pos);
1575 propValues.append(prop.getValue().toString());
1577 pos = cimInstance.findProperty(CURRENT_VALUE);
1578 prop = (CIMProperty)cimInstance.getProperty(pos);
1579 propValues.append(prop.getValue().toString());
1581 pos = cimInstance.findProperty(PLANNED_VALUE);
1582 prop = (CIMProperty)cimInstance.getProperty(pos);
1583 propValues.append(prop.getValue().toString());
1585 pos = cimInstance.findProperty(DYNAMIC_PROPERTY);
1586 prop = (CIMProperty)cimInstance.getProperty(pos);
1587 propValues.append(prop.getValue().toString());
1591 Send an updated property value to the CIM Server.
1593 void CIMConfigCommand::_updatePropertyInCIMServer
1595 ostream& outPrintWriter,
1596 ostream& errPrintWriter,
1597 const CIMName& propName,
1598 const String& propValue,
1599 Boolean isUnsetOperation
1602 Array<CIMKeyBinding> kbArray;
1605 kb.setName(PROPERTY_NAME);
1606 kb.setValue(propName.getString());
1607 kb.setType(CIMKeyBinding::STRING);
1611 CIMObjectPath reference(
1612 _hostName, PEGASUS_NAMESPACENAME_CONFIG,
1613 PEGASUS_CLASSNAME_CONFIGSETTING, kbArray);
1615 if (_timeoutSeconds == 0)
1617 _timeoutSeconds = (PEGASUS_DEFAULT_CLIENT_TIMEOUT_MILLISECONDS / 1000);
1620 Array<CIMParamValue> inParams;
1621 Array<CIMParamValue> outParams;
1624 CIMParamValue(PARAM_PROPERTYVALUE, CIMValue(propValue)));
1629 CIMValue(isUnsetOperation)));
1633 PARAM_UPDATEPLANNEDVALUE,
1634 CIMValue(_plannedValueSet)));
1638 PARAM_UPDATECURRENTVALUE,
1639 CIMValue(_currentValueSet)));
1643 PARAM_TIMEOUTPERIOD,
1644 CIMValue(_timeoutSeconds)));
1646 // Set timeout and add some grace time.
1647 _client->setTimeout( (_timeoutSeconds + 10) * 1000);
1649 _client->invokeMethod(
1650 PEGASUS_NAMESPACENAME_CONFIG,
1652 METHOD_UPDATE_PROPERTY_VALUE,
1659 get a list of all property names and value from the CIM Server.
1661 void CIMConfigCommand::_listAllPropertiesInCIMServer
1663 ostream& outPrintWriter,
1664 ostream& errPrintWriter,
1665 Array <CIMName>& propNames,
1666 Array <String>& propValues
1669 Array<CIMInstance> configNamedInstances;
1671 if ( _currentValueSet || _plannedValueSet )
1674 // get all the instances of class PG_ConfigSetting
1676 configNamedInstances =
1677 _client->enumerateInstances(
1678 PEGASUS_NAMESPACENAME_CONFIG,
1679 PEGASUS_CLASSNAME_CONFIGSETTING);
1682 // copy all the property names and values
1684 for (Uint32 i = 0; i < configNamedInstances.size(); i++)
1686 CIMInstance& configInstance =
1687 configNamedInstances[i];
1689 Uint32 pos = configInstance.findProperty
1690 (CIMName ("PropertyName"));
1691 CIMProperty prop = (CIMProperty)configInstance.getProperty(pos);
1692 propNames.append(prop.getValue().toString());
1694 if (_currentValueSet)
1697 // get current value
1699 pos = configInstance.findProperty(CIMName ("CurrentValue"));
1700 prop = (CIMProperty)configInstance.getProperty(pos);
1701 propValues.append(prop.getValue().toString());
1703 else if (_plannedValueSet)
1706 // get planned value
1708 pos = configInstance.findProperty(CIMName ("PlannedValue"));
1709 prop = (CIMProperty)configInstance.getProperty(pos);
1710 propValues.append(prop.getValue().toString());
1717 // call enumerateInstanceNames
1719 Array<CIMObjectPath> instanceNames =
1720 _client->enumerateInstanceNames(
1721 PEGASUS_NAMESPACENAME_CONFIG,
1722 PEGASUS_CLASSNAME_CONFIGSETTING);
1724 // copy all the property names
1726 for (Uint32 i = 0; i < instanceNames.size(); i++)
1728 Array<CIMKeyBinding> kbArray =
1729 instanceNames[i].getKeyBindings();
1731 if (kbArray.size() > 0)
1733 propNames.append(kbArray[0].getValue());
1739 PEGASUS_NAMESPACE_END
1742 // exclude main from the Pegasus Namespace
1744 PEGASUS_USING_PEGASUS;
1748 ///////////////////////////////////////////////////////////////////////////////
1750 Parses the command line, and execute the command.
1752 @param args the string array containing the command line arguments
1754 ///////////////////////////////////////////////////////////////////////////////
1756 int main (int argc, char* argv [])
1758 #ifdef PEGASUS_OS_PASE
1759 // Allow user group name larger than 8 chars in PASE environemnt
1760 setenv("PASE_USRGRP_LIMITED","N",1);
1762 AutoPtr<CIMConfigCommand> command;
1765 //l10n set message loading to process locale
1766 MessageLoader::_useProcessLocale = true;
1767 MessageLoader::setPegasusMsgHomeRelative(argv[0]);
1769 #ifdef PEGASUS_OS_PASE
1770 // Check special authorities in PASE environment
1771 if (!umeCheckCmdAuthorities(false))
1772 return Command::RC_ERROR;
1775 #ifdef PEGASUS_OS_ZOS
1776 // for z/OS set stdout and stderr to EBCDIC
1777 setEBCDICEncoding(STDOUT_FILENO);
1778 setEBCDICEncoding(STDERR_FILENO);
1781 command.reset(new CIMConfigCommand ());
1785 command->setCommand (argc, argv);
1787 catch (const CommandFormatException& cfe)
1789 cerr << COMMAND_NAME << ": " << cfe.getMessage() << endl;
1791 MessageLoaderParms parms(ERR_USAGE_KEY,ERR_USAGE);
1792 parms.msg_src_path = MSG_PATH;
1793 cerr << COMMAND_NAME <<
1794 ": " << MessageLoader::getMessage(parms) << endl;
1795 exit (Command::RC_ERROR);
1798 returnCode = command->execute (cout, cerr);