Merge "zun rebuild on local node"
This commit is contained in:
commit
748e27539a
@ -66,6 +66,7 @@ openstack.container.v1 =
|
||||
appcontainer_image_search = zunclient.osc.v1.images:SearchImage
|
||||
appcontainer_remove_security_group = zunclient.osc.v1.containers:RemoveSecurityGroup
|
||||
appcontainer_image_show = zunclient.osc.v1.images:ShowImage
|
||||
appcontainer_rebuild = zunclient.osc.v1.containers:RebuildContainer
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
|
@ -1121,3 +1121,30 @@ class NetworkAttach(command.Command):
|
||||
except Exception as e:
|
||||
print("Attach network to container %(container)s failed: "
|
||||
"%(e)s" % {'container': parsed_args.container, 'e': e})
|
||||
|
||||
|
||||
class RebuildContainer(command.Command):
|
||||
"""Rebuild one or more running container(s)"""
|
||||
log = logging.getLogger(__name__ + ".RebuildContainer")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RebuildContainer, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'containers',
|
||||
metavar='<container>',
|
||||
nargs='+',
|
||||
help='ID or name of the (container)s to rebuild.')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = _get_client(self, parsed_args)
|
||||
for container in parsed_args.containers:
|
||||
opts = {}
|
||||
opts['id'] = container
|
||||
try:
|
||||
client.containers.rebuild(**opts)
|
||||
print(_('Request to rebuild container %s has '
|
||||
'been accepted') % container)
|
||||
except Exception as e:
|
||||
print("rebuild container %(container)s failed: %(e)s" %
|
||||
{'container': container, 'e': e})
|
||||
|
@ -336,7 +336,14 @@ fake_responses = {
|
||||
None,
|
||||
),
|
||||
},
|
||||
|
||||
'/v1/containers/%s/rebuild'
|
||||
% (CONTAINER1['id']):
|
||||
{
|
||||
'POST': (
|
||||
{},
|
||||
None,
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -702,3 +709,12 @@ class ContainerManagerTest(testtools.TestCase):
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
self.assertTrue(containers)
|
||||
|
||||
def test_containers_rebuild(self):
|
||||
self.mgr.rebuild(CONTAINER1['id'])
|
||||
expect = [
|
||||
('POST',
|
||||
'/v1/containers/%s/rebuild' % (CONTAINER1['id']),
|
||||
{'Content-Length': '0'}, None)
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
|
@ -130,6 +130,9 @@ class ContainerManager(base.Manager):
|
||||
return self._action(id, '/stop',
|
||||
qparams={'timeout': timeout})
|
||||
|
||||
def rebuild(self, id):
|
||||
return self._action(id, '/rebuild')
|
||||
|
||||
def restart(self, id, timeout):
|
||||
return self._action(id, '/reboot',
|
||||
qparams={'timeout': timeout})
|
||||
|
@ -258,6 +258,22 @@ def do_show(cs, args):
|
||||
_show_container(container)
|
||||
|
||||
|
||||
@utils.arg('containers',
|
||||
metavar='<container>',
|
||||
nargs='+',
|
||||
help='ID of the (container)s to rebuild.')
|
||||
def do_rebuild(cs, args):
|
||||
"""Rebuild specified containers."""
|
||||
for container in args.containers:
|
||||
try:
|
||||
cs.containers.rebuild(container)
|
||||
print("Request to rebuild container %s has been accepted." %
|
||||
container)
|
||||
except Exception as e:
|
||||
print("Rebuild for container %(container)s failed: %(e)s" %
|
||||
{'container': container, 'e': e})
|
||||
|
||||
|
||||
@utils.arg('containers',
|
||||
metavar='<container>',
|
||||
nargs='+',
|
||||
|
Loading…
Reference in New Issue
Block a user