Merge "Add delete operation to fuel2 openstack-config"
This commit is contained in:
@@ -17,7 +17,6 @@ from fuelclient.common import data_utils
|
||||
|
||||
|
||||
class OpenstackConfigMixin(object):
|
||||
|
||||
entity_name = 'openstack-config'
|
||||
|
||||
columns = (
|
||||
@@ -161,3 +160,22 @@ class OpenstackConfigExecute(OpenstackConfigMixin, base.BaseCommand):
|
||||
|
||||
msg = "OpenStack configuration execution started.\n"
|
||||
self.app.stdout.write(msg)
|
||||
|
||||
|
||||
class OpenstackConfigDelete(OpenstackConfigMixin, base.BaseCommand):
|
||||
"""Delete configuration with given id.
|
||||
"""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(OpenstackConfigDelete, self).get_parser(prog_name)
|
||||
|
||||
self.add_config_id_arg(parser)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, args):
|
||||
self.client.delete(args.config)
|
||||
|
||||
msg = ("Openstack configuration '{0}' "
|
||||
"has been deleted.".format(args.config))
|
||||
self.app.stdout.write(msg)
|
||||
|
||||
@@ -18,7 +18,6 @@ from fuelclient.tests.unit.v2.cli import test_engine
|
||||
|
||||
|
||||
class TestOpenstackConfig(test_engine.BaseCLITest):
|
||||
|
||||
CLUSTER_ID = 42
|
||||
NODE_ID = 64
|
||||
|
||||
@@ -123,3 +122,10 @@ class TestOpenstackConfig(test_engine.BaseCLITest):
|
||||
self.m_client.execute.assert_called_once_with(
|
||||
cluster_id=self.CLUSTER_ID, node_ids=[self.NODE_ID],
|
||||
node_role=None, force=True)
|
||||
|
||||
def test_config_delete(self):
|
||||
cmd = 'openstack-config delete 1'
|
||||
self.exec_command(cmd)
|
||||
|
||||
self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
|
||||
self.m_client.delete.assert_called_once_with(1)
|
||||
|
||||
@@ -139,3 +139,13 @@ class TestOpenstackConfigClient(test_api.BaseLibTest):
|
||||
self.assertEqual(body['cluster_id'], cluster_id)
|
||||
self.assertEqual(body['node_ids'], [42, 44])
|
||||
self.assertNotIn('node_role', body)
|
||||
|
||||
def test_config_delete(self):
|
||||
config_id = 42
|
||||
uri = self.uri + '{0}/'.format(config_id)
|
||||
fake_config = utils.get_fake_openstack_config(id=config_id)
|
||||
|
||||
m_del = self.m_request.delete(uri, json=fake_config)
|
||||
|
||||
self.client.delete(config_id)
|
||||
self.assertTrue(m_del.called)
|
||||
|
||||
@@ -45,6 +45,10 @@ class OpenstackConfigClient(base_v1.BaseV1Client):
|
||||
cluster_id=cluster_id, node_ids=node_ids,
|
||||
node_role=node_role, is_active=is_active)
|
||||
|
||||
def delete(self, config_id):
|
||||
config = self._entity_wrapper(config_id)
|
||||
config.delete()
|
||||
|
||||
|
||||
def get_client(connection):
|
||||
return OpenstackConfigClient(connection)
|
||||
|
||||
@@ -70,10 +70,11 @@ fuelclient =
|
||||
task_settings_download=fuelclient.commands.task:TaskClusterSettingsDownload
|
||||
task_deployment-info_download=fuelclient.commands.task:TaskDeploymentInfoDownload
|
||||
task_network-configuration_download=fuelclient.commands.task:TaskNetworkConfigurationDownload
|
||||
openstack-config_list=fuelclient.commands.openstack_config:OpenstackConfigList
|
||||
openstack-config_upload=fuelclient.commands.openstack_config:OpenstackConfigUpload
|
||||
openstack-config_delete=fuelclient.commands.openstack_config:OpenstackConfigDelete
|
||||
openstack-config_download=fuelclient.commands.openstack_config:OpenstackConfigDownload
|
||||
openstack-config_execute=fuelclient.commands.openstack_config:OpenstackConfigExecute
|
||||
openstack-config_list=fuelclient.commands.openstack_config:OpenstackConfigList
|
||||
openstack-config_upload=fuelclient.commands.openstack_config:OpenstackConfigUpload
|
||||
vip_create=fuelclient.commands.vip:VipCreate
|
||||
vip_download=fuelclient.commands.vip:VipDownload
|
||||
vip_upload=fuelclient.commands.vip:VipUpload
|
||||
|
||||
Reference in New Issue
Block a user