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:
Cédric Bosdonnat 2018-07-03 15:15:02 +02:00
parent fc75872fb6
commit c7c5d6ee88
No known key found for this signature in database
GPG Key ID: 743CCED3EDD1578D
2 changed files with 17 additions and 12 deletions

View File

@ -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:

View File

@ -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')),