示例#1
0
    def test_set_boot_device_fail(self, mock_ccj, mock_cfcj, mock_glcv,
                                  mock_gbd, mock_client_pywsman):
        controller_version = '2.1.5.0'
        mock_glcv.return_value = controller_version
        mock_gbd.return_value = {'boot_device': boot_devices.PXE,
                                 'persistent': True}
        result_xml_enum = test_utils.build_soap_xml(
            [{'InstanceID': 'NIC', 'BootSourceType': 'IPL'}],
            resource_uris.DCIM_BootSourceSetting)
        result_xml_invk = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_ERROR, 'Message': 'E_FAKE'}],
            resource_uris.DCIM_BootConfigSetting)

        mock_xml_enum = test_utils.mock_wsman_root(result_xml_enum)
        mock_xml_invk = test_utils.mock_wsman_root(result_xml_invk)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml_enum
        mock_pywsman.invoke.return_value = mock_xml_invk
        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            task.node = self.node
            self.assertRaises(exception.DracOperationFailed,
                              self.driver.set_boot_device, task,
                              boot_devices.PXE)

        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_BootConfigSetting,
            'ChangeBootOrderByInstanceID', None)
        mock_glcv.assert_called_once_with(self.node)
        mock_gbd.assert_called_once_with(self.node, controller_version)
        mock_cfcj.assert_called_once_with(self.node)
        self.assertFalse(mock_ccj.called)
示例#2
0
    def test_set_boot_device_11g(self, mock_ccj, mock_cfcj, mock_glcv,
                                 mock_gbd, mock_client_pywsman):
        controller_version = '1.5.0.0'
        mock_glcv.return_value = controller_version
        mock_gbd.return_value = {'boot_device': boot_devices.PXE,
                                 'persistent': True}
        result_xml_enum = test_utils.build_soap_xml(
            [{'InstanceID': 'NIC'}],
            resource_uris.DCIM_BootSourceSetting)
        result_xml_invk = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_SUCCESS}],
            resource_uris.DCIM_BootConfigSetting)

        mock_xml_enum = test_utils.mock_wsman_root(result_xml_enum)
        mock_xml_invk = test_utils.mock_wsman_root(result_xml_invk)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml_enum
        mock_pywsman.invoke.return_value = mock_xml_invk

        with task_manager.acquire(self.context, self.node.uuid,
                                  shared=False) as task:
            task.node = self.node
            result = self.driver.set_boot_device(task, boot_devices.PXE)

        self.assertIsNone(result)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_BootConfigSetting,
            'ChangeBootOrderByInstanceID', None)
        mock_glcv.assert_called_once_with(self.node)
        mock_gbd.assert_called_once_with(self.node, controller_version)
        mock_cfcj.assert_called_once_with(self.node)
        mock_ccj.assert_called_once_with(self.node)
示例#3
0
    def test__power_status(self, mock_gwc):
        namespace = resource_uris.CIM_AssociatedPowerManagementService
        result_xml = test_utils.build_soap_xml([{'PowerState':
                                                 '2'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_client = mock_gwc.return_value
        mock_client.wsman_get.return_value = mock_doc
        self.assertEqual(
            states.POWER_ON, amt_power._power_status(self.node))

        result_xml = test_utils.build_soap_xml([{'PowerState':
                                                 '8'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_client = mock_gwc.return_value
        mock_client.wsman_get.return_value = mock_doc
        self.assertEqual(
            states.POWER_OFF, amt_power._power_status(self.node))

        result_xml = test_utils.build_soap_xml([{'PowerState':
                                                 '4'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_client = mock_gwc.return_value
        mock_client.wsman_get.return_value = mock_doc
        self.assertEqual(
            states.ERROR, amt_power._power_status(self.node))
示例#4
0
    def test_wsman_enumerate_with_additional_pull(self, mock_client_pywsman):
        mock_root = mock.Mock(spec=['string'])
        mock_root.string.side_effect = [
            test_utils.build_soap_xml([{'item1': 'test1'}]),
            test_utils.build_soap_xml([{'item2': 'test2'}])
        ]
        mock_xml = mock.Mock(spec=['context', 'root'])
        mock_xml.root.return_value = mock_root
        mock_xml.context.side_effect = [42, 42, None]

        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.enumerate.return_value = mock_xml
        mock_pywsman_client.pull.return_value = mock_xml

        client = drac_client.Client(**INFO_DICT)
        result = client.wsman_enumerate(self.resource_uri)

        # assert the XML was merged
        result_string = ElementTree.tostring(result)
        self.assertIn(b'<item1>test1</item1>', result_string)
        self.assertIn(b'<item2>test2</item2>', result_string)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_options.set_flags.assert_called_once_with(
            mock_client_pywsman.FLAG_ENUMERATION_OPTIMIZATION)
        mock_options.set_max_elements.assert_called_once_with(100)
        mock_pywsman_client.enumerate.assert_called_once_with(
            mock_options, None, self.resource_uri)
示例#5
0
    def test__set_power_state_fail(self, mock_power_pywsman,
                                   mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_ERROR,
              'Message': 'error message'}],
            resource_uris.DCIM_ComputerSystem)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.return_value = mock_xml

        mock_pywsman_clientopts = (
            mock_client_pywsman.ClientOptions.return_value)

        self.assertRaises(exception.DracOperationFailed,
                          drac_power._set_power_state, self.node,
                          states.POWER_ON)

        mock_pywsman_clientopts.add_selector.assert_has_calls([
            mock.call('CreationClassName', 'DCIM_ComputerSystem'),
            mock.call('Name', 'srv:system')
        ], any_order=True)
        mock_pywsman_clientopts.add_property.assert_called_once_with(
            'RequestedState', '2')

        mock_pywsman_client.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_ComputerSystem,
            'RequestStateChange', None)
示例#6
0
    def test_xml_find(self):
        namespace = 'http://fake'
        value = 'fake_value'
        test_xml = test_utils.build_soap_xml([{'test_element': value}],
                                             namespace)
        mock_doc = test_utils.mock_wsman_root(test_xml)

        result = amt_common.xml_find(mock_doc, namespace, 'test_element')
        self.assertEqual(value, result.text)
示例#7
0
    def test_wsman_get_fail(self, mock_client_pywsman):
        namespace = amt_common._SOAP_ENVELOPE
        result_xml = test_utils.build_soap_xml([{'Fault': 'fault'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.get.return_value = mock_doc
        client = amt_common.Client(**self.info)

        self.assertRaises(exception.AMTFailure, client.wsman_get, namespace)
        mock_pywsman.get.assert_called_once_with(mock.ANY, namespace)
示例#8
0
    def test__get_power_state(self, mock_power_pywsman, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'EnabledState': '2'}], resource_uris.DCIM_ComputerSystem)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.enumerate.return_value = mock_xml

        self.assertEqual(states.POWER_ON,
                         drac_power._get_power_state(self.node))

        mock_pywsman_client.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_ComputerSystem)
示例#9
0
    def test_wsman_get(self, mock_client_pywsman):
        namespace = resource_uris.CIM_AssociatedPowerManagementService
        result_xml = test_utils.build_soap_xml([{'PowerState':
                                                 '2'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.get.return_value = mock_doc
        client = amt_common.Client(**self.info)

        client.wsman_get(namespace)
        mock_pywsman.get.assert_called_once_with(mock.ANY, namespace)
示例#10
0
    def test__enable_boot_config(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootService
        result_xml = test_utils.build_soap_xml([{'ReturnValue': '0'}],
                                               namespace)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        amt_mgmt._enable_boot_config(self.node)

        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, namespace, 'SetBootConfigRole', mock.ANY)
示例#11
0
    def test__set_boot_device_order(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootConfigSetting
        device = boot_devices.PXE
        result_xml = test_utils.build_soap_xml([{'ReturnValue': '0'}],
                                               namespace)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        amt_mgmt._set_boot_device_order(self.node, device)

        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, namespace, 'ChangeBootOrder', mock.ANY)
示例#12
0
    def test__check_for_config_job(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'DCIM_LifecycleJob': {'Name': 'fake'}}],
            resource_uris.DCIM_LifecycleJob)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml

        result = drac_mgmt.check_for_config_job(self.node)

        self.assertIsNone(result)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_LifecycleJob)
示例#13
0
    def test_wsman_invoke(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_SUCCESS}], self.resource_uri)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.return_value = mock_xml

        method_name = 'method'
        client = drac_client.Client(**INFO_DICT)
        client.wsman_invoke(self.resource_uri, method_name)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_pywsman_client.invoke.assert_called_once_with(
            mock_options, self.resource_uri, method_name, None)
示例#14
0
    def test__get_lifecycle_controller_version(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'DCIM_SystemView': {'LifecycleControllerVersion': '42'}}],
            resource_uris.DCIM_SystemView)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml

        result = drac_mgmt._get_lifecycle_controller_version(self.node)

        self.assertEqual('42', result)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_SystemView)
示例#15
0
    def test__check_for_config_job_already_exist(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'DCIM_LifecycleJob': {'Name': 'BIOS.Setup.1-1',
                                    'JobStatus': 'scheduled',
                                    'InstanceID': 'fake'}}],
            resource_uris.DCIM_LifecycleJob)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml

        self.assertRaises(exception.DracPendingConfigJobExists,
                          drac_mgmt.check_for_config_job, self.node)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_LifecycleJob)
示例#16
0
    def test_create_config_job(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_CREATED}],
            resource_uris.DCIM_BIOSService)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        result = drac_mgmt.create_config_job(self.node)

        self.assertIsNone(result)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_BIOSService,
            'CreateTargetedConfigJob', None)
示例#17
0
    def test_create_config_job_error(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_ERROR,
              'Message': 'E_FAKE'}],
            resource_uris.DCIM_BIOSService)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        self.assertRaises(exception.DracOperationFailed,
                          drac_mgmt.create_config_job, self.node)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_BIOSService,
            'CreateTargetedConfigJob', None)
示例#18
0
    def test_wsman_invoke_retry(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_SUCCESS}], self.resource_uri)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.side_effect = [None, mock_xml]

        method_name = 'method'
        client = drac_client.Client(**INFO_DICT)
        client.wsman_invoke(self.resource_uri, method_name)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_pywsman_client.invoke.assert_has_calls([
            mock.call(mock_options, self.resource_uri, method_name, None),
            mock.call(mock_options, self.resource_uri, method_name, None)
        ])
示例#19
0
    def test__get_next_boot_list(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'DCIM_BootConfigSetting': {'InstanceID': 'IPL',
                                         'IsNext': drac_mgmt.PERSISTENT}}],
            resource_uris.DCIM_BootConfigSetting)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml

        expected = {'instance_id': 'IPL', 'is_next': drac_mgmt.PERSISTENT}
        result = drac_mgmt._get_next_boot_list(self.node)

        self.assertEqual(expected, result)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_BootConfigSetting)
示例#20
0
    def test_wsman_invoke_receives_unexpected_return_value(
            self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': '42'}], self.resource_uri)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.return_value = mock_xml

        method_name = 'method'
        client = drac_client.Client(**INFO_DICT)
        self.assertRaises(exception.DracUnexpectedReturnValue,
                          client.wsman_invoke, self.resource_uri, method_name,
                          {}, {}, drac_client.RET_SUCCESS)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_pywsman_client.invoke.assert_called_once_with(
            mock_options, self.resource_uri, method_name, None)
示例#21
0
 def test_wsman_invoke(self, mock_client_pywsman):
     namespace = resource_uris.CIM_BootSourceSetting
     result_xml = test_utils.build_soap_xml([{'ReturnValue':
                                              '0'}],
                                            namespace)
     mock_doc = test_utils.mock_wsman_root(result_xml)
     mock_pywsman = mock_client_pywsman.Client.return_value
     mock_pywsman.invoke.return_value = mock_doc
     method = 'ChangeBootOrder'
     options = mock.Mock(spec_set=[])
     client = amt_common.Client(**self.info)
     doc = None
     client.wsman_invoke(options, namespace, method, doc)
     mock_pywsman.invoke.assert_called_once_with(options, namespace, method)
     doc = 'fake-input'
     client.wsman_invoke(options, namespace, method, doc)
     mock_pywsman.invoke.assert_called_with(options, namespace, method, doc)
示例#22
0
    def test_wsman_invoke_fail(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootSourceSetting
        result_xml = test_utils.build_soap_xml([{'ReturnValue':
                                                 '2'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_doc
        method = 'fake-method'
        options = mock.Mock(spec_set=[])

        client = amt_common.Client(**self.info)

        self.assertRaises(exception.AMTFailure,
                          client.wsman_invoke,
                          options, namespace, method)
        mock_pywsman.invoke.assert_called_once_with(options, namespace, method)
示例#23
0
    def test_wsman_invoke_receives_error_return_value(
            self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_ERROR,
              'Message': 'error message'}],
            self.resource_uri)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.return_value = mock_xml

        method_name = 'method'
        client = drac_client.Client(**INFO_DICT)
        self.assertRaises(exception.DracOperationFailed,
                          client.wsman_invoke, self.resource_uri, method_name)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_pywsman_client.invoke.assert_called_once_with(
            mock_options, self.resource_uri, method_name, None)
示例#24
0
    def test__enable_boot_config_fail(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootService
        result_xml = test_utils.build_soap_xml([{'ReturnValue': '2'}],
                                               namespace)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        self.assertRaises(exception.AMTFailure,
                          amt_mgmt._enable_boot_config, self.node)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, namespace, 'SetBootConfigRole', mock.ANY)

        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = None

        self.assertRaises(exception.AMTConnectFailure,
                          amt_mgmt._enable_boot_config, self.node)
示例#25
0
    def test_get_boot_device(self, mock_glcv, mock_gnbl, mock_client_pywsman):
        controller_version = '2.1.5.0'
        mock_glcv.return_value = controller_version
        mock_gnbl.return_value = {'instance_id': 'OneTime',
                                  'is_next': drac_mgmt.ONE_TIME_BOOT}

        result_xml = test_utils.build_soap_xml(
            [{'InstanceID': 'HardDisk'}], resource_uris.DCIM_BootSourceSetting)

        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.enumerate.return_value = mock_xml

        result = self.driver.get_boot_device(self.task)
        expected = {'boot_device': boot_devices.DISK, 'persistent': False}

        self.assertEqual(expected, result)
        mock_pywsman.enumerate.assert_called_once_with(
            mock.ANY, mock.ANY, resource_uris.DCIM_BootSourceSetting)
示例#26
0
    def test__check_for_config_job_not_exist(self, mock_client_pywsman):
        job_statuses = ["Completed", "Completed with Errors", "Failed"]
        for job_status in job_statuses:
            result_xml = test_utils.build_soap_xml(
                [{'DCIM_LifecycleJob': {'Name': 'BIOS.Setup.1-1',
                                        'JobStatus': job_status,
                                        'InstanceID': 'fake'}}],
                resource_uris.DCIM_LifecycleJob)

            mock_xml = test_utils.mock_wsman_root(result_xml)
            mock_pywsman = mock_client_pywsman.Client.return_value
            mock_pywsman.enumerate.return_value = mock_xml

            try:
                drac_mgmt.check_for_config_job(self.node)
            except (exception.DracClientError,
                    exception.DracPendingConfigJobExists):
                self.fail("Failed to detect completed job due to "
                          "\"{}\" job status".format(job_status))
示例#27
0
    def test__set_boot_device_order_fail(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootConfigSetting
        device = boot_devices.PXE
        result_xml = test_utils.build_soap_xml([{'ReturnValue': '2'}],
                                               namespace)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        self.assertRaises(exception.AMTFailure,
                          amt_mgmt._set_boot_device_order, self.node, device)
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, namespace, 'ChangeBootOrder', mock.ANY)

        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = None

        self.assertRaises(exception.AMTConnectFailure,
                          amt_mgmt._set_boot_device_order, self.node, device)
示例#28
0
    def test_create_config_job_with_reboot(self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_CREATED}],
            resource_uris.DCIM_BIOSService)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_xml

        mock_pywsman_clientopts = (
            mock_client_pywsman.ClientOptions.return_value)

        result = drac_mgmt.create_config_job(self.node, reboot=True)

        self.assertIsNone(result)
        mock_pywsman_clientopts.add_property.assert_has_calls([
            mock.call('RebootJobType', '3'),
        ])
        mock_pywsman.invoke.assert_called_once_with(
            mock.ANY, resource_uris.DCIM_BIOSService,
            'CreateTargetedConfigJob', None)
示例#29
0
    def test_wsman_invoke_with_properties_including_a_list(
            self, mock_client_pywsman):
        result_xml = test_utils.build_soap_xml(
            [{'ReturnValue': drac_client.RET_SUCCESS}], self.resource_uri)
        mock_xml = test_utils.mock_wsman_root(result_xml)
        mock_pywsman_client = mock_client_pywsman.Client.return_value
        mock_pywsman_client.invoke.return_value = mock_xml
        mock_request_xml = mock_client_pywsman.XmlDoc.return_value

        method_name = 'method'
        properties = {'foo': ['bar', 'baz']}
        client = drac_client.Client(**INFO_DICT)
        client.wsman_invoke(self.resource_uri, method_name,
                            properties=properties)

        mock_options = mock_client_pywsman.ClientOptions.return_value
        mock_pywsman_client.invoke.assert_called_once_with(
            mock_options, self.resource_uri, method_name, mock_request_xml)
        mock_request_xml.root().add.assert_has_calls([
            mock.call(self.resource_uri, 'foo', 'bar'),
            mock.call(self.resource_uri, 'foo', 'baz')
        ])
        self.assertEqual(2, mock_request_xml.root().add.call_count)
示例#30
0
def _set_config(responses=[]):
    ccj_xml = test_utils.build_soap_xml([{'DCIM_LifecycleJob':
                                          {'Name': 'fake'}}],
                                        resource_uris.DCIM_LifecycleJob)
    responses.append(test_utils.mock_wsman_root(ccj_xml))
    return _base_config(responses)