def medium(self, value): '''Set boot medium for next boot.''' # Zero out boot options - unwise, but just testing right now... settings = self.get('AMT_BootSettingData') for setting in settings: if type(settings[setting]) == int: settings[setting] = 0 elif type(settings[setting]) == bool: settings[setting] = False else: pass sources = self.walk('CIM_BootSourceSetting')['CIM_BootSourceSetting'] for source in sources: if value in source['StructuredBootString']: instance_id = source['InstanceID'] break else: raise LookupError('This medium is not supported by the device') boot_config = self.get('CIM_BootConfigSetting') # Should be an # enumerate, as it has intances... But for now... config_instance = str(boot_config['InstanceID']) response = common.invoke_method( service_name='CIM_BootConfigSetting', resource_name='CIM_BootSourceSetting', affected_item='Source', method_name='ChangeBootOrder', options=self.options, client=self.client, selector=('InstanceID', instance_id, config_instance, ), ) self._set_boot_config_role() return response
def request_power_state_change(self, power_state): resource_name = 'CIM_PowerManagementService' input_dict = { resource_name: { 'RequestPowerStateChange_INPUT': { 'PowerState': power_state, 'ManagedElement': OrderedDict([ ('Address', { '#text': SCHEMAS['addressing_anonymous'], '@xmlns': SCHEMAS['addressing'], }), ('ReferenceParameters', { 'ResourceURI': { '#text': RESOURCE_URIs['CIM_ComputerSystem'], '@xmlns': SCHEMAS['wsman'], }, '@xmlns': SCHEMAS['addressing'], 'SelectorSet': { 'Selector': { '#text': 'ManagedSystem', '@Name': 'Name', }, '@xmlns': SCHEMAS['wsman'], }, }), ]), }, } } self.options.add_selector('Name', 'Intel(r) AMT Power Management Service') # possible to work on a copy of this? response = common.invoke_method(self.client, 'RequestPowerStateChange', input_dict, options=self.options) return not response['RequestPowerStateChange_OUTPUT']['ReturnValue']
def request_state_change(self, resource_name, requested_state): input_dict = { resource_name: {'RequestStateChange_INPUT': { 'RequestedState': requested_state, }, } } return common.invoke_method(self.client, 'RequestStateChange', input_dict, options=self.options)
def request_power_state_change(self, power_state): return common.invoke_method( service_name='CIM_PowerManagementService', resource_name='CIM_ComputerSystem', affected_item='ManagedElement', method_name='RequestPowerStateChange', options=self.options, client=self.client, selector=('Name', 'ManagedSystem', 'Intel(r) AMT Power Management Service', ), args_before=[('PowerState', str(power_state)), ], anonymous=True, )
def request_state_change(self, resource_name, requested_state): input_dict = { resource_name: {'RequestStateChange_INPUT': { 'RequestedState': requested_state, }, } } return common.invoke_method( service_name='CIM_KVMRedirectionSAP', method_name='RequestStateChange', options=self.options, client=self.client, args_before=[('RequestedState', str(requested_state)), ], )
def _set_boot_config_role(self, enabled_state=True): if enabled_state == True: role = '1' elif enabled_state == False: role = '32768' svc = self.get('CIM_BootService') assert svc['ElementName'] == 'Intel(r) AMT Boot Service' return common.invoke_method( service_name='CIM_BootService', resource_name='CIM_BootConfigSetting', affected_item='BootConfigSetting', method_name='SetBootConfigRole', options=self.options, client=self.client, selector=('InstanceID', 'Intel(r) AMT: Boot Configuration 0', ), args_after=[('Role', role)], )