%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/vagrant.pyc

�
���^c@@sQdZddlmZmZmZddlZddlZddlZddlZ	ddl
jZddlZ	ddl
mZddlmZmZmZeje�Zd�Zdd�Zdd�Zdd	�Zdd
�Zd�Zdd�Zdd
�Zdd�Zdd�Z d�Z!d�Z"d�Z#dd�Z$dd�Z%dS(uV
Vagrant Cloud Driver
====================

The Vagrant cloud is designed to "vagrant up" a virtual machine as a
Salt minion.

Use of this module requires some configuration in cloud profile and provider
files as described in the
:ref:`Getting Started with Vagrant <getting-started-with-vagrant>` documentation.

.. versionadded:: 2018.3.0


i(tabsolute_importtprint_functiontunicode_literalsN(t	ipaddress(tSaltCloudExceptiontSaltCloudSystemExittSaltInvocationErrorcC@stS(u(
    Needs no special configuration
    (tTrue(((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyt__virtual__#scC@siS(u�
    This function returns a list of locations available.

    CLI Example:

    .. code-block:: bash

        salt-cloud --list-locations my-cloud-provider

        # \[ vagrant will always returns an empty dictionary \]

    ((tcall((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytavail_locations*scC@s+t�}ig|dD]}|^qd6S(u�This function returns a list of images available for this cloud provider.
     vagrant will return a list of profiles.
     salt-cloud --list-images my-cloud-provider
    uprofilesuProfiles(tget_configured_provider(R	tvm_tprofile((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytavail_images;s	cC@siS(u�
    This function returns a list of sizes available for this cloud provider.

    CLI Example:

    .. code-block:: bash

        salt-cloud --list-sizes my-cloud-provider

        # \[ vagrant always returns an empty dictionary \]

    ((R	((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytavail_sizesDs
cC@st|�}t|�S(u�
    List the nodes which have salt-cloud:driver:vagrant grains.

    CLI Example:

    .. code-block:: bash

        salt-cloud -Q
    (t_list_nodest_build_required_items(R	tnodes((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyt
list_nodesTs
c	C@s�i}x�|j�D]�\}}|rg}g}|d|d}xO|D]G}tj|�}|jsJ|jr�|j|�q�|j|�qJqJWi|dd6|ddd6|d6|d6d	d
6dd6||<qqW|S(
Nuipv4uipv6uidu
salt-clouduprofileuimageuprivate_ipsu
public_ipsuusizeurunningustate(titemsRt
ip_addresstis_loopbackt
is_privatetappend(	Rtrettnametgrainstprivate_ipst
public_ipstipstadrstip_((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyRbs(
		cC@s�t|�}xl|j�D]^\}}y'|d=|d=|d=|d=|d=Wqtk
r_qtk
rv||=qXqWt|�}x#|D]}||j||�q�W|S(u�
    List the nodes, ask all 'vagrant' minions, return dict of grains (enhanced).

    CLI Example:

    .. code-block:: bash

        salt-call -F
    u	cpu_flagsudisksu
pythonpathudnsugpus(RRtKeyErrort	TypeErrorRtupdate(R	RtkeyRtreqsR((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytlist_nodes_full}s
'


cC@s.tjj�}|jddddd�}|S(uK
    List the nodes, ask all 'vagrant' minions, return dict of grains.
    usalt-cloud:driver:vagrantugrains.itemsuttgt_typeugrain(tsalttclienttLocalClienttcmd(R	tlocalR((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyR�scC@s#tjjjtd�td|�S(u[
    Return a list of the minions that have salt-cloud grains, with
    select fields.
    ufunctionuquery.selection(R(tutilstcloudtlist_nodes_selectR&t__opts__(R	((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyR/�scC@sItjj�}|j|dd�}t|�}||j||�|S(u8
    List the a single node, return dict of grains.
    ugrains.itemsu(R(R)R*R+RR#(RR	R,RR%((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyt
show_instance�s
cC@s%tjj�}|j|ddg�S(Nu
grains.getu
salt-cloud(R(R)R*R+(RR,((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyt_get_my_info�scC@s�|d}tjd|tdd�}||d<tjd|tdt�}tjd|tdd�|d<tjd|tdtjd	��|d
<tjd|tdd�|d
<tjd|tdd�|d<ii|d6|d6d6|d<tjd|||�tj	j
�}|j|d|gdi|d6td6�}tjd||�tjd|tdd�}d|kr�|j|d|gdi|d6td6�|}nt
j��2}d|kr|r|jdt�r|j|d�|j�tjd|j�|j|d<nd|kr�yZ|jd|d�|jd�ra|d|d<n"|d|d<|jd |d �Wq�ttfk
r�td!j|���q�Xntjd"|||d�td#|t�}|SWd$QXd$S(%u~
    Provision a single machine

    CLI Example:

    .. code-block:: bash

        salt-cloud -p my_profile new_node_1

    unameumachinetdefaultuuhostucwdu/u
vagrant_runasu	SUDO_USERurunasuvagrant_up_timeouti,utimeoutuvagrant_providerusalt-cloud:vagrantugrainsu2sending 'vagrant.init %s machine=%s' command to %suvagrant.inittkwarguvmustarturesponse ==> %sunetwork_maskussh_hostuvagrant.get_ssh_configuget_private_keyuprivate_keyuwrote private key to %sukey_filenameussh_usernameu
ip_addressussh_portu.Insufficient SSH addressing information for {}u/Provisioning machine %s as node %s using ssh %sucloud.bootstrapN(tconfigtget_cloud_config_valueR0tNotImplementedtostgetenvtlogtinfoR(R)R*R+RttempfiletNamedTemporaryFiletgettFalsetwritetflushtdebugRt
setdefaultR!R"Rtformatt	__utils__(RRtmachinethostR,Rtnetwork_masktpks((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytcreate�s^

",		
$
	cC@stjttpdd�}|S(u/
    Return the first configured instance.
    uvagrantu(R5tis_provider_configuredR0t__active_provider_name__(R((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyR�s
		c	C@s�|dkrtd��nt}tddddj|�di|d6d	|d
d|d�t|�}|rm||d
}|d|}|d}tjj�}|j|d|g�}||rVtddddj|�di|d6d	|d
d|d�|j	dt
�tkrBtd|tj
d�d|�nidj|�d6Sidj|�d6Snidj|�d6SdS(um
    Destroy a node.

    CLI Example:

    .. code-block:: bash

        salt-cloud --destroy mymachine
    ufunctionuFThe destroy action must be called with -d, --destroy, -a, or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingtargsunametsock_dirusock_dirt	transportu	transportuprofileuprofilesuhostuvagrant.destroyudestroyed instanceusalt/cloud/{0}/destroyeduupdate_cachedirucloud.delete_minion_cachediru:iu{0} was destroyed.u	DestroyeduError destroying {}uErroru$No response from {}. Cannot destroy.N(RR0RERDR2R(R)R*R+R>R?RRLtsplit(	RR	toptstmy_infotprofile_nameR
RGR,R((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytdestroys@






cC@sr|dkrtd��nt|�}||d}td|}|d}tjj�}|j|d|g�S(u�
    Reboot a vagrant minion.

    name
        The name of the VM to reboot.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a reboot vm_name
    uactionu5The reboot action must be called with -a or --action.uprofileuprofilesuhostuvagrant.reboot(RR2R0R(R)R*R+(RR	RRRSR
RGR,((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pytreboot@s

(&t__doc__t
__future__RRRtloggingR8R<t
salt.utilsR(tsalt.configR5tsalt.clienttsalt._compatRtsalt.exceptionsRRRt	getLoggert__name__R:RtNoneR
RRRRR&RR/R1R2RJRRTRU(((s=/usr/lib/python2.7/site-packages/salt/cloud/clouds/vagrant.pyt<module>s2				
		A	
8

Zerion Mini Shell 1.0