Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust qvm.template_installed to use qvm-check #32

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _modules/ext_module_qvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,14 @@ def check(vmname, *varargs, **kwargs):
# Optional Flags
- flags:
- quiet
- template
"""
# Hide 'check' flag from argv as its not a valid qvm.check option
qvm = _QVMBase('qvm.check', **kwargs)
qvm.argparser.options['hide'] = ['check']

qvm.parser.add_argument('--quiet', action='store_true', help='Quiet')
qvm.parser.add_argument('--template', action='store_true', help='Check if it is template')
qvm.parser.add_argument(
'vmname',
action=_VMAction,
Expand Down
7 changes: 3 additions & 4 deletions _states/ext_state_qvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,10 @@ def template_installed(name, fromrepo=None, pool=None, **kwargs):
Install into given storage pool. Will not move already installed template.
"""
ret = {'name': name, 'result': False, 'changes': {}, 'comment': ''}
info = __salt__['qvm.template_info'](name)
if info:
status = __salt__['qvm.check'](name, flags=['template'])
if status.passed():
ret['result'] = True
ret['comment'] = 'Template {} version {} already installed'.format(
info['name'], info['version'])
ret['comment'] = 'Template {} already installed'.format(name)
return ret
if __opts__['test']:
ret['result'] = None
Expand Down