(file) Return to ConsoleManager_zOS.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Server

  1 martin 1.9 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.10 //
  3 martin 1.9  // 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
  8             // License.
  9 martin 1.10 //
 10 martin 1.9  // 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:
 16 martin 1.10 //
 17 martin 1.9  // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.10 //
 20 martin 1.9  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.10 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.9  // 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.
 27 martin 1.10 //
 28 martin 1.9  //////////////////////////////////////////////////////////////////////////
 29 r.kieninger 1.1  //
 30                  //%////////////////////////////////////////////////////////////////////////////
 31                  
 32                  
 33                  /////////////////////////////////////////////////////////////////////////////
 34                  //  ConsoleManager
 35                  /////////////////////////////////////////////////////////////////////////////
 36                  
 37                  #include <Pegasus/Common/Constants.h>
 38                  #include <Pegasus/Common/Tracer.h>
 39                  #include <Pegasus/Common/Logger.h>
 40                  #include <Pegasus/Common/PegasusVersion.h>
 41                  #include <Pegasus/Common/FileSystem.h>
 42 kumpf       1.3  #include <Pegasus/Common/AuditLogger.h>
 43 r.kieninger 1.1  #include <Pegasus/Config/ConfigManager.h>
 44                  
 45                  #include <sys/__messag.h>
 46                  
 47                  #include "ConsoleManager_zOS.h"
 48                  #include "CIMServer.h"
 49                  
 50                  PEGASUS_NAMESPACE_BEGIN
 51                  
 52 thilo.boehm 1.17 #define ZOSCONSOLEMANAGER_TOKEN_CONFIG  "CONFIG,"
 53                  #define ZOSCONSOLEMANAGER_TOKEN_VERSION "VERSION"
 54                  #define ZOSCONSOLEMANAGER_TOKEN_ENV     "ENV"
 55                  #define ZOSCONSOLEMANAGER_TOKEN_PLANNED "PLANNED"
 56 r.kieninger 1.1  
 57 thilo.boehm 1.17 enum CommandType
 58                  {
 59                      consoleCmdConfig,
 60                      consoleCmdVersion,
 61                      consoleCmdEnv,
 62                      consoleCmdInvalid
 63                  };
 64 r.kieninger 1.1  
 65                  
 66 thilo.boehm 1.17 char* ZOSConsoleManager::_skipBlanks( char* commandPtr)
 67 r.kieninger 1.1  {
 68                      if (commandPtr != NULL)
 69                      {
 70                          while (*commandPtr == ' ')
 71                          {
 72                              commandPtr++;
 73                          }
 74                      }
 75                  
 76                      return commandPtr;
 77                  }
 78                  
 79 thilo.boehm 1.17 void ZOSConsoleManager::_stripTrailingBlanks( char* token )
 80 r.kieninger 1.1  {
 81                      if (token != NULL)
 82                      {
 83                          int len = strlen(token)-1;
 84                  
 85                          while ((len >= 0) && (token[len] == ' '))
 86                          {
 87                              token[len] = '\0';
 88                              len--;
 89                          }
 90                      }
 91                  
 92                      return;
 93                  }
 94                  
 95 thilo.boehm 1.17 void ZOSConsoleManager::_displayServiceLevel()
 96                  {
 97                      PEG_METHOD_ENTER(TRC_SERVER,
 98                          "ZOSConsoleManager::_displayServiceLevel");
 99                  
100                      // PEGASUS_ZOS_SERVICE_STRING is defined in the z/OS platform make file
101                      String serviceString(STRLIT_ARGS(PEGASUS_ZOS_SERVICE_STRING));
102                  
103                      Logger::put_l(
104                          Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
105                          MessageLoaderParms(
106                              "Server.ConsoleManager_zOS.VERSION.PEGASUS_OS_ZOS",
107                              "CIM Server Service Level: $0",
108                              serviceString));
109                  
110                      PEG_METHOD_EXIT();
111                  }
112                  
113                  void ZOSConsoleManager::_issueSyntaxError(const char* command)
114 r.kieninger 1.1  {
115 kumpf       1.11     PEG_METHOD_ENTER(TRC_SERVER,
116 thilo.boehm 1.17         "ZOSConsoleManager::_issueSyntaxError");
117                  
118 r.kieninger 1.1      Logger::put_l(
119                          Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
120 kumpf       1.7          MessageLoaderParms(
121                              "Server.ConsoleManager_zOS.CON_SYNTAX_ERR.PEGASUS_OS_ZOS",
122                              "CIM MODIFY COMMAND REJECTED DUE TO SYNTAX ERROR"));
123 thilo.boehm 1.17 
124                      if (!strncmp(command,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_CONFIG)))
125                      {
126                          Logger::put_l(
127                              Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
128                              MessageLoaderParms(
129                                  "Server.ConsoleManager_zOS.CON_MODIFY_SYNTAX.PEGASUS_OS_ZOS",
130                                  "Syntax is: "
131                                      "MODIFY CFZCIM,APPL=CONFIG,<name>=<value>[,PLANNED]"));
132                      } 
133                      else if (!strncmp(command,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_ENV)))
134                      {
135                          Logger::put_l(
136                              Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
137                              MessageLoaderParms(
138                                  "Server.ConsoleManager_zOS."
139                                      "CON_MODIFY_ENV_SYNTAX.PEGASUS_OS_ZOS",
140                                  "Syntax is:"
141                                      " MODIFY CFZCIM,APPL=ENV[,<varname>][=<value>]"));
142                      }
143 r.kieninger 1.1  
144                      PEG_METHOD_EXIT();
145                  }
146                  
147                  
148 thilo.boehm 1.17 void ZOSConsoleManager::_updateConfiguration( 
149                      const String& configProperty,
150                      const String& propertyValue,
151                      Boolean currentValueIsNull,
152                      Boolean planned)
153 r.kieninger 1.1  {
154 thilo.boehm 1.17     PEG_METHOD_ENTER(TRC_SERVER,"ZOSConsoleManager::_updateConfiguration");
155 r.kieninger 1.1  
156                      String preValue;
157                      String currentValue;
158 thilo.boehm 1.16     String displayValue;
159                      String defaultValue;
160 r.kieninger 1.1  
161                      try
162                      {
163                          ConfigManager* _configManager = ConfigManager::getInstance();
164                  
165                          preValue = _configManager->getCurrentValue(configProperty);
166 thilo.boehm 1.16         defaultValue = _configManager->getDefaultValue(configProperty);
167                  
168                          //If currentValueIsNull is true, the updateCurrentValue() will use the
169                          // default value, so we need the default value for the messages.
170                          if(currentValueIsNull)
171                          {
172                              displayValue = defaultValue;
173                          }
174                          else
175                          {
176                              displayValue = propertyValue;
177                          }
178 r.kieninger 1.1  
179                          if (!planned)
180                          {
181                              //
182                              // Update the current value
183                              //
184 r.kieninger 1.12             if ( !_configManager->updateCurrentValue(
185                                                        configProperty,
186                                                        propertyValue,
187                                                        System::getEffectiveUserName(),
188 venkat.puvvada 1.13                                       0,
189 r.kieninger    1.12                                       currentValueIsNull) )
190 r.kieninger    1.1              {
191                                     Logger::put_l(
192                                         Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
193 kumpf          1.7                      MessageLoaderParms(
194                                             "Server.ConsoleManager_zOS."
195                                                 "CON_MODIFY_FAILED.PEGASUS_OS_ZOS",
196                                             "Failed to update CONFIG value."));
197 r.kieninger    1.1              }
198                                 else
199                                 {
200                                     Logger::put_l(
201 thilo.boehm    1.17                     Logger::STANDARD_LOG, System::CIMSERVER,Logger::INFORMATION,
202 kumpf          1.7                      MessageLoaderParms(
203                                             "Server.ConsoleManager_zOS."
204                                                 "CON_MODIFY_UPDATED.PEGASUS_OS_ZOS",
205                                             "Updated current value for $0 to $1",
206 thilo.boehm    1.17                         configProperty,
207                                             displayValue));
208 r.kieninger    1.1              }
209                             }
210                             else
211                             {
212                                 //
213                                 // Update the planned value
214                                 //
215                                 if ( !_configManager->updatePlannedValue(configProperty,
216                                                                          propertyValue,
217                                                                          currentValueIsNull) )
218                                 {
219                                     Logger::put_l(
220                                         Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
221 kumpf          1.7                      MessageLoaderParms(
222                                             "Server.ConsoleManager_zOS."
223                                                 "CON_MODIFY_FAILED.PEGASUS_OS_ZOS",
224                                             "Failed to update CONFIG value."));
225 r.kieninger    1.1              }
226                                 else
227                                 {
228                                     Logger::put_l(
229                                         Logger::STANDARD_LOG, System::CIMSERVER,
230                                         Logger::INFORMATION,
231 kumpf          1.7                      MessageLoaderParms(
232                                             "Server.ConsoleManager_zOS."
233                                                 "CON_MODIFY_PLANNED.PEGASUS_OS_ZOS",
234                                             "Updated planned value for $0 to $1",
235 thilo.boehm    1.17                         configProperty,
236                                             displayValue));
237                     
238 r.kieninger    1.1                  Logger::put_l(
239                                         Logger::STANDARD_LOG, System::CIMSERVER,
240                                         Logger::INFORMATION,
241 kumpf          1.7                      MessageLoaderParms(
242                                             "Server.ConsoleManager_zOS."
243                                                 "CON_MODIFY_PLANNED2.PEGASUS_OS_ZOS",
244                                             "This change will become effective "
245                                             "after CIM Server restart."));
246 r.kieninger    1.1              }
247                             }
248                     
249                             // send notify config change message to ProviderManager Service
250 thilo.boehm    1.16         _sendNotifyConfigChangeMessage(displayValue,
251 r.kieninger    1.1                                         currentValue,
252 thilo.boehm    1.4                                            !planned);
253 r.kieninger    1.1  
254                             PEG_AUDIT_LOG(logSetConfigProperty("OPERATOR",
255 thilo.boehm    1.16                                            displayValue,
256 r.kieninger    1.1                                             preValue,
257                                                                currentValue,
258 thilo.boehm    1.4                                             planned));
259 r.kieninger    1.1  
260                         }
261 marek          1.19     catch(const Exception& e)
262 r.kieninger    1.1      {
263                             Logger::put_l(
264                                 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
265 kumpf          1.7              MessageLoaderParms(
266                                     "Server.ConsoleManager_zOS.CON_MODIFY_ERR.PEGASUS_OS_ZOS",
267                                     "MODIFY command failed: \"$0\"",
268 marek          1.19                 e.getMessage()));
269 r.kieninger    1.1      }
270                         PEG_METHOD_EXIT();
271                     }
272                     
273                     
274 thilo.boehm    1.17 void ZOSConsoleManager::_updateEnvironment( 
275                         const char* envVarName,
276                         const char* envVarValue)
277                     {
278                         PEG_METHOD_ENTER(TRC_SERVER,
279                             "ZOSConsoleManager::_updateEnvironment");
280                     
281                         String envVarNameString(envVarName);
282                     
283                         int rc=setenv(envVarName,envVarValue,1);
284                     
285                         if (rc==0)
286                         {
287                             String envVarValueString;
288                             if (envVarValue!=NULL)
289                             {
290                                 envVarValueString.assign(envVarValue);
291                                 Logger::put_l(
292                                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
293                                     MessageLoaderParms(
294                                         "Server.ConsoleManager_zOS."
295 thilo.boehm    1.17                         "CON_MODIFY_SETENV.PEGASUS_OS_ZOS",
296                                         "Environment variable \"$0\" set to \"$1\" successfully.",
297                                         envVarNameString, 
298                                         envVarValueString));
299                             }
300                             else
301                             {
302                                 Logger::put_l(
303                                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
304                                     MessageLoaderParms(
305                                         "Server.ConsoleManager_zOS."
306                                             "CON_MODIFY_DELETEENV.PEGASUS_OS_ZOS",
307                                         "Environment variable \"$0\" deleted successfully.",
308                                         envVarNameString));
309                             }
310                         }
311                         else
312                         {
313                             Logger::put_l(
314                                 Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
315                                 MessageLoaderParms(
316 thilo.boehm    1.17                 "Server.ConsoleManager_zOS.CON_MODIFYENV_FAILED.PEGASUS_OS_ZOS",
317                                     "Failed to update environment variable \"$0\".",
318                                     envVarNameString));
319                         }
320                     
321                         // To be 100% complete we would need an AuditLog here.
322                         // But since we don't track env vars for z/OS, this is
323                         // omitted intentionally.
324                     
325                         PEG_METHOD_EXIT();
326                     }
327                     
328                     
329                     /******************************************************************************
330                      Either displays the value of a specific environment variable
331                      (envVarName!=null) or the complete list of all currently defined
332                      environment variables with their values.
333                     ******************************************************************************/
334                     void ZOSConsoleManager::_showEnvironment(const char* envVarName)
335                     {
336                         PEG_METHOD_ENTER(TRC_SERVER,
337 thilo.boehm    1.17         "ZOSConsoleManager::_showEnvironment");
338                     
339                         // See XL C/C++ Runtime Library Reference for documentation on the
340                         // **environ variable
341                         extern char** environ;
342                     
343                         if ((0==envVarName) || strlen(envVarName)==0)
344                         {
345                             // Display list of all environment variables
346                             char** var;
347                             char varMessage[4080];
348                             char* varMsgPtr = &(varMessage[0]);
349                             unsigned int varMsgLength = 0;
350                             // For each line we add 3 extra characters: '-' + ' ' + '\n'
351                             const unsigned int extraCharsPerLine = 3;
352                     
353                             var = environ;
354                             while (*var != NULL)
355                             {
356                                 int varLen = strlen(*var);
357                                 varMsgLength += (varLen+extraCharsPerLine);
358 thilo.boehm    1.17 
359                                 // The Logger will not display messages longer than 4000 characters
360                                 // Therefore we list the environment variables in multiple messages
361                                 // when the size of the environment string exceeds 3900.
362                                 do
363                                 {
364                                     *varMsgPtr='-';     // extra char #1
365                                     varMsgPtr++;
366                                     *varMsgPtr=' ';     // extra char #2
367                                     varMsgPtr++;
368                                     memcpy(varMsgPtr,*var,varLen);
369                                     varMsgPtr+=varLen;
370                                     *varMsgPtr='\n';    // extra char #3
371                                     varMsgPtr++;
372                     
373                                     // Move on to the next env var
374                                     ++var;
375                                     varLen = strlen(*var);
376                                     varMsgLength += (varLen+extraCharsPerLine);
377                                 } while ((varMsgLength < 3900) && (*var != NULL));
378                     
379 thilo.boehm    1.17             *varMsgPtr = '\0';
380                                 String envVarString(varMessage);
381                                 Logger::put_l(
382                                     Logger::STANDARD_LOG, System::CIMSERVER,
383                                     Logger::INFORMATION,
384                                     MessageLoaderParms(
385                                         "Server.ConsoleManager_zOS."
386                                             "CON_MODIFY_DISPLAY_ALLENV.PEGASUS_OS_ZOS",
387                                         "CFZENV: $0",envVarString));
388                     
389                                 varMsgPtr = &(varMessage[0]);
390                                 varMsgLength = 0;
391                     
392                             } // end for
393                         }
394                         else
395                         {
396                             // Just display a single environment variable
397                             String envVarNameString(envVarName);
398                             const char* envVarValue = getenv(envVarName);
399                             if (envVarValue)
400 thilo.boehm    1.17         {
401                                 String envVarValueString(envVarValue);
402                                 Logger::put_l(
403                                     Logger::STANDARD_LOG, System::CIMSERVER,
404                                     Logger::INFORMATION,
405                                     MessageLoaderParms(
406                                         "Server.ConsoleManager_zOS."
407                                             "CON_MODIFY_DISPLAY_ENV.PEGASUS_OS_ZOS",
408                                         "CFZENV: $0=$1",
409                                         envVarNameString, envVarValueString));
410                             }
411                             else
412                             {
413                                 Logger::put_l(
414                                     Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
415                                     MessageLoaderParms(
416                                         "Server.ConsoleManager_zOS."
417                                             "CON_MODIFY_ENV_UNDEFINED.PEGASUS_OS_ZOS",
418                                         "CFZENV: Variable '$0' is undefined",
419                                         envVarNameString));
420                             }
421 thilo.boehm    1.17     }
422                         PEG_METHOD_EXIT();
423                     }
424                     
425                     /******************************************************************************
426                      Syntax for Modify command is:
427                     
428                      MODIFY <jobname>,APPL=CONFIG,<properyname>=['<value>'|<value>][,PLANNED]
429                                            VERSION
430                                            ENV[,<varname>][=<value>]
431                     
432                      Parameter <command> represents the string following the "APPL=" token.
433                     
434                     ******************************************************************************/
435 r.kieninger    1.1  void ZOSConsoleManager::processModifyCommand( char* command )
436                     {
437 kumpf          1.11     PEG_METHOD_ENTER(TRC_SERVER,
438 thilo.boehm    1.4          "ZOSConsoleManager::processModifyCommand");
439 r.kieninger    1.1  
440                         char* currentPtr = command;
441                         char* cmdPtr = NULL;
442                         char* cfgProperty = NULL;
443                         char* cfgValue = NULL;
444                         char* planned = NULL;
445                         Boolean currentValueIsNull = false;
446 thilo.boehm    1.17     Boolean valueIsQuoted = false;
447                         CommandType consCmd=consoleCmdInvalid;
448 r.kieninger    1.1  
449                     
450 thilo.boehm    1.17     currentPtr = _skipBlanks(currentPtr);
451 r.kieninger    1.1  
452 thilo.boehm    1.17     if (!memcmp(currentPtr,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_CONFIG)))
453 r.kieninger    1.1      {
454 thilo.boehm    1.17         currentPtr += strlen(ZOSCONSOLEMANAGER_TOKEN_CONFIG);
455                             consCmd = consoleCmdConfig;
456                         }
457                         else if (!memcmp(currentPtr,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_VERSION)))
458                         {
459                             consCmd = consoleCmdVersion;
460                             _displayServiceLevel();
461                             PEG_METHOD_EXIT();
462                             return;
463                         }
464                         else if (!memcmp(currentPtr,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_ENV)))
465                         {
466                             consCmd = consoleCmdEnv;
467                             currentPtr += strlen(ZOSCONSOLEMANAGER_TOKEN_ENV);
468                             if (*currentPtr == ',')
469                             {
470                                 currentPtr++;
471                             }
472 r.kieninger    1.1      }
473                         else
474                         {
475 thilo.boehm    1.17         _issueSyntaxError(command);
476                             PEG_METHOD_EXIT();
477 r.kieninger    1.1          return;
478                         }
479                     
480 thilo.boehm    1.17 
481                         // Here currentPtr points after the [CONFIG,|VERSION|ENV] token.
482                         // Following is either the name of a variable or nothing
483                         currentPtr = _skipBlanks(currentPtr);
484 r.kieninger    1.1  
485                         cfgProperty = currentPtr;
486                         currentPtr = strchr(currentPtr,'=');
487                     
488                         if (currentPtr==NULL)
489                         {
490 thilo.boehm    1.17         if (consCmd == consoleCmdEnv)
491                             {
492                                 _showEnvironment(cfgProperty);
493                                 PEG_METHOD_EXIT();
494                                 return;
495                             }
496                             else
497                             {
498                                 _issueSyntaxError(command);
499                                 PEG_METHOD_EXIT();
500                                 return;
501                             }
502 r.kieninger    1.1      }
503                         else
504                         {
505                             // skip the "="
506                             *currentPtr = '\0';
507                             currentPtr++;
508                     
509 thilo.boehm    1.17         currentPtr = _skipBlanks(currentPtr);
510 r.kieninger    1.1  
511 thilo.boehm    1.16         if (*currentPtr == '\0' || *currentPtr ==',')
512 r.kieninger    1.1          {
513                                 currentValueIsNull=true;
514                             }
515                             else if (*currentPtr == '\'')
516                             {
517 thilo.boehm    1.17             // Check if value is enclosed in quotes
518 r.kieninger    1.1              char* temp = strchr(currentPtr+1,'\'');
519                                 if (temp!=NULL)
520                                 {
521                                     // skip the starting "'"
522                                     *currentPtr = '\0';
523                                     currentPtr++;
524                     
525                                     cfgValue = currentPtr;
526                                     currentPtr = temp;
527                     
528                                     // skip the ending "'"
529                                     *currentPtr = '\0';
530                                     currentPtr++;
531 thilo.boehm    1.17                 valueIsQuoted = true;
532 r.kieninger    1.1              }
533                                 else
534                                 {
535 thilo.boehm    1.17                 _issueSyntaxError(command);
536                                     PEG_METHOD_EXIT();
537 r.kieninger    1.1                  return;
538                                 }
539                             }
540                             else
541                             {
542                                 cfgValue = currentPtr;
543                             }
544                         }
545                     
546 thilo.boehm    1.17     currentPtr = _skipBlanks(currentPtr);
547 r.kieninger    1.1  
548                         planned = strchr(currentPtr,',');
549                         if (planned!=NULL)
550                         {
551                             *planned = '\0';
552                             planned++;
553                     
554 thilo.boehm    1.17         planned = _skipBlanks(planned);
555 r.kieninger    1.1  
556                             if (memcmp(planned,STRLIT_ARGS(ZOSCONSOLEMANAGER_TOKEN_PLANNED)))
557                             {
558 thilo.boehm    1.17             _issueSyntaxError(command);
559                                 PEG_METHOD_EXIT();
560 r.kieninger    1.1              return;
561                             }
562                         }
563                     
564                     
565 thilo.boehm    1.17     _stripTrailingBlanks( cfgProperty );
566                         PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,"Update property: %s", cfgProperty));
567 r.kieninger    1.1  
568                         if (currentValueIsNull)
569                         {
570                             PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL4,
571                                 "Set property with null value");
572                         }
573 thilo.boehm    1.17     else
574 r.kieninger    1.1      {
575 thilo.boehm    1.17         _stripTrailingBlanks( cfgValue );
576 r.kieninger    1.1          PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
577                                 "Update property value to: %s", cfgValue));
578                         }
579                     
580                         if (planned != NULL)
581                         {
582                             PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL4,
583                                 "Updating planned value");
584                         }
585                     
586 thilo.boehm    1.17     if (consCmd == consoleCmdEnv)
587                         {
588                             _updateEnvironment(cfgProperty, cfgValue);
589                             PEG_METHOD_EXIT();
590                             return;
591                         }
592                     
593 r.kieninger    1.1      String propertyString(cfgProperty);
594                         String propertyValue;
595                     
596                         if (!currentValueIsNull)
597                         {
598                              propertyValue.assign(cfgValue);
599 thilo.boehm    1.17 
600                              if (!valueIsQuoted)
601                              {
602                                  // All values that were not enclosed in quotes are
603                                  // converted to lowercase
604                                  propertyValue.toLower();
605                              }
606                     
607 r.kieninger    1.1      }
608                     
609 thilo.boehm    1.17     _updateConfiguration(propertyString,
610 r.kieninger    1.1                          propertyValue,
611                                             currentValueIsNull,
612                                             planned);
613                         PEG_METHOD_EXIT();
614                     }
615                     
616                     
617                     void ZOSConsoleManager::startConsoleWatchThread(void)
618                     {
619 kumpf          1.11     PEG_METHOD_ENTER(TRC_SERVER,
620 thilo.boehm    1.4          "ZOSConsoleManager::startConsoleWatchThread");
621 r.kieninger    1.1  
622                         pthread_t thid;
623                     
624                         if ( pthread_create(&thid,
625                                             NULL,
626 thilo.boehm    1.17                         ZOSConsoleManager::_consoleCommandWatchThread,
627 r.kieninger    1.1                          NULL) != 0 )
628                         {
629                             char str_errno2[10];
630                             sprintf(str_errno2,"%08X",__errno2());
631                             Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
632 kumpf          1.7              MessageLoaderParms(
633                                     "Server.ConsoleManager_zOS.NO_CONSOLE_THREAD.PEGASUS_OS_ZOS",
634                                     "CIM Server Console command thread cannot be created: "
635                                         "$0 ( errno $1, reason code 0x$2 ).",
636                                     strerror(errno),
637                                     errno,
638                                     str_errno2));
639 r.kieninger    1.1      }
640                     
641                         PEG_METHOD_EXIT();
642                     }
643                     
644                     
645                     
646                     //
647                     // z/OS console interface waiting for operator stop command
648                     //
649 thilo.boehm    1.17 void* ZOSConsoleManager::_consoleCommandWatchThread(void*)
650 r.kieninger    1.1  {
651 kumpf          1.11     PEG_METHOD_ENTER(TRC_SERVER,
652 thilo.boehm    1.17         "ZOSConsoleManager::_consoleCommandWatchThread");
653 r.kieninger    1.1  
654                         struct __cons_msg    cons;
655                         int                  concmd=0;
656                         char                 modstr[128];
657                         int                  rc;
658                     
659                         memset(&cons,0,sizeof(cons));
660                         memset(modstr,0,sizeof(modstr));
661                     
662                         do
663                         {
664                             rc = __console(&cons, modstr, &concmd);
665                     
666                             if (rc != 0)
667                             {
668                                 int errornumber = errno;
669                                 char str_errno2[10];
670                                 sprintf(str_errno2,"%08X",__errno2());
671                     
672                                 Logger::put_l(
673                                     Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE,
674 kumpf          1.7                  MessageLoaderParms(
675                                         "Server.ConsoleManager_zOS.CONSOLE_ERROR.PEGASUS_OS_ZOS",
676                                         "Console Communication Service failed:"
677                                             "$0 ( errno $1, reason code 0x$2 ).",
678                                         strerror(errornumber),
679                                         errornumber,
680                                         str_errno2));
681 r.kieninger    1.1  
682                                 break;
683                             }
684                     
685                             // Check if we received a stop command from the console
686                             if (concmd == _CC_modify)
687                             {
688                                 // Ensure the command we received from the console is
689                                 // null terminated.
690                                 modstr[127] = '\0';
691                     
692                                 PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
693                                     "Received MODIFY command: %s", modstr));
694                     
695                                 processModifyCommand(modstr);
696                             }
697                             else if (concmd != _CC_stop)
698                             {
699                                 // Just issue a console message that the command was
700                                 // not recognized and wait again for the stop command.
701                                 Logger::put_l(
702 r.kieninger    1.1                  Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
703 kumpf          1.7                  MessageLoaderParms(
704                                         "Server.ConsoleManager_zOS.CONSOLE_NO_MODIFY."
705                                             "PEGASUS_OS_ZOS",
706                                         "Command not recognized by CIM server."));
707 r.kieninger    1.1          }
708                             else
709                             {
710                                 Logger::put_l(
711                                     Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
712 kumpf          1.7                  MessageLoaderParms(
713                                         "Server.ConsoleManager_zOS.CONSOLE_STOP.PEGASUS_OS_ZOS",
714                                         "STOP command received from z/OS console,"
715                                             " initiating shutdown."));
716 r.kieninger    1.1          }
717                     
718                         // keep on until we encounter an error or received a STOP
719                         } while ( (concmd != _CC_stop) && (rc == 0) );
720                     
721                         CIMServer::shutdownSignal();
722                     
723                         PEG_METHOD_EXIT();
724                         pthread_exit(0);
725                     
726                         return NULL;
727                     }
728                     
729                     
730                     //
731                     // Send notify config change message to provider manager service
732                     // This code was borrowed from the ConfigSettingProvider and should
733                     // be kept in sync.
734                     // The purpose is to ensure that OOP agents also get the update.
735                     // TBD, or is it for other reasons as well?
736                     //
737 r.kieninger    1.1  void ZOSConsoleManager::_sendNotifyConfigChangeMessage(
738                         const String& propertyName,
739                         const String& newPropertyValue,
740                         Boolean currentValueModified)
741                     {
742 thilo.boehm    1.4      PEG_METHOD_ENTER(TRC_SERVER,
743 r.kieninger    1.1          "ZOSConsoleManager::_sendNotifyConfigChangeMessage");
744                     
745                         ModuleController* controller = ModuleController::getModuleController();
746                     
747                         MessageQueue * queue = MessageQueue::lookup(
748                             PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP);
749                     
750                         MessageQueueService * service = dynamic_cast<MessageQueueService *>(queue);
751                     
752                         if (service != NULL)
753                         {
754                             // create CIMNotifyConfigChangeRequestMessage
755                             CIMNotifyConfigChangeRequestMessage * notify_req =
756                                 new CIMNotifyConfigChangeRequestMessage (
757                                 XmlWriter::getNextMessageId (),
758                                 propertyName,
759                                 newPropertyValue,
760                                 currentValueModified,
761                                 QueueIdStack(service->getQueueId()));
762                     
763 thilo.boehm    1.17         notify_req->operationContext.insert(
764                                 IdentityContainer(System::getEffectiveUserName()));
765                     
766 r.kieninger    1.1          // create request envelope
767                             AsyncLegacyOperationStart asyncRequest(
768                                 NULL,
769                                 service->getQueueId(),
770 venkat.puvvada 1.8              notify_req);
771 r.kieninger    1.1  
772                             AutoPtr<AsyncReply> asyncReply(
773                                 controller->ClientSendWait(service->getQueueId(), &asyncRequest));
774                     
775                             AutoPtr<CIMNotifyConfigChangeResponseMessage> response(
776                                 reinterpret_cast<CIMNotifyConfigChangeResponseMessage *>(
777                                 (static_cast<AsyncLegacyOperationResult *>
778                                 (asyncReply.get()))->get_result()));
779                     
780                             if (response->cimException.getCode() != CIM_ERR_SUCCESS)
781                             {
782                                 CIMException e = response->cimException;
783 thilo.boehm    1.17             const CString exMsg = e.getMessage().getCString();
784                                 PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
785                                            "Notify config changed failed with rc=%d, message = %s",
786                                            e.getCode(), 
787                                            (const char*)exMsg));
788                     
789 r.kieninger    1.1              PEG_METHOD_EXIT();
790                             }
791                         }
792                         PEG_METHOD_EXIT();
793                     }
794                     
795                     
796                     
797                     PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2