Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/netvisor/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pyo

�
�Udac@s�dZidd6dgd6dd6ZdZdZd	Zd
dlZd
dlmZda	da
dad
�Zd�Z
d�Zd�Zd�Zedkr�e�ndS(s& PN CLI cluster-create/cluster-delete s1.1tmetadata_versiont
deprecatedtstatust	communitytsupported_bys
---
module: pn_cluster
author: "Pluribus Networks (@amitsi)"
version_added: "2.2"
short_description: CLI command to create/delete a cluster.
deprecated:
  removed_in: '2.12'
  why: Doesn't support latest Pluribus Networks netvisor
  alternative: Latest modules will be pushed in Ansible future versions.
description:
  - Execute cluster-create or cluster-delete command.
  - A cluster allows two switches to cooperate in high-availability (HA)
    deployments. The nodes that form the cluster must be members of the same
    fabric. Clusters are typically used in conjunction with a virtual link
    aggregation group (VLAG) that allows links physically connected to two
    separate switches appear as a single trunk to a third device. The third
    device can be a switch,server, or any Ethernet device.
options:
  pn_cliusername:
    description:
      - Provide login username if user is not root.
    required: False
  pn_clipassword:
    description:
      - Provide login password if user is not root.
    required: False
  pn_cliswitch:
    description:
      - Target switch to run the cli on.
    required: False
    default: 'local'
  state:
    description:
      - Specify action to perform. Use 'present' to create cluster and 'absent'
        to delete cluster.
    required: true
    choices: ['present', 'absent']
  pn_name:
    description:
      - Specify the name of the cluster.
    required: true
  pn_cluster_node1:
    description:
      - Specify the name of the first switch in the cluster.
      - Required for 'cluster-create'.
  pn_cluster_node2:
    description:
      - Specify the name of the second switch in the cluster.
      - Required for 'cluster-create'.
  pn_validate:
    description:
      - Validate the inter-switch links and state of switches in the cluster.
    type: bool
s7
- name: create spine cluster
  pn_cluster:
    state: 'present'
    pn_name: 'spine-cluster'
    pn_cluster_node1: 'spine01'
    pn_cluster_node2: 'spine02'
    pn_validate: True
    pn_quiet: True

- name: delete spine cluster
  pn_cluster:
    state: 'absent'
    pn_name: 'spine-cluster'
    pn_quiet: True
s�
command:
  description: The CLI command run on the target node(s).
  returned: always
  type: str
stdout:
  description: The set of responses from the cluster command.
  returned: always
  type: list
stderr:
  description: The set of error responses from the cluster command.
  returned: on error
  type: list
changed:
  description: Indicates whether the CLI caused changes on the target.
  returned: always
  type: bool
i����N(t
AnsibleModulecCsw|jd}|jd}|jd}|rF|rFd||f}nd}|dkre|d7}n|d|7}|S(	s
    This method is to generate the cli portion to launch the Netvisor cli.
    It parses the username, password, switch parameters from module.
    :param module: The Ansible module to fetch username, password and switch
    :return: returns the cli string for further processing
    tpn_cliusernametpn_clipasswordtpn_cliswitchs"/usr/bin/cli --quiet --user %s:%s s/usr/bin/cli --quiet tlocals switch-local s switch (tparams(tmoduletusernametpasswordt	cliswitchtcli((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pytpn_cli�s



cCs�|jd}|jd}|jd}|d}tj|�}|j|�d}|j�}||krttanta||kr�tanta||kr�tantadS(s$
    This method checks for idempotency using the cluster-show command.
    If a cluster with given name exists, return NAME_EXISTS as True else False.
    If the given cluster-node-1 is already a part of another cluster, return
    NODE1_EXISTS as True else False.
    If the given cluster-node-2 is already a part of another cluster, return
    NODE2_EXISTS as True else False.
    :param module: The Ansible module to fetch input parameters
    :param cli: The CLI string
    :return Global Booleans: NAME_EXISTS, NODE1_EXISTS, NODE2_EXISTS
    tpn_nametpn_cluster_node1tpn_cluster_node2s9 cluster-show  format name,cluster-node-1,cluster-node-2 iN(	R
tshlextsplittrun_commandtTruetNAME_EXISTStFalsetNODE1_EXISTStNODE2_EXISTS(RRtnametnode1tnode2tshowtout((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pyt	check_cli�s 



			c
	Cs�|jd}|jd}t|�}tj|�}|j|�\}}}|j|�d}	|dkr�|jd|	d|j�dd|d	t�n|r�|jd|	d
|j�dd|d	t�n |jd|	dd|d	t�dS(
s
    This method executes the cli command on the target node(s) and returns the
    output. The module then exits based on the output.
    :param cli: the complete cli string to be executed on the target node(s).
    :param module: The Ansible module to fetch command
    Rtstateiitcommandtstderrtmsgs%s operation failedtchangedtstdouts%s operation completedN(	R
tget_command_from_stateRRRt	exit_jsontstripRR(
RRRR"R#tcmdtresultR terrt	print_cli((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pytrun_cli�s,

	

	

	
cCs4d}|dkrd}n|dkr0d}n|S(s�
    This method gets appropriate command name for the state specified. It
    returns the command name for the specified state.
    :param state: The state for which the respective command name is required.
    tpresentscluster-createtabsentscluster-deleteN(tNone(R"R#((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pyR(�s		cCs�tdtdtdtdd�dtdtdddt�dtdtddd	d
�dtdtdddd
dg�dtdtdd�dtdd�dtdd�dtdd��ddd
dddggdddggf�}|jd}|jd}|jd}|jd}|jd}t|�}t|�}|dkr4t||�ttkr�|j	dtdd|�nt
tkr�|j	dtdd|�nttkr�|j	dtdd|�n|d||f7}|d||f7}|tkr|d7}n|tkr4|d7}q4n|dkr�t||�ttkrv|j	dtdd|�n|d||f7}nt||�d S(!s' This section is for arguments parsing t
argument_specRtrequiredttypetstrRtno_logRtdefaultR	R"tchoicesR0R1RRRtpn_validatetbooltrequired_ifscluster-createtskippedR%s#Cluster with name %s already existss!Node %s already part of a clusters %s name %s s$cluster-node-1 %s cluster-node-2 %s s
 validate s
 no-validate scluster-deletes#Cluster with name %s does not existN(
RtdictRRR
R(RR!RR)RRR/(RR"Rt
cluster_node1t
cluster_node2tvalidateR#R((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pytmain�sd





				

	t__main__(t__doc__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRtansible.module_utils.basicRR2RRRRR!R/R(RBt__name__(((sP/usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/_pn_cluster.pyt<module>s$


9		&	,		K

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