Skip to content

Commit

Permalink
virt.pool_running: fix pool start
Browse files Browse the repository at this point in the history
Building a libvirt pool starts it. When defining a new pool, we need to
let build start it or we will get libvirt errors.
  • Loading branch information
cbosdo committed Apr 8, 2019
1 parent 30981d2 commit 25b9681
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
7 changes: 1 addition & 6 deletions salt/states/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def pool_running(name,
source_name=(source or {}).get('name', None),
source_format=(source or {}).get('format', None),
transient=transient,
start=True,
start=False,
connection=connection,
username=username,
password=password)
Expand All @@ -795,11 +795,6 @@ def pool_running(name,
connection=connection,
username=username,
password=password)

__salt__['virt.pool_start'](name,
connection=connection,
username=username,
password=password)
ret['changes'][name] = 'Pool defined and started'
ret['comment'] = 'Pool {0} defined and started'.format(name)
except libvirt.libvirtError as err:
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/states/test_virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ class LibvirtMock(MagicMock): # pylint: disable=too-many-ancestors
'''
libvirt library mockup
'''

class libvirtError(Exception): # pylint: disable=invalid-name
'''
libvirt error mockup
'''

def get_error_message(self):
'''
Fake function return error message
Expand Down Expand Up @@ -655,7 +653,7 @@ def test_pool_running(self):
source_name=None,
source_format=None,
transient=True,
start=True,
start=False,
connection='myconnection',
username='user',
password='secret')
Expand All @@ -668,6 +666,7 @@ def test_pool_running(self):
connection='myconnection',
username='user',
password='secret')
mocks['start'].assert_not_called()

with patch.dict(virt.__salt__, { # pylint: disable=no-member
'virt.pool_info': MagicMock(return_value={'state': 'running'}),
Expand Down

0 comments on commit 25b9681

Please sign in to comment.