1 karl 1.13 //%2004////////////////////////////////////////////////////////////////////////
|
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 kumpf 1.1 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 kumpf 1.3 //
|
17 kumpf 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
|
26 kumpf 1.3 //==============================================================================
|
27 kumpf 1.1 //
28 // Author: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
29 //
30 // Modified By:
31 // Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)
32 // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com)
33 //
34 //%////////////////////////////////////////////////////////////////////////////
35
36
37 ///////////////////////////////////////////////////////////////////////////////
38 // Shutdown Provider
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #include "ShutdownProvider.h"
42 #include <Pegasus/Common/Config.h>
|
43 mday 1.10 #include <Pegasus/Common/Signal.h>
|
44 kumpf 1.1 #include <Pegasus/Common/Tracer.h>
|
45 mday 1.10 #include <Pegasus/Common/Monitor.h>
|
46 kumpf 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
47 #include <Pegasus/Server/ShutdownService.h>
48
|
49 humberto 1.7 // l10n
50 #include <Pegasus/Common/MessageLoader.h>
51
|
52 kumpf 1.1 PEGASUS_USING_STD;
53
54 PEGASUS_NAMESPACE_BEGIN
55
|
56 kumpf 1.8 static const CIMName METHOD_NAME_SHUTDOWN = CIMName ("shutdown");
57
|
58 kumpf 1.1 //
59 // Invoke method used to shutdown cimom.
60 //
61 void ShutdownProvider::invokeMethod(
62 const OperationContext & context,
|
63 kumpf 1.2 const CIMObjectPath & objectReference,
|
64 kumpf 1.4 const CIMName & methodName,
|
65 kumpf 1.1 const Array<CIMParamValue> & inParameters,
|
66 kumpf 1.5 MethodResultResponseHandler & handler)
|
67 kumpf 1.1 {
68 PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownProvider::invokeMethod()");
|
69 kumpf 1.8
|
70 mday 1.10
71
|
72 kumpf 1.8 // Check to see if the method name is correct
73 if (!methodName.equal(METHOD_NAME_SHUTDOWN))
74 {
75 PEG_METHOD_EXIT();
76 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
77 }
78
79 // Get user name
80 String userName;
81 try
82 {
83 IdentityContainer container = context.get(IdentityContainer::NAME);
84 userName = container.getUserName();
85 }
86 catch (...)
87 {
88 PEG_METHOD_EXIT();
89 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
90 }
91
92 // Only privileged user can execute this operation
93 kumpf 1.8 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
94 {
95 PEG_METHOD_EXIT();
96 // l10n
97 MessageLoaderParms parms(
98 "ControlProviders.UserAuthProvider.MUST_BE_PRIVILEGED_USER",
99 "Must be a privileged user to execute this CIM operation.");
100 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms);
101 }
|
102 kumpf 1.1
103 // Begin processing the request
104 handler.processing();
105
106 // Check if the input parameters are passed.
107 if ( inParameters.size() < 2 )
108 {
109 PEG_METHOD_EXIT();
|
110 humberto 1.7
111 // l10n
112
113 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, MessageLoaderParms("Server.ShutdownProvider.INPUT_NOT_VALID","Input parameters are not valid."));
114
115 // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
116 // "Input parameters are not valid.");
|
117 kumpf 1.1 }
118
119 Boolean force = false;
120 Uint32 timeoutValue = 0;
121
122 // Get the input parameter values
123 for (Uint32 i = 0; i < inParameters.size(); i++)
124 {
125 String parmName = inParameters[i].getParameterName();
126 if (String::equalNoCase(parmName, "force"))
127 {
128 //
129 // get the force parameter
130 //
131 inParameters[i].getValue().get(force);
132 }
133 else
134 {
135 if (String::equalNoCase(parmName, "timeout"))
136 {
137 //
138 kumpf 1.1 // get the timeout value
139 //
140 inParameters[i].getValue().get(timeoutValue);
141 }
142 else
143 {
144 PEG_METHOD_EXIT();
|
145 humberto 1.7
146 // l10n
147
148 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, MessageLoaderParms("Server.ShutdownProvider.INPUT_NOT_VALID","Input parameters are not valid."));
149
150 // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER,
151 // "Input parameters are not valid.");
|
152 kumpf 1.1 }
153 }
154 }
155
156 try
157 {
|
158 mday 1.10
|
159 kumpf 1.6 _shutdownService->shutdown(force, timeoutValue, true);
|
160 mday 1.10
|
161 kumpf 1.1 }
162 catch (CIMException& e)
163 {
164 PEG_METHOD_EXIT();
165 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
166 }
167 catch (Exception& e)
168 {
169 PEG_METHOD_EXIT();
170 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
171 }
172
173 handler.deliver(CIMValue(0));
174 handler.complete();
175
176 PEG_METHOD_EXIT();
177 return;
178 }
179
180 PEGASUS_NAMESPACE_END
181
|