mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Remove unneeded kwargs in virt states
Avoid using kwargs to get the states parameters, perfer documented named parameters with default value.
This commit is contained in:
parent
fc75872fb6
commit
c7c5d6ee88
@ -250,7 +250,9 @@ def running(name,
|
||||
install=True,
|
||||
pub_key=None,
|
||||
priv_key=None,
|
||||
**kwargs):
|
||||
connection=None,
|
||||
username=None,
|
||||
password=None):
|
||||
'''
|
||||
Starts an existing guest, or defines and starts a new VM with specified arguments.
|
||||
|
||||
@ -368,8 +370,6 @@ def running(name,
|
||||
'comment': '{0} is running'.format(name)
|
||||
}
|
||||
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
|
||||
try:
|
||||
try:
|
||||
__salt__['virt.vm_state'](name)
|
||||
@ -380,7 +380,6 @@ def running(name,
|
||||
else:
|
||||
ret['comment'] = 'Domain {0} exists and is running'.format(name)
|
||||
except CommandExecutionError:
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
if image:
|
||||
salt.utils.versions.warn_until(
|
||||
'Sodium',
|
||||
@ -401,7 +400,9 @@ def running(name,
|
||||
install=install,
|
||||
pub_key=pub_key,
|
||||
priv_key=priv_key,
|
||||
**kwargs)
|
||||
connection=connection,
|
||||
username=username,
|
||||
password=password)
|
||||
ret['changes'][name] = 'Domain defined and started'
|
||||
ret['comment'] = 'Domain {0} defined and started'.format(name)
|
||||
except libvirt.libvirtError as err:
|
||||
@ -567,7 +568,15 @@ def reverted(name, snapshot=None, cleanup=False): # pylint: disable=redefined-o
|
||||
return ret
|
||||
|
||||
|
||||
def network_running(name, bridge, forward, connection=None, username=None, password=None, **kwargs):
|
||||
def network_running(name,
|
||||
bridge,
|
||||
forward,
|
||||
vport=None,
|
||||
tag=None,
|
||||
autostart=True,
|
||||
connection=None,
|
||||
username=None,
|
||||
password=None):
|
||||
'''
|
||||
Defines and starts a new network with specified arguments.
|
||||
|
||||
@ -603,11 +612,6 @@ def network_running(name, bridge, forward, connection=None, username=None, passw
|
||||
'comment': ''
|
||||
}
|
||||
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
vport = kwargs.pop('vport', None)
|
||||
tag = kwargs.pop('tag', None)
|
||||
autostart = kwargs.pop('autostart', True)
|
||||
|
||||
try:
|
||||
info = __salt__['virt.network_info'](name, connection=connection, username=username, password=password)
|
||||
if info:
|
||||
|
@ -255,7 +255,8 @@ class LibvirtTestCase(TestCase, LoaderModuleMockMixin):
|
||||
init_mock.assert_called_with('myvm', cpu=2, mem=2048, image='/path/to/img.qcow2',
|
||||
disk=None, disks=None, nic=None, interfaces=None,
|
||||
graphics=None, hypervisor=None,
|
||||
seed=True, install=True, pub_key=None, priv_key=None)
|
||||
seed=True, install=True, pub_key=None, priv_key=None,
|
||||
connection=None, username=None, password=None)
|
||||
|
||||
with patch.dict(virt.__salt__, { # pylint: disable=no-member
|
||||
'virt.vm_state': MagicMock(side_effect=CommandExecutionError('not found')),
|
||||
|
Loading…
Reference in New Issue
Block a user