Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/f5/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyc

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZyTdd
l
mZddlmZddlmZddlmZddlmZWnaek
r%dd
lmZddlmZddlmZddlmZddlmZnXdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZ d efd!��YZ!d"efd#��YZ"d$�Z#e$d%kre#�ndS(&i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bysh
---
module: bigiq_utility_license_assignment
short_description: Manage utility license assignment on BIG-IPs from a BIG-IQ
description:
  - Manages the assignment of utility licenses on a BIG-IQ. Assignment means that
    the license is assigned to a BIG-IP, or, it needs to be assigned to a BIG-IP.
    Additionally, this module supported revoking the assignments from BIG-IP devices.
version_added: 2.7
options:
  unit_of_measure:
    description:
      - Sets the rate at which this license usage is billed.
      - Depending on your license, you may have different units of measures
        available to you. If a particular unit is not available to you, the module
        will notify you at licensing time.
    type: str
    choices:
      - hourly
      - daily
      - monthly
      - yearly
    default: hourly
  key:
    description:
      - The registration key that you want choose an offering from.
    type: str
    required: True
  offering:
    description:
      - Name of the license offering to assign to the device.
    type: str
  device:
    description:
      - When C(managed) is C(no), specifies the address, or hostname, where the BIG-IQ
        can reach the remote device to register.
      - When C(managed) is C(yes), specifies the managed device, or device UUID, that
        you want to register.
      - If C(managed) is C(yes), it is very important that you do not have more than
        one device with the same name. BIG-IQ internally recognizes devices by their ID,
        and therefore, this module's cannot guarantee that the correct device will be
        registered. The device returned is the device that will be used.
    type: str
  managed:
    description:
      - Whether the specified device is a managed or un-managed device.
      - When C(state) is C(present), this parameter is required.
    type: bool
  device_port:
    description:
      - Specifies the port of the remote device to connect to.
      - If this parameter is not specified, the default of C(443) will be used.
    type: int
    default: 443
  device_username:
    description:
      - The username used to connect to the remote device.
      - This username should be one that has sufficient privileges on the remote device
        to do licensing. Usually this is the C(Administrator) role.
      - When C(managed) is C(no), this parameter is required.
    type: str
  device_password:
    description:
      - The password of the C(device_username).
      - When C(managed) is C(no), this parameter is required.
    type: str
  state:
    description:
      - When C(present), ensures that the device is assigned the specified license.
      - When C(absent), ensures the license is revokes from the remote device and freed
        on the BIG-IQ.
    type: str
    choices:
      - present
      - absent
    default: present
extends_documentation_fragment: f5
author:
  - Tim Rupp (@caphrim007)
s

- name: Register an unmanaged device
  bigiq_utility_license_assignment:
    key: XXXX-XXXX-XXXX-XXXX-XXXX
    offering: F5-BIG-MSP-AFM-10G-LIC
    device: 1.1.1.1
    managed: no
    device_username: admin
    device_password: secret
    state: present
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Register a managed device, by name
  bigiq_utility_license_assignment:
    key: XXXX-XXXX-XXXX-XXXX-XXXX
    offering: F5-BIG-MSP-AFM-10G-LIC
    device: bigi1.foo.com
    managed: yes
    state: present
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost

- name: Register a managed device, by UUID
  bigiq_utility_license_assignment:
    key: XXXX-XXXX-XXXX-XXXX-XXXX
    offering: F5-BIG-MSP-AFM-10G-LIC
    device: 7141a063-7cf8-423f-9829-9d40599fa3e0
    managed: yes
    state: present
    provider:
      password: secret
      server: lb.mydomain.com
      user: admin
  delegate_to: localhost
s
# only common fields returned
N(t
AnsibleModule(tF5RestClient(t
F5ModuleError(tAnsibleF5Parameters(tf5_argument_spec(tis_valid_ipt
ParameterscB`s~eZidd6dd6dd6dd6ZdddddgZddd	d
dddgZddd	d
dddgZd�ZRS(tdevice_referencetdeviceReferencetdevice_addresst
deviceAddresstdevice_portt	httpsPorttunit_of_measuret
unitOfMeasuretmanagedtdevice_usernametdevice_passwordcC`sXi}y:x$|jD]}t||�||<qW|j|�}Wntk
rSnX|S(N(treturnablestgetattrt_filter_paramst	Exception(tselftresultt
returnable((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt	to_return�s
(t__name__t
__module__tapi_maptapi_attributesRt
updatablesR!(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�s
t
ApiParameterscB`seZRS((R"R#(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR'�stModuleParameterscB`s�eZed��Zed��Zed��Zed��Zed��Zed��Zed��Z	ed��Z
ed��Zed	��ZRS(
cC`s"|jddkrdS|jdS(NR(t_valuestNone(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�scC`s"|jddkrdS|jdS(NR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�scC`s|jr|jdSdS(Ntdevice(tdevice_is_addressR)(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�s	cC`s(|jddkrdSt|jd�S(NR(R)R*tint(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�scC`st|j�rtStS(N(R
R+tTruetFalse(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR,�scC`s#d}tj||j�rtStS(NsK[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}(tretmatchR+R.R/(Rtpattern((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytdevice_is_id�scC`s|jr|jrtStS(N(R,R3R.R/(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytdevice_is_name�scC`s�|js
dS|jr+dj|j�}nT|jrIdj|j�}n6|jrgdj|j�}ntdj|j���dj|jj	d|jj	d|�}|jj
j|�}y|j�}Wn%t
k
r�}tt|���nX|jdkr#|d	d
kr#td��nMd|krp|dd
krpd|kr^t|d��qpt|j��n|dd
d}tddj|��}|S(Nsaddress+eq+'{0}...{0}'shostname+eq+'{0}'s
uuid+eq+'{0}'sUnknown device format '{0}'sghttps://{0}:{1}/mgmt/shared/resolver/device-groups/cm-bigip-allBigIpDevices/devices/?$filter={2}&$top=1tservertserver_porti�t
totalItemsis/No device with the specified address was found.tcodei�tmessagetitemstuuidtlinksYhttps://localhost/mgmt/shared/resolver/device-groups/cm-bigip-allBigIpDevices/devices/{0}(RR*R,tformatR+R4R3R
tclienttprovidertapitgettjsont
ValueErrortstrRt_contenttdict(RtfilterturitresptresponsetextidR((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�s<				

	cC`sdj|j�}dj|jjd|jjd|j|�}|jjj|�}y|j�}Wn%tk
r�}t	t
|���nX|jdkr�|ddkr�t	d��nMd	|kr	|d	d
kr	d|kr�t	|d��q	t	|j��n|ddd
S(Ns(name+eq+'{0}')s_https://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings?$filter={3}&$top=1R5R6i�R7is.No offering with the specified name was found.R8i�R9R:RL(
R=tofferingR>R?tkeyR@RARBRCR
RDRRE(RRGRHRIRJRK((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytoffering_ids&

	cC`sz|jrdj|j�}nT|jr<dj|j�}n6|jrZdj|j�}ntdj|j���dj|jjd|jjd|j|j	|�}|jj
j|�}y|j�}Wn%t
k
r�}tt|���nX|jdkr|d	d
krdSd|krd|ddkrdd
|krRt|d
��qdt|j��n|dd
d}|S(NsdeviceAddress+eq+'{0}...{0}'sdeviceName+eq+'{0}'sdeviceMachineId+eq+'{0}'sUnknown device format '{0}'sehttps://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings/{3}/members/?$filter={4}R5R6i�R7iR8i�R9R:RL(R,R=R+R4R3R
R>R?RNROR@RARBRCRDRR*RE(RRGRHRIRJRKR((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt	member_id3s6			

	(
R"R#tpropertyRRRRR,R3R4RRORP(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR(�s)tChangescB`seZRS((R"R#(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRRXst
UsableChangescB`sbeZed��Zed��Zed��Zed��Zed��Zed��ZRS(cC`s|jdrdS|jdS(NRR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR]s
cC`s|jdrdS|jdS(NRR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRcs
cC`s|jdrdS|jdS(NRR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRis
cC`s|jdsdS|jdS(NRR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRos
cC`s|jdrdS|jdS(NRR(R)R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRus
cC`sdS(N(R*(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR{s(	R"R#RQRRRRRR(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRS\stReportableChangescB`seZRS((R"R#(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRT�st
DifferencecB`s&eZdd�Zd�Zd�ZRS(cC`s||_||_dS(N(twantthave(RRVRW((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt__init__�s	cC`s9yt||�}|SWntk
r4|j|�SXdS(N(RtAttributeErrort_Difference__default(RtparamR((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytcompare�s

cC`sQt|j|�}y&t|j|�}||kr7|SWntk
rL|SXdS(N(RRVRWRY(RR[tattr1tattr2((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt	__default�s
N(R"R#R*RXR\RZ(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRU�s	t
ModuleManagercB`s�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(cO`sg|jdd�|_t|jj�|_td|jjd|j�|_t�|_	t
�|_dS(NtmoduletparamsR>(RAR*RaR	RbR>R(RVR'RWRStchanges(Rtargstkwargs((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRX�s
!cC`sji}xBtjD]7}t|j|�dk	rt|j|�||<qqW|rftd|�|_ndS(NRb(RRRRVR*RRRc(RtchangedRN((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt_set_changed_options�scC`s�t|j|j�}tj}t�}xX|D]P}|j|�}|dkrUq.q.t|t�rt|j	|�q.|||<q.W|r�t
d|�|_tSt
S(NRb(RURVRWRR&RFR\R*t
isinstancetupdateRRRcR.R/(RtdiffR&Rftktchange((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt_update_changed_options�s		
cC`s|j�}|rtStS(N(RmR.R/(RR((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt
should_update�scC`s�t}t�}|jj}|dkr6|j�}n|dkrQ|j�}ntd|jj��}|j�}|j	|�|j	td|��|j
|�|S(NtpresenttabsentRbRf(R/RFRVtstateRoRpRTRcR!Rit_announce_deprecations(RRfRRqt
reportableRc((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytexec_module�s	

cC`sH|jdg�}x/|D]'}|jjd|dd|d�qWdS(Nt
__warningstmsgtversion(tpopRat	deprecate(RRtwarningstwarning((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRr�s


cC`s|j�rtS|j�S(N(texistsR/tcreate(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRo�scC`s�|jjdkrtSdj|jjd|jjd|jj|jj|jj�}|jj	j
|�}|jdkrtStS(Ns\https://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings/{3}/members/{4}R5R6i�(
RVRPR*R/R=R>R?RNROR@RARR.(RRHRI((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR|�s

		cC`sC|j�|jjrtS|j�|j�r?td��ntS(NsFailed to delete the resource.(RgRat
check_modeR.tremove_from_deviceR|R
(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytremove�s

cC`s�|j�|jjs[|jjdkr7td��n|jjdkr[td��q[n|jjrkt	S|j
�|j�s�td��n|j�t	S(NsIYou must specify a 'device_username' when working with unmanaged devices.sIYou must specify a 'device_password' when working with unmanaged devices.s$Failed to license the remote device.(
RgRVRRR*R
RRaR~R.tcreate_on_deviceR|twait_for_device_to_be_licensed(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR}�s 


cC`s|jj�}dj|jjd|jjd|jj|jj�}|jjsv|jj	|d<|jj
|d<n|jjj|d|�}y|j
�}Wn%tk
r�}tt|���nXd|kr|ddkrd	|krt|d	��qt|j��ndS(
NsYhttps://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings/{3}/members/R5R6tusernametpasswordRBR8i�R9(Rct
api_paramsR=R>R?RVRNRORRRR@tpostRBRCR
RDtcontent(RRbRHRIRJRK((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�
s$

	cC`sd}dj|jjd|jjd|jj|jj|jj�}x�|dkr|jjj|�}y|j	�}Wn%t
k
r�}tt|���nXd|kr�|ddkr�d|kr�t|d��q�t|j
��n|d	d
kr
|d7}qJd}qJWdS(Nis\https://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings/{3}/members/{4}R5R6iR8i�R9RtLICENSEDi(R=R>R?RVRNRORPR@RARBRCR
RDR�(RtcountRHRIRJRK((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�&s(

		
cC`s|j�r|j�StS(N(R|R�R/(R((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRp@s
cC`s�dj|jjd|jjd|jj|jj|jj�}i}|jjs�|j|j	j
��|jj|d<|jj|d<|jj|d<n|jj
j|d|�dS(Ns\https://{0}:{1}/mgmt/cm/device/licensing/pool/utility/licenses/{2}/offerings/{3}/members/{4}R5R6RLR�R�RB(R=R>R?RVRNRORPRRiRcR�RRR@tdelete(RRHRb((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyREs

		(R"R#RXRgRmRnRtRrRoR|R�R}R�R�RpR(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR`�s														tArgumentSpeccB`seZd�ZRS(cC`s/t|_tdtdt�dtddddddd	g�d
tdtdt�dtdt�d
tdd�dtdddd�dtdt�dtdt�dtdddddg��	}i|_|jjt�|jj|�ddd
d
ggd
tdddggd
tdggg|_dS(NRMtrequiredRtdefaultthourlytchoicestdailytmonthlytyearlyRNtno_logR+RttypetboolRR-i�RRRqRoRp(R.tsupports_check_modeRFt
argument_specRiRR/trequired_if(RR�((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyRXWs&		(R"R#RX(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyR�VscC`s�t�}td|jd|jd|j�}y,td|�}|j�}|j|�Wn)tk
r�}|j	dt
|��nXdS(NR�R�R�RaRv(R�RR�R�R�R`Rtt	exit_jsonR
t	fail_jsonRD(tspecRatmmtresultsRK((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pytmainss			t__main__(%t
__future__RRRR�t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR0tansible.module_utils.basicRt%library.module_utils.network.f5.bigiqR	t&library.module_utils.network.f5.commonR
RRt)library.module_utils.network.f5.ipaddressR
tImportErrort%ansible.module_utils.network.f5.bigiqt&ansible.module_utils.network.f5.commont)ansible.module_utils.network.f5.ipaddressRR'R(RRRSRTtobjectRUR`R�R�R"(((s_/usr/lib/python2.7/site-packages/ansible/modules/network/f5/bigiq_utility_license_assignment.pyt<module>sB


Q+
!�$�	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]