mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
further linting
This commit is contained in:
parent
4aec37397c
commit
39fa11b696
2 changed files with 33 additions and 35 deletions
|
@ -1850,7 +1850,7 @@ def load(imagepath):
|
|||
try:
|
||||
dockercmd = ['docker', 'load', '-i', imagepath]
|
||||
ret = __salt__['cmd.run'](dockercmd, python_shell=False)
|
||||
if ((isinstance(ret, dict) and ('retcode' in ret) and (ret['retcode'] != 0))):
|
||||
if isinstance(ret, dict) and ('retcode' in ret) and (ret['retcode'] != 0):
|
||||
return _invalid(status, id_=None,
|
||||
out=ret,
|
||||
comment='Command to load image {0} failed.'.format(imagepath))
|
||||
|
@ -1901,7 +1901,7 @@ def save(image, filename):
|
|||
try:
|
||||
dockercmd = ['docker', 'save', '-o', filename, image]
|
||||
ret = __salt__['cmd.run'](dockercmd)
|
||||
if ((isinstance(ret, dict) and ('retcode' in ret) and (ret['retcode'] != 0))):
|
||||
if isinstance(ret, dict) and ('retcode' in ret) and (ret['retcode'] != 0):
|
||||
return _invalid(status,
|
||||
id_=image,
|
||||
out=ret,
|
||||
|
|
|
@ -274,8 +274,8 @@ def _parse_volumes(volumes):
|
|||
contvolumes.append(str(vol))
|
||||
continue
|
||||
bindvolumes[source] = {
|
||||
'bind': target,
|
||||
'ro': read_only
|
||||
'bind': target,
|
||||
'ro': read_only
|
||||
}
|
||||
result = {'bindvols': bindvolumes, 'contvols': contvolumes}
|
||||
log.trace("Finished parsing volumes, with result: " + str(result))
|
||||
|
@ -460,9 +460,9 @@ def loaded(name, source=None, source_hash='', force=False):
|
|||
|
||||
tmp_filename = salt.utils.mkstemp()
|
||||
__salt__['state.single']('file.managed',
|
||||
name=tmp_filename,
|
||||
source=source,
|
||||
source_hash=source_hash)
|
||||
name=tmp_filename,
|
||||
source=source,
|
||||
source_hash=source_hash)
|
||||
changes = {}
|
||||
|
||||
if image_infos['status']:
|
||||
|
@ -471,7 +471,7 @@ def loaded(name, source=None, source_hash='', force=False):
|
|||
remove_info = remove_image(name)
|
||||
if not remove_info['status']:
|
||||
return _invalid(name=name,
|
||||
comment='Image could not be removed: {0}'.format(name))
|
||||
comment='Image could not be removed: {1}'.format(name))
|
||||
|
||||
load = __salt__['docker.load']
|
||||
returned = load(tmp_filename)
|
||||
|
@ -686,23 +686,23 @@ def absent(name):
|
|||
is_gone = __salt__['docker.exists'](cid)
|
||||
if is_gone:
|
||||
return _valid(comment=('Container {0!r}'
|
||||
' was stopped and destroyed, '.format(cid)),
|
||||
changes={name: True})
|
||||
' was stopped and destroyed, '.format(cid)),
|
||||
changes={name: True})
|
||||
else:
|
||||
return _valid(comment=('Container {0!r}'
|
||||
' was stopped but could not be destroyed,'.format(cid)),
|
||||
changes={name: True})
|
||||
' was stopped but could not be destroyed,'.format(cid)),
|
||||
changes={name: True})
|
||||
else:
|
||||
__salt__['docker.remove_container'](cid)
|
||||
is_gone = __salt__['docker.exists'](cid)
|
||||
if is_gone:
|
||||
return _valid(comment=('Container {0!r}'
|
||||
' is stopped and was destroyed, '.format(cid)),
|
||||
changes={name: True})
|
||||
'is stopped and was destroyed, '.format(cid)),
|
||||
changes={name: True})
|
||||
else:
|
||||
return _valid(comment=('Container {0!r}'
|
||||
' is stopped but could not be destroyed,'.format(cid)),
|
||||
changes={name: True})
|
||||
' is stopped but could not be destroyed,'.format(cid)),
|
||||
changes={name: True})
|
||||
else:
|
||||
return _valid(comment="Container {0!r} not found".format(name))
|
||||
|
||||
|
@ -1062,21 +1062,21 @@ def running(name,
|
|||
|
||||
if not already_exists:
|
||||
args, kwargs = [image], dict(
|
||||
command=command,
|
||||
hostname=hostname,
|
||||
user=user,
|
||||
detach=detach,
|
||||
stdin_open=stdin_open,
|
||||
tty=tty,
|
||||
mem_limit=mem_limit,
|
||||
ports=exposeports,
|
||||
environment=denvironment,
|
||||
dns=dns,
|
||||
binds=bindvolumes,
|
||||
volumes=contvolumes,
|
||||
name=name,
|
||||
cpu_shares=cpu_shares,
|
||||
cpuset=cpuset)
|
||||
command=command,
|
||||
hostname=hostname,
|
||||
user=user,
|
||||
detach=detach,
|
||||
stdin_open=stdin_open,
|
||||
tty=tty,
|
||||
mem_limit=mem_limit,
|
||||
ports=exposeports,
|
||||
environment=denvironment,
|
||||
dns=dns,
|
||||
binds=bindvolumes,
|
||||
volumes=contvolumes,
|
||||
name=name,
|
||||
cpu_shares=cpu_shares,
|
||||
cpuset=cpuset)
|
||||
out = create(*args, **kwargs)
|
||||
# if container has been created, even if not started, we mark
|
||||
# it as installed
|
||||
|
@ -1109,10 +1109,8 @@ def running(name,
|
|||
if is_running:
|
||||
changes.append('Container {0!r} started.\n'.format(name))
|
||||
else:
|
||||
return _invalid(
|
||||
comment=(
|
||||
'Container {0!r} cannot be started\n{1!s}'
|
||||
.format(name, started['out'],)))
|
||||
return _invalid(comment=('Container {0!r} cannot be started\n{1!s}'
|
||||
.format(name, started['out'],)))
|
||||
else:
|
||||
changes.append('Container {0!r} started.\n'.format(name))
|
||||
return _valid(comment=','.join(changes), changes={name: True})
|
||||
|
|
Loading…
Add table
Reference in a new issue