OpenstackClient plugin for software deployment metadata show

This change implements the
"openstack software deployment metadata show" command
Based on "heat deployment-metadata-show" command

Blueprint: heat-support-python-openstackclient

Change-Id: I43788230cec346ecdb22073a14ef58187d3d1fab
This commit is contained in:
dixiaoli 2016-02-02 11:17:02 +08:00
parent a5fdf2318e
commit 4f7085355d
3 changed files with 39 additions and 0 deletions

View File

@ -14,6 +14,7 @@
"""Orchestration v1 Software Deployment action implementations"""
import logging
from oslo_serialization import jsonutils
from cliff import command
from cliff import lister
@ -263,3 +264,25 @@ class ShowDeployment(show.ShowOne):
if parsed_args.long:
columns.append('output_values')
return columns, utils.get_item_properties(data, columns)
class ShowMetadataDeployment(command.Command):
"""Get deployment configuration metadata for the specified server."""
log = logging.getLogger(__name__ + '.ShowMetadataDeployment')
def get_parser(self, prog_name):
parser = super(ShowMetadataDeployment, self).get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
help=_('ID of the server to fetch deployments for')
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
heat_client = self.app.client_manager.orchestration
md = heat_client.software_deployments.metadata(
server_id=parsed_args.server)
print(jsonutils.dumps(md, indent=2))

View File

@ -383,3 +383,18 @@ class TestDeploymentShow(TestDeployment):
exc.CommandError,
self.cmd.take_action,
parsed_args)
class TestDeploymentMetadataShow(TestDeployment):
def setUp(self):
super(TestDeploymentMetadataShow, self).setUp()
self.cmd = software_deployment.ShowMetadataDeployment(self.app, None)
self.sd_client.metadata = mock.Mock(return_value={})
def test_deployment_show_metadata(self):
arglist = ['ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5']
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
self.sd_client.metadata.assert_called_with(
server_id='ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5')

View File

@ -41,6 +41,7 @@ openstack.orchestration.v1 =
software_deployment_create = heatclient.osc.v1.software_deployment:CreateDeployment
software_deployment_delete = heatclient.osc.v1.software_deployment:DeleteDeployment
software_deployment_list = heatclient.osc.v1.software_deployment:ListDeployment
software_deployment_metadata_show = heatclient.osc.v1.software_deployment:ShowMetadataDeployment
software_deployment_show = heatclient.osc.v1.software_deployment:ShowDeployment
stack_abandon = heatclient.osc.v1.stack:AbandonStack
stack_adopt = heatclient.osc.v1.stack:AdoptStack