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