|
From: <jc...@us...> - 2007-12-18 23:37:44
|
Revision: 522
http://omc.svn.sourceforge.net/omc/?rev=522&view=rev
Author: jcarey
Date: 2007-12-18 15:37:41 -0800 (Tue, 18 Dec 2007)
Log Message:
-----------
Changed methods to only allow root...
Modified Paths:
--------------
pybase/trunk/OMC_OperatingSystem.py
Modified: pybase/trunk/OMC_OperatingSystem.py
===================================================================
--- pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:35:00 UTC (rev 521)
+++ pybase/trunk/OMC_OperatingSystem.py 2007-12-18 23:37:41 UTC (rev 522)
@@ -177,60 +177,11 @@
def cim_method_requeststatechange(self, env, object_name, method,
param_requestedstate,
param_timeoutperiod):
- """Implements OMC_OperatingSystem.RequestStateChange()
-
- Requests that the state of the element be changed to the value
- specified in the RequestedState parameter. When the requested
- state change takes place, the EnabledState and RequestedState of
- the element will be the same. Invoking the RequestStateChange
- method multiple times could result in earlier requests being
- overwritten or lost. If 0 is returned, then the task completed
- successfully and the use of ConcreteJob was not required. If 4096
- (0x1000) is returned, then the task will take some time to
- complete, ConcreteJob will be created, and its reference returned
- in the output parameter Job. Any other return code indicates an
- error condition.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method RequestStateChange()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
- param_requestedstate -- The input parameter RequestedState (type pywbem.Uint16 self.Values.RequestStateChange.RequestedState)
- The state requested for the element. This information will be
- placed into the RequestedState property of the instance if the
- return code of the RequestStateChange method is 0 ('Completed
- with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job
- Started'). Refer to the description of the EnabledState and
- RequestedState properties for the detailed explanations of the
- RequestedState values.
-
- param_timeoutperiod -- The input parameter TimeoutPeriod (type pywbem.CIMDateTime)
- A timeout period that specifies the maximum amount of time that
- the client expects the transition to the new state to take.
- The interval format must be used to specify the TimeoutPeriod.
- A value of 0 or a null parameter indicates that the client has
- no time requirements for the transition. If this property
- does not contain 0 or null and the implementation does not
- support this parameter, a return code of 'Use Of Timeout
- Parameter Not Supported' must be returned.
-
-
- Returns a two-tuple containing the return value (type pywbem.Uint32 self.Values.RequestStateChange)
- and a dictionary with the out-parameters
-
- Output parameters:
- Job -- (type REF (pywbem.CIMInstanceName(classname='CIM_ConcreteJob', ...))
- Reference to the job (can be null if the task is completed).
-
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_requeststatechange()' \
% self.__class__.__name__)
-
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
rstate = int(param_requestedstate)
if rstate == 3: # Disable
logger.log_info('OS Disabled State Requested. Shutting Down now...')
@@ -261,32 +212,11 @@
return (pywbem.Uint32(1), {})
def cim_method_reboot(self, env, object_name, method):
- """Implements OMC_OperatingSystem.Reboot()
-
- Requests a reboot of the OperatingSystem. The return value should
- be 0 if the request was successfully executed, 1 if the request is
- not supported and some other value if an error occurred. In a
- subclass, the set of possible return codes could be specified,
- using a ValueMap qualifier on the method. The strings to which the
- ValueMap contents are 'translated' may also be specified in the
- subclass as a Values array qualifier.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method Reboot()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
-
- Returns a two-tuple containing the return value (type pywbem.Uint32)
- and a dictionary with the out-parameters
-
- Output parameters: none
-
- """
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_reboot()' \
% self.__class__.__name__)
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
logger.log_info('OMC_OperatingSystem.reboot called. '
'Rebooting system now')
if os.system('/sbin/shutdown -r now'):
@@ -294,38 +224,11 @@
return ('Success', {})
def cim_method_shutdown(self, env, object_name, method):
- """Implements OMC_OperatingSystem.Shutdown()
-
- Requests a shutdown of the OperatingSystem. The return value should
- be 0 if the request was successfully executed, 1 if the request is
- not supported and some other value if an error occurred. It is up
- to the implementation or subclass of OperatingSystem to establish
- dependencies between the Shutdown and Reboot methods, and for
- example, to provide more sophisticated capabilities such as
- scheduled shutdown/ reboot, etc. In a subclass, the set of
- possible return codes could be specified, using a ValueMap
- qualifier on the method. The strings to which the ValueMap
- contents are 'translated' may also be specified in the subclass as
- a Values array qualifier.
-
- Keyword arguments:
- env -- Provider Environment (pycimmb.ProviderEnvironment)
- object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName
- specifying the object on which the method Shutdown()
- should be invoked.
- method -- A pywbem.CIMMethod representing the method meta-data
-
- Returns a two-tuple containing the return value (type pywbem.Uint32)
- and a dictionary with the out-parameters
-
- Output parameters: none
-
- """
-
logger = env.get_logger()
logger.log_debug('Entering %s.cim_method_shutdown()' \
% self.__class__.__name__)
-
+ if os.geteuid() != 0:
+ raise pywbem.CIMError(pywbem.CIM_ERR_ACCESS_DENIED)
logger.log_info('OMC_OperatingSystem.shutdown called. '
'shutdown system now')
if os.system('/sbin/shutdown -h now'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|