示例#1
0
    def test__power_status(self, mock_gwc, mock_aw):
        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))
        self.assertTrue(mock_aw.called)
示例#2
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)
示例#3
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)
示例#4
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)
示例#5
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)
示例#6
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)
示例#7
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)
示例#8
0
    def test__enable_boot_config(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)
示例#9
0
    def test__set_boot_device_order(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)
示例#10
0
    def test__enable_boot_config(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)
示例#11
0
    def test__set_boot_device_order(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)
示例#12
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)
示例#13
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)
示例#14
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)
示例#15
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)
示例#16
0
    def test__enable_boot_config_fail(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)
示例#17
0
    def test__enable_boot_config_fail(self, mock_aw, 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)
        self.assertTrue(mock_aw.called)