diff --git a/setup.cfg b/setup.cfg index 6107bdbf..8028c459 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,7 +38,8 @@ openstack.container.v1 = appcontainer_delete = zunclient.osc.v1.containers:DeleteContainer appcontainer_reboot = zunclient.osc.v1.containers:RebootContainer appcontainer_start = zunclient.osc.v1.containers:StartContainer - + appcontainer_pause = zunclient.osc.v1.containers:PauseContainer + [build_sphinx] source-dir = doc/source build-dir = doc/build diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 6847cebc..846f7247 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -249,3 +249,29 @@ class StartContainer(command.Command): except Exception as e: print("Start for container %(container)s failed: %(e)s" % {'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='', + 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})