%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/pbm.pyc

�
���^c@@s	dZddlmZmZmZddlZddlZddlm	Z	m
Z
mZy&ddlm
Z
mZmZeZWnek
r�eZnXeje�Zd�Zd�Zd�Zd	�Zd
�Zded�Zd�Zd
�Zd�Z d�Z!dS(u�
Library for VMware Storage Policy management (via the pbm endpoint)

This library is used to manage the various policies available in VMware

:codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com>

Dependencies
~~~~~~~~~~~~

- pyVmomi Python Module

pyVmomi
-------

PyVmomi can be installed via pip:

.. code-block:: bash

    pip install pyVmomi

.. note::

    versions of Python. If using version 6.0 of pyVmomi, Python 2.6,
    Python 2.7.9, or newer must be present. This is due to an upstream dependency
    in pyVmomi 6.0 that is not supported in Python versions 2.7 to 2.7.8. If the
    version of Python is not in the supported range, you will need to install an
    earlier version of pyVmomi. See `Issue #29537`_ for more information.

.. _Issue #29537: https://github.com/saltstack/salt/issues/29537

Based on the note above, to install an earlier version of pyVmomi than the
version currently listed in PyPi, run the following:

.. code-block:: bash

    pip install pyVmomi==5.5.0.2014.1.1
i(tabsolute_importtprint_functiontunicode_literalsN(tVMwareApiErrortVMwareRuntimeErrortVMwareObjectRetrievalError(tpbmtvimtvmodlcC@str
tStdfSdS(u,
    Only load if PyVmomi is installed.
    uJMissing dependency: The salt.utils.pbm module requires the pyvmomi libraryN(tHAS_PYVMOMItTruetFalse(((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pyt__virtual__>scC@s�tjjj|dddd�}tjd|�}y|j�j}Wn�tj	j
k
r�}tj|�t
dj|j���nftj	jk
r�}tj|�t
|j��n2tjk
r�}tj|�t|j��nX|S(ui
    Returns a profile manager

    service_instance
        Service instance to the host or vCenter
    tnsupbm/2.0tpathu/pbm/sdkuServiceInstanceu/Not enough permissions. Required privilege: {0}(tsalttutilstvmwaretget_new_service_instance_stubRtServiceInstancetRetrieveContenttprofileManagerRtfaulttNoPermissiontlogt	exceptionRtformattprivilegeIdtVimFaulttmsgRtRuntimeFaultR(tservice_instancetstubtpbm_sitprofile_managertexc((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytget_profile_managerIs 
	

cC@s�tjjj|dddd�}tjd|�}y|j�j}Wn�tj	j
k
r�}tj|�t
dj|j���nftj	jk
r�}tj|�t
|j��n2tjk
r�}tj|�t|j��nX|S(uj
    Returns a placement solver

    service_instance
        Service instance to the host or vCenter
    R
upbm/2.0Ru/pbm/sdkuServiceInstanceu/Not enough permissions. Required privilege: {0}(RRRRRRRtplacementSolverRRRRRRRRRRRRR(RR R!R"R#((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytget_placement_solverbs 
	

cC@stjjdtjjj�}y|j|�}Wn�tjjk
rq}t	j
|�tdj|j
���nftjjk
r�}t	j
|�t|j��n2tjk
r�}t	j
|�t|j��nXg}x|D]}|j|j�q�W|S(uv
    Returns a list of all capability definitions.

    profile_manager
        Reference to the profile manager.
    tresourceTypeu/Not enough permissions. Required privilege: {0}(RtprofiletResourceTypetResourceTypeEnumtSTORAGEtFetchCapabilityMetadataRRRRRRRRRRRRRtextendtcapabilityMetadata(R"tres_typetcap_categoriesR#tcap_definitionstcat((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytget_capability_definitions{s$
	


cC@s�y|j|�SWn�tjjk
rQ}tj|�tdj|j���nftjj	k
r�}tj|�t|j
��n2tjk
r�}tj|�t
|j
��nXdS(u�
    Returns a list of policies with the specified ids.

    profile_manager
        Reference to the profile manager.

    policy_ids
        List of policy ids to retrieve.
    u/Not enough permissions. Required privilege: {0}N(RRRRRRRRRRRRRR(R"t
policy_idsR#((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytget_policies_by_id�s

	

cC@sctjjdtjjj�}y|j|�}Wn�tjjk
rq}t	j
|�tdj|j
���nftjjk
r�}t	j
|�t|j��n2tjk
r�}t	j
|�t|j��nXt	jd|�gt||�D]'}|jjtjjjkr�|^q�}|r.|S|s=g}ng|D]}|j|krD|^qDS(uJ
    Returns a list of the storage policies, filtered by name.

    profile_manager
        Reference to the profile manager.

    policy_names
        List of policy names to filter by.
        Default is None.

    get_all_policies
        Flag specifying to return all policies, regardless of the specified
        filter.
    R'u/Not enough permissions. Required privilege: {0}upolicy_ids = %s(RR(R)R*R+tQueryProfileRRRRRRRRRRRRRttraceR5R'tname(R"tpolicy_namestget_all_policiesR/R4R#tptpolicies((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytget_storage_policies�s.
	

		cC@s�y|j|�Wn�tjjk
rQ}tj|�tdj|j���nftjj	k
r�}tj|�t|j
��n2tjk
r�}tj|�t
|j
��nXdS(u�
    Creates a storage policy.

    profile_manager
        Reference to the profile manager.

    policy_spec
        Policy update spec.
    u/Not enough permissions. Required privilege: {0}N(tCreateRRRRRRRRRRRRR(R"tpolicy_specR#((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytcreate_storage_policy�s

	

cC@s�y|j|j|�Wn�tjjk
rW}tj|�tdj|j	���nftjj
k
r�}tj|�t|j��n2tj
k
r�}tj|�t|j��nXdS(u�
    Updates a storage policy.

    profile_manager
        Reference to the profile manager.

    policy
        Reference to the policy to be updated.

    policy_spec
        Policy update spec.
    u/Not enough permissions. Required privilege: {0}N(tUpdatet	profileIdRRRRRRRRRRRRR(R"tpolicyR?R#((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pytupdate_storage_policy�s

	

cC@stjjd|jdd�}tjd|�y|j|�}Wn�tjj	k
r�}tj
|�tdj|j
���nftjjk
r�}tj
|�t|j��n2tjk
r�}tj
|�t|j��nXt||g�}|stdj|���n|dS(u�
    Returns the default storage policy reference assigned to a datastore.

    profile_manager
        Reference to the profile manager.

    datastore
        Reference to the datastore.
    thubIdthubTypeu	Datastoreuplacement_hub = %su/Not enough permissions. Required privilege: {0}u*Storage policy with id '{0}' was not foundi(Rt	placementtPlacementHubt_moIdRR7tQueryDefaultRequirementProfileRRRRRRRRRRRRR5R(R"t	datastorethubt	policy_idR#tpolicy_refs((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pyt'get_default_storage_policy_of_datastores(
	

	cC@s�tjjd|jdd�}tjd|�y|j|j|g�Wn�tj	j
k
r�}tj|�tdj
|j���nftj	jk
r�}tj|�t|j��n2tjk
r�}tj|�t|j��nXdS(u�
    Assigns a storage policy as the default policy to a datastore.

    profile_manager
        Reference to the profile manager.

    policy
        Reference to the policy to assigned.

    datastore
        Reference to the datastore.
    RERFu	Datastoreuplacement_hub = %su/Not enough permissions. Required privilege: {0}N(RRGRHRIRR7tAssignDefaultRequirementProfileRBRRRRRRRRRRRR(R"RCRKt
placement_hubR#((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pyt*assign_default_storage_policy_to_datastore,s 
	

("t__doc__t
__future__RRRtloggingtsalt.utils.vmwareRtsalt.exceptionsRRRtpyVmomiRRRR
R	tImportErrorRt	getLoggert__name__RRR$R&R3R5tNoneR=R@RDRORR(((s2/usr/lib/python2.7/site-packages/salt/utils/pbm.pyt<module>'s*


					)			!

Zerion Mini Shell 1.0