|
|
@ -1009,17 +1009,25 @@ class ContainerManager(DockerBaseClass):
|
|
|
|
scale=0
|
|
|
|
scale=0
|
|
|
|
)
|
|
|
|
)
|
|
|
|
containers = service.containers(stopped=True)
|
|
|
|
containers = service.containers(stopped=True)
|
|
|
|
if len(containers) != self.scale[service.name]:
|
|
|
|
scale = self.parse_scale(service.name)
|
|
|
|
|
|
|
|
if len(containers) != scale:
|
|
|
|
result['changed'] = True
|
|
|
|
result['changed'] = True
|
|
|
|
service_res['scale'] = self.scale[service.name] - len(containers)
|
|
|
|
service_res['scale'] = scale - len(containers)
|
|
|
|
if not self.check_mode:
|
|
|
|
if not self.check_mode:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
service.scale(int(self.scale[service.name]))
|
|
|
|
service.scale(scale)
|
|
|
|
except Exception as exc:
|
|
|
|
except Exception as exc:
|
|
|
|
self.client.fail("Error scaling %s - %s" % (service.name, str(exc)))
|
|
|
|
self.client.fail("Error scaling %s - %s" % (service.name, str(exc)))
|
|
|
|
result['actions'].append(service_res)
|
|
|
|
result['actions'].append(service_res)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_scale(self, service_name):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
return int(self.scale[service_name])
|
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
|
|
self.client.fail("Error scaling %s - expected int, got %s",
|
|
|
|
|
|
|
|
service_name, str(type(self.scale[service_name])))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec = dict(
|
|
|
|