1 karl 1.17 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.13 // 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 karl 1.12 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.13 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.14 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.17 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
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 kumpf 1.3 //
|
21 kumpf 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // 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 kumpf 1.3 //==============================================================================
|
31 kumpf 1.1 //
32 // Author: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
33 //
34 // Modified By:
35 // Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)
36 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
37 //
38 //%////////////////////////////////////////////////////////////////////////////
39
40
41 ///////////////////////////////////////////////////////////////////////////////
42 // Shutdown Provider
43 ///////////////////////////////////////////////////////////////////////////////
44
|
45 mike 1.19 #include <Pegasus/Common/Signal.h>
|
46 kumpf 1.1 #include <Pegasus/Common/Config.h>
47 #include <Pegasus/Common/Tracer.h>
|
48 mday 1.10 #include <Pegasus/Common/Monitor.h>
|
49 kumpf 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
50 #include <Pegasus/Server/ShutdownService.h>
|
51 mike 1.19 #include "ShutdownProvider.h"
|
52 kumpf 1.1
|
53 humberto 1.7 // l10n
54 #include <Pegasus/Common/MessageLoader.h>
55
|
56 kumpf 1.1 PEGASUS_USING_STD;
57
58 PEGASUS_NAMESPACE_BEGIN
59
|
60 kumpf 1.8 static const CIMName METHOD_NAME_SHUTDOWN = CIMName ("shutdown");
61
|
62 kumpf 1.1 //
63 // Invoke method used to shutdown cimom.
64 //
65 void ShutdownProvider::invokeMethod(
66 const OperationContext & context,
|
67 kumpf 1.2 const CIMObjectPath & objectReference,
|
68 kumpf 1.4 const CIMName & methodName,
|
69 kumpf 1.1 const Array<CIMParamValue> & inParameters,
|
70 kumpf 1.5 MethodResultResponseHandler & handler)
|
71 kumpf 1.1 {
72 PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownProvider::invokeMethod()");
|
73 kumpf 1.8
|
74 mday 1.10
75
|
76 kumpf 1.8 // Check to see if the method name is correct
77 if (!methodName.equal(METHOD_NAME_SHUTDOWN))
78 {
79 PEG_METHOD_EXIT();
80 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
81 }
82
83 // Get user name
84 String userName;
|
85 a.dunfey 1.18 if(context.contains(IdentityContainer::NAME))
|
86 kumpf 1.8 {
87 IdentityContainer container = context.get(IdentityContainer::NAME);
88 userName = container.getUserName();
89 }
|
90 a.dunfey 1.18 else
|
91 kumpf 1.8 {
92 PEG_METHOD_EXIT();
93 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
94 }
|
95 marek 1.16 #ifndef PEGASUS_ZOS_SECURITY
|
96 kumpf 1.8 // Only privileged user can execute this operation
97 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
98 {
99 PEG_METHOD_EXIT();
100 // l10n
101 MessageLoaderParms parms(
102 "ControlProviders.UserAuthProvider.MUST_BE_PRIVILEGED_USER",
103 "Must be a privileged user to execute this CIM operation.");
104 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms);
105 }
|
106 marek 1.16 #endif
|
107 kumpf 1.1
108 // Begin processing the request
109 handler.processing();
110
111 // Check if the input parameters are passed.
112 if ( inParameters.size() < 2 )
113 {
114 PEG_METHOD_EXIT();
|
115 humberto 1.7
116 // l10n
117
118 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, MessageLoaderParms("Server.ShutdownProvider.INPUT_NOT_VALID","Input parameters are not valid."));
119
120 // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
121 // "Input parameters are not valid.");
|
122 kumpf 1.1 }
123
124 Boolean force = false;
125 Uint32 timeoutValue = 0;
126
127 // Get the input parameter values
128 for (Uint32 i = 0; i < inParameters.size(); i++)
129 {
130 String parmName = inParameters[i].getParameterName();
131 if (String::equalNoCase(parmName, "force"))
132 {
133 //
134 // get the force parameter
135 //
136 inParameters[i].getValue().get(force);
137 }
138 else
139 {
140 if (String::equalNoCase(parmName, "timeout"))
141 {
142 //
143 kumpf 1.1 // get the timeout value
144 //
145 inParameters[i].getValue().get(timeoutValue);
146 }
147 else
148 {
149 PEG_METHOD_EXIT();
|
150 humberto 1.7
151 // l10n
152
153 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, MessageLoaderParms("Server.ShutdownProvider.INPUT_NOT_VALID","Input parameters are not valid."));
154
155 // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
156 // "Input parameters are not valid.");
|
157 kumpf 1.1 }
158 }
159 }
160
161 try
162 {
|
163 mday 1.10
|
164 konrad.r 1.15
|
165 kumpf 1.6 _shutdownService->shutdown(force, timeoutValue, true);
|
166 mday 1.10
|
167 kumpf 1.1 }
168 catch (CIMException& e)
169 {
170 PEG_METHOD_EXIT();
171 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
172 }
173 catch (Exception& e)
174 {
175 PEG_METHOD_EXIT();
176 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
177 }
178
179 handler.deliver(CIMValue(0));
180 handler.complete();
181 PEG_METHOD_EXIT();
182 return;
183 }
184
185 PEGASUS_NAMESPACE_END
186
|