Merge "Adding environment-get-definition for easy environment-update"
This commit is contained in:
@@ -115,6 +115,36 @@ class Get(command.ShowOne):
|
||||
return format(environment)
|
||||
|
||||
|
||||
class GetDefinition(command.ShowOne):
|
||||
"""Show specific environment definition."""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(GetDefinition, self).get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
'environment',
|
||||
help='Environment name'
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
mistral_client = self.app.client_manager.workflow_engine
|
||||
env = mistral_client.environments.get(parsed_args.environment)
|
||||
|
||||
columns = ('name',
|
||||
'description',
|
||||
'scope',
|
||||
'variables')
|
||||
|
||||
data = (env.name,
|
||||
env.description,
|
||||
env.scope,
|
||||
json.dumps(env.variables))
|
||||
|
||||
return columns, data
|
||||
|
||||
|
||||
class Create(command.ShowOne):
|
||||
"""Create new environment."""
|
||||
|
||||
|
@@ -706,6 +706,8 @@ class MistralShell(app.App):
|
||||
mistralclient.commands.v2.environments.Update,
|
||||
'environment-list': mistralclient.commands.v2.environments.List,
|
||||
'environment-get': mistralclient.commands.v2.environments.Get,
|
||||
'environment-get-definition':
|
||||
mistralclient.commands.v2.environments.GetDefinition,
|
||||
'run-action': mistralclient.commands.v2.action_executions.Create,
|
||||
'action-execution-list':
|
||||
mistralclient.commands.v2.action_executions.List,
|
||||
|
@@ -447,6 +447,17 @@ class EnvironmentIsolationCLITests(base_v2.MistralClientTestBase):
|
||||
params=env_name
|
||||
)
|
||||
|
||||
def test_get_env_definition_from_another_tenant(self):
|
||||
env = self.environment_create(self.env_file)
|
||||
env_name = self.get_field_value(env, "Name")
|
||||
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.mistral_alt_user,
|
||||
"environment-get-definition",
|
||||
params=env_name
|
||||
)
|
||||
|
||||
def test_delete_env_from_another_tenant(self):
|
||||
env = self.environment_create(self.env_file)
|
||||
env_name = self.get_field_value(env, "Name")
|
||||
|
@@ -1528,6 +1528,21 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase):
|
||||
self.assertEqual(env_name, fetched_env_name)
|
||||
self.assertEqual(env_desc, fetched_env_desc)
|
||||
|
||||
def test_environment_get_definition(self):
|
||||
env = self.environment_create('env.yaml')
|
||||
|
||||
env_name = self.get_field_value(env, 'Name')
|
||||
env_desc = self.get_field_value(env, 'Description')
|
||||
|
||||
env = self.mistral_admin('environment-get-definition', params=env_name)
|
||||
|
||||
fetched_env_name = self.get_field_value(env, 'name')
|
||||
fetched_env_desc = self.get_field_value(env, 'description')
|
||||
|
||||
self.assertTableStruct(env, ['Field', 'Value'])
|
||||
self.assertEqual(env_name, fetched_env_name)
|
||||
self.assertEqual(env_desc, fetched_env_desc)
|
||||
|
||||
|
||||
class ActionExecutionCLITests(base_v2.MistralClientTestBase):
|
||||
"""Test suite checks commands to work with action executions."""
|
||||
@@ -2183,6 +2198,21 @@ class NegativeCLITests(base_v2.MistralClientTestBase):
|
||||
params='nonexist'
|
||||
)
|
||||
|
||||
def test_env_get_definition_without_param(self):
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.mistral_admin,
|
||||
'environment-get-definition'
|
||||
)
|
||||
|
||||
def test_env_get_definition_nonexistent(self):
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.mistral_admin,
|
||||
'environment-get-definition',
|
||||
params='nonexist'
|
||||
)
|
||||
|
||||
def test_env_create_same_name(self):
|
||||
self.create_file(
|
||||
'env.yaml',
|
||||
|
@@ -61,6 +61,7 @@ openstack.workflow_engine.v2 =
|
||||
workflow_env_update = mistralclient.commands.v2.environments:Update
|
||||
workflow_env_list = mistralclient.commands.v2.environments:List
|
||||
workflow_env_show = mistralclient.commands.v2.environments:Get
|
||||
workflow_env_definition_show = mistralclient.commands.v2.environments:GetDefinition
|
||||
|
||||
action_execution_run = mistralclient.commands.v2.action_executions:Create
|
||||
action_execution_list = mistralclient.commands.v2.action_executions:List
|
||||
|
Reference in New Issue
Block a user