Merge "Dry-run option added to fuel graph execute command"

This commit is contained in:
Jenkins
2016-06-06 14:17:18 +00:00
committed by Gerrit Code Review
4 changed files with 47 additions and 4 deletions

View File

@@ -138,13 +138,22 @@ class GraphExecute(base.BaseCommand):
nargs='+',
required=False,
help='Ids of the nodes to use for deployment.')
parser.add_argument('-d',
'--dry-run',
action="store_true",
required=False,
default=False,
help='Specifies to dry-run a deployment by '
'configuring task executor to dump the '
'deployment graph to a dot file.')
return parser
def take_action(self, args):
self.client.execute(
env_id=args.env,
graph_type=args.type,
nodes=args.nodes
nodes=args.nodes,
dry_run=args.dry_run
)
self.app.stdout.write(
"Deployment was executed\n"

View File

@@ -91,7 +91,20 @@ class TestGraphActions(test_engine.BaseCLITest):
dict(
env_id=1,
graph_type='custom_graph',
nodes=[1, 2, 3]
nodes=[1, 2, 3],
dry_run=False
)
)
def test_execute_w_dry_run(self):
self._test_cmd(
'execute',
'--env 1 --type custom_graph --nodes 1 2 3 --dry-run',
dict(
env_id=1,
graph_type='custom_graph',
nodes=[1, 2, 3],
dry_run=True
)
)

View File

@@ -103,7 +103,8 @@ class TestDeploymentGraphFacade(test_api.BaseLibTest):
def test_new_graph_run(self):
matcher_put = self.m_request.put(
'/api/v1/clusters/1/deploy/?nodes=1,2,3&graph_type=custom_graph',
'/api/v1/clusters/1/deploy/?nodes=1,2,3&graph_type=custom_graph'
'&dry_run=',
json=fake_task.get_fake_task(cluster=370))
# this is required to form running task info
self.m_request.get(
@@ -116,6 +117,24 @@ class TestDeploymentGraphFacade(test_api.BaseLibTest):
graph_type="custom_graph")
self.assertTrue(matcher_put.called)
def test_new_graph_dry_run(self):
matcher_put = self.m_request.put(
'/api/v1/clusters/1/deploy/?nodes=1,2,3&graph_type=custom_graph'
'&dry_run=1',
json=fake_task.get_fake_task(cluster=370))
# this is required to form running task info
self.m_request.get(
'/api/v1/nodes/?cluster_id=370',
json={}
)
self.client.execute(
env_id=1,
nodes=[1, 2, 3],
graph_type="custom_graph",
dry_run=True
)
self.assertTrue(matcher_put.called)
def test_graphs_list(self):
matcher_get = self.m_request.get(
'/api/v1/clusters/1/deployment_graphs/',

View File

@@ -79,7 +79,7 @@ class GraphClient(base_v1.BaseV1Client):
self.create_graph_for_model(
{'tasks': data}, related_model, related_id, graph_type)
def execute(self, env_id, nodes, graph_type=None):
def execute(self, env_id, nodes, graph_type=None, dry_run=False):
put_args = []
if nodes:
@@ -88,6 +88,8 @@ class GraphClient(base_v1.BaseV1Client):
if graph_type:
put_args.append(("graph_type=" + graph_type))
if dry_run:
put_args.append("dry_run=1")
url = "".join([
self.cluster_deploy_api_path.format(env_id=env_id),
'?',