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

  1 thilo.boehm 1.1 //%2006////////////////////////////////////////////////////////////////////////
  2                 //
  3                 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4                 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5                 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6                 // IBM Corp.; EMC Corporation, The Open Group.
  7                 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8                 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9                 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10                 // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11                 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12                 // EMC Corporation; Symantec Corporation; The Open Group.
 13                 //
 14                 // Permission is hereby granted, free of charge, to any person obtaining a copy
 15                 // of this software and associated documentation files (the "Software"), to
 16                 // deal in the Software without restriction, including without limitation the
 17                 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18                 // sell copies of the Software, and to permit persons to whom the Software is
 19                 // furnished to do so, subject to the following conditions:
 20                 // 
 21                 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 thilo.boehm 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23                 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24                 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25                 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26                 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27                 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28                 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29                 //
 30                 //==============================================================================
 31                 //
 32                 // Author: Thilo Boehm (tboehm@de.ibm.com)
 33                 //
 34                 //%/////////////////////////////////////////////////////////////////////////////
 35                 
 36                 #include <stdio.h>
 37                 #include <string.h>
 38                 #include <errno.h>
 39                 #define _POSIX_SOURCE 
 40                 #include <sys/utsname.h> 
 41                 #include <leawi.h>
 42                 #include <ceeedcct.h>
 43 thilo.boehm 1.1 #include <unistd.h>
 44                 
 45                 #include <Pegasus/Common/Tracer.h>
 46                 #include <Pegasus/Common/Logger.h>
 47                 #include "AutoRestartMgr_ZOS_ZSERIES_IBM.h"
 48                 #include "ARM_zOS.h"
 49                 
 50                 
 51                 // __arm_status_tags ARM_zOS_Status = NOT_REGISTERED; // ARM stautus for CIM Server Status
 52                 
 53                 #define ARM_ELEMNAME_SIZE 17          // 16 Bytes for ARM element name + '\0'
 54                 
 55                 PEGASUS_NAMESPACE_BEGIN
 56                    
 57                            
 58                 //*******************************************************************************
 59                 // 
 60                 // Methode: void ARM_zOS::Register(void) 
 61                 // 
 62                 // Description:
 63                 // Registration and make element READY for z/OS ARM (Automatic Restart Mangager). 
 64 thilo.boehm 1.1 // 
 65                 // Function: 
 66                 //            a) do the registration with ARM   
 67                 //            b) make the element READY for ARM 
 68                 // 
 69                 //    All errors are handled inside this routine, a failure to register or    
 70                 //    a failure to make READY the element does not impact the further function 
 71                 //    of the CIM Server. The success and failures are written to the 
 72                 //    z/OS console and the appropriate CIM Server logs.
 73                 // 
 74                 //    The registration status is saved in the global variable ARM_zOS_Status
 75                 //    for further use ( e.g. actions after a restart) within the CIM Server.
 76                 //                                                                        
 77                 //******************************************************************************
 78                 void ARM_zOS::Register(void)
 79                 {
 80                 
 81                     int i;
 82                     
 83                     char arm_elemname[ARM_ELEMNAME_SIZE] = "CFZ_SRV_"; // ARM element name init with base.
 84                     int full_elemname_size;
 85 thilo.boehm 1.1 
 86                     char arm_buffer[256];               // ARM buffer
 87                     int arm_ret=0;                      // ARM return code 
 88                     int arm_res=0;                      // ARM reason code 
 89                     struct utsname uts;                 // structure to get the SYSNAME for the element name 
 90                     int rc;
 91                 
 92                     rc = __osname(&uts);
 93                     if(rc < 0)
 94                     {
 95 marek       1.1.20.2         PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
 96                                         "Failed to issue __osname() command:"
 97                                         " rc=%d, errno=%d, reason=%08X",
 98                                         rc,
 99                                         errno,
100                                         __errno2()));
101 thilo.boehm 1.1              ARM_zOS_Status = NOT_REGISTERED;
102                              return;
103                          }
104                      
105                          // concatinate the element name base and the nodename to the full element name 
106                          strcat(arm_elemname,uts.nodename);
107                          full_elemname_size = strlen(arm_elemname);
108                      
109                          // padd the elementname with spaces 
110                          memset(arm_elemname+full_elemname_size,' ',ARM_ELEMNAME_SIZE-full_elemname_size);
111                      
112                      
113                          // put a Null-termination at Pos 17 to make string printable 
114                          arm_elemname[ARM_ELEMNAME_SIZE-1] = '\0';
115                      
116                      
117 marek       1.1.20.2     PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
118                                     "About to register the CIM server with element name \'%s\' with ARM.",
119                                     arm_elemname));
120 thilo.boehm 1.1      
121                          // CIM server is running in ASCII and the assembler module needs the module in EBCDIC
122                          __atoe(arm_elemname); 
123                      
124                          __register_arm(arm_elemname, arm_buffer, &arm_ret, &arm_res); 
125                      
126                          // convert back to ascii for further processing.
127                          __etoa(arm_elemname);
128                      
129                          if(arm_ret <= 0x04)
130                          {
131                             Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
132                                           "Common.ARM_zOS.ARM_READY",
133                                           "The CIM server successfully registered to ARM using element name $0.",arm_elemname);
134                      
135                              if(arm_ret == 0x00)
136                              {
137                                  // ARM registration at normal startup
138                                  ARM_zOS_Status = REGISTERED;
139                              } else {
140                      
141 thilo.boehm 1.1                  // ret = 0x04 and reason code 0x104 & 0x108 indicates server restart
142                                  if(arm_res <= 0x108)
143                                  {
144                                      // ARM registration at restart
145                                      ARM_zOS_Status = RESTARTED;
146                                  } else {
147                                      // ret = 0x04 and reason code 0x204 & 0x304 indicates dependen component not started.
148                                      // This can only be happen if somebody define dependencies in the restart policy.
149                                      // CIM Server does not depend on other elements; This is a normal start up.
150                                      ARM_zOS_Status = REGISTERED;
151                                  }
152                      
153                              } // end evaluate return codes.
154                      
155                              // set CIM server ready with ARM
156                              __ready_arm(arm_buffer, &arm_ret, &arm_res);
157                              if(arm_ret != 0)
158                              {
159 marek       1.1.20.2             PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
160                                             "Failed to set the CIM server ready with ARM: ret=%02X reason=%04X.",
161                                             arm_ret,arm_res));
162 thilo.boehm 1.1                  ARM_zOS_Status = NOT_REGISTERED;
163                              }
164                      
165                          } else
166                          {
167                      
168                              // ARM registration fails
169                              char str_arm_ret[4];
170                              sprintf(str_arm_ret,"%02X",arm_ret);
171                              char str_arm_res[8];
172                              sprintf(str_arm_res,"%04X",arm_res);
173 thilo.boehm 1.1.20.1         Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
174 thilo.boehm 1.1                            "Common.ARM_zOS.ARM_FAIL",
175                                            "The CIM server failed to register with ARM using element name $0: return code 0x$1, reason code 0x$2."
176                                            ,arm_elemname,str_arm_ret,str_arm_res);
177                      
178                              ARM_zOS_Status = NOT_REGISTERED;
179                      
180                          }                
181                      
182                          return;
183                      }
184                      
185                      
186                      //*******************************************************************************
187                      // 
188                      // Method: void ARM_zOS::DeRegister(void) 
189                      // 
190                      // Description:
191                      // De-Register CIM Server from z/OS ARM (Automatic Restart Mangager). 
192                      // 
193                      // Function: 
194                      //            de-registration with ARM   
195 thilo.boehm 1.1      // 
196                      //    All errors are handled inside this routine.
197                      // 
198                      //                                                                        
199                      //******************************************************************************
200                      
201                      void ARM_zOS::DeRegister(void)
202                      {
203                          char arm_buffer[256];              
204                          int arm_ret=0;                     // ARM return code 
205                          int arm_res=0;                     // ARM reason code 
206                          
207                          // If CIM Server is not not registeres -> if it is REGISTERED or RESTARTED.
208                          if(ARM_zOS_Status != NOT_REGISTERED)
209                          {
210                              __deregister_arm(arm_buffer, &arm_ret, &arm_res);
211                              if(arm_ret != 0)
212                              {
213                                  // write out errormessage from de-register with ARM
214 marek       1.1.20.2             PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
215                                             "Failed to de-register CIM Server with ARM: ret=%02X reason=%04X.",
216                                             arm_ret,arm_res));
217 thilo.boehm 1.1              } else {
218                      
219 marek       1.1.20.2             PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL2,
220 thilo.boehm 1.1                                   "CIM Server sucessfully de-reginster with ARM.");
221                      
222                              }
223                              ARM_zOS_Status = NOT_REGISTERED;
224                          }// End if
225                      }
226                      
227                      
228                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2