def test_show_resource(self, mock_server_get):
        plugin = ServerProtectablePlugin(self._context)

        server_info = collections.namedtuple('server_info', ['id', 'name'])
        mock_server_get.return_value = \
            server_info(id='123', name='name123')
        self.assertEqual(Resource('OS::Nova::Server', '123', 'name123'),
                         plugin.show_resource(self._context, '123'))
 def test_create_client_by_endpoint(self):
     cfg.CONF.set_default('nova_endpoint',
                          'http://127.0.0.1:8774/v2.1',
                          'nova_client')
     plugin = ServerProtectablePlugin(self._context)
     self.assertEqual('compute',
                      plugin._client(self._context).client.service_type)
     self.assertEqual('http://127.0.0.1:8774/v2.1/abcd',
                      plugin._client(self._context).client.management_url)
Ejemplo n.º 3
0
 def test_create_client_by_catalog(self, mock_generate_session):
     plugin = ServerProtectablePlugin(self._context)
     mock_generate_session.return_value = keystone_session.Session(
         auth=None)
     self.assertEqual('compute',
                      plugin._client(self._context).client.service_type)
     self.assertEqual(
         'http://127.0.0.1:8774/v2.1/abcd',
         plugin._client(self._context).client.endpoint_override)
    def test_get_dependent_resources(self, mock_server_list):
        plugin = ServerProtectablePlugin(self._context)

        server_info = collections.namedtuple('server_info', ['id', 'name'])
        mock_server_list.return_value = [
            server_info(id='123', name='name123'),
            server_info(id='456', name='name456')]
        self.assertEqual([Resource('OS::Nova::Server', '123', 'name123'),
                          Resource('OS::Nova::Server', '456', 'name456')],
                         plugin.get_dependent_resources(self._context, None))
Ejemplo n.º 5
0
    def test_show_resource(self, mock_server_get, mock_generate_session):
        plugin = ServerProtectablePlugin(self._context)
        mock_generate_session.return_value = keystone_session.Session(
            auth=None)

        server_info = collections.namedtuple('server_info',
                                             ['id', 'name', 'status'])
        mock_server_get.return_value = server_info(id='123',
                                                   name='name123',
                                                   status='ACTIVE')
        self.assertEqual(Resource('OS::Nova::Server', '123', 'name123'),
                         plugin.show_resource(self._context, '123'))
Ejemplo n.º 6
0
    def test_list_resources(self, mock_server_list, mock_generate_session):
        plugin = ServerProtectablePlugin(self._context)
        mock_generate_session.return_value = keystone_session.Session(
            auth=None)

        server_info = collections.namedtuple('server_info',
                                             ['id', 'name', 'status'])
        mock_server_list.return_value = [
            server_info(id='123', name='name123', status='ACTIVE'),
            server_info(id='456', name='name456', status='ACTIVE')
        ]
        self.assertEqual([
            Resource('OS::Nova::Server', '123', 'name123'),
            Resource('OS::Nova::Server', '456', 'name456')
        ], plugin.list_resources(self._context))
 def test_get_parent_resource_types(self):
     plugin = ServerProtectablePlugin(self._context)
     self.assertEqual(("OS::Keystone::Project", ),
                      plugin.get_parent_resource_types())
 def test_get_resource_type(self):
     plugin = ServerProtectablePlugin(self._context)
     self.assertEqual("OS::Nova::Server", plugin.get_resource_type())
 def test_create_client_by_catalog(self):
     plugin = ServerProtectablePlugin(self._context)
     self.assertEqual('compute',
                      plugin._client(self._context).client.service_type)
     self.assertEqual('http://127.0.0.1:8774/v2.1/abcd',
                      plugin._client(self._context).client.management_url)
Ejemplo n.º 10
0
 def test_get_parent_resource_types(self, mock_generate_session):
     plugin = ServerProtectablePlugin(self._context)
     mock_generate_session.return_value = keystone_session.Session(
         auth=None)
     self.assertEqual(("OS::Keystone::Project", ),
                      plugin.get_parent_resource_types())
Ejemplo n.º 11
0
 def test_get_resource_type(self, mock_generate_session):
     plugin = ServerProtectablePlugin(self._context)
     mock_generate_session.return_value = keystone_session.Session(
         auth=None)
     self.assertEqual("OS::Nova::Server", plugin.get_resource_type())