Remove noop deployment mode from client

We merged client fixes to early as noop mode was rejected for
its immaturity

Change-Id: I783263152754fd4dbb787ee8b5131d131cf87555
Related-bug: #1569839
This commit is contained in:
Vladimir Kuklin
2016-05-27 13:21:55 +03:00
parent 298187d131
commit 19007f1d78
8 changed files with 39 additions and 224 deletions

View File

@@ -15,7 +15,6 @@
from fuelclient.cli.actions.base import Action
import fuelclient.cli.arguments as Args
from fuelclient.cli.arguments import group
from fuelclient.cli.formatting import print_deploy_progress
from fuelclient.objects.environment import Environment
@@ -29,9 +28,7 @@ class ChangesAction(Action):
super(ChangesAction, self).__init__()
self.args = (
Args.get_env_arg(required=True),
group(
Args.get_dry_run_deployment_arg(),
Args.get_noop_deployment_arg())
Args.get_dry_run_deployment_arg(),
)
self.flag_func_map = (
(None, self.deploy_changes),
@@ -45,7 +42,7 @@ class ChangesAction(Action):
deploy_task = getattr(
env, self.actions_func_map[self.action_name])(
dry_run=params.dry_run, noop=params.noop)
dry_run=params.dry_run)
self.serializer.print_to_output(
deploy_task.data,
deploy_task,

View File

@@ -266,14 +266,6 @@ def get_dry_run_deployment_arg():
"to dump the deployment graph to a dot file.")
def get_noop_deployment_arg():
return get_boolean_arg(
"noop",
help="Specifies for task executor to do noop deployment "
"which will ask task executor to run noop drivers"
"for each task (e.g. puppet apply --noop)")
def get_file_pattern_arg():
return get_str_arg(
"filepattern",

View File

@@ -210,24 +210,15 @@ class EnvDeploy(EnvMixIn, base.BaseCommand):
'data in the db and ask the task executor ' \
'to dump the resulting graph into a dot file'
noop_help_string = 'Perform noop run of the deployment by asking the' \
'task executor to run noop drivers of each task'
dryrun_noop_group = parser.add_mutually_exclusive_group(required=False)
dryrun_noop_group.add_argument(
parser.add_argument(
'-d', '--dry-run', dest="dry_run",
action='store_true', help=dry_run_help_string)
dryrun_noop_group.add_argument(
'-n', '--noop', action='store_true',
help=noop_help_string)
return parser
def take_action(self, parsed_args):
task_id = self.client.deploy_changes(parsed_args.id,
dry_run=parsed_args.dry_run,
noop=parsed_args.noop)
dry_run=parsed_args.dry_run)
msg = 'Deployment task with id {t} for the environment {e} '\
'has been started.\n'.format(t=task_id, e=parsed_args.id)
@@ -240,8 +231,7 @@ class EnvRedeploy(EnvDeploy):
def take_action(self, parsed_args):
task_id = self.client.redeploy_changes(parsed_args.id,
dry_run=parsed_args.dry_run,
noop=parsed_args.noop)
dry_run=parsed_args.dry_run)
msg = 'Deployment task with id {t} for the environment {e} '\
'has been started.\n'.format(t=task_id, e=parsed_args.id)

View File

@@ -93,17 +93,17 @@ class Environment(BaseObject):
[{"id": n.id} for n in nodes]
)
def deploy_changes(self, dry_run=False, noop=False):
def deploy_changes(self, dry_run=False):
deploy_data = self.connection.put_request(
"clusters/{0}/changes".format(self.id),
{}, dry_run=int(dry_run), noop=int(noop)
{}, dry_run=int(dry_run)
)
return DeployTask.init_with_data(deploy_data)
def redeploy_changes(self, dry_run=False, noop=False):
def redeploy_changes(self, dry_run=False):
deploy_data = self.connection.put_request(
"clusters/{0}/changes/redeploy".format(self.id),
{}, dry_run=int(dry_run), noop=int(noop)
{}, dry_run=int(dry_run)
)
return DeployTask.init_with_data(deploy_data)

View File

@@ -62,106 +62,55 @@ class TestEnvironment(base.UnitTestCase):
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_deploy_changes(self, task_data):
dry_run = False
noop = False
mdeploy = self.m_request.put('/api/v1/clusters/1/changes'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
'?dry_run={0}'.format(
int(dry_run)), json={})
cmd = ['fuel', 'deploy-changes', '--env', '1']
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
self.check_deploy_redeploy_changes(dry_run, mdeploy)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_deploy_changes_dry_run(self, task_data):
dry_run = True
noop = False
mdeploy = self.m_request.put('/api/v1/clusters/1/changes'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
'?dry_run={0}'.format(
int(dry_run)), json={})
cmd = ['fuel', 'deploy-changes', '--env', '1']
cmd.append('--dry-run')
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_deploy_changes_noop(self, task_data):
dry_run = False
noop = True
mdeploy = self.m_request.put('/api/v1/clusters/1/changes'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
cmd = ['fuel', 'deploy-changes', '--env', '1']
cmd.append('--noop')
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_deploy_changes_noop_dry_run(self, task_data):
cmd = ['fuel', 'deploy-changes', '--env', '1']
cmd.append('--dry-run')
cmd.append('--noop')
self.assertRaises(SystemExit, self.execute, cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_redeploy_changes(self, task_data):
dry_run = False
noop = False
mdeploy = self.m_request.put('/api/v1/clusters/1/changes/redeploy'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
'?dry_run={0}'.format(
int(dry_run)), json={})
cmd = ['fuel', 'redeploy-changes', '--env', '1']
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
self.check_deploy_redeploy_changes(dry_run, mdeploy)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_redeploy_changes_dry_run(self, task_data):
dry_run = True
noop = False
mdeploy = self.m_request.put('/api/v1/clusters/1/changes/redeploy'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
'?dry_run={0}'.format(
int(dry_run)), json={})
cmd = ['fuel', 'redeploy-changes', '--env', '1']
cmd.append('--dry-run')
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
self.check_deploy_redeploy_changes(dry_run, mdeploy)
def check_deploy_redeploy_changes(self, dry_run, mdeploy, noop):
def check_deploy_redeploy_changes(self, dry_run, mdeploy):
self.assertEqual(mdeploy.last_request.qs['dry_run'][0],
str(int(dry_run)))
self.assertEqual(mdeploy.last_request.qs['noop'][0],
str(int(noop)))
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_redeploy_changes_noop(self, task_data):
dry_run = False
noop = True
mdeploy = self.m_request.put('/api/v1/clusters/1/changes/redeploy'
'?dry_run={0}&noop={1}'.format(
int(dry_run), int(noop)), json={})
cmd = ['fuel', 'redeploy-changes', '--env', '1']
if dry_run:
cmd.append('--dry-run')
if noop:
cmd.append('--noop')
self.execute(cmd)
self.check_deploy_redeploy_changes(dry_run, mdeploy, noop)
@mock.patch('fuelclient.objects.task.DeployTask.init_with_data')
def test_redeploy_changes_noop_dry_run(self, task_data):
cmd = ['fuel', 'redeploy-changes', '--env', '1']
cmd.append('--dry-run')
cmd.append('--noop')
self.assertRaises(SystemExit, self.execute, cmd)
class TestEnvironmentOstf(base.UnitTestCase):

View File

@@ -90,7 +90,6 @@ class TestEnvCommand(test_engine.BaseCLITest):
def test_env_deploy(self):
dry_run = False
noop = False
args = 'env deploy'
args += ' 42'
@@ -99,15 +98,13 @@ class TestEnvCommand(test_engine.BaseCLITest):
calls = list()
calls.append(mock.call.deploy_changes(42,
dry_run=dry_run,
noop=noop))
dry_run=dry_run))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_deploy_dry_run(self):
dry_run = True
noop = False
args = 'env deploy -d'
args += ' 42'
@@ -116,39 +113,13 @@ class TestEnvCommand(test_engine.BaseCLITest):
calls = list()
calls.append(mock.call.deploy_changes(42,
dry_run=dry_run,
noop=noop))
dry_run=dry_run))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_deploy_noop(self):
dry_run = False
noop = True
args = 'env deploy -n'
args += ' 42'
self.exec_command(args)
calls = list()
calls.append(mock.call.deploy_changes(42,
dry_run=dry_run,
noop=noop))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_deploy_noop_dry_run(self):
args = 'env deploy -d -n'
args += ' 42'
self.assertRaises(SystemExit, self.exec_command, args)
def test_env_redeploy(self):
dry_run = False
noop = False
args = 'env redeploy'
args += ' 42'
@@ -157,15 +128,13 @@ class TestEnvCommand(test_engine.BaseCLITest):
calls = list()
calls.append(mock.call.redeploy_changes(42,
dry_run=dry_run,
noop=noop))
dry_run=dry_run))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_redeploy_dry_run(self):
dry_run = True
noop = False
args = 'env redeploy -d'
args += ' 42'
@@ -174,36 +143,11 @@ class TestEnvCommand(test_engine.BaseCLITest):
calls = list()
calls.append(mock.call.redeploy_changes(42,
dry_run=dry_run,
noop=noop))
dry_run=dry_run))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_redeploy_noop(self):
dry_run = False
noop = True
args = 'env redeploy -n'
args += ' 42'
self.exec_command(args)
calls = list()
calls.append(mock.call.redeploy_changes(42,
dry_run=dry_run,
noop=noop))
self.m_get_client.assert_called_with('environment', mock.ANY)
self.m_client.assert_has_calls(calls)
def test_env_redeploy_noop_dry_run(self):
args = 'env redeploy -d -n'
args += ' 42'
self.assertRaises(SystemExit, self.exec_command, args)
def test_env_add_nodes(self):
args = 'env add nodes -e 42 -n 24 25 -r compute cinder'
self.exec_command(args)

View File

@@ -117,17 +117,14 @@ class TestEnvFacade(test_api.BaseLibTest):
expected_uri = self.get_object_uri(self.res_uri, env_id, '/changes')
matcher = self.m_request.put(expected_uri, json={})
dry_run = False
noop = False
self.client.deploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
self.client.deploy_changes(env_id, dry_run=dry_run)
self.check_deploy_redeploy_changes(dry_run, matcher)
def check_deploy_redeploy_changes(self, dry_run, matcher, noop):
def check_deploy_redeploy_changes(self, dry_run, matcher):
self.assertTrue(matcher.called)
self.assertEqual(matcher.last_request.qs['dry_run'][0],
str(int(dry_run)))
self.assertEqual(matcher.last_request.qs['noop'][0],
str(int(noop)))
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_deploy_dry_run(self, m_init):
@@ -136,32 +133,9 @@ class TestEnvFacade(test_api.BaseLibTest):
matcher = self.m_request.put(expected_uri, json={})
dry_run = True
noop = False
self.client.deploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_deploy_noop(self, m_init):
env_id = 42
expected_uri = self.get_object_uri(self.res_uri, env_id, '/changes')
matcher = self.m_request.put(expected_uri, json={})
dry_run = False
noop = True
self.client.deploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_deploy_noop_dry_run(self, m_init):
env_id = 42
dry_run = True
noop = True
self.assertRaises(error.ActionException, self.client.deploy_changes,
env_id, dry_run=dry_run, noop=noop)
self.client.deploy_changes(env_id, dry_run=dry_run)
self.check_deploy_redeploy_changes(dry_run, matcher)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_redeploy(self, m_init):
@@ -170,10 +144,9 @@ class TestEnvFacade(test_api.BaseLibTest):
'/changes/redeploy')
matcher = self.m_request.put(expected_uri, json={})
dry_run = False
noop = False
self.client.redeploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
self.client.redeploy_changes(env_id, dry_run=dry_run)
self.check_deploy_redeploy_changes(dry_run, matcher)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_redeploy_dry_run(self, m_init):
@@ -183,33 +156,9 @@ class TestEnvFacade(test_api.BaseLibTest):
matcher = self.m_request.put(expected_uri, json={})
dry_run = True
noop = False
self.client.redeploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_redeploy_noop(self, m_init):
env_id = 42
expected_uri = self.get_object_uri(self.res_uri, env_id,
'/changes/redeploy')
matcher = self.m_request.put(expected_uri, json={})
dry_run = False
noop = True
self.client.redeploy_changes(env_id, dry_run=dry_run, noop=noop)
self.check_deploy_redeploy_changes(dry_run, matcher, noop)
@mock.patch.object(task_object.DeployTask, 'init_with_data')
def test_env_redeploy_noop_dry_run(self, m_init):
env_id = 42
dry_run = True
noop = True
self.assertRaises(error.ActionException, self.client.redeploy_changes,
env_id, dry_run=dry_run, noop=noop)
self.client.redeploy_changes(env_id, dry_run=dry_run)
self.check_deploy_redeploy_changes(dry_run, matcher)
@mock.patch.object(base_object.BaseObject, 'init_with_data')
def test_env_update(self, m_init):

View File

@@ -65,22 +65,16 @@ class EnvironmentClient(base_v1.BaseV1Client):
env.assign(nodes, roles)
def deploy_changes(self, environment_id, dry_run=False, noop=False):
def deploy_changes(self, environment_id, dry_run=False):
env = self._entity_wrapper(obj_id=environment_id)
if dry_run and noop:
raise error.ActionException("Dry run and noop actions are"
"not allowed together")
deploy_task = env.deploy_changes(dry_run=dry_run, noop=noop)
deploy_task = env.deploy_changes(dry_run=dry_run)
return deploy_task.id
def redeploy_changes(self, environment_id, dry_run=False, noop=False):
def redeploy_changes(self, environment_id, dry_run=False):
env = self._entity_wrapper(obj_id=environment_id)
if dry_run and noop:
raise error.ActionException("Dry run and noop actions are"
"not allowed together")
redeploy_task = env.redeploy_changes(dry_run=dry_run, noop=noop)
redeploy_task = env.redeploy_changes(dry_run=dry_run)
return redeploy_task.id
def spawn_vms(self, environment_id):