Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/net_tools/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyo

�
�Udac@`stddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
dZydddlmZmZmZmZdd
lmZmZmZmZddlmZmZeZWn#ek
re
j�ZeZnXddl m!Z!m"Z"ddl#m$Z$m%Z%ddd��YZ&d�Z'e(dkrpe'�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysB
---
module: omapi_host
short_description: Setup OMAPI hosts.
description: Manage OMAPI hosts into compatible DHCPd servers
version_added: "2.3"
requirements:
  - pypureomapi
author:
- Loic Blot (@nerzhul)
options:
    state:
        description:
            - Create or remove OMAPI host.
        type: str
        required: true
        choices: [ absent, present ]
    hostname:
        description:
            - Sets the host lease hostname (mandatory if state=present).
        type: str
        aliases: [ name ]
    host:
        description:
            - Sets OMAPI server host to interact with.
        type: str
        default: localhost
    port:
        description:
            - Sets the OMAPI server port to interact with.
        type: int
        default: 7911
    key_name:
        description:
            - Sets the TSIG key name for authenticating against OMAPI server.
        type: str
        required: true
    key:
        description:
            - Sets the TSIG key content for authenticating against OMAPI server.
        type: str
        required: true
    macaddr:
        description:
            - Sets the lease host MAC address.
        type: str
        required: true
    ip:
        description:
            - Sets the lease host IP address.
        type: str
    statements:
        description:
            - Attach a list of OMAPI DHCP statements with host lease (without ending semicolon).
        type: list
        default: []
    ddns:
        description:
            - Enable dynamic DNS updates for this host.
        type: bool
        default: no

s�
- name: Add a host using OMAPI
  omapi_host:
    key_name: defomapi
    key: +bFQtBCta6j2vWkjPkNFtgA==
    host: 10.98.4.55
    macaddr: 44:dd:ab:dd:11:44
    name: server01
    ip: 192.168.88.99
    ddns: yes
    statements:
    - filename "pxelinux.0"
    - next-server 1.1.1.1
    state: present

- name: Remove a host using OMAPI
  omapi_host:
    key_name: defomapi
    key: +bFQtBCta6j2vWkjPkNFtgA==
    host: 10.1.1.1
    macaddr: 00:66:ab:dd:11:44
    state: absent
s�
lease:
    description: dictionary containing host information
    returned: success
    type: complex
    contains:
        ip-address:
            description: IP address, if there is.
            returned: success
            type: str
            sample: '192.168.1.5'
        hardware-address:
            description: MAC address
            returned: success
            type: str
            sample: '00:11:22:33:44:55'
        hardware-type:
            description: hardware type, generally '1'
            returned: success
            type: int
            sample: 1
        name:
            description: hostname
            returned: success
            type: str
            sample: 'mydesktop'
N(tOmapitOmapiMessaget
OmapiErrortOmapiErrorNotFound(tpack_ipt	unpack_iptpack_mact
unpack_mac(tOMAPI_OP_STATUStOMAPI_OP_UPDATE(t
AnsibleModuletmissing_required_lib(tto_bytest	to_nativetOmapiHostManagercB`sDeZd�Zd�Zd�Zed��Zd�Zd�ZRS(cC`s ||_d|_|j�dS(N(tmoduletNonetomapitconnect(tselfR((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyt__init__�s		cC`s�yDt|jjd|jjd|jjd|jjd�|_Wn�tjk
rm|jjdd�nbtk
r�}|jjddt|��n3t	j
k
r�}|jjddt|��nXdS(	Nthosttporttkey_nametkeytmsgsAUnable to open OMAPI connection. 'key' is not a valid base64 key.siUnable to open OMAPI connection. Ensure 'host', 'port', 'key' and 'key_name' are valid. Exception was: %ss%Unable to connect to OMAPI server: %s(RRtparamsRtbinasciitErrort	fail_jsonR
Rtsocketterror(Rte((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyR�s*cC`s�tjtddd��}|jjtddd�t|�f�|jjtddd�tjdd�f�|jj	|�}|j
tkr�dS|S(NRterrorstsurrogate_or_strictshardware-addresss
hardware-types!Ii(
R	topenRtobjtappendRtstructtpackRtquery_servertopcodeRR(RtmacaddrR!tresponse((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pytget_host�s(.cC`st|�}d|kr/t|d�|d<nd|krRt|d�|d<nd|kr{tjd|d�|d<n|S(Nshardware-addresss
ip-addresss
hardware-types!I(tdictRR
R.tunpack(R,tresult((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pytunpack_facts�sc	C`s�|jjddks2t|jjd�dkrH|jjdd�nd}|j|jjd�}|dkr�tjtddd��}|j	j
d	tjd
d�f�|j	j
dtjd
d�f�|j
j
d
t|jjd�f�|j
j
dtjd
d�f�|j
j
d|jjdf�|jjddk	r�|j
j
tddd�t|jjd�f�nd}|jjdr�|dj|jjd�7}nyJt|jjd�dkr|dj|jjd�7}|d7}nWn0tk
r7}|jjddt|��nXt|�dkrc|j
j
d|f�ny`|jj|�}|jtkr�|jjdd�n|jjdtd|j|j
��Wq�tk
r�}|jjddt|��q�Xn�|j|j
�}i}tddd�|ksUt|tddd��|jjdkrrt|jjd�|d<nd|ks�|d|jjdkr�|jjdd|d|jjdf�nt|�dkr�|jjdtd|�ntj|j�}|j |�yN|jj|�}|jt!krM|jjdd�n|jjdt�Wn0tk
r�}|jjddt|��nXdS(NthostnameiR!s@name attribute could not be empty when adding or modifying host.R2RR)R*tcreates!Iit	exclusiveshardware-addresss
hardware-typetnametips
ip-addressttddnssddns-hostname "{0}"; t
statementss; sInvalid statements found: %ssHFailed to add host, ensure authentication and host parameters are valid.tchangedtleasesOMAPI error: %ssZChanging hostname is not supported. Old was %s, new is %s. Please delete host and add new.sKFailed to modify host, ensure authentication and host parameters are valid.("RR"RtlenR%R4R	R+RtmessageR-R.R/R,RRtformattjoint	TypeErrorRRR0R1Rt	exit_jsontTrueR8R
R
tFalsetupdatethandlet
update_objectR(RR!t
host_responset	stmt_joinR(R3tresponse_objtfields_to_update((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyt
setup_host�sd2""&" 5 !)$,&

cC`s�y1|jj|jjd�|jjdt�WnMtk
rQ|jj�n0tk
r�}|jjddt	|��nXdS(NR2RAR!sOMAPI error: %s(
Rtdel_hostRR"RHRIRR
R%R(RR(((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pytremove_hosts
(	t__name__t
__module__RRR4tstaticmethodR8RRRT(((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyR�s					McC`s tdtdtdddtdddg�d	tddd
d�dtdd
d
d�dtdddt�dtdddtdt�dtdddt�dtddddg�dtdd�dtddd
t�dtddd
g��
dt�}ts|jdtd�dt�n|jddksJt
|jd�dkr]|jdd �n|jddks�t
|jd�dkr�|jdd!�nt|�}yD|jddkr�|j�n |jddkr�|j
�nWn-tk
r}|jdd"t|��nXdS(#Nt
argument_spectstatettypetstrtrequiredtchoicestabsenttpresentRtdefaultt	localhostRtinti�RR tno_logR2R9taliasesR<R=R?tboolR@tlisttsupports_check_modeR!tpypureomapit	exceptionis 'key' parameter cannot be empty.s%'key_name' parameter cannot be empty.sOMAPI input value error: %s(RR5RIRJtpureomapi_foundR%RtPUREOMAPI_IMP_ERRR"RRCRRRRTt
ValueErrorR(Rthost_managerR(((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pytmains6!	,,
t__main__(()t
__future__RRRRZt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR#R&R.t	tracebackRRkRhRR	R
RRR
RRRRRIRjtImportErrort
format_excRJtansible.module_utils.basicRRtansible.module_utils._textRRRRnRU(((sH/usr/lib/python2.7/site-packages/ansible/modules/net_tools/omapi_host.pyt<module>	s4


@""


�	$

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