(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                         Tracer::trace(TRC_SERVER, Tracer::LEVEL2,
 96                                          "Failed to issue __osname() command: rc=%d, errno=%d, reason=%08X", rc,errno,__errno2());
 97                         ARM_zOS_Status = NOT_REGISTERED;
 98                         return;
 99                     }
100                 
101                     // concatinate the element name base and the nodename to the full element name 
102                     strcat(arm_elemname,uts.nodename);
103                     full_elemname_size = strlen(arm_elemname);
104                 
105                     // padd the elementname with spaces 
106 thilo.boehm 1.1     memset(arm_elemname+full_elemname_size,' ',ARM_ELEMNAME_SIZE-full_elemname_size);
107                 
108                 
109                     // put a Null-termination at Pos 17 to make string printable 
110                     arm_elemname[ARM_ELEMNAME_SIZE-1] = '\0';
111                 
112                 
113                     Tracer::trace(TRC_SERVER, Tracer::LEVEL2,
114                                      "About to register the CIM server with element name \'%s\' with ARM.", arm_elemname);
115                 
116                     // CIM server is running in ASCII and the assembler module needs the module in EBCDIC
117                     __atoe(arm_elemname); 
118                 
119                     __register_arm(arm_elemname, arm_buffer, &arm_ret, &arm_res); 
120                 
121                     // convert back to ascii for further processing.
122                     __etoa(arm_elemname);
123                 
124                     if(arm_ret <= 0x04)
125                     {
126                        Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
127 thilo.boehm 1.1                      "Common.ARM_zOS.ARM_READY",
128                                      "The CIM server successfully registered to ARM using element name $0.",arm_elemname);
129                 
130                         if(arm_ret == 0x00)
131                         {
132                             // ARM registration at normal startup
133                             ARM_zOS_Status = REGISTERED;
134                         } else {
135                 
136                             // ret = 0x04 and reason code 0x104 & 0x108 indicates server restart
137                             if(arm_res <= 0x108)
138                             {
139                                 // ARM registration at restart
140                                 ARM_zOS_Status = RESTARTED;
141                             } else {
142                                 // ret = 0x04 and reason code 0x204 & 0x304 indicates dependen component not started.
143                                 // This can only be happen if somebody define dependencies in the restart policy.
144                                 // CIM Server does not depend on other elements; This is a normal start up.
145                                 ARM_zOS_Status = REGISTERED;
146                             }
147                 
148 thilo.boehm 1.1         } // end evaluate return codes.
149                 
150                         // set CIM server ready with ARM
151                         __ready_arm(arm_buffer, &arm_ret, &arm_res);
152                         if(arm_ret != 0)
153                         {
154                             Tracer::trace(TRC_SERVER, Tracer::LEVEL2,
155                                              "Failed to set the CIM server ready with ARM: ret=%02X reason=%04X.", arm_ret,arm_res);
156                             ARM_zOS_Status = NOT_REGISTERED;
157                         }
158                 
159                     } else
160                     {
161                 
162                         // ARM registration fails
163                         char str_arm_ret[4];
164                         sprintf(str_arm_ret,"%02X",arm_ret);
165                         char str_arm_res[8];
166                         sprintf(str_arm_res,"%04X",arm_res);
167                         Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::WARNING,
168                                       "Common.ARM_zOS.ARM_FAIL",
169 thilo.boehm 1.1                       "The CIM server failed to register with ARM using element name $0: return code 0x$1, reason code 0x$2."
170                                       ,arm_elemname,str_arm_ret,str_arm_res);
171                 
172                         ARM_zOS_Status = NOT_REGISTERED;
173                 
174                     }                
175                 
176                     return;
177                 }
178                 
179                 
180                 //*******************************************************************************
181                 // 
182                 // Method: void ARM_zOS::DeRegister(void) 
183                 // 
184                 // Description:
185                 // De-Register CIM Server from z/OS ARM (Automatic Restart Mangager). 
186                 // 
187                 // Function: 
188                 //            de-registration with ARM   
189                 // 
190 thilo.boehm 1.1 //    All errors are handled inside this routine.
191                 // 
192                 //                                                                        
193                 //******************************************************************************
194                 
195                 void ARM_zOS::DeRegister(void)
196                 {
197                     char arm_buffer[256];              
198                     int arm_ret=0;                     // ARM return code 
199                     int arm_res=0;                     // ARM reason code 
200                     
201                     // If CIM Server is not not registeres -> if it is REGISTERED or RESTARTED.
202                     if(ARM_zOS_Status != NOT_REGISTERED)
203                     {
204                         __deregister_arm(arm_buffer, &arm_ret, &arm_res);
205                         if(arm_ret != 0)
206                         {
207                             // write out errormessage from de-register with ARM
208                             Tracer::trace(TRC_SERVER, Tracer::LEVEL2,
209                                              "Failed to de-register CIM Server with ARM: ret=%02X reason=%04X.", arm_ret,arm_res);
210                         } else {
211 thilo.boehm 1.1 
212                             Tracer::trace(TRC_SERVER, Tracer::LEVEL2,
213                                              "CIM Server sucessfully de-reginster with ARM.");
214                 
215                         }
216                         ARM_zOS_Status = NOT_REGISTERED;
217                     }// End if
218                 }
219                 
220                 
221                 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2