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.2 PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
99 "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.2 PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
|
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.4 "Common.ARM_zOS.ARM_READY",
139 "The CIM server successfully registered to ARM using element "
140 "name $0.",
141 arm_elemname);
|
142 thilo.boehm 1.1
|
143 kumpf 1.4 if (arm_ret == 0x00)
|
144 thilo.boehm 1.1 {
145 // ARM registration at normal startup
146 ARM_zOS_Status = REGISTERED;
|
147 kumpf 1.4 }
148 else
149 {
|
150 thilo.boehm 1.1 // ret = 0x04 and reason code 0x104 & 0x108 indicates server restart
151 if(arm_res <= 0x108)
152 {
153 // ARM registration at restart
154 ARM_zOS_Status = RESTARTED;
|
155 kumpf 1.4 }
156 else
157 {
158 // ret = 0x04 and reason code 0x204 & 0x304 indicates dependent
159 // component not started. This can only be happen if somebody
160 // define dependencies in the restart policy.
161 // CIM Server does not depend on other elements; This is a
162 // normal start up.
|
163 thilo.boehm 1.1 ARM_zOS_Status = REGISTERED;
164 }
165
166 } // end evaluate return codes.
167
168 // set CIM server ready with ARM
169 __ready_arm(arm_buffer, &arm_ret, &arm_res);
170 if(arm_ret != 0)
171 {
|
172 marek 1.2 PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
|
173 kumpf 1.4 "Failed to set the CIM server ready with ARM: "
174 "ret=%02X reason=%04X.",
175 arm_ret,
176 arm_res));
|
177 thilo.boehm 1.1 ARM_zOS_Status = NOT_REGISTERED;
178 }
|
179 kumpf 1.4 }
180 else
|
181 thilo.boehm 1.1 {
182 // ARM registration fails
183 char str_arm_ret[4];
184 sprintf(str_arm_ret,"%02X",arm_ret);
185 char str_arm_res[8];
186 sprintf(str_arm_res,"%04X",arm_res);
|
187 thilo.boehm 1.3 Logger::put_l(Logger::STANDARD_LOG, "CIM Server", Logger::INFORMATION,
|
188 kumpf 1.4 "Common.ARM_zOS.ARM_FAIL",
189 "The CIM server failed to register with ARM using element "
190 "name $0: return code 0x$1, reason code 0x$2.",
191 arm_elemname,
192 str_arm_ret,
193 str_arm_res);
|
194 thilo.boehm 1.1
195 ARM_zOS_Status = NOT_REGISTERED;
196 }
197
198 return;
199 }
200
201
|
202 kumpf 1.4 //******************************************************************************
|
203 thilo.boehm 1.1 //
204 // Method: void ARM_zOS::DeRegister(void)
205 //
206 // Description:
207 // De-Register CIM Server from z/OS ARM (Automatic Restart Mangager).
208 //
209 // Function:
210 // de-registration with ARM
211 //
212 // All errors are handled inside this routine.
213 //
214 //
215 //******************************************************************************
216
217 void ARM_zOS::DeRegister(void)
218 {
219 char arm_buffer[256];
220 int arm_ret=0; // ARM return code
221 int arm_res=0; // ARM reason code
222
223 // If CIM Server is not not registeres -> if it is REGISTERED or RESTARTED.
224 thilo.boehm 1.1 if(ARM_zOS_Status != NOT_REGISTERED)
225 {
226 __deregister_arm(arm_buffer, &arm_ret, &arm_res);
227 if(arm_ret != 0)
228 {
229 // write out errormessage from de-register with ARM
|
230 marek 1.2 PEG_TRACE((TRC_SERVER, Tracer::LEVEL2,
|
231 kumpf 1.4 "Failed to de-register CIM Server with ARM: "
232 "ret=%02X reason=%04X.",
233 arm_ret,
234 arm_res));
235 }
236 else
237 {
|
238 marek 1.2 PEG_TRACE_CSTRING(TRC_SERVER, Tracer::LEVEL2,
|
239 kumpf 1.4 "CIM Server sucessfully de-reginster with ARM.");
|
240 thilo.boehm 1.1 }
241 ARM_zOS_Status = NOT_REGISTERED;
242 }// End if
243 }
244
245 PEGASUS_NAMESPACE_END
|