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

Add Xen function to get and set PV_ARGS #47091

Merged
merged 2 commits into from Apr 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 53 additions & 1 deletion salt/cloud/clouds/xen.py
Expand Up @@ -430,7 +430,7 @@ def avail_locations(session=None, call=None):

def avail_sizes(session=None, call=None):
'''
Return a list of Xen templat definitions
Return a list of Xen template definitions

.. code-block:: bash

Expand Down Expand Up @@ -1286,3 +1286,55 @@ def destroy_template(name=None, call=None, kwargs=None):
if not found:
ret[name] = {'status': 'not found'}
return ret


def get_pv_args(name, session=None, call=None):
'''
Get PV arguments for a VM

.. code-block:: bash

salt-cloud -a get_pv_args xenvm01

'''
if call == 'function':
raise SaltCloudException(
'This function must be called with -a or --action.'
)
if session is None:
log.debug('New session being created')
session = _get_session()
vm = _get_vm(name, session=session)
pv_args = session.xenapi.VM.get_PV_args(vm)
if len(pv_args) > 0:
return pv_args
return None


def set_pv_args(name, kwargs=None, session=None, call=None):
'''
Set PV arguments for a VM

.. code-block:: bash

salt-cloud -a set_pv_args xenvm01 pv_args="utf-8 graphical"

'''
if call == 'function':
raise SaltCloudException(
'This function must be called with -a or --action.'
)
if session is None:
log.debug('New session being created')
session = _get_session()
vm = _get_vm(name, session=session)
try:
log.debug('Setting PV Args: %s', kwargs['pv_args'])
session.xenapi.VM.set_PV_args(vm, str(kwargs['pv_args']))
except KeyError:
log.error('No pv_args parameter found.')
return False
except XenAPI.Failure:
log.info('Setting PV Args failed.')
return False
return True