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 //%////////////////////////////////////////////////////////////////////////////
33
34
35 ///////////////////////////////////////////////////////////////////////////////
36 // Shutdown Provider
37 ///////////////////////////////////////////////////////////////////////////////
38
|
39 mike 1.19 #include <Pegasus/Common/Signal.h>
|
40 kumpf 1.1 #include <Pegasus/Common/Config.h>
41 #include <Pegasus/Common/Tracer.h>
|
42 kumpf 1.20 #include <Pegasus/Common/MessageLoader.h>
|
43 kumpf 1.1 #include <Pegasus/Provider/CIMMethodProvider.h>
44 #include <Pegasus/Server/ShutdownService.h>
|
45 mike 1.19 #include "ShutdownProvider.h"
|
46 kumpf 1.1
47 PEGASUS_USING_STD;
48
49 PEGASUS_NAMESPACE_BEGIN
50
|
51 kumpf 1.8 static const CIMName METHOD_NAME_SHUTDOWN = CIMName ("shutdown");
52
|
53 kumpf 1.1 //
54 // Invoke method used to shutdown cimom.
55 //
56 void ShutdownProvider::invokeMethod(
|
57 kumpf 1.20 const OperationContext& context,
58 const CIMObjectPath& objectReference,
59 const CIMName& methodName,
60 const Array<CIMParamValue>& inParameters,
61 MethodResultResponseHandler& handler)
|
62 kumpf 1.1 {
63 PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownProvider::invokeMethod()");
|
64 kumpf 1.8
65 // Check to see if the method name is correct
66 if (!methodName.equal(METHOD_NAME_SHUTDOWN))
67 {
68 PEG_METHOD_EXIT();
|
69 kumpf 1.20 throw PEGASUS_CIM_EXCEPTION(
70 CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
|
71 kumpf 1.8 }
72
73 // Get user name
74 String userName;
|
75 kumpf 1.20 if (context.contains(IdentityContainer::NAME))
|
76 kumpf 1.8 {
77 IdentityContainer container = context.get(IdentityContainer::NAME);
78 userName = container.getUserName();
79 }
|
80 a.dunfey 1.18 else
|
81 kumpf 1.8 {
82 PEG_METHOD_EXIT();
83 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
84 }
|
85 kumpf 1.20
|
86 marek 1.16 #ifndef PEGASUS_ZOS_SECURITY
|
87 kumpf 1.8 // Only privileged user can execute this operation
88 if ((userName != String::EMPTY) && !System::isPrivilegedUser(userName))
89 {
90 PEG_METHOD_EXIT();
91 MessageLoaderParms parms(
92 "ControlProviders.UserAuthProvider.MUST_BE_PRIVILEGED_USER",
93 "Must be a privileged user to execute this CIM operation.");
94 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms);
95 }
|
96 marek 1.16 #endif
|
97 kumpf 1.1
98 // Begin processing the request
99 handler.processing();
100
101 // Check if the input parameters are passed.
|
102 kumpf 1.20 if (inParameters.size() < 2)
|
103 kumpf 1.1 {
104 PEG_METHOD_EXIT();
|
105 kumpf 1.20 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
106 MessageLoaderParms(
107 "Server.ShutdownProvider.INPUT_NOT_VALID",
108 "Input parameters are not valid."));
|
109 kumpf 1.1 }
110
111 Boolean force = false;
112 Uint32 timeoutValue = 0;
113
114 // Get the input parameter values
115 for (Uint32 i = 0; i < inParameters.size(); i++)
116 {
117 String parmName = inParameters[i].getParameterName();
118 if (String::equalNoCase(parmName, "force"))
119 {
120 //
121 // get the force parameter
122 //
123 inParameters[i].getValue().get(force);
124 }
125 else
126 {
127 if (String::equalNoCase(parmName, "timeout"))
128 {
129 //
130 kumpf 1.1 // get the timeout value
131 //
132 inParameters[i].getValue().get(timeoutValue);
133 }
134 else
135 {
136 PEG_METHOD_EXIT();
|
137 kumpf 1.20 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
138 MessageLoaderParms(
139 "Server.ShutdownProvider.INPUT_NOT_VALID",
140 "Input parameters are not valid."));
|
141 kumpf 1.1 }
142 }
143 }
144
145 try
146 {
|
147 kumpf 1.6 _shutdownService->shutdown(force, timeoutValue, true);
|
148 kumpf 1.1 }
149 catch (CIMException& e)
150 {
151 PEG_METHOD_EXIT();
152 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
153 }
154 catch (Exception& e)
155 {
156 PEG_METHOD_EXIT();
157 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
158 }
159
160 handler.deliver(CIMValue(0));
161 handler.complete();
162 PEG_METHOD_EXIT();
163 }
164
165 PEGASUS_NAMESPACE_END
|