Merge "Add 'fuel2 env stop-deployment' command"

This commit is contained in:
Jenkins
2016-09-01 09:21:36 +00:00
committed by Gerrit Code Review
5 changed files with 46 additions and 0 deletions

View File

@@ -339,6 +339,27 @@ class EnvReset(EnvMixIn, base.BaseCommand):
self.app.stdout.write(msg)
class EnvStopDeploy(EnvMixIn, base.BaseCommand):
"""Stop deployment process for specific environment."""
def get_parser(self, prog_name):
parser = super(EnvStopDeploy, self).get_parser(prog_name)
parser.add_argument('id',
type=int,
help='Id of the environment to stop deployment.')
return parser
def take_action(self, parsed_args):
result = self.client.stop(parsed_args.id)
msg = ('Stop deployment task with id {t} for the environment '
'{e} has been started.\n'.format(t=result.data['id'],
e=result.data['cluster']))
self.app.stdout.write(msg)
class EnvAddNodes(EnvMixIn, base.BaseCommand):
"""Adds nodes to an environment with the specified roles."""

View File

@@ -281,6 +281,15 @@ class TestEnvCommand(test_engine.BaseCLITest):
self.m_get_client.assert_called_once_with('environment', mock.ANY)
self.m_client.provision_nodes.assert_called_once_with(env_id, node_ids)
def test_env_stop(self):
env_id = 45
args = 'env stop-deployment {env_id}'.format(env_id=env_id)
self.exec_command(args)
self.m_get_client.assert_called_once_with('environment', mock.ANY)
self.m_client.stop.assert_called_once_with(env_id)
def test_env_network_verify(self):
env_id = 42
args = 'env network verify {}'.format(env_id)

View File

@@ -262,6 +262,17 @@ class TestEnvFacade(test_api.BaseLibTest):
self.assertTrue(matcher.called)
def test_env_stop(self):
env_id = 42
expected_uri = self.get_object_uri(self.res_uri, env_id,
'/stop_deployment/')
matcher = self.m_request.put(expected_uri, json=utils.get_fake_task())
self.client.stop(env_id)
self.assertTrue(matcher.called)
def test_env_remove_nodes_by_id(self):
nodes = [25, 26]
env_id = 42

View File

@@ -186,6 +186,10 @@ class EnvironmentClient(base_v1.BaseV1Client):
env = self._entity_wrapper(obj_id=env_id)
return env.reset(force)
def stop(self, env_id):
env = self._entity_wrapper(obj_id=env_id)
return env.stop()
def get_client(connection):
return EnvironmentClient(connection)

View File

@@ -54,6 +54,7 @@ fuelclient =
env_settings_upload=fuelclient.commands.environment:EnvSettingsUpload
env_show=fuelclient.commands.environment:EnvShow
env_spawn-vms=fuelclient.commands.environment:EnvSpawnVms
env_stop-deployment=fuelclient.commands.environment:EnvStopDeploy
env_update=fuelclient.commands.environment:EnvUpdate
fuel-version=fuelclient.commands.fuelversion:FuelVersion
graph_download=fuelclient.commands.graph:GraphDownload