%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/cloud/clouds/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	j
Z
ddlmZm
Z
mZmZmZddlZddlZddlmZy&ddlZddlmZeZWnek
r�eZnXeje�ZdZ d�Z!d	�Z"d
�Z#dd�Z%dd�Z&dd
�Z'dd�Z(dd�Z)dd�Z*dd�Z+dd�Z,dd�Z-dd�Z.dd�Z/dd�Z0dd�Z1dd�Z2dd�Z3ddd�Z4ddd�Z5ddd�Z6ddd�Z7d�Z8ddd�Z9d �Z:ddd!�Z;ddd"�Z<ddd#�Z=d$�Z>ddd%�Z?ddd&�Z@dd'�ZAd(�ZBdd)�ZCddd*�ZDddd+�ZEddd,�ZFddd-�ZGddd.�ZHddd/�ZIddd0�ZJddd1�ZKddd2�ZLdd3�ZMddd4�ZNddd5�ZOddd6�ZPddd7�ZQddd8�ZRddd9�ZSddd:�ZTddd;�ZUddd<�ZVddd=�ZWddd>�ZXddd?�ZYddd@�ZZdddA�Z[dddB�Z\dddC�Z]dddD�Z^dddE�Z_dddF�Z`dddG�ZadddH�ZbddI�ZcdddJ�ZdddK�ZedddL�ZfdddM�ZgdddN�ZhdddO�ZidddP�ZjdddQ�ZkdddR�ZldddS�ZmdddT�ZndddU�ZodddV�ZpdddW�ZqdddX�ZrdY�ZsdZ�Ztd[�Zued\�Zvd]�ZwdS(^ub
OpenNebula Cloud Module
=======================

The OpenNebula cloud module is used to control access to an OpenNebula cloud.

.. versionadded:: 2014.7.0

:depends: lxml
:depends: OpenNebula installation running version ``4.14`` or later.

Use of this module requires the ``xml_rpc``, ``user``, and ``password``
parameters to be set.

Set up the cloud configuration at ``/etc/salt/cloud.providers`` or
``/etc/salt/cloud.providers.d/opennebula.conf``:

.. code-block:: yaml

    my-opennebula-config:
      xml_rpc: http://localhost:2633/RPC2
      user: oneadmin
      password: JHGhgsayu32jsa
      driver: opennebula

This driver supports accessing new VM instances via DNS entry instead
of IP address.  To enable this feature, in the provider or profile file
add `fqdn_base` with a value matching the base of your fully-qualified
domain name.  Example:

.. code-block:: yaml

    my-opennebula-config:
      [...]
      fqdn_base: <my.basedomain.com>
      [...]

The driver will prepend the hostname to the fqdn_base and do a DNS lookup
to find the IP of the new VM.

.. note:

    Whenever ``data`` is provided as a kwarg to a function and the
    attribute=value syntax is used, the entire ``data`` value must be
    wrapped in single or double quotes. If the value given in the
    attribute=value data string contains multiple words, double quotes
    *must* be used for the value while the entire data string should
    be encapsulated in single quotes. Failing to do so will result in
    an error. Example:

.. code-block:: bash

    salt-cloud -f image_allocate opennebula datastore_name=default \
        data='NAME="My New Image" DESCRIPTION="Description of the image." \
        PATH=/home/one_user/images/image_name.img'
    salt-cloud -f secgroup_allocate opennebula \
        data="Name = test RULE = [PROTOCOL = TCP, RULE_TYPE = inbound, \
        RANGE = 1000:2000]"

i(tabsolute_importtprint_functiontunicode_literalsN(tSaltCloudConfigErrortSaltCloudExecutionFailuretSaltCloudExecutionTimeouttSaltCloudNotFoundtSaltCloudSystemExit(tsix(tetreeu
opennebulacC@s*t�tkrtSt�tkr&tStS(u'
    Check for OpenNebula configs.
    (tget_configured_providertFalsetget_dependenciest__virtualname__(((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt__virtual__bs
cC@stjttptd�S(u/
    Return the first configured instance.
    uxml_rpcuuserupassword(uxml_rpcuuserupassword(tconfigtis_provider_configuredt__opts__t__active_provider_name__R
(((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR
os	cC@stjtitd6�S(u*
    Warn if dependencies aren't met.
    ulmxl(Rtcheck_driver_dependenciesR
tHAS_XML_LIBS(((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyRzscC@s�|dkrtd��nt�\}}}dj||g�}|jjj|ddd�d}i}x0t|�D]"}t|�||jd�j	<qwW|S(u�
    Return available OpenNebula images.

    CLI Example:

    .. code-block:: bash

        salt-cloud --list-images opennebula
        salt-cloud --function avail_images opennebula
        salt-cloud -f avail_images opennebula

    uactionu`The avail_images function must be called with -f or --function, or with the --list-images optionu:i����i����iuNAME(
Rt_get_xml_rpctjointonet	imagepooltinfot_get_xmlt_xml_to_dicttfindttext(tcalltservertusertpasswordtautht
image_pooltimagestimage((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytavail_images�s
" cC@s�|dkrtd��nt�\}}}dj||g�}|jjj|�d}i}x0t|�D]"}t|�||jd�j	<qnW|S(u�
    Return available OpenNebula locations.

    CLI Example:

    .. code-block:: bash

        salt-cloud --list-locations opennebula
        salt-cloud --function avail_locations opennebula
        salt-cloud -f avail_locations opennebula

    uactionugThe avail_locations function must be called with -f or --function, or with the --list-locations option.u:iuNAME(
RRRRthostpoolRRRRR(RRR R!R"t	host_poolt	locationsthost((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytavail_locations�s
 cC@s,|dkrtd��ntjd�iS(ul
    Because sizes are built into templates with OpenNebula, there will be no sizes to
    return here.
    uactionu_The avail_sizes function must be called with -f or --function, or with the --list-sizes option.uUBecause sizes are built into templates with OpenNebula, there are no sizes to return.(Rtlogtwarning(R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytavail_sizes�scC@s�|dkrtd��nt�\}}}dj||g�}|jjj|�d}i}x0t|�D]"}t|�||jd�j	<qnW|S(u�
    Returns a list of clusters in OpenNebula.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_clusters opennebula
    uactionu@The list_clusters function must be called with -f or --function.u:iuNAME(
RRRRtclusterpoolRRRRR(RRR R!R"tcluster_pooltclusterstcluster((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
list_clusters�s cC@s�|dkrtd��nt�\}}}dj||g�}|jjj|�d}i}x0t|�D]"}t|�||jd�j	<qnW|S(u�
    Returns a list of data stores on OpenNebula.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_datastores opennebula
    uactionuBThe list_datastores function must be called with -f or --function.u:iuNAME(
RRRRt
datastorepoolRRRRR(RRR R!R"tdatastore_poolt
datastorest	datastore((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_datastores�s cC@s"|dkrtd��nt�S(u�
    Returns a list of hosts on OpenNebula.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_hosts opennebula
    uactionu=The list_hosts function must be called with -f or --function.(RR+(R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
list_hostsscC@s(|dkrtd��ntdt�S(u�
    Return a list of VMs on OpenNebula.

    CLI Example:

    .. code-block:: bash

        salt-cloud -Q
        salt-cloud --query
        salt-cloud --function list_nodes opennebula
        salt-cloud -f list_nodes opennebula

    uactionu=The list_nodes function must be called with -f or --function.tfull(Rt_list_nodesR(R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
list_nodes scC@s(|dkrtd��ntdt�S(u�
    Return a list of the VMs on OpenNebula.

    CLI Example:

    .. code-block:: bash

        salt-cloud -F
        salt-cloud --full-query
        salt-cloud --function list_nodes_full opennebula
        salt-cloud -f list_nodes_full opennebula

    uactionuBThe list_nodes_full function must be called with -f or --function.R:(RR;tTrue(R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_nodes_full6scC@s9|dkrtd��ntdtd�td|�S(uP
    Return a list of the VMs that are on the provider, with select fields.
    uactionuBThe list_nodes_full function must be called with -f or --function.ucloud.list_nodes_selectufunctionuquery.selection(Rt	__utils__R>R(R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_nodes_selectLs
cC@s�|dkrtd��nt�\}}}dj||g�}|jjj|ddd�d}i}x0t|�D]"}t|�||jd�j	<qwW|S(u�
    Lists all security groups available to the user and the user's groups.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_security_groups opennebula
    uactionuGThe list_security_groups function must be called with -f or --function.u:i����i����iuNAME(
RRRRtsecgrouppoolRRRRR(RRR R!R"t
secgroup_pooltgroupstgroup((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_security_groupsZs" cC@s�|dkrtd��nt�\}}}dj||g�}|jjj|ddd�d}i}x0t|�D]"}t|�||jd�j	<qwW|S(u�
    Lists all templates available to the user and the user's groups.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_templates opennebula
    uactionuAThe list_templates function must be called with -f or --function.u:i����i����iuNAME(
RRRRttemplatepoolRRRRR(RRR R!R"t
template_poolt	templatesttemplate((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_templatesvs" cC@s�|dkrtd��nt�\}}}dj||g�}|jjj|ddd�d}i}x0t|�D]"}t|�||jd�j	<qwW|S(u�
    Lists all virtual networks available to the user and the user's groups.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_vns opennebula
    uactionu;The list_vns function must be called with -f or --function.u:i����i����iuNAME(
RRRRtvnpoolRRRRR(RRR R!R"tvn_pooltvnst	v_network((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytlist_vns�s" cC@sH|dkrtd��ntjd|�t|didd6d|�S(u�
    Reboot a VM.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to reboot.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a reboot my-vm
    uactionu4The start action must be called with -a or --action.uRebooting node %stkwargsurebootR(RR,Rt	vm_action(tnameR((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytreboot�s
cC@sH|dkrtd��ntjd|�t|didd6d|�S(u�
    Start a VM.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to start.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a start my-vm
    uactionu4The start action must be called with -a or --action.uStarting node %sRPuresumeR(RR,RRQ(RRR((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytstart�s
cC@sH|dkrtd��ntjd|�t|didd6d|�S(u�
    Stop a VM.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to stop.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a stop my-vm
    uactionu4The start action must be called with -a or --action.uStopping node %sRPustopR(RR,RRQ(RRR((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytstop�s
cC@sn|dkrtd��n|dkr0i}nt�\}}}dj||g�}|jjj|�dS(u�
    Returns the OpenNebula version.

    .. versionadded:: 2016.3.5

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_one_version one_provider_name
    uactionuAThe get_cluster_id function must be called with -f or --function.u:iN(RtNoneRRRtsystemtversion(RPRRR R!R"((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_one_version�s
	cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a cluster's ID from the given cluster name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_cluster_id opennebula name=my-cluster-name
    uactionuAThe get_cluster_id function must be called with -f or --function.unameu,The get_cluster_id function requires a name.uidu$The cluster '{0}' could not be foundN(RRVtgetR3tKeyErrortformat(RPRRRtret((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_cluster_ids	
cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a data store's ID from the given data store name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_datastore_id opennebula name=my-datastore-name
    uactionuCThe get_datastore_id function must be called with -f or --function.unameu.The get_datastore_id function requires a name.uidu'The datastore '{0}' could not be found.N(RRVRZR8R[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_datastore_id8s	
cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a host's ID from the given host name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_host_id opennebula name=my-host-name
    uactionu>The get_host_id function must be called with -f or --function.unameu)The get_host_id function requires a name.uidu!The host '{0}' could not be foundN(RRVRZR+R[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_host_id\s	
cC@s�t�}tjtjd|tdt��}x<|D]4}|||d||dfkr4||dSq4Wtdj|���dS(uk
    Return the image object to use.

    vm\_
        The VM dictionary for which to obtain an image.
    uimaget
search_globalunameuidu/The specified image, '{0}', could not be found.N(	R&Rt	text_typeRtget_cloud_config_valueRRRR\(tvm_R$tvm_imageR%((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	get_image�s	
"cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns an image's ID from the given image name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_image_id opennebula name=my-image-name
    uactionu?The get_image_id function must be called with -f or --function.unameu*The get_image_id function requires a name.uidu"The image '{0}' could not be foundN(RRVRZR&R[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_image_id�s	
cC@s�t�}tjtjd|tdt��}|dkr=dSx<|D]4}|||d||dfkrD||dSqDWtdj	|���dS(ug
    Return the VM's location.

    vm\_
        The VM dictionary for which to obtain a location.
    ulocationRauNoneunameuidu2The specified location, '{0}', could not be found.N(
R+RRbRRcRRRVRR\(RdR)tvm_locationtlocation((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_location�s	
cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a security group's ID from the given security group name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_secgroup_id opennebula name=my-secgroup-name
    uactionuBThe get_secgroup_id function must be called with -f or --function.unameu/The get_secgroup_id function requires a 'name'.uidu,The security group '{0}' could not be found.N(RRVRZRER[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_secgroup_id�s	
cC@s�|dkrtd��n|d	kr0i}n|jdd	�}|d	kr]td��nyt�|ddd}Wn&tk
r�tdj|���nX|S(
u�
    Returns a template's image from the given template name.

    .. versionadded:: 2018.3.0

    .. code-block:: bash

        salt-cloud -f get_template_image opennebula name=my-template-name
    uactionuEThe get_template_image function must be called with -f or --function.unameu2The get_template_image function requires a 'name'.utemplateudiskuimageu0The image for template '{0}' could not be found.N(RRVRZRJR[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_template_image�s
	
cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a template's ID from the given template name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_template_id opennebula name=my-template-name
    uactionuBThe get_template_id function must be called with -f or --function.unameu/The get_template_id function requires a 'name'.uidu&The template '{0}' could not be found.N(RRVRZRJR[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_template_ids	
cC@sdtjtjd|tdt��}yt�|dSWn&tk
r_tdj	|���nXdS(u�
    Return the template id for a VM.

    .. versionadded:: 2016.11.0

    vm\_
        The VM dictionary for which to obtain a template.
    utemplateRauidu2The specified template, '{0}', could not be found.N(
RRbRRcRRRJR[RR\(Rdtvm_template((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytget_template;s

cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a virtual machine's ID from the given virtual machine's name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_vm_id opennebula name=my-vm
    uactionu<The get_vm_id function must be called with -f or --function.unameu'The get_vm_id function requires a name.uidu The VM '{0}' could not be found.N(RRVRZR<R[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	get_vm_idPs	
cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nyt�|d}Wn&tk
r�tdj|���nX|S(u�
    Returns a virtual network's ID from the given virtual network's name.

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -f get_vn_id opennebula name=my-vn-name
    uactionu<The get_vn_id function must be called with -f or --function.unameu'The get_vn_id function requires a name.uidu The VN '{0}' could not be found.N(RRVRZROR[R\(RPRRRR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	get_vn_idts	
c@s��fd�}|dd��d}�d}|dkr�d�krX�d}ntdi|d6�}tdi|d6�}dj|||�}|S|d	kr|d
��d
}	dj|	|�}|	dkr|d
��d
}
dj|	||
�}n|SdS(uf
    Returns the template format to create a disk in open nebula

    .. versionadded:: 2018.3.0

    c@s<x5|D]-}|�krtdj�|���qqWdS(Nu7The disk {0} requires a {1}                    argument(RR\(targstarg(tdiskt	disk_info(s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt_require_disk_opts�s
u	disk_typeusizeucloneuimageRPunameuJDISK=[IMAGE={0}, IMAGE_ID={1}, CLONE=YES,                        SIZE={2}]uvolatileutypeuDISK=[TYPE={0}, SIZE={1}]ufsuformatu%DISK=[TYPE={0}, SIZE={1}, FORMAT={2}]N(RlRgR\(RtRuRIRvtsizet	disk_typetclone_imagetclone_image_idttemptv_typeR\((RtRus@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt_get_device_template�s.



	
	



	cC@s�y7|dr6tjttpd|d�tkr6tSWntk
rJnXtddddj|d�dtd	d
|ddddg�d
tddtd�tj	d|d�i|dd6t
|�d6t|�d6}d|krti|dd6�|d<ntj
d|tdtdd>�}|r8dnd|d<tddddj|d�ditd	d|t|��d6d
td�g}|jd�r�|jdj|jd���n|jd �r�|jd!j|jd ���n|jd"�r)|jd#j|jd"���n|jd$�rZ|jd%j|jd$���n|jd&�r�|jd&�}|d'}x.|D]&}|jt|||d(|��q�Wd)tj|�kr�td*��q�nd+j|�}y�t�\}}	}
d,j|	|
g�}|jjj|t|d�|dt|�}|d-sttjd.|d|d/d0tj�tSWn4tk
r�}
tjd1|d|
d0tj�tSX|jd2�}|d>k	r�d3j|d|�}nd4�}yWtd5|d6|dfd7tj
d8|tddU�d;tj
d<|tdd=��}Wn\t t!fk
r�}
z*yt"|d�Wntk
r�nXWd>ttj|
���XnXtj
d?|tdtdd>�}|d>k	r�t#j$j%|�r�t&d@j|���n|r||dA<dB}nly|dCd-}WnWt'k
r{y|ddDdE}Wn#t'k
rm|ddDdF}nX||dA<nXtj
dG|tddH�}||dI<||dJ<tdK|t�}|dL|dL<|d'|d'<|d|d<|dd |dM<|dN|dN<||dC<g|dO<tj	dP|d�tj(dQ|dt)j*|��tdddRdSj|d�dtd	dT|ddddg�d
td�|S(Vu#
    Create a single VM from a data dict.

    vm\_
        The dictionary use to create a VM.

    Optional vm\_ dict options for overwriting template:

    region_id
        Optional - OpenNebula Zone ID

    memory
        Optional - In MB

    cpu
        Optional - Percent of host CPU to allocate

    vcpu
        Optional - Amount of vCPUs to allocate

     CLI Example:

     .. code-block:: bash

         salt-cloud -p my-opennebula-profile vm_name

        salt-cloud -p my-opennebula-profile vm_name memory=16384 cpu=2.5 vcpu=16

    uprofileu
opennebulaucloud.fire_eventueventustarting createusalt/cloud/{0}/creatingunameRrucloud.filter_eventucreatinguproviderudrivertsock_dirusock_dirt	transportu	transportuCreating Cloud VM %sutemplate_idu	region_idutemplateuimage_iduprivate_networkingRatdefaultutrueufalseurequesting instanceusalt/cloud/{0}/requestingu
requestingukwargsuSCHED_REQUIREMENTS="ID={0}"umemoryu
MEMORY={0}ucpuuCPU={0}uvcpuuVCPU={0}udiskuimageRIuCLONEu^Missing an image disk to clone. Must define a clone disk alongside all other disk definitions.u
u:iumError creating %s on OpenNebula

The following error was returned when trying to instantiate the template: %sitexc_info_on_logleveluqError creating %s on OpenNebula

The following exception was thrown when trying to run the initial deployment: %su	fqdn_baseu{0}.{1}cS@sHt|dd�}|stS|ddkr0tS|ddkrD|SdS(NRuactionustateu7u	lcm_stateu3(t
show_instanceR(tvm_namet	node_data((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt__query_node_dataFsucloud.wait_for_iptupdate_argsttimeoutuwait_for_ip_timeouti
i<tintervaluwait_for_ip_intervaliNuprivate_keyu-The defined key_filename '{0}' does not existussh_hostu0.0.0.0uprivate_ipsunicuipu
ip6_globalussh_usernameurootuusernameukey_filenameucloud.bootstrapuidusizeustateu
public_ipsuCreated Cloud VM '%s'u'%s' VM creation details:
%sucreated instanceusalt/cloud/{0}/createducreatediX(+Rtis_profile_configuredRRRtAttributeErrorR?R\R,RRoRjRmRcRVtlistRZtappendR}RRbRRRRRItinstantiatetintterrortloggingtDEBUGt	ExceptionRRtdestroytostpathtisfileRR[tdebugtpprinttpformat(RdRPtprivate_networkingRIt	get_diskst
template_nameRtt
template_argsRR R!R"tcrettexctfqdnR�tdatatkey_filenamet
private_iptssh_usernameR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytcreate�s	
"

 """"


	



	



	





"c	C@sO|dkrtd��ntddddj|�di|d6d	td
�t�\}}}dj||g�}t|dd
�}|jjj	|dt
|d��}tddddj|�di|d6d	td
�tjdt�t
krtd|tjd�dt�nidd
6|dd6|dd6|dd6}|S(uI
    Destroy a node. Will check termination protection and warn if enabled.

    name
        The name of the vm to be destroyed.

    CLI Example:

    .. code-block:: bash

        salt-cloud --destroy vm_name
        salt-cloud -d vm_name
        salt-cloud --action destroy vm_name
        salt-cloud -a destroy vm_name

    ufunctionuEThe destroy action must be called with -d, --destroy, -a or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingRrunameR~usock_diru:Ruactionudeleteuidudestroyed instanceusalt/cloud/{0}/destroyeduupdate_cachedirucloud.delete_minion_cachediriu	vm.deleteudeletediunode_idiu
error_code(RR?R\RRRR�RtvmtactionR�RZRR=Rtsplit(RRRRR R!R"R�tnode((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR��s<
%

c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��|r�|r&tjd�q&nE|rtjjj	|dd
��}|j
�}WdQXntd��t�\}}}	dj||	g�}
|j
jj|
|t|��}idd6|dd6|dd6|dd6}|S(u)
    Allocates a new image in OpenNebula.

    .. versionadded:: 2016.3.0

    path
        The path to a file containing the template of the image to allocate.
        Syntax within the file can be the usual attribute=value or XML. Can be
        used instead of ``data``.

    data
        The data containing the template of the image to allocate. Syntax can be the
        usual attribute=value or XML. Can be used instead of ``path``.

    datastore_id
        The ID of the data-store to be used for the new image. Can be used instead
        of ``datastore_name``.

    datastore_name
        The name of the data-store to be used for the new image. Can be used instead of
        ``datastore_id``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_allocate opennebula path=/path/to/image_file.txt datastore_id=1
        salt-cloud -f image_allocate opennebula datastore_name=default \
            data='NAME="Ubuntu 14.04" PATH="/home/one_user/images/ubuntu_desktop.img" \
            DESCRIPTION="Ubuntu 14.04 for development."'
    ufunctionuAThe image_allocate function must be called with -f or --function.upathudataudatastore_idudatastore_nameu`Both a 'datastore_id' and a 'datastore_name' were provided. 'datastore_id' will take precedence.RPunameubThe image_allocate function requires either a 'datastore_id' or a 'datastore_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.tmodeurNuSThe image_allocate function requires either a file 'path' or 'data' to be provided.u:uimage.allocateuactioniu	allocatediuimage_idiu
error_code(RRVRZR,R-R_tsalttutilstfilestfopentreadRRRR%tallocateR�(
RRPR�R�tdatastore_idtdatastore_nametrfhRR R!R"tresponseR]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_allocate�sF 	
	
	!cC@sL|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d6�}ntd	��t�\}}}d
j||g�}|jj	j
|t|�|�}	idd6|	d
d6|	dd6|d6|	dd6}
|
S(u
    Clones an existing image.

    .. versionadded:: 2016.3.0

    name
        The name of the new image.

    image_id
        The ID of the image to be cloned. Can be used instead of ``image_name``.

    image_name
        The name of the image to be cloned. Can be used instead of ``image_id``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_clone opennebula name=my-new-image image_id=10
        salt-cloud -f image_clone opennebula name=my-new-image image_name=my-image-to-clone
    ufunctionu>The image_clone function must be called with -f or --function.unameuimage_idu
image_nameu:The image_clone function requires a 'name' to be provided.u^Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.RPuYThe image_clone function requires either an 'image_id' or an 'image_name' to be provided.u:uimage.cloneuactioniuclonediucloned_image_iducloned_image_nameiu
error_codeN(RRVRZR,R-RgRRRR%tcloneR�(RRPRRtimage_idt
image_nameRR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_clone4s:	
	!c
C@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}|jj	j
|t|��}id	d
6|dd6|d
d6|dd6}	|	S(u�
    Deletes the given image from OpenNebula. Either a name or an image_id must
    be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the image to delete. Can be used instead of ``image_id``.

    image_id
        The ID of the image to delete. Can be used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_delete opennebula name=my-image
        salt-cloud --function image_delete opennebula image_id=100
    ufunctionu?The image_delete function must be called with -f or --function.unameuimage_iduXBoth the 'image_id' and 'name' arguments were provided. 'image_id' will take precedence.RPuSThe image_delete function requires either an 'image_id' or a 'name' to be provided.u:uimage.deleteuactioniudeletediiu
error_codeN(RRVRZR,R-RgRRRR%tdeleteR�(
RRPRRR�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_deletexs0	
	cC@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}i}|jj	j
|t|��d	}	t|	�}
t
|
�||
jd
�j<|S(u
    Retrieves information for a given image. Either a name or an image_id must be
    supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the image for which to gather information. Can be used instead
        of ``image_id``.

    image_id
        The ID of the image for which to gather information. Can be used instead of
        ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_info opennebula name=my-image
        salt-cloud --function image_info opennebula image_id=5
    ufunctionu=The image_info function must be called with -f or --function.unameuimage_iduXBoth the 'image_id' and 'name' arguments were provided. 'image_id' will take precedence.RPuPThe image_info function requires either a 'name or an 'image_id' to be provided.u:iuNAMEN(RRVRZR,R-RgRRRR%RR�RRRR(RRPRRR�RR R!R"RR�ttree((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
image_info�s,	
	"cC@sT|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d6�}ntd	��t�\}}}d
j||g�}|jj	j
|t|�tj
jj|��}	idd6|	d
d6|	dd6|	dd6}
|
S(uX
    Sets the Image as persistent or not persistent.

    .. versionadded:: 2016.3.0

    name
        The name of the image to set. Can be used instead of ``image_id``.

    image_id
        The ID of the image to set. Can be used instead of ``name``.

    persist
        A boolean value to set the image as persistent or not. Set to true
        for persistent, false for non-persistent.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_persistent opennebula name=my-image persist=True
        salt-cloud --function image_persistent opennebula image_id=5 persist=False
    ufunctionuCThe image_persistent function must be called with -f or --function.unameupersistuimage_iduPThe image_persistent function requires 'persist' to be set to 'True' or 'False'.uXBoth the 'image_id' and 'name' arguments were provided. 'image_id' will take precedence.RPuWThe image_persistent function requires either a 'name' or an 'image_id' to be provided.u:uimage.persistentuactioniuresponseiiu
error_codeN(RRVRZR,R-RgRRRR%t
persistentR�R�R�R�tis_true(RRPRRtpersistR�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_persistent�s8	
	0cC@sK|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��t�\}}}dj||g�}|jj	j
|t|�t|��}	idd
6|	dd6|	dd6|	dd6}
|
S(u=
    Deletes a snapshot from the image.

    .. versionadded:: 2016.3.0

    image_id
        The ID of the image from which to delete the snapshot. Can be used instead of
        ``image_name``.

    image_name
        The name of the image from which to delete the snapshot. Can be used instead
        of ``image_id``.

    snapshot_id
        The ID of the snapshot to delete.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_snapshot_delete vm_id=106 snapshot_id=45
        salt-cloud -f image_snapshot_delete vm_name=my-vm snapshot_id=111
    ufunctionuHThe image_snapshot_delete function must be called with -f or --function.uimage_idu
image_nameusnapshot_iduKThe image_snapshot_delete function requires a 'snapshot_id' to be provided.u^Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.RPunameubThe image_snapshot_delete function requires either an 'image_id' or a 'image_name' to be provided.u:uimage.snapshotdeleteuactioniudeletediiu
error_codeN(RRVRZR,R-RgRRRR%tsnapshotdeleteR�(RRPR�R�tsnapshot_idRR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_snapshot_delete2s8	
	'cC@sK|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��t�\}}}dj||g�}|jj	j
|t|�t|��}	idd
6|	dd6|	dd6|	dd6}
|
S(u#
    Reverts an image state to a previous snapshot.

    .. versionadded:: 2016.3.0

    image_id
        The ID of the image to revert. Can be used instead of ``image_name``.

    image_name
        The name of the image to revert. Can be used instead of ``image_id``.

    snapshot_id
        The ID of the snapshot to which the image will be reverted.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_snapshot_revert vm_id=106 snapshot_id=45
        salt-cloud -f image_snapshot_revert vm_name=my-vm snapshot_id=120
    ufunctionuHThe image_snapshot_revert function must be called with -f or --function.uimage_idu
image_nameusnapshot_iduKThe image_snapshot_revert function requires a 'snapshot_id' to be provided.u^Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.RPunameucThe image_snapshot_revert function requires either an 'image_id' or an 'image_name' to be provided.u:uimage.snapshotrevertuactioniurevertediiu
error_codeN(RRVRZR,R-RgRRRR%tsnapshotrevertR�(RRPR�R�R�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_snapshot_revertws8	
	'cC@sK|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��t�\}}}dj||g�}|jj	j
|t|�t|��}	idd
6|	dd6|	dd6|	dd6}
|
S(u�
    Flattens the snapshot of an image and discards others.

    .. versionadded:: 2016.3.0

    image_id
        The ID of the image. Can be used instead of ``image_name``.

    image_name
        The name of the image. Can be used instead of ``image_id``.

    snapshot_id
        The ID of the snapshot to flatten.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_snapshot_flatten vm_id=106 snapshot_id=45
        salt-cloud -f image_snapshot_flatten vm_name=my-vm snapshot_id=45
    ufunctionuIThe image_snapshot_flatten function must be called with -f or --function.uimage_idu
image_nameusnapshot_iduMThe image_stanpshot_flatten function requires a 'snapshot_id' to be provided.u^Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.RPunameudThe image_snapshot_flatten function requires either an 'image_id' or an 'image_name' to be provided.u:uimage.snapshotflattenuactioniu	flattenediiu
error_codeN(RRVRZR,R-RgRRRR%tsnapshotflattenR�(RRPR�R�R�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_snapshot_flatten�s8	
	'cC@s4|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}dd	g}|dkr�td
��n||dkr�d}n9||dkr�d}n td
j|d|d���|r"|rMtjd�qMn+|rAtdi|d6�}ntd��|rl|r�tjd�q�nE|r�tjj	j
|dd��}	|	j�}WdQXntd��t�\}
}}dj
||g�}
|
jjj|
t|�|t|��}idd6|dd6|dd6|dd6}|S(us
    Replaces the image template contents.

    .. versionadded:: 2016.3.0

    image_id
        The ID of the image to update. Can be used instead of ``image_name``.

    image_name
        The name of the image to update. Can be used instead of ``image_id``.

    path
        The path to a file containing the template of the image. Syntax within the
        file can be the usual attribute=value or XML. Can be used instead of ``data``.

    data
        Contains the template of the image. Syntax can be the usual attribute=value
        or XML. Can be used instead of ``path``.

    update_type
        There are two ways to update an image: ``replace`` the whole template
        or ``merge`` the new template with the existing one.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f image_update opennebula image_id=0 file=/path/to/image_update_file.txt update_type=replace
        salt-cloud -f image_update opennebula image_name="Ubuntu 14.04" update_type=merge \
            data='NAME="Ubuntu Dev" PATH="/home/one_user/images/ubuntu_desktop.img" \
            DESCRIPTION = "Ubuntu 14.04 for development."'
    ufunctionuAThe image_allocate function must be called with -f or --function.uimage_idu
image_nameupathudatauupdate_typeureplaceumergeuCThe image_update function requires an 'update_type' to be provided.iiu3The update_type argument must be either {0} or {1}.u^Both the 'image_id' and 'image_name' arguments were provided. 'image_id' will take precedence.RPunameuZThe image_update function requires either an 'image_id' or an 'image_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuQThe image_update function requires either 'data' or a file 'path' to be provided.u:uimage.updateuactionuupdatediu
error_code(RRVRZR\R,R-RgR�R�R�R�R�RRRR%tupdateR�(RRPR�R�R�R�tupdate_typeR�t
update_numberR�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytimage_update�s`!			
	
	*cC@s?|dkrtd��nt|�}td|tt�|S(u_
    Show the details from OpenNebula concerning a named VM.

    name
        The name of the VM for which to display details.

    call
        Type of call to use with this function such as ``function``.

    CLI Example:

    .. code-block:: bash

        salt-cloud --action show_instance vm_name
        salt-cloud -a show_instance vm_name

    uactionu<The show_instance action must be called with -a or --action.ucloud.cache_node(Rt	_get_nodeR?RR(RRRR�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR�jscC@s)|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�nE|r�tjjj|dd��}|j	�}WdQXntd	��t
�\}}}d
j||g�}|jj
j||�}	idd6|	d
d6|	dd6|	dd6}
|
S(u�
    Allocates a new security group in OpenNebula.

    .. versionadded:: 2016.3.0

    path
        The path to a file containing the template of the security group. Syntax
        within the file can be the usual attribute=value or XML. Can be used
        instead of ``data``.

    data
        The template data of the security group. Syntax can be the usual
        attribute=value or XML. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f secgroup_allocate opennebula path=/path/to/secgroup_file.txt
        salt-cloud -f secgroup_allocate opennebula \
            data="NAME = test RULE = [PROTOCOL = TCP, RULE_TYPE = inbound, \
            RANGE = 1000:2000]"
    ufunctionuDThe secgroup_allocate function must be called with -f or --function.upathudatauPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuVThe secgroup_allocate function requires either 'data' or a file 'path' to be provided.u:usecgroup.allocateuactioniu	allocatediusecgroup_idiu
error_code(RRVRZR,R-R�R�R�R�R�RRRtsecgroupR�(RRPR�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytsecgroup_allocate�s2	
	cC@sL|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d6�}ntd	��t�\}}}d
j||g�}|jj	j
|t|�|�}	idd6|	d
d6|	dd6|d6|	dd6}
|
S(uO
    Clones an existing security group.

    .. versionadded:: 2016.3.0

    name
        The name of the new template.

    secgroup_id
        The ID of the security group to be cloned. Can be used instead of
        ``secgroup_name``.

    secgroup_name
        The name of the security group to be cloned. Can be used instead of
        ``secgroup_id``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f secgroup_clone opennebula name=my-cloned-secgroup secgroup_id=0
        salt-cloud -f secgroup_clone opennebula name=my-cloned-secgroup secgroup_name=my-secgroup
    ufunctionuAThe secgroup_clone function must be called with -f or --function.unameusecgroup_idu
secgroup_nameu=The secgroup_clone function requires a 'name' to be provided.ugBoth the 'secgroup_id' and 'secgroup_name' arguments were provided. 'secgroup_id' will take precedence.RPu`The secgroup_clone function requires either a 'secgroup_id' or a 'secgroup_name' to be provided.u:usecgroup.cloneuactioniuclonediucloned_secgroup_iducloned_secgroup_nameiu
error_codeN(RRVRZR,R-RkRRRR�R�R�(RRPRRtsecgroup_idt
secgroup_nameRR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytsecgroup_clone�s:	
	!c
C@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}|jj	j
|t|��}id	d
6|dd6|d
d6|dd6}	|	S(u
    Deletes the given security group from OpenNebula. Either a name or a secgroup_id
    must be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the security group to delete. Can be used instead of
        ``secgroup_id``.

    secgroup_id
        The ID of the security group to delete. Can be used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f secgroup_delete opennebula name=my-secgroup
        salt-cloud --function secgroup_delete opennebula secgroup_id=100
    ufunctionuBThe secgroup_delete function must be called with -f or --function.unameusecgroup_idu^Both the 'secgroup_id' and 'name' arguments were provided. 'secgroup_id' will take precedence.RPuXThe secgroup_delete function requires either a 'name' or a 'secgroup_id' to be provided.u:usecgroup.deleteuactioniudeletediiu
error_codeN(RRVRZR,R-RkRRRR�R�R�(
RRPRRR�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytsecgroup_delete
s0	
	cC@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}i}|jj	j
|t|��d	}	t|	�}
t
|
�||
jd
�j<|S(uF
    Retrieves information for the given security group. Either a name or a
    secgroup_id must be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the security group for which to gather information. Can be
        used instead of ``secgroup_id``.

    secgroup_id
        The ID of the security group for which to gather information. Can be
        used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f secgroup_info opennebula name=my-secgroup
        salt-cloud --function secgroup_info opennebula secgroup_id=5
    ufunctionu@The secgroup_info function must be called with -f or --function.unameusecgroup_idu^Both the 'secgroup_id' and 'name' arguments were provided. 'secgroup_id' will take precedence.RPuRThe secgroup_info function requires either a name or a secgroup_id to be provided.u:iuNAMEN(RRVRZR,R-RkRRRR�RR�RRRR(RRPRRR�RR R!R"RR�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
secgroup_infoIs,	
	"cC@s4|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}dd	g}|dkr�td
��n||dkr�d}n9||dkr�d}n td
j|d|d���|r"|rMtjd�qMn+|rAtdi|d6�}ntd��|rl|r�tjd�q�nE|r�tjj	j
|dd��}	|	j�}WdQXntd��t�\}
}}dj
||g�}
|
jjj|
t|�|t|��}idd6|dd6|dd6|dd6}|S(u�
    Replaces the security group template contents.

    .. versionadded:: 2016.3.0

    secgroup_id
        The ID of the security group to update. Can be used instead of
        ``secgroup_name``.

    secgroup_name
        The name of the security group to update. Can be used instead of
        ``secgroup_id``.

    path
        The path to a file containing the template of the security group. Syntax
        within the file can be the usual attribute=value or XML. Can be used instead
        of ``data``.

    data
        The template data of the security group. Syntax can be the usual attribute=value
        or XML. Can be used instead of ``path``.

    update_type
        There are two ways to update a security group: ``replace`` the whole template
        or ``merge`` the new template with the existing one.

    CLI Example:

    .. code-block:: bash

        salt-cloud --function secgroup_update opennebula secgroup_id=100 \
            path=/path/to/secgroup_update_file.txt \
            update_type=replace
        salt-cloud -f secgroup_update opennebula secgroup_name=my-secgroup update_type=merge \
            data="Name = test RULE = [PROTOCOL = TCP, RULE_TYPE = inbound, RANGE = 1000:2000]"
    ufunctionuDThe secgroup_allocate function must be called with -f or --function.usecgroup_idu
secgroup_nameupathudatauupdate_typeureplaceumergeuFThe secgroup_update function requires an 'update_type' to be provided.iiu3The update_type argument must be either {0} or {1}.ugBoth the 'secgroup_id' and 'secgroup_name' arguments were provided. 'secgroup_id' will take precedence.RPunameuaThe secgroup_update function requires either a 'secgroup_id' or a 'secgroup_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuTThe secgroup_update function requires either 'data' or a file 'path' to be provided.u:usecgroup.updateuactionuupdatediu
error_code(RRVRZR\R,R-RkR�R�R�R�R�RRRR�R�R�(RRPR�R�R�R�R�R�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytsecgroup_update�s`%			
	
	*cC@s)|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�nE|r�tjjj|dd��}|j	�}WdQXntd	��t
�\}}}d
j||g�}|jj
j||�}	idd6|	d
d6|	dd6|	dd6}
|
S(u�
    Allocates a new template in OpenNebula.

    .. versionadded:: 2016.3.0

    path
        The path to a file containing the elements of the template to be allocated.
        Syntax within the file can be the usual attribute=value or XML. Can be used
        instead of ``data``.

    data
        Contains the elements of the template to be allocated. Syntax can be the usual
        attribute=value or XML. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f template_allocate opennebula path=/path/to/template_file.txt
        salt-cloud -f template_allocate opennebula \
            data='CPU="1.0" DISK=[IMAGE="Ubuntu-14.04"] GRAPHICS=[LISTEN="0.0.0.0",TYPE="vnc"] \
            MEMORY="1024" NETWORK="yes" NIC=[NETWORK="192net",NETWORK_UNAME="oneadmin"] \
            OS=[ARCH="x86_64"] SUNSTONE_CAPACITY_SELECT="YES" SUNSTONE_NETWORK_SELECT="YES" \
            VCPU="1"'
    ufunctionuDThe template_allocate function must be called with -f or --function.upathudatauPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuVThe template_allocate function requires either 'data' or a file 'path' to be provided.u:utemplate.allocateuactioniu	allocatediutemplate_idiu
error_code(RRVRZR,R-R�R�R�R�R�RRRRIR�(RRPR�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyttemplate_allocate�s2	
	cC@sa|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdt�}|dkr�td��n|r�|r�tjd�q�n+|r�td	i|d6�}ntd
��t�\}}}dj||g�}	|j	j
j|	t|�||�}
idd
6|
dd6|
dd6|d6|
dd6}|S(u�
    Clones an existing virtual machine template.

    .. versionadded:: 2016.3.0

    name
        The name of the new template.

    template_id
        The ID of the template to be cloned. Can be used instead of ``template_name``.

    template_name
        The name of the template to be cloned. Can be used instead of ``template_id``.

    clone_images
        Optional, defaults to False. Indicates if the images attached to the template should be cloned as well.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f template_clone opennebula name=my-new-template template_id=0
        salt-cloud -f template_clone opennebula name=my-new-template template_name=my-template
    ufunctionuAThe template_clone function must be called with -f or --function.unameutemplate_idu
template_nameuclone_imagesu;The template_clone function requires a name to be provided.ugBoth the 'template_id' and 'template_name' arguments were provided. 'template_id' will take precedence.RPu`The template_clone function requires either a 'template_id' or a 'template_name' to be provided.u:utemplate.cloneuactioniuclonediucloned_template_iducloned_template_nameiu
error_codeN(
RRVRZRR,R-RmRRRRIR�R�(RRPRRttemplate_idR�tclone_imagesRR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyttemplate_clone5	s<	
	$c
C@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}|jj	j
|t|��}id	d
6|dd6|d
d6|dd6}	|	S(u�
    Deletes the given template from OpenNebula. Either a name or a template_id must
    be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the template to delete. Can be used instead of ``template_id``.

    template_id
        The ID of the template to delete. Can be used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f template_delete opennebula name=my-template
        salt-cloud --function template_delete opennebula template_id=5
    ufunctionuBThe template_delete function must be called with -f or --function.unameutemplate_idu^Both the 'template_id' and 'name' arguments were provided. 'template_id' will take precedence.RPuXThe template_delete function requires either a 'name' or a 'template_id' to be provided.u:utemplate.deleteuactioniudeletediiu
error_codeN(RRVRZR,R-RmRRRRIR�R�(
RRPRRR�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyttemplate_delete~	s0	
	cC@sL|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��t�\}}}dj||g�}|jj	j
|t|�|�}	idd
6|	dd6|	dd6|d6|	dd6}
|
S(u
    Instantiates a new virtual machine from a template.

    .. versionadded:: 2016.3.0

    .. note::
        ``template_instantiate`` creates a VM on OpenNebula from a template, but it
        does not install Salt on the new VM. Use the ``create`` function for that
        functionality: ``salt-cloud -p opennebula-profile vm-name``.

    vm_name
        Name for the new VM instance.

    template_id
        The ID of the template from which the VM will be created. Can be used instead
        of ``template_name``.

    template_name
        The name of the template from which the VM will be created. Can be used instead
        of ``template_id``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f template_instantiate opennebula vm_name=my-new-vm template_id=0

    ufunctionuGThe template_instantiate function must be called with -f or --function.uvm_nameutemplate_idu
template_nameuFThe template_instantiate function requires a 'vm_name' to be provided.ugBoth the 'template_id' and 'template_name' arguments were provided. 'template_id' will take precedence.RPunameufThe template_instantiate function requires either a 'template_id' or a 'template_name' to be provided.u:utemplate.instantiateuactioniuinstantiatediuinstantiated_vm_idiu
error_codeN(RRVRZR,R-RmRRRRIR�R�(RRPR�R�R�RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyttemplate_instantiate�	s:	
	!cC@s4|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}dd	g}|dkr�td
��n||dkr�d}n9||dkr�d}n td
j|d|d���|r"|rMtjd�qMn+|rAtdi|d6�}ntd��|rl|r�tjd�q�nE|r�tjj	j
|dd��}	|	j�}WdQXntd��t�\}
}}dj
||g�}
|
jjj|
t|�|t|��}idd6|dd6|dd6|dd6}|S(uk
    Replaces the template contents.

    .. versionadded:: 2016.3.0

    template_id
        The ID of the template to update. Can be used instead of ``template_name``.

    template_name
        The name of the template to update. Can be used instead of ``template_id``.

    path
        The path to a file containing the elements of the template to be updated.
        Syntax within the file can be the usual attribute=value or XML. Can be
        used instead of ``data``.

    data
        Contains the elements of the template to be updated. Syntax can be the
        usual attribute=value or XML. Can be used instead of ``path``.

    update_type
        There are two ways to update a template: ``replace`` the whole template
        or ``merge`` the new template with the existing one.

    CLI Example:

    .. code-block:: bash

        salt-cloud --function template_update opennebula template_id=1 update_type=replace \
            path=/path/to/template_update_file.txt
        salt-cloud -f template_update opennebula template_name=my-template update_type=merge \
            data='CPU="1.0" DISK=[IMAGE="Ubuntu-14.04"] GRAPHICS=[LISTEN="0.0.0.0",TYPE="vnc"] \
            MEMORY="1024" NETWORK="yes" NIC=[NETWORK="192net",NETWORK_UNAME="oneadmin"] \
            OS=[ARCH="x86_64"] SUNSTONE_CAPACITY_SELECT="YES" SUNSTONE_NETWORK_SELECT="YES" \
            VCPU="1"'
    ufunctionuBThe template_update function must be called with -f or --function.utemplate_idu
template_nameupathudatauupdate_typeureplaceumergeuFThe template_update function requires an 'update_type' to be provided.iiu3The update_type argument must be either {0} or {1}.ugBoth the 'template_id' and 'template_name' arguments were provided. 'template_id' will take precedence.RPunameuaThe template_update function requires either a 'template_id' or a 'template_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuTThe template_update function requires either 'data' or a file 'path' to be provided.u:utemplate.updateuactionuupdatediu
error_code(RRVRZR\R,R-RmR�R�R�R�R�RRRRIR�R�(RRPR�R�R�R�R�R�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyttemplate_update
s`%			
	
	*cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	|||�}	idt
j|�d6|	dd	6|	d
d6|	dd
6}
|
S(u�
    Submits an action to be performed on a given virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to action.

    action
        The action to be performed on the VM. Available options include:
          - boot
          - delete
          - delete-recreate
          - hold
          - poweroff
          - poweroff-hard
          - reboot
          - reboot-hard
          - release
          - resched
          - resume
          - shutdown
          - shutdown-hard
          - stop
          - suspend
          - undeploy
          - undeploy-hard
          - unresched

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_action my-vm action='release'
    uactionu:The vm_action function must be called with -a or --action.u6The vm_action function must have an 'action' provided.u:RPunameu
vm.action.iuactionediuvm_idiu
error_codeN(RRVRZRRR�RpRR�R�RRb(RRRPRR�RR R!R"tvm_idR�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyRQt
s&$	cC@sM|dkrtd��n|d	kr0i}n|jdd	�}|jdd	�}|jdt�}|r�|r�tjd�q�nE|r�tjjj	|dd��}|j
�}Wd	QXntd
��t�\}}}dj||g�}	|j
jj|	|tjjj|��}
idd
6|
dd6|
dd6|
dd6}|S(uB
    Allocates a new virtual machine in OpenNebula.

    .. versionadded:: 2016.3.0

    path
        The path to a file defining the template of the VM to allocate.
        Syntax within the file can be the usual attribute=value or XML.
        Can be used instead of ``data``.

    data
        Contains the template definitions of the VM to allocate. Syntax can
        be the usual attribute=value or XML. Can be used instead of ``path``.

    hold
        If this parameter is set to ``True``, the VM will be created in
        the ``HOLD`` state. If not set, the VM is created in the ``PENDING``
        state. Default is ``False``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vm_allocate path=/path/to/vm_template.txt
        salt-cloud --function vm_allocate path=/path/to/vm_template.txt hold=True
    ufunctionu>The vm_allocate function must be called with -f or --function.upathudatauholduPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuPThe vm_allocate function requires either 'data' or a file 'path' to be provided.u:uvm.allocateuactioniu	allocatediuvm_idiu
error_code(RRVRZRR,R-R�R�R�R�R�RRRR�R�R�R�(RRPR�R�tholdR�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_allocate�
s4	
	*c
C@sH|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�nE|r�tjjj|dd��}|j	�}WdQXntd	��t
�\}}}d
j||g�}	tt
di|d6��}
|jjj|	|
|�}id
d6|dd6|dd6|dd6}|S(u�
    Attaches a new disk to the given virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM for which to attach the new disk.

    path
        The path to a file containing a single disk vector attribute.
        Syntax within the file can be the usual attribute=value or XML.
        Can be used instead of ``data``.

    data
        Contains the data needed to attach a single disk vector attribute.
        Syntax can be the usual attribute=value or XML. Can be used instead
        of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_attach my-vm path=/path/to/disk_file.txt
        salt-cloud -a vm_attach my-vm data="DISK=[DISK_ID=1]"
    uactionu8The vm_attach action must be called with -a or --action.upathudatauPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuNThe vm_attach function requires either 'data' or a file 'path' to be provided.u:RPunameu	vm.attachiuattachediuvm_idiu
error_code(RRVRZR,R-R�R�R�R�R�RRR�RpRR�tattach(
RRRPRR�R�R�RR R!R"R�R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vm_attach�
s4	
	c
C@sH|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�nE|r�tjjj|dd��}|j	�}WdQXntd	��t
�\}}}d
j||g�}	tt
di|d6��}
|jjj|	|
|�}id
d6|dd6|dd6|dd6}|S(u�
    Attaches a new network interface to the given virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM for which to attach the new network interface.

    path
        The path to a file containing a single NIC vector attribute.
        Syntax within the file can be the usual attribute=value or XML. Can
        be used instead of ``data``.

    data
        Contains the single NIC vector attribute to attach to the VM.
        Syntax can be the usual attribute=value or XML. Can be used instead
        of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_attach_nic my-vm path=/path/to/nic_file.txt
        salt-cloud -a vm_attach_nic my-vm data="NIC=[NETWORK_ID=1]"
    uactionu<The vm_attach_nic action must be called with -a or --action.upathudatauPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuRThe vm_attach_nic function requires either 'data' or a file 'path' to be provided.u:RPunameuvm.attachniciunic_attachediuvm_idiu
error_code(RRVRZR,R-R�R�R�R�R�RRR�RpRR�t	attachnic(
RRRPRR�R�R�RR R!R"R�R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vm_attach_nic<s4	
	cC@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdt�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�td	i|d
6�}ntd��|r�|rtjd�qn%|rtd	i|d
6�}nd
}t�\}}	}
dj	|	|
g�}t
d	i|d
6�}|jjj
|t|�t|�tjjj|�t|��}
idd6|
dd6|
dd6|
dd6}|S(u�
    Initiates the instance of the given VM on the target host.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to deploy.

    host_id
        The ID of the target host where the VM will be deployed. Can be used instead
        of ``host_name``.

    host_name
        The name of the target host where the VM will be deployed. Can be used instead
        of ``host_id``.

    capacity_maintained
        True to enforce the Host capacity is not over-committed. This parameter is only
        acknowledged for users in the ``oneadmin`` group. Host capacity will be always
        enforced for regular users.

    datastore_id
        The ID of the target system data-store where the VM will be deployed. Optional
        and can be used instead of ``datastore_name``. If neither ``datastore_id`` nor
        ``datastore_name`` are set, OpenNebula will choose the data-store.

    datastore_name
        The name of the target system data-store where the VM will be deployed. Optional,
        and can be used instead of ``datastore_id``. If neither ``datastore_id`` nor
        ``datastore_name`` are set, OpenNebula will choose the data-store.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_deploy my-vm host_id=0
        salt-cloud -a vm_deploy my-vm host_id=1 capacity_maintained=False
        salt-cloud -a vm_deploy my-vm host_name=host01 datastore_id=1
        salt-cloud -a vm_deploy my-vm host_name=host01 datastore_name=default
    uactionu8The vm_deploy action must be called with -a or --action.uhost_idu	host_nameucapacity_maintainedudatastore_idudatastore_nameu[Both the 'host_id' and 'host_name' arguments were provided. 'host_id' will take precedence.RPunameuLThe vm_deploy function requires a 'host_id' or a 'host_name' to be provided.ujBoth the 'datastore_id' and 'datastore_name' arguments were provided. 'datastore_id' will take precedence.u-1u:u	vm.deployiudeployediuvm_idiu
error_codeN(RRVRZR=R,R-R`R_RRRpRR�tdeployR�R�R�R�R�(RRRPRthost_idt	host_nametcapacity_maintainedR�R�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vm_deploysN)	
	
		cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	||t|��}	idd6|	d	d
6|	dd6|	d
d6}
|
S(u%
    Detaches a disk from a virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM from which to detach the disk.

    disk_id
        The ID of the disk to detach.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_detach my-vm disk_id=1
    uactionu8The vm_detach action must be called with -a or --action.udisk_idu;The vm_detach function requires a 'disk_id' to be provided.u:RPunameu	vm.detachiudetachediuvm_idiu
error_codeN(
RRVRZRRR�RpRR�tdetach(RRRPRtdisk_idRR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vm_detach�s&	!cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	||t|��}	idd6|	d	d
6|	dd6|	d
d6}
|
S(u3
    Detaches a disk from a virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM from which to detach the network interface.

    nic_id
        The ID of the nic to detach.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_detach_nic my-vm nic_id=1
    uactionu<The vm_detach_nic action must be called with -a or --action.unic_idu>The vm_detach_nic function requires a 'nic_id' to be provided.u:RPunameuvm.detachniciunic_detachediuvm_idiu
error_codeN(
RRVRZRRR�RpRR�t	detachnic(RRRPRtnic_idRR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vm_detach_nics&	!cC@sD|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}t|jdd��}|dks�|dkr�td	��nt�\}}}	d
j||	g�}
ttdi|d6��}|jjj	|
|t|�|||�}id
d6|dd6|dd6|dd6}
|
S(uI
    Sets the disk to be saved in the given image.

    .. versionadded:: 2016.3.0

    name
        The name of the VM containing the disk to save.

    disk_id
        The ID of the disk to save.

    image_name
        The name of the new image where the disk will be saved.

    image_type
        The type for the new image. If not set, then the default ``ONED`` Configuration
        will be used. Other valid types include: OS, CDROM, DATABLOCK, KERNEL, RAMDISK,
        and CONTEXT.

    snapshot_id
        The ID of the snapshot to export. If not set, the current image state will be
        used.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_disk_save my-vm disk_id=1 image_name=my-new-image
        salt-cloud -a vm_disk_save my-vm disk_id=1 image_name=my-new-image image_type=CONTEXT snapshot_id=10
    uactionu;The vm_disk_save action must be called with -a or --action.udisk_idu
image_nameu
image_typeuusnapshot_idu-1uRThe vm_disk_save function requires a 'disk_id' and an 'image_name' to be provided.u:RPunameuvm.disksaveiusavediuimage_idiu
error_codeN(
RRVRZR�RRRpRR�tdisksave(RRRPRR�R�t
image_typeR�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_disk_save@s6			cC@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|dksl|dkr{td��nt�\}}}dj||g�}ttdi|d6��}	|jjj	||	t|�|�}
id	d6|
d
d6|
dd
6|
dd6}|S(u�
    Takes a new snapshot of the disk image.

    .. versionadded:: 2016.3.0

    name
        The name of the VM of which to take the snapshot.

    disk_id
        The ID of the disk to save.

    description
        The description for the snapshot.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_disk_snapshot_create my-vm disk_id=0 description="My Snapshot Description"
    uactionuFThe vm_disk_snapshot_create action must be called with -a or --action.udisk_idudescriptionu]The vm_disk_snapshot_create function requires a 'disk_id' and a 'description' to be provided.u:RPunameuvm.disksnapshotcreateiucreatediusnapshot_idiu
error_codeN(
RRVRZRRR�RpRR�tdisksnapshotcreate(RRRPRR�tdescriptionRR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_disk_snapshot_create�s.			cC@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|dksl|dkr{td��nt�\}}}dj||g�}ttdi|d6��}	|jjj	||	t|�t|��}
id	d6|
d
d6|
dd6|
d
d6}|S(u�
    Deletes a disk snapshot based on the given VM and the disk_id.

    .. versionadded:: 2016.3.0

    name
        The name of the VM containing the snapshot to delete.

    disk_id
        The ID of the disk to save.

    snapshot_id
        The ID of the snapshot to be deleted.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_disk_snapshot_delete my-vm disk_id=0 snapshot_id=6
    uactionuFThe vm_disk_snapshot_delete action must be called with -a or --action.udisk_idusnapshot_idu]The vm_disk_snapshot_create function requires a 'disk_id' and a 'snapshot_id' to be provided.u:RPunameuvm.disksnapshotdeleteiudeletediiu
error_codeN(
RRVRZRRR�RpRR�tdisksnapshotdelete(RRRPRR�R�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_disk_snapshot_delete�s.		cC@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|dksl|dkr{td��nt�\}}}dj||g�}ttdi|d6��}	|jjj	||	t|�t|��}
id	d6|
d
d6|
dd6|
d
d6}|S(u�
    Reverts a disk state to a previously taken snapshot.

    .. versionadded:: 2016.3.0

    name
        The name of the VM containing the snapshot.

    disk_id
        The ID of the disk to revert its state.

    snapshot_id
        The ID of the snapshot to which the snapshot should be reverted.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_disk_snapshot_revert my-vm disk_id=0 snapshot_id=6
    uactionuFThe vm_disk_snapshot_revert action must be called with -a or --action.udisk_idusnapshot_idu]The vm_disk_snapshot_revert function requires a 'disk_id' and a 'snapshot_id' to be provided.u:RPunameuvm.disksnapshotrevertiudeletediiu
error_codeN(
RRVRZRRR�RpRR�tdisksnapshotrevert(RRRPRR�R�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_disk_snapshot_revert�s.		c
C@s�|dkrtd��nt�\}}}dj||g�}ttdi|d6��}|jjj||�}|dtkr�|dSi}t	|d�}	t
|	�||	jd�j<|Sd	S(
u
    Retrieves information for a given virtual machine. A VM name must be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the VM for which to gather information.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_info my-vm
    uactionu6The vm_info action must be called with -a or --action.u:RPunameiiuNAMEN(
RRRR�RpRR�RRRRRR(
RRRRR R!R"R�R�RR�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_info.
scC@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdt�}|jdt�}|jdd�}|jdd�}|r�|r�tjd	�q�n+|r�td
i|d6�}ntd��|r|r0tjd
�q0n+|r$td
i|d6�}ntd��t	�\}	}
}dj
|
|g�}ttd
i|d6��}
|	j
jj||
t|�tjjj|�tjjj|�t|��}idd6|dd6|dd6|dd6}|S(u
    Migrates the specified virtual machine to the specified target host.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to migrate.

    host_id
        The ID of the host to which the VM will be migrated. Can be used instead
        of ``host_name``.

    host_name
        The name of the host to which the VM will be migrated. Can be used instead
        of ``host_id``.

    live_migration
        If set to ``True``, a live-migration will be performed. Default is ``False``.

    capacity_maintained
        True to enforce the Host capacity is not over-committed. This parameter is only
        acknowledged for users in the ``oneadmin`` group. Host capacity will be always
        enforced for regular users.

    datastore_id
        The target system data-store ID where the VM will be migrated. Can be used
        instead of ``datastore_name``.

    datastore_name
        The name of the data-store target system where the VM will be migrated. Can be
        used instead of ``datastore_id``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_migrate my-vm host_id=0 datastore_id=1
        salt-cloud -a vm_migrate my-vm host_id=0 datastore_id=1 live_migration=True
        salt-cloud -a vm_migrate my-vm host_name=host01 datastore_name=default
    uactionu9The vm_migrate action must be called with -a or --action.uhost_idu	host_nameulive_migrationucapacity_maintainedudatastore_idudatastore_nameujBoth the 'datastore_id' and 'datastore_name' arguments were provided. 'datastore_id' will take precedence.RPunameu^The vm_migrate function requires either a 'datastore_id' or a 'datastore_name' to be provided.u[Both the 'host_id' and 'host_name' arguments were provided. 'host_id' will take precedence.uTThe vm_migrate function requires either a 'host_id' or a 'host_name' to be provided.u:u
vm.migrateiumigratediuvm_idiu
error_codeN(RRVRZRR=R,R-R_R`RRR�RpRR�tmigrateR�R�R�R�(RRRPRR�R�tlive_migrationR�R�R�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vm_migrateP
sT)	
	
		c
C@s�|dkrtd��nt�\}}}dj||g�}ttdi|d6��}|jjj||�}|dtkr�t	j
d�iSi}x4t|d�D]"}	t|	�||	j
d	�j<q�W|Sd
S(u�
    Returns the monitoring records for a given virtual machine. A VM name must be
    supplied.

    The monitoring information returned is a list of VM elements. Each VM element
    contains the complete dictionary of the VM with the updated information returned
    by the poll action.

    .. versionadded:: 2016.3.0

    name
        The name of the VM for which to gather monitoring records.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_monitoring my-vm
    uactionu<The vm_monitoring action must be called with -a or --action.u:RPunameiuHThere was an error retrieving the specified VM's monitoring information.iuIDN(RRRR�RpRR�t
monitoringRR,R�RRRR(
RRRRR R!R"R�R�RRd((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vm_monitoring�
s cC@sl|dkrtd��n|d	kr0i}n|jdd	�}|jdd	�}|jdt�}|r�|r�tjd�q�nE|r�tjjj	|dd��}|j
�}Wd	QXntd
��t�\}}}	dj||	g�}
t
tdi|d
6��}|jjj|
||tjjj|��}idd6|dd6|dd6|dd6}
|
S(u�
    Changes the capacity of the virtual machine.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to resize.

    path
        The path to a file containing new capacity elements CPU, VCPU, MEMORY. If one
        of them is not present, or its value is 0, the VM will not be re-sized. Syntax
        within the file can be the usual attribute=value or XML. Can be used instead
        of ``data``.

    data
        Contains the new capacity elements CPU, VCPU, and MEMORY. If one of them is not
        present, or its value is 0, the VM will not be re-sized. Can be used instead of
        ``path``.

    capacity_maintained
        True to enforce the Host capacity is not over-committed. This parameter is only
        acknowledged for users in the ``oneadmin`` group. Host capacity will be always
        enforced for regular users.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_resize my-vm path=/path/to/capacity_template.txt
        salt-cloud -a vm_resize my-vm path=/path/to/capacity_template.txt capacity_maintained=False
        salt-cloud -a vm_resize my-vm data="CPU=1 VCPU=1 MEMORY=1024"
    uactionu8The vm_resize action must be called with -a or --action.upathudataucapacity_maintaineduPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuNThe vm_resize function requires either 'data' or a file 'path' to be provided.u:RPunameu	vm.resizeiuresizediuvm_idiu
error_code(RRVRZR=R,R-R�R�R�R�R�RRR�RpRR�tresizeR�R�(RRRPRR�R�R�R�RR R!R"R�R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vm_resize�
s6!	
	-cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	|||�}	idd6|	d	d
6|	dd6|	d
d6}
|
S(un
    Creates a new virtual machine snapshot from the provided VM.

    .. versionadded:: 2016.3.0

    vm_name
        The name of the VM from which to create the snapshot.

    snapshot_name
        The name of the snapshot to be created.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_snapshot_create my-vm snapshot_name=my-new-snapshot
    uactionuAThe vm_snapshot_create action must be called with -a or --action.u
snapshot_nameuJThe vm_snapshot_create function requires a 'snapshot_name' to be provided.u:RPunameuvm.snapshotcreateiusnapshot_creatediusnapshot_idiu
error_codeN(
RRVRZRRR�RpRR�tsnapshotcreate(R�RPRt
snapshot_nameRR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_snapshot_create.s&	cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	||t|��}	idd6|	d	d
6|	dd6|	d
d6}
|
S(uV
    Deletes a virtual machine snapshot from the provided VM.

    .. versionadded:: 2016.3.0

    vm_name
        The name of the VM from which to delete the snapshot.

    snapshot_id
        The ID of the snapshot to be deleted.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_snapshot_delete my-vm snapshot_id=8
    uactionuAThe vm_snapshot_delete action must be called with -a or --action.usnapshot_iduHThe vm_snapshot_delete function requires a 'snapshot_id' to be provided.u:RPunameuvm.snapshotdeleteiusnapshot_deletediuvm_idiu
error_codeN(
RRVRZRRR�RpRR�R�(R�RPRR�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_snapshot_delete]s&	!cC@s�|dkrtd��n|dkr0i}n|jdd�}|dkr]td��nt�\}}}dj||g�}ttdi|d6��}|jjj	||t|��}	idd6|	d	d
6|	dd6|	d
d6}
|
S(u
    Reverts a virtual machine to a snapshot

    .. versionadded:: 2016.3.0

    vm_name
        The name of the VM to revert.

    snapshot_id
        The snapshot ID.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_snapshot_revert my-vm snapshot_id=42
    uactionuAThe vm_snapshot_revert action must be called with -a or --action.usnapshot_iduHThe vm_snapshot_revert function requires a 'snapshot_id' to be provided.u:RPunameuvm.snapshotrevertiusnapshot_revertediuvm_idiu
error_codeN(
RRVRZRRR�RpRR�R�(R�RPRR�RR R!R"R�R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvm_snapshot_revert�s&	!cC@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}ddg}|dkr�td��n||d	kr�d	}n9||d
kr�d
}n tdj|d	|d
���|r�|rCtjd�qCnE|r7tjjj	|d
d��}|j
�}WdQXntd��t�\}	}
}dj|
|g�}t
tdi|d6��}
|	jjj||
|t
|��}idd6|d	d6|d
d6|dd6}|S(u�
    Replaces the user template contents.

    .. versionadded:: 2016.3.0

    name
        The name of the VM to update.

    path
        The path to a file containing new user template contents. Syntax within the
        file can be the usual attribute=value or XML. Can be used instead of ``data``.

    data
        Contains the new user template contents. Syntax can be the usual attribute=value
        or XML. Can be used instead of ``path``.

    update_type
        There are two ways to update a VM: ``replace`` the whole template
        or ``merge`` the new template with the existing one.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a vm_update my-vm path=/path/to/user_template_file.txt update_type='replace'
    uactionu8The vm_update action must be called with -a or --action.upathudatauupdate_typeureplaceumergeu@The vm_update function requires an 'update_type' to be provided.iiu3The update_type argument must be either {0} or {1}.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuNThe vm_update function requires either 'data' or a file 'path' to be provided.u:RPunameu	vm.updateuupdateduresource_idiu
error_code(RRVRZR\R,R-R�R�R�R�R�RRR�RpRR�R�(RRRPRR�R�R�R�R�R�RR R!R"R�R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vm_update�sN			
	$c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��|r�|r&tjd�q&nE|rtjjj	|dd
��}|j
�}WdQXntd��t�\}}}	dj||	g�}
|j
jj|
t|�|�}idd6|dd6|dd6|dd6}|S(u�
    Adds address ranges to a given virtual network.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network to add the address range. Can be used
        instead of ``vn_name``.

    vn_name
        The name of the virtual network to add the address range. Can be used
        instead of ``vn_id``.

    path
        The path to a file containing the template of the address range to add.
        Syntax within the file can be the usual attribute=value or XML. Can be
        used instead of ``data``.

    data
        Contains the template of the address range to add. Syntax can be the
        usual attribute=value or XML. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_add_ar opennebula vn_id=3 path=/path/to/address_range.txt
        salt-cloud -f vn_add_ar opennebula vn_name=my-vn \
            data="AR=[TYPE=IP4, IP=192.168.0.5, SIZE=10]"
    ufunctionu<The vn_add_ar function must be called with -f or --function.uvn_iduvn_nameupathudatauUBoth the 'vn_id' and 'vn_name' arguments were provided. 'vn_id' will take precedence.RPunameuIThe vn_add_ar function requires a 'vn_id' and a 'vn_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuNThe vn_add_ar function requires either 'data' or a file 'path' to be provided.u:u	vn.add_aruactioniuaddress_range_addediuresource_idiu
error_code(RRVRZR,R-RqR�R�R�R�R�RRRtvntadd_arR�(
RRPtvn_idtvn_nameR�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vn_add_arsF	
	
	!c
C@s�|dkrtd��n|d
kr0i}n|jdd
�}|jdd
�}|jdd
�}|jdd
�}|r�|r�tjd�q�nE|r�tjjj|dd	��}|j	�}Wd
QXntd��|r�|r tjd�q n%|rt
d
i|d6�}nd}t�\}}}	dj||	g�}
|j
jj|
|t|��}idd6|dd6|dd6|dd6}|S(uI
    Allocates a new virtual network in OpenNebula.

    .. versionadded:: 2016.3.0

    path
        The path to a file containing the template of the virtual network to allocate.
        Syntax within the file can be the usual attribute=value or XML. Can be used
        instead of ``data``.

    data
        Contains the template of the virtual network to allocate. Syntax can be the
        usual attribute=value or XML. Can be used instead of ``path``.

    cluster_id
        The ID of the cluster for which to add the new virtual network. Can be used
        instead of ``cluster_name``. If neither ``cluster_id`` nor ``cluster_name``
        are provided, the virtual network won’t be added to any cluster.

    cluster_name
        The name of the cluster for which to add the new virtual network. Can be used
        instead of ``cluster_id``. If neither ``cluster_name`` nor ``cluster_id`` are
        provided, the virtual network won't be added to any cluster.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_allocate opennebula path=/path/to/vn_file.txt
    ufunctionu>The vn_allocate function must be called with -f or --function.u
cluster_iducluster_nameupathudatauPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuPThe vn_allocate function requires either 'data' or a file 'path' to be provided.udBoth the 'cluster_id' and 'cluster_name' arguments were provided. 'cluster_id' will take precedence.RPunameu-1u:uvn.allocateuactioniu	allocatediuvn_idiu
error_code(RRVRZR,R-R�R�R�R�R�R^RRRRR�R�(
RRPt
cluster_idtcluster_nameR�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvn_allocateisD	
	
!c
C@s|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}|jj	j
|t|��}id	d
6|dd6|d
d6|dd6}	|	S(u�
    Deletes the given virtual network from OpenNebula. Either a name or a vn_id must
    be supplied.

    .. versionadded:: 2016.3.0

    name
        The name of the virtual network to delete. Can be used instead of ``vn_id``.

    vn_id
        The ID of the virtual network to delete. Can be used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_delete opennebula name=my-virtual-network
        salt-cloud --function vn_delete opennebula vn_id=3
    ufunctionu<The vn_delete function must be called with -f or --function.unameuvn_iduRBoth the 'vn_id' and 'name' arguments were provided. 'vn_id' will take precedence.RPuEThe vn_delete function requires a 'name' or a 'vn_id' to be provided.u:u	vn.deleteuactioniudeletediiu
error_codeN(RRVRZR,R-RqRRRRR�R�(
RRPRRR	RR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt	vn_delete�s0	
	cC@sK|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|dkr�td��n|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��t�\}}}dj||g�}|jj	j
|t|�t|��}	idd
6|	dd6|	dd6|	dd6}
|
S(uI
    Frees a reserved address range from a virtual network.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to free an address range.
        Can be used instead of ``vn_name``.

    vn_name
        The name of the virtual network from which to free an address range.
        Can be used instead of ``vn_id``.

    ar_id
        The ID of the address range to free.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_free_ar opennebula vn_id=3 ar_id=1
        salt-cloud -f vn_free_ar opennebula vn_name=my-vn ar_id=1
    ufunctionu=The vn_free_ar function must be called with -f or --function.uvn_iduvn_nameuar_idu;The vn_free_ar function requires an 'rn_id' to be provided.uUBoth the 'vn_id' and 'vn_name' arguments were provided. 'vn_id' will take precedence.RPunameuIThe vn_free_ar function requires a 'vn_id' or a 'vn_name' to be provided.u:u
vn.free_aruactioniuar_freediuresource_idiu
error_codeN(RRVRZR,R-RqRRRRtfree_arR�(RRPR	R
tar_idRR R!R"R�R�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vn_free_ar�s8	
	'c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��|r�|r&tjd�q&nE|rtjjj	|dd
��}|j
�}WdQXntd��t�\}}}	dj||	g�}
|j
jj|
t|�|�}idd6|dd6|dd6|dd6}|S(ut
    Holds a virtual network lease as used.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to hold the lease. Can be used
        instead of ``vn_name``.

    vn_name
        The name of the virtual network from which to hold the lease. Can be used
        instead of ``vn_id``.

    path
        The path to a file defining the template of the lease to hold.
        Syntax within the file can be the usual attribute=value or XML. Can be
        used instead of ``data``.

    data
        Contains the template of the lease to hold. Syntax can be the usual
        attribute=value or XML. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_hold opennebula vn_id=3 path=/path/to/vn_hold_file.txt
        salt-cloud -f vn_hold opennebula vn_name=my-vn data="LEASES=[IP=192.168.0.5]"
    ufunctionu:The vn_hold function must be called with -f or --function.uvn_iduvn_nameupathudatauUBoth the 'vn_id' and 'vn_name' arguments were provided. 'vn_id' will take precedence.RPunameuFThe vn_hold function requires a 'vn_id' or a 'vn_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuGThe vn_hold function requires either 'data' or a 'path' to be provided.u:uvn.holduactioniuheldiuresource_idiu
error_code(RRVRZR,R-RqR�R�R�R�R�RRRRR�R�(
RRPR	R
R�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvn_hold=sF	
	
	!cC@s5|dkrtd��n|dkr0i}n|jdd�}|jdd�}|rs|r�tjd�q�n+|r�tdi|d6�}ntd��t�\}}}dj||g�}|jj	j
|t|��}|d	tkr�|d
Si}	t
|d
�}
t|
�|	|
jd�j<|	SdS(
u�
    Retrieves information for the virtual network.

    .. versionadded:: 2016.3.0

    name
        The name of the virtual network for which to gather information. Can be
        used instead of ``vn_id``.

    vn_id
        The ID of the virtual network for which to gather information. Can be
        used instead of ``name``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_info opennebula vn_id=3
        salt-cloud --function vn_info opennebula name=public
    ufunctionu:The vn_info function must be called with -f or --function.unameuvn_iduRBoth the 'vn_id' and 'name' arguments were provided. 'vn_id' will take precedence.RPuJThe vn_info function requires either a 'name' or a 'vn_id' to be provided.u:iiuNAMEN(RRVRZR,R-RqRRRRRR�RRRRR(RRPRRR	RR R!R"R�RR�((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pytvn_info�s0	
	c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��|r�|r&tjd�q&nE|rtjjj	|dd
��}|j
�}WdQXntd��t�\}}}	dj||	g�}
|j
jj|
t|�|�}idd6|dd6|dd6|dd6}|S(u�
    Releases a virtual network lease that was previously on hold.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to release the lease. Can be
        used instead of ``vn_name``.

    vn_name
        The name of the virtual network from which to release the lease.
        Can be used instead of ``vn_id``.

    path
        The path to a file defining the template of the lease to release.
        Syntax within the file can be the usual attribute=value or XML. Can be
        used instead of ``data``.

    data
        Contains the template defining the lease to release. Syntax can be the
        usual attribute=value or XML. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_release opennebula vn_id=3 path=/path/to/vn_release_file.txt
        salt-cloud =f vn_release opennebula vn_name=my-vn data="LEASES=[IP=192.168.0.5]"
    ufunctionu=The vn_reserve function must be called with -f or --function.uvn_iduvn_nameupathudatauUBoth the 'vn_id' and 'vn_name' arguments were provided. 'vn_id' will take precedence.RPunameuIThe vn_release function requires a 'vn_id' or a 'vn_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNuJThe vn_release function requires either 'data' or a 'path' to be provided.u:u
vn.releaseuactioniureleasediuresource_idiu
error_code(RRVRZR,R-RqR�R�R�R�R�RRRRtreleaseR�(
RRPR	R
R�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vn_release�sF	
	
	!c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|r�|r�tjd�q�n+|r�tdi|d	6�}ntd
��|r�|r&tjd�q&nE|rtjjj	|dd
��}|j
�}WdQXntd��t�\}}}	dj||	g�}
|j
jj|
t|�|�}idd6|dd6|dd6|dd6}|S(u�
    Reserve network addresses.

    .. versionadded:: 2016.3.0

    vn_id
        The ID of the virtual network from which to reserve addresses. Can be used
        instead of vn_name.

    vn_name
        The name of the virtual network from which to reserve addresses. Can be
        used instead of vn_id.

    path
        The path to a file defining the template of the address reservation.
        Syntax within the file can be the usual attribute=value or XML. Can be used
        instead of ``data``.

    data
        Contains the template defining the address reservation. Syntax can be the
        usual attribute=value or XML. Data provided must be wrapped in double
        quotes. Can be used instead of ``path``.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f vn_reserve opennebula vn_id=3 path=/path/to/vn_reserve_file.txt
        salt-cloud -f vn_reserve opennebula vn_name=my-vn data="SIZE=10 AR_ID=8 NETWORK_ID=1"
    ufunctionu=The vn_reserve function must be called with -f or --function.uvn_iduvn_nameupathudatauUBoth the 'vn_id' and 'vn_name' arguments were provided. 'vn_id' will take precedence.RPunameuIThe vn_reserve function requires a 'vn_id' or a 'vn_name' to be provided.uPBoth the 'data' and 'path' arguments were provided. 'data' will take precedence.R�urNu9The vn_reserve function requires a 'path' to be provided.u:u
vn.reserveuactioniureservediuresource_idiu
error_code(RRVRZR,R-RqR�R�R�R�R�RRRRtreserveR�(
RRPR	R
R�R�R�RR R!R"R�R]((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt
vn_reserve$sF	
	
	!cC@sjd}x]|dkreyt�|SWq	tk
ra|d8}tjd||�tjd�q	Xq	WiS(u�
    Helper function that returns all information about a named node.

    name
        The name of the node for which to get information.
    i
iiu<Failed to get the data for node '%s'. Remaining attempts: %sg�?(R>R[R,R�ttimetsleep(RRtattempts((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR�|s


cC@sEytj|�}Wn+tjk
r@}tdj|���nX|S(uN
    Intrepret the data coming from opennebula and raise if it's not XML.
    uopennebula returned: {0}(R	tXMLtXMLSyntaxErrorRR\(txml_strtxml_dataterr((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR�s
cC@s�t�}tjd|tdt�}tjd|tdt�}tjd|tdt�}tjjjj	j
|�}|||fS(u�
    Uses the OpenNebula cloud provider configurations to connect to the
    OpenNebula API.

    Returns the server connection created as well as the user and password
    values from the cloud provider config file used to make the connection.
    uxml_rpcRauuserupassword(R
RRcRRR�textRtmovest
xmlrpc_clienttServerProxy(Rdtxml_rpcR R!R((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR�s	c
C@s�t�\}}}dj||g�}|jjj|dddd�d}i}x�t|�D]�}|jd�j}i||<|jd�jd�j}	|jd�jd�j}
g}xQ|jd�jd	�D]7}y|j	|jd
�j�Wq�t
k
rq�Xq�W|jd�j||d<d
|jd�krf|jd�jd
�j||d<n|||d<i|	d6|
d6||d<|jd�j||d<|||d<g||d<|r_t|�||jd�j<q_q_W|S(u�
    Helper function for the list_* query functions - Constructs the
    appropriate dictionaries to return from the API query.

    full
        If performing a full query, such as in list_nodes_full, change
        this parameter to ``True``.
    u:i����i����iuNAMEuTEMPLATEuCPUuMEMORYuNICuIPuIDuiduTEMPLATE_IDuimageunameucpuumemoryusizeuSTATEustateuprivate_ipsu
public_ips(RRRtvmpoolRRRRtfindallR�R�R(
R:RR R!R"tvm_pooltvmsR�RRtcpu_sizetmemory_sizetprivate_ipstnic((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR;�s4	%

&#cC@s�i}x�|D]z}|jj�}d}x-||krW|tj|�7}|d7}q+W|jdkrzt|�||<q
|j||<q
W|S(ui
    Helper function to covert xml into a data dictionary.

    xml
        The xml data to convert.
    iN(ttagtlowerRRbRRVR(txmltdictstitemtkeytidx((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyR�s
(xt__doc__t
__future__RRRR�R�R�Rtsalt.configRtsalt.exceptionsRRRRRtsalt.utils.dataR�tsalt.utils.filestsalt.extRt salt.ext.six.moves.xmlrpc_clienttlxmlR	R=RtImportErrorRt	getLoggert__name__R,R
RR
RRVR&R+R.R3R8R9R<R>R@RERJRORSRTRURYR^R_R`RfRgRjRkRlRmRoRpRqR}R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RQR�R�R�R�R�R�R�R�R�R�R�R�R�RRRRRRRRRRRRRR�RRR;R(((s@/usr/lib/python2.7/site-packages/salt/cloud/clouds/opennebula.pyt<module>=s�(


	
		
$$$	$	$"$	$$/	�>XD;:EECDl@F<:pBI;KpADCCc//F888"h+K///WWT;EV;VX			,

Zerion Mini Shell 1.0