Anons79 Mini Shell

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

�
�Udac@s idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZd	dlmZm	Z	d	d
lm
Z
mZd	dlm
Z
dd�Zd�Zd�Zd�Zed�Zd�Zd
d�Zd
d�Zd�Zd
d�Zd
d�Zd�Zedkre�nd
S(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys4	
---
module: nxos_install_os
extends_documentation_fragment: nxos
short_description: Set boot options like boot, kickstart image and issu.
description:
    - Install an operating system by setting the boot options like boot
      image and kickstart image and optionally select to install using
      ISSU (In Server Software Upgrade).
notes:
    - Tested against the following platforms and images
      - N9k 7.0(3)I4(6), 7.0(3)I5(3), 7.0(3)I6(1), 7.0(3)I7(1), 7.0(3)F2(2), 7.0(3)F3(2)
      - N3k 6.0(2)A8(6), 6.0(2)A8(8), 7.0(3)I6(1), 7.0(3)I7(1)
      - N7k 7.3(0)D1(1), 8.0(1), 8.1(1), 8.2(1)
    - This module requires both the ANSIBLE_PERSISTENT_CONNECT_TIMEOUT and
      ANSIBLE_PERSISTENT_COMMAND_TIMEOUT timers to be set to 600 seconds or higher.
      The module will exit if the timers are not set properly.
    - When using connection local, ANSIBLE_PERSISTENT_CONNECT_TIMEOUT and
      ANSIBLE_PERSISTENT_COMMAND_TIMEOUT can only be set using ENV variables or
      the ansible.cfg file.
    - Do not include full file paths, just the name of the file(s) stored on
      the top level flash directory.
    - This module attempts to install the software immediately,
      which may trigger a reboot.
    - In check mode, the module will indicate if an upgrade is needed and
      whether or not the upgrade is disruptive or non-disruptive(ISSU).
author:
    - Jason Edelman (@jedelman8)
    - Gabriele Gerbibo (@GGabriele)
version_added: 2.2
options:
    system_image_file:
        description:
            - Name of the system (or combined) image file on flash.
        required: true
    kickstart_image_file:
        description:
            - Name of the kickstart image file on flash.
              (Not required on all Nexus platforms)
    issu:
        version_added: "2.5"
        description:
            - Upgrade using In Service Software Upgrade (ISSU).
              (Supported on N5k, N7k, N9k platforms)
            - Selecting 'required' or 'yes' means that upgrades will only
              proceed if the switch is capable of ISSU.
            - Selecting 'desired' means that upgrades will use ISSU if possible
              but will fall back to disruptive upgrade if needed.
            - Selecting 'no' means do not use ISSU. Forced disruptive.
        choices: ['required','desired', 'yes', 'no']
        default: 'no'
s
- name: Install OS on N9k
  check_mode: no
  nxos_install_os:
    system_image_file: nxos.7.0.3.I6.1.bin
    issu: desired

- name: Wait for device to come back up with new image
  wait_for:
    port: 22
    state: started
    timeout: 500
    delay: 60
    host: "{{ inventory_hostname }}"

- name: Check installed OS for newly installed version
  nxos_command:
    commands: ['show version | json']
    provider: "{{ connection }}"
  register: output
- assert:
    that:
    - output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I6(1)'
sm
install_state:
    description: Boot and install information.
    returned: always
    type: dict
    sample: {
    "install_state": [
        "Compatibility check is done:",
        "Module  bootable          Impact  Install-type  Reason",
        "------  --------  --------------  ------------  ------",
        "     1       yes  non-disruptive         reset  ",
        "Images will be upgraded according to following table:",
        "Module       Image                  Running-Version(pri:alt)           New-Version  Upg-Required",
        "------  ----------  ----------------------------------------  --------------------  ------------",
        "     1        nxos                               7.0(3)I6(1)           7.0(3)I7(1)           yes",
        "     1        bios                        v4.4.0(07/12/2017)    v4.4.0(07/12/2017)            no"
    ],
    }
i����N(tsleep(tload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulettextcCs$i|d6|d6g}t||�S(Ntcommandtoutput(R(tmoduleRR
tcmds((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytexecute_show_command�s
cCs�t|dd�}|ddddd}tjd|�rGd}nrtjd|�rbd}nWtjd	|�r}d	}n<tjd
|�r�d
}n!tjd|�r�d}nd}|S(
sDetermine platform typesshow inventorytjsonit	TABLE_invtROW_invt	productidtN3KtN5KtN6KtN7KtN9Ktunknown(Rtretsearch(Rtdatatpidttype((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytget_platform�s					cCsmt|�dkr!t|�}ni|d6}g|d<t|d<t|d<t|d<t|d<t|d<t|d	<t|d
<t|d<t|t�r�|dkr�t|d	<nK|d
kr�t|d	<n2|dkr�t|d	<n|dkr�t|d	<n|S|jd�|d<xT|dD]H}tjd|�rCt|d<Pntjd|�rmt|d<t|d<Pntjd|�r�t|d<Pntjd|�r�t|d<Pntjd|�r�t|d	<Pntjd|�r�t|d	<Pntjd|�r
t|d	<Pntjd|�r-t|d
<Pntjd|�rMt|d
<Pntjd|�rmt|d
<Pntjd|�r�t|d
<t|d<Pntjd|�r�t|d
<t|d<Pntjd|�r�|dj	|�qnd}tj||�}|r�|dj	|�d |j
d�}d}|j
d!�d"kr[it|6||<nt||<it|6||<d#}|j
d$�d%kr�||jit|6�q||jit|6�qntjd&|�}|r|dj	|�d'|j
d�|j
d$�f}d}|j
d(�d%krNt||<it|6||<qit|6||<qqqW|S()shHelper method to parse the output of the 'show install all impact' or
        'install all' commands.

    Sample Output:

    Installer will perform impact only check. Please wait.

    Verifying image bootflash:/nxos.7.0.3.F2.2.bin for boot variable "nxos".
    [####################] 100% -- SUCCESS

    Verifying image type.
    [####################] 100% -- SUCCESS

    Preparing "bios" version info using image bootflash:/nxos.7.0.3.F2.2.bin.
    [####################] 100% -- SUCCESS

    Preparing "nxos" version info using image bootflash:/nxos.7.0.3.F2.2.bin.
    [####################] 100% -- SUCCESS

    Performing module support checks.
    [####################] 100% -- SUCCESS

    Notifying services about system upgrade.
    [####################] 100% -- SUCCESS



    Compatibility check is done:
    Module  bootable          Impact  Install-type  Reason
    ------  --------  --------------  ------------  ------
         8       yes      disruptive         reset  Incompatible image for ISSU
        21       yes      disruptive         reset  Incompatible image for ISSU


    Images will be upgraded according to following table:
    Module       Image  Running-Version(pri:alt)    New-Version   Upg-Required
    ------  ----------  ----------------------------------------  ------------
         8       lcn9k                7.0(3)F3(2)    7.0(3)F2(2)           yes
         8        bios                     v01.17         v01.17            no
        21       lcn9k                7.0(3)F3(2)    7.0(3)F2(2)           yes
        21        bios                     v01.70         v01.70            no
    itrawt	processedt
disruptivetupgrade_neededterrortinvalid_commandtinstall_in_progresstserver_errortupgrade_succeededtuse_impact_datai����i�i����is
t	list_datasPre-upgrade check faileds[I|i]nvalid commandsNo install all data founds.Another install procedure may\s*be in progresssBackend processing errors	timed outs^(-1|5\d\d)$sFinishing the upgradesInstall has been successfulsSwitching over onto standbys)timeout .*trying to send command: installs![C|c]onnection failure: timed outs%----|Module|Images will|Compatibilitys3(\d+)\s+(\S+)\s+(disruptive|non-disruptive)\s+(\S+)sm%sisnon-disruptivetbootableityess((\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(yes|no)sm%s_%si(tlentmassage_install_datatFalset
isinstancetinttTruetsplitRRtappendtgrouptupdate(Rtudtxtrdtmotkeytfield((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytparse_show_install�s�+





























	"

cCs�d}t|�dkr%|d}n%t|�dkrD|d}n|}t|�dkr�t|dt�r�d|dj�kr�|dd}q�d|dj�kr�|dddkr�|dd}q�|}n|S(	NsNo install all data foundiiitclierrortcodet500tmsg(R.R1tdicttkeys(Rtdefault_error_msgtresult_data((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pyR/Ls

%*	cCs�dg}tjd|�r9|dkr0d}q`d}n'|dkrNd}n|rZdnd}|dkr�d}|r�d}q�nd}|dkr�|jd	|||f�n|jd
||||f�|S(Nsterminal dont-asksrequired|desired|yessnon-disruptivettforcetimpactsshow install all impactsinstall alls
%s nxos %s %ss%s %s system %s kickstart %s(RRtNoneR5(tissutimagetkickRRHtcommandstissu_cmdtrootcmd((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytbuild_install_cmd_setds&				cCs�i|djd�d6}d|d<t|d<xC|dD]7}tjd|�}|r9|jd�|d<q9q9q9W|ddkr�t|d<n|S(	Nis
R!RGtversionR%s*(kickstart|system|NXOS):\s+version\s+(\S+)i(R4R0RRR6R3(Rtversion_dataR9R;((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytparse_show_version�s



cCs�t|dd�d}td�}d}t|d<d|}|g|d<tt||��}|dr�t|d<|d	|d	<n|d
|dkr�|dr�t|d<t|d
<d|}n|dk	rv|drvd|}	|dj|�tt||	��}
|
dr/t|d<|
d	|d	<n|d
|
dkrv|drvt|d<t|d
<|d|	}qvn|d	|d<||d<|S(s}Some platforms/images/transports don't support the 'install all impact'
        command so we need to use a different method.sshow versionRiRGsNo upgrade requiredR%sshow version image bootflash:%stupgrade_cmdR!tkickstart_ver_strRRR$R#sSwitch upgraded: system: %ss kickstart: %sR+R"N(RR>R0RTR3RJR5(RRKRLRMtcurrentRtupgrade_msgttsverttarget_imagettkverttarget_kick((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytcheck_mode_legacy�s8













cCs�itd6}t|||d�}tt||t|��}|dr�|dkr�d}t|||d�}t|||�}n|dr�t|d<n||d<|S(s3Use the 'install all impact' command for check_modetignore_timeoutRIR%tdesiredtnoR(RU(R3RQR>Rtcheck_install_in_progress(RRKRLRMtoptsRNR((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytcheck_mode_nextgen�s



cCsQxJtd�D]<}tt||t|��}|drHtd�q
nPq
W|S(NiR'i(trangeR>RR3R(RRNRbtattemptR((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pyRa�s

cCs]t||||�}|dr7t||||�}n|drYt||||�}n|S(sCCheck switch upgrade impact using 'show install all impact' commandR(R&(RcR](RRKRLRMR((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pyt
check_mode�s

c	Cs�t||||�}|jr9d}|dj|�|S|drG|S|dsU|S|dr�|dkr�d}|jd|d	|d
�q�d}nt|||d�}itd
6}t|||�}|drd|dkrt|||dt�}t|||�}n||d<|dr=t|d<t|d<n|drw|drd|}t|d<qw|}t|d<n|ds�t|d<n|S(s:Perform the switch upgrade using the 'install all' commands1*** SWITCH WAS NOT UPGRADED: IMPACT DATA ONLY ***R"R%R$R#R-sGISSU/ISSD requested but impact data indicates ISSU/ISSD is not possibleRBtraw_dataR+R`tinstallR^R&RHiRUR(R)R*(RfR5t	fail_jsonRQR3RaR0(	RRKRLRMtimpact_dataRBRNRbtupgrade((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytdo_install_all�sB	


	










cCsjtdtdt�dtdt�dtdddddgd	d��}|jt�td
|dt�}t�}t||�|jd}|jd}|jd}t	j
d|�r�d}n|d
ks�|dkr�d}nt|||d|�}|dr6|d}d|}|j
d|d|d�n|d}	|d}
|jd|
d|	d|�dS(Ntsystem_image_filetrequiredtkickstart_image_fileRKtchoicesR_R`R-tdefaultt
argument_spectsupports_check_modes(yes|required)tnullRGRMR%RUs*Failed to upgrade device using command: %sRBRgR+R"R$tchangedt
install_statetwarnings(RCR3R0R7RR
tlistR	tparamsRRRJRlRit	exit_json(RrRRwtsiftkifRKtinstall_resulttcmdRBtstateRu((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pytmain.s0$
		



		




t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRttimeRt&ansible.module_utils.network.nxos.nxosRRRR	tansible.module_utils.basicR
RR R>R/R3RQRTRJR]RcRaRfRlR�t__name__(((sP/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_install_os.pyt<module>s0


6			�	)	(	
<	&

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