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

  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 thilo.boehm 1.1  //
 30                  // Author: Thilo Boehm (tboehm@de.ibm.com)
 31                  //
 32                  //%/////////////////////////////////////////////////////////////////////////////
 33                  
 34                  #include <stdio.h>
 35                  #include <string.h>
 36                  #include <errno.h>
 37                  #define _POSIX_SOURCE 
 38                  #include <sys/utsname.h> 
 39                  #include <leawi.h>
 40                  #include <ceeedcct.h>
 41                  #include <unistd.h>
 42                  
 43                  #include <Pegasus/Common/Tracer.h>
 44                  #include <Pegasus/Common/Logger.h>
 45 r.kieninger 1.8  #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
 46 thilo.boehm 1.1  #include "AutoRestartMgr_ZOS_ZSERIES_IBM.h"
 47 r.kieninger 1.8  #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES64_IBM)
 48                  #include "AutoRestartMgr_ZOS_ZSERIES64_IBM.h"
 49                  #endif
 50 thilo.boehm 1.1  #include "ARM_zOS.h"
 51                  
 52                  
 53 kumpf       1.4  // ARM status for CIM Server Status
 54                  // __arm_status_tags ARM_zOS_Status = NOT_REGISTERED;
 55 thilo.boehm 1.1  
 56                  #define ARM_ELEMNAME_SIZE 17          // 16 Bytes for ARM element name + '\0'
 57                  
 58                  PEGASUS_NAMESPACE_BEGIN
 59                     
 60                             
 61 kumpf       1.4  //******************************************************************************
 62 martin      1.10 //
 63 thilo.boehm 1.1  // Methode: void ARM_zOS::Register(void) 
 64 martin      1.10 //
 65 thilo.boehm 1.1  // Description:
 66 kumpf       1.4  // Registration and make element READY for z/OS ARM (Automatic Restart Manager).
 67 martin      1.10 //
 68 thilo.boehm 1.1  // Function: 
 69                  //            a) do the registration with ARM   
 70                  //            b) make the element READY for ARM 
 71 martin      1.10 //
 72 thilo.boehm 1.1  //    All errors are handled inside this routine, a failure to register or    
 73                  //    a failure to make READY the element does not impact the further function 
 74                  //    of the CIM Server. The success and failures are written to the 
 75                  //    z/OS console and the appropriate CIM Server logs.
 76 martin      1.10 //
 77 thilo.boehm 1.1  //    The registration status is saved in the global variable ARM_zOS_Status
 78                  //    for further use ( e.g. actions after a restart) within the CIM Server.
 79                  //                                                                        
 80                  //******************************************************************************
 81                  void ARM_zOS::Register(void)
 82                  {
 83                  
 84                      int i;
 85                      
 86 kumpf       1.4      // ARM element name init with base.
 87                      char arm_elemname[ARM_ELEMNAME_SIZE] = "CFZ_SRV_";
 88 thilo.boehm 1.1      int full_elemname_size;
 89                  
 90                      char arm_buffer[256];               // ARM buffer
 91                      int arm_ret=0;                      // ARM return code 
 92                      int arm_res=0;                      // ARM reason code 
 93 kumpf       1.4      struct utsname uts;                 // structure to get the SYSNAME for
 94                                                          // the element name 
 95 thilo.boehm 1.1      int rc;
 96                  
 97 r.kieninger 1.8  #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES64_IBM
 98 thilo.boehm 1.1      rc = __osname(&uts);
 99                      if(rc < 0)
100                      {
101 marek       1.5          PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
102 marek       1.2                     "Failed to issue __osname() command:"
103                                     " rc=%d, errno=%d, reason=%08X",
104                                     rc,
105                                     errno,
106                                     __errno2()));
107 thilo.boehm 1.1          ARM_zOS_Status = NOT_REGISTERED;
108                          return;
109                      }
110                  
111 kumpf       1.4      // concatenate the element name base and the nodename to the full element
112                      // name 
113 thilo.boehm 1.1      strcat(arm_elemname,uts.nodename);
114                      full_elemname_size = strlen(arm_elemname);
115                  
116 kumpf       1.4      // pad the elementname with spaces 
117                      memset(arm_elemname + full_elemname_size, ' ',
118                          ARM_ELEMNAME_SIZE - full_elemname_size);
119 thilo.boehm 1.1  
120                  
121                      // put a Null-termination at Pos 17 to make string printable 
122                      arm_elemname[ARM_ELEMNAME_SIZE-1] = '\0';
123                  
124                  
125 marek       1.5      PEG_TRACE((TRC_SERVER, Tracer::LEVEL3,
126 kumpf       1.4          "About to register the CIM server with element name \'%s\' with ARM.",
127                          arm_elemname));
128 thilo.boehm 1.1  
129 kumpf       1.4      // CIM server is running in ASCII and the assembler module needs the
130                      // module in EBCDIC
131 thilo.boehm 1.1      __atoe(arm_elemname); 
132                  
133 r.kieninger 1.8      __register_arm(arm_elemname, arm_buffer, &arm_ret, &arm_res);
134 thilo.boehm 1.1  
135                      // convert back to ascii for further processing.
136                      __etoa(arm_elemname);
137                  
138 kumpf       1.4      if (arm_ret <= 0x04)
139 thilo.boehm 1.1      {
140                         Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
141 kumpf       1.6             MessageLoaderParms(
142                                 "Common.ARM_zOS.ARM_READY",
143                                 "The CIM server successfully registered to ARM using element "
144                                     "name $0.",
145                                 arm_elemname));
146 thilo.boehm 1.1  
147 kumpf       1.4          if (arm_ret == 0x00)
148 thilo.boehm 1.1          {
149                              // ARM registration at normal startup
150                              ARM_zOS_Status = REGISTERED;
151 kumpf       1.4          }
152                          else
153                          {
154 thilo.boehm 1.1              // ret = 0x04 and reason code 0x104 & 0x108 indicates server restart
155                              if(arm_res <= 0x108)
156                              {
157                                  // ARM registration at restart
158                                  ARM_zOS_Status = RESTARTED;
159 kumpf       1.4              }
160                              else
161                              {
162                                  // ret = 0x04 and reason code 0x204 & 0x304 indicates dependent
163                                  // component not started.  This can only be happen if somebody
164                                  // define dependencies in the restart policy.
165                                  // CIM Server does not depend on other elements; This is a
166                                  // normal start up.
167 thilo.boehm 1.1                  ARM_zOS_Status = REGISTERED;
168                              }
169                  
170                          } // end evaluate return codes.
171                  
172                          // set CIM server ready with ARM
173                          __ready_arm(arm_buffer, &arm_ret, &arm_res);
174                          if(arm_ret != 0)
175                          {
176 marek       1.2              PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
177 kumpf       1.4                  "Failed to set the CIM server ready with ARM: "
178                                      "ret=%02X reason=%04X.",
179                                  arm_ret,
180                                  arm_res));
181 thilo.boehm 1.1              ARM_zOS_Status = NOT_REGISTERED;
182                          }
183 kumpf       1.4      }
184                      else
185 thilo.boehm 1.1      {
186                          // ARM registration fails
187                          char str_arm_ret[4];
188                          sprintf(str_arm_ret,"%02X",arm_ret);
189                          char str_arm_res[8];
190                          sprintf(str_arm_res,"%04X",arm_res);
191 thilo.boehm 1.3          Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
192 kumpf       1.6              MessageLoaderParms(
193                                  "Common.ARM_zOS.ARM_FAIL",
194                                  "The CIM server failed to register with ARM using element "
195                                      "name $0: return code 0x$1, reason code 0x$2.",
196 kumpf       1.7                  arm_elemname,
197                                  str_arm_ret,
198                                  str_arm_res));
199 thilo.boehm 1.1  
200                          ARM_zOS_Status = NOT_REGISTERED;
201                      }                
202 r.kieninger 1.8  #endif
203 thilo.boehm 1.1      return;
204                  }
205                  
206                  
207 kumpf       1.4  //******************************************************************************
208 martin      1.10 //
209 thilo.boehm 1.1  // Method: void ARM_zOS::DeRegister(void) 
210 martin      1.10 //
211 thilo.boehm 1.1  // Description:
212                  // De-Register CIM Server from z/OS ARM (Automatic Restart Mangager). 
213 martin      1.10 //
214 thilo.boehm 1.1  // Function: 
215                  //            de-registration with ARM   
216 martin      1.10 //
217 thilo.boehm 1.1  //    All errors are handled inside this routine.
218 martin      1.10 //
219 thilo.boehm 1.1  //                                                                        
220                  //******************************************************************************
221                  
222                  void ARM_zOS::DeRegister(void)
223                  {
224                      char arm_buffer[256];              
225                      int arm_ret=0;                     // ARM return code 
226                      int arm_res=0;                     // ARM reason code 
227                      
228 r.kieninger 1.8  #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES64_IBM
229 thilo.boehm 1.1      // If CIM Server is not not registeres -> if it is REGISTERED or RESTARTED.
230                      if(ARM_zOS_Status != NOT_REGISTERED)
231                      {
232                          __deregister_arm(arm_buffer, &arm_ret, &arm_res);
233                          if(arm_ret != 0)
234                          {
235                              // write out errormessage from de-register with ARM
236 marek       1.2              PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
237 marek       1.5                  "Failed to deregister CIM Server with ARM: "
238 kumpf       1.4                      "ret=%02X reason=%04X.",
239                                  arm_ret,
240                                  arm_res));
241                          }
242                          else
243                          {
244 marek       1.5              PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL3,
245                                  "CIM Server sucessfully deregistered with ARM.");
246 thilo.boehm 1.1          }
247                          ARM_zOS_Status = NOT_REGISTERED;
248                      }// End if
249 r.kieninger 1.8  #endif
250 thilo.boehm 1.1  }
251                  
252                  PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2