Esempio n. 1
0
    def test_manage_servers_with_network_exception(self,
                                                   get_manageable_mock,
                                                   manage_mock,
                                                   umanage_mock,
                                                   server_create_mock,
                                                   rollback_quota_mock):
        get_manageable_mock.side_effect = None
        manage_mock.side_effect = exception.NetworkError()
        server_create_mock.side_effect = None

        server = obj_utils.get_test_server(
            self.context, status=None, node_uuid=None,
            power_state=states.NOSTATE, availability_zone=None,
            image_uuid=None)
        node_uuid = 'aacdbd78-d670-409e-95aa-ecfcfb94fee2'

        self.assertRaises(exception.NetworkError,
                          self.service.manage_server,
                          self.context, server, node_uuid)

        get_manageable_mock.assert_called_once_with(node_uuid)
        manage_mock.assert_called_once()
        umanage_mock.assert_not_called()
        server_create_mock.assert_not_called()
        rollback_quota_mock.assert_called_once_with(self.context, -1)
Esempio n. 2
0
    def test__manage_servers(self,
                             put_allocations_mock, show_port_mock,
                             manage_mock, bind_port_mock):
        neutron_port_id = '67ec8e86-d77b-4729-b11d-a009864d289d'
        neutron_mac_address = '52:54:00:8e:6a:03'
        node_uuid = 'aacdbd78-d670-409e-95aa-ecfcfb94fee2'
        image_uuid = 'efe0a06f-ca95-4808-b41e-9f55b9c5eb98'

        node = {
            'uuid': node_uuid,
            'name': 'test_manageable_mode',
            'resource_class': 'gold',
            'power_state': 'power on',
            'provision_state': 'active',
            "ports": [
                {
                    "address": neutron_mac_address,
                    "uuid": "1ec01153-685a-49b5-a6d3-45a4e7dddf53",
                    "neutron_port_id": neutron_port_id
                }
            ],
            "portgroups": [
                {
                    "address": "a4:dc:be:0e:82:a6",
                    "uuid": "1ec01153-685a-49b5-a6d3-45a4e7dddf54",
                    "neutron_port_id": None
                }
            ],
            'image_source': image_uuid
        }

        put_allocations_mock.side_effect = None
        show_port_mock.return_value = {
            'id': neutron_port_id,
            'network_id': '34ec8e86-d77b-4729-b11d-a009864d3456',
            'mac_address': neutron_mac_address,
            'fixed_ips': [{"subnet_id": "d2d7a7c2-17d2-4268-906d-1da8dde24fa8",
                           "ip_address": "10.80.20.12"}]
        }

        bind_port_mock.side_effect = None
        server = obj_utils.get_test_server(
            self.context, status=None, node_uuid=None,
            power_state=states.NOSTATE, availability_zone=None,
            image_uuid=None)

        manage_mock.side_effect = None
        self.service._manage_server(self.context, server, node)

        put_allocations_mock.assert_called_once()
        manage_mock.assert_called_once()
        show_port_mock.assert_called_once_with(self.context, neutron_port_id)
        bind_port_mock.assert_called_once_with(self.context, neutron_port_id,
                                               server)
        self.assertEqual(server.node_uuid, node_uuid)
        self.assertIsNone(server.availability_zone)
        self.assertEqual(server.status, 'active')
        self.assertEqual(server.power_state, 'power on')
        self.assertEqual(server.image_uuid, image_uuid)
Esempio n. 3
0
    def test_create_server_task_execute(self, mock_spawn):
        flow_manager = manager.EngineManager('test-host', 'test-topic')
        task = create_server.CreateServerTask(flow_manager.driver)
        server_obj = obj_utils.get_test_server(self.ctxt)
        mock_spawn.side_effect = None

        task.execute(self.ctxt, server_obj, {'value': 'configdrive'}, None)
        mock_spawn.assert_called_once_with(self.ctxt, server_obj,
                                           'configdrive', None)
Esempio n. 4
0
    def test_create_network_task_execute(self, mock_build_networks, mock_save):
        fake_engine_manager = mock.MagicMock()
        fake_requested_networks = mock.MagicMock()
        task = create_server.BuildNetworkTask(fake_engine_manager)
        server_obj = obj_utils.get_test_server(self.ctxt)
        mock_build_networks.return_value = None
        mock_save.return_value = None

        task.execute(self.ctxt, server_obj, fake_requested_networks)
        mock_build_networks.assert_called_once_with(self.ctxt, server_obj,
                                                    fake_requested_networks)
Esempio n. 5
0
    def setUp(self):
        super(TestAuthorizeWsgi, self).setUp()
        self.fake_controller = mock.MagicMock()
        self.ctxt = context.RequestContext(
            tenant='c18e8a1a870d4c08a0b51ced6e0b6459',
            user='******')
        self.test_server = utils.get_test_server(self.ctxt)
        self.fake_controller._get_resource.return_value = self.test_server

        def power(self, server_uuid, target):
            pass

        def lock(self, server_uuid, target):
            pass

        self.fake_power = power
        self.fake_lock = lock
Esempio n. 6
0
    def test_manage_servers(self, get_manageable_mock,
                            manage_mock, umanage_mock, server_create_mock):
        get_manageable_mock.side_effect = None
        manage_mock.side_effect = None
        server_create_mock.side_effect = None

        server = obj_utils.get_test_server(
            self.context, status=None, node_uuid=None,
            power_state=states.NOSTATE, availability_zone=None,
            image_uuid=None)
        node_uuid = 'aacdbd78-d670-409e-95aa-ecfcfb94fee2'

        self.service.manage_server(self.context, server, node_uuid)

        get_manageable_mock.assert_called_once_with(node_uuid)
        manage_mock.assert_called_once()
        umanage_mock.assert_not_called()
        server_create_mock.assert_called_once()
Esempio n. 7
0
 def setUp(self):
     super(TestServerObject, self).setUp()
     self.ctxt = context.get_admin_context()
     self.fake_server = utils.get_test_server(context=self.ctxt)
     self.server = obj_utils.get_test_server(self.ctxt, **self.fake_server)