Add OSC Plugin for openstack appcontainer pause

This change implements the "openstack appcontainer pause" command
 Based on existing zun command: zun pause

Partially Implements:blueprint zun-osc-plugin

Change-Id: I48a06b3a2e7945b9942cbaff51451d4068773d0f
This commit is contained in:
Namrata Sitlani
2017-01-04 08:55:58 +00:00
committed by Hongbin Lu
parent 1d1c5ca68f
commit d4be58a54d
2 changed files with 28 additions and 1 deletions

View File

@@ -38,6 +38,7 @@ openstack.container.v1 =
appcontainer_delete = zunclient.osc.v1.containers:DeleteContainer appcontainer_delete = zunclient.osc.v1.containers:DeleteContainer
appcontainer_reboot = zunclient.osc.v1.containers:RebootContainer appcontainer_reboot = zunclient.osc.v1.containers:RebootContainer
appcontainer_start = zunclient.osc.v1.containers:StartContainer appcontainer_start = zunclient.osc.v1.containers:StartContainer
appcontainer_pause = zunclient.osc.v1.containers:PauseContainer
[build_sphinx] [build_sphinx]
source-dir = doc/source source-dir = doc/source

View File

@@ -249,3 +249,29 @@ class StartContainer(command.Command):
except Exception as e: except Exception as e:
print("Start for container %(container)s failed: %(e)s" % print("Start for container %(container)s failed: %(e)s" %
{'container': container, 'e': e}) {'container': container, 'e': e})
class PauseContainer(command.Command):
"""Pause specified container"""
log = logging.getLogger(__name__ + ".PauseContainer")
def get_parser(self, prog_name):
parser = super(PauseContainer, self).get_parser(prog_name)
parser.add_argument(
'container',
metavar='<container>',
nargs='+',
help='ID or name of the (container)s to pause.')
return parser
def take_action(self, parsed_args):
client = _get_client(self, parsed_args)
containers = parsed_args.container
for container in containers:
try:
client.containers.pause(container)
print(_('Request to pause container %s has been accepted')
% container)
except Exception as e:
print("Pause for container %(container)s failed: %(e)s" %
{'container': container, 'e': e})