
    VhgF                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d dlmZmZmZ d dlmZmZ d	d	d
dddfdddddddfddddddfddddifdddddddfdddddddfgZd Zed k(  r e        y!y!)"    )absolute_importdivisionprint_functiona  
module: boot
short_description: Set boot configuration
version_added: 1.2.0
author:
  - Felix Fontein (@felixfontein)
description:
  - Set the boot configuration for a dedicated server.
seealso:
  - module: community.hrobot.ssh_key
    description: Add, remove or update SSH key.
  - module: community.hrobot.ssh_key_info
    description: Query information on SSH keys.
extends_documentation_fragment:
  - community.hrobot.robot
  - community.hrobot.attributes
  - community.hrobot.attributes.actiongroup_robot

attributes:
  action_group:
    version_added: 1.6.0
  check_mode:
    support: full
  diff_mode:
    support: none
  idempotent:
    support: full

options:
  server_number:
    description:
      - The server number of the server whose boot configuration to adjust.
    type: int
    required: true
  regular_boot:
    description:
      - If this option is provided, all special boot configurations are removed and the installed operating system will be
        booted up next (assuming it is bootable).
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: bool
    choices:
      - true
  rescue:
    description:
      - If this option is provided, the rescue system will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      os:
        description:
          - The operating system to use for the rescue system. Possible choices can change over time.
          - Currently, V(linux), V(linuxold), V(freebsd), V(freebsdold), V(freebsdax), V(freebsdbetaax), V(vkvm), and V(vkvmold)
            seem to be available.
        type: str
        required: true
      arch:
        description:
          - The architecture to use for the rescue system.
          - Not all architectures are available for all operating systems.
          - Defaults to V(64).
          - This option is deprecated and will be removed in community.hrobot 3.0.0.
        type: int
        choices:
          - 32
          - 64
      authorized_keys:
        description:
          - One or more SSH key fingerprints to equip the rescue system with. You can also specify the public key itself,
            the module will compute its fingerprint and pass it on to the Robot API.
          - Only fingerprints for SSH keys deposited in the Robot API can be used.
          - You can use the M(community.hrobot.ssh_key_info) module to query the SSH keys you can use, and the M(community.hrobot.ssh_key)
            module to add or update SSH keys.
        type: list
        elements: str
  install_linux:
    description:
      - If this option is provided, a Linux system install will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      dist:
        description:
          - The distribution to install.
        type: str
        required: true
      arch:
        description:
          - The architecture to use for the install.
          - Not all architectures are available for all distributions.
          - Defaults to V(64).
          - This option is deprecated and will be removed in community.hrobot 3.0.0.
        type: int
        choices:
          - 32
          - 64
      lang:
        description:
          - The language to use for the operating system.
        type: str
        required: true
      authorized_keys:
        description:
          - One or more SSH key fingerprints to equip the rescue system with. You can also specify the public key itself,
            the module will compute its fingerprint and pass it on to the Robot API.
          - Only fingerprints for SSH keys deposited in the Robot API can be used.
          - You can use the M(community.hrobot.ssh_key_info) module to query the SSH keys you can use, and the M(community.hrobot.ssh_key)
            module to add or update SSH keys.
        type: list
        elements: str
  install_vnc:
    description:
      - If this option is provided, a VNC installation will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      dist:
        description:
          - The distribution to install.
        type: str
        required: true
      arch:
        description:
          - The architecture to use for the install.
          - Not all architectures are available for all distributions.
          - Defaults to V(64).
          - This option is deprecated and will be removed in community.hrobot 3.0.0.
        type: int
        choices:
          - 32
          - 64
      lang:
        description:
          - The language to use for the operating system.
        type: str
        required: true
  install_windows:
    description:
      - If this option is provided, a Windows installation will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      lang:
        description:
          - The language to use for Windows.
        type: str
        required: true
  install_plesk:
    description:
      - If this option is provided, a Plesk installation will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      dist:
        description:
          - The distribution to install.
        type: str
        required: true
      arch:
        description:
          - The architecture to use for the install.
          - Not all architectures are available for all distributions.
          - Defaults to V(64).
          - This option is deprecated and will be removed in community.hrobot 3.0.0.
        type: int
        choices:
          - 32
          - 64
      lang:
        description:
          - The language to use for the operating system.
        type: str
        required: true
      hostname:
        description:
          - The hostname.
        type: str
        required: true
  install_cpanel:
    description:
      - If this option is provided, a cPanel installation will be activated for the next boot.
      - Precisely one of O(regular_boot), O(rescue), O(install_linux), O(install_vnc), O(install_windows), O(install_plesk),
        and O(install_cpanel) must be provided.
    type: dict
    suboptions:
      dist:
        description:
          - The distribution to install.
        type: str
        required: true
      arch:
        description:
          - The architecture to use for the install.
          - Not all architectures are available for all distributions.
          - Defaults to V(64).
          - This option is deprecated and will be removed in community.hrobot 3.0.0.
        type: int
        choices:
          - 32
          - 64
      lang:
        description:
          - The language to use for the operating system.
        type: str
        required: true
      hostname:
        description:
          - The hostname.
        type: str
        required: true
a  
---
- name: Disable all special boot configurations
  community.hrobot.boot:
    hetzner_user: foo
    hetzner_password: bar
    regular_boot: true

- name: Enable a rescue system (64bit Linux) for the next boot
  community.hrobot.boot:
    hetzner_user: foo
    hetzner_password: bar
    rescue:
      os: linux

- name: Enable a Linux install for the next boot
  community.hrobot.boot:
    hetzner_user: foo
    hetzner_password: bar
    install_linux:
      dist: CentOS 5.5 minimal
      lang: en
      authorized_keys:
        - 56:29:99:a4:5d:ed:ac:95:c1:f5:88:82:90:5d:dd:10
        - 15:28:b0:03:95:f0:77:b3:10:56:15:6b:77:22:a5:bb
a"  
configuration_type:
  description:
    - Describes the active boot configuration.
  returned: success
  type: str
  choices:
    - regular_boot
    - rescue
    - install_linux
    - install_vnc
    - install_windows
    - install_plesk
    - install_cpanel
password:
  description:
    - The root password for the active boot configuration, if available.
    - For non-rescue boot configurations, it is avised to change the root password as soon as possible.
  returned: success and if RV(configuration_type) is not V(regular_boot)
  type: str
)AnsibleModule)	urlencode)BASE_URLROBOT_DEFAULT_ARGUMENT_SPECfetch_url_json)FingerprintErrorextract_fingerprintrescue)osr   )archr   )authorized_keyzauthorized_key[]r   r   authorized_keysinstall_linuxlinux)distr   )langr   r   r   r   r   install_vncvncr   r   r   install_windowswindowsr   install_pleskplesk)hostnamer   r   r   r   r   install_cpanelcpanelc                  
   t        t        dd      t        ddg      t        dt        t        dd      t        ddd	gd
d      t        ddd                  t        dt        t        dd      t        ddd	gd
d      t        dd      t        ddd                  t        dt        t        dd      t        ddd	gd
d      t        dd                  t        dt        t        dd                  t        dt        t        dd      t        ddd	gd
d      t        dd      t        dd                  t        dt        t        dd      t        ddd	gd
d      t        dd      t        dd                        } | j                  t               t        | ddgdg      }|j                  d   }d}dj                  t        |      }t        ||ddg      \  }}|H|dk(  r|j                  d       |dk(  r|j                  d        t        d!j                  |            t        D ]s  \  }}}	|d"   j                  |      xs i j                  d#      s/|j                  |   r?d}|j                  rNd$j                  t        ||      }t        ||d%d&       u d'd d(}
t        D ];  \  }}}|j                  |   s||
d)<   |d"   j                  |      xs i }|j                  d*      |
d*<   i }|j                         D ]'  \  }\  }}|j                  |   |   }||g k(  r#|||<   ) d+}|j                  |   j                  |      rK|j                  |   |   }t        |      D ]  \  }}d,|v s	 t        |      ||<    ||j                  |   |<   |j                  d#      rd}|j                         D ]  \  }\  }}|j                  |   |   }||j                  |      }|r|d+k(  r|D cg c]
  }|d0   d1    }}t#        |t$              r)t'        |      }t#        |t$              s|g}t'        |      }||k7  sd} nd}|sd}|j                  sd$j                  t        ||      }|j                  d#      rt        ||d%d&       d2d3i}t        ||t)        |d      |d45      \  }}	|j                  |      xs i j                  d*      |
d*<   7d |
d*<   >  |j*                  d7d6|i|
 y # t         $ r4}|j                  d-j                  |||d.z   ||/             Y d }~d }~ww xY wc c}w )8NintT)typerequiredbool)r%   choicesdictstr    @   z3.0.0zcommunity.hrobot)r%   r(   removed_in_versionremoved_from_collectionlistF)r%   elementsno_logr   )r%   optionsr   r   )r   r    )server_numberregular_bootr   r   r   r   r   r!   )r4   r   r   r   r   r   r!   )argument_specsupports_check_modemutually_exclusiverequired_one_ofr3   z{0}/boot/{1}SERVER_NOT_FOUNDBOOT_NOT_AVAILABLE)accept_errorszCThis server does not exist, or you do not have access rights for it)msgz8There is no boot configuration available for this serverzUnexpected error {0}bootactivez{0}/boot/{1}/{2}DELETE)methodallow_empty_resultr4   )configuration_typepasswordrB   rC   r    z^Error while extracting fingerprint of {option_name}.{option_key}[{idx}]'s value {key!r}: {exc}   )option_name
option_keyidxkeyexcrI   fingerprintzContent-typez!application/x-www-form-urlencodedPOST)dataheadersr@   changed )r)   updater	   r   paramsformatr   r
   	fail_jsonAssertionErrorBOOT_CONFIGURATION_DATAget
check_modeitems	enumerater   r   
isinstancer/   sortedr   	exit_json)r5   moduler3   rO   urlresulterrorrF   
other_namedummyreturn_valuesr2   existingrM   rG   
result_keydata_keyoptionshouldindexrI   rJ   needs_changehasxrN   s                             i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/boot.pymainro   H  s   5vv6.52r(whz{ fuUK*
 
 54052r(whz{540 fuUK	1
  fd54052r(whz{540/
 
 &$5403
  54052r(whz{540ut4	1
  54052r(whz{540ut4	2
 9"MF 45#  M  N J  K	F MM/2MG 

-
8C"63?QSg>hiMFE&&!fg((![\3::5ABB +B V&Z6Nz*0b55h?VaHbG$$(//-Tvs8PTUV -M -D E5(Z==%2=M./f~))*5;H(0Z(@M*%D6=mmo (2
2Z{3J?>Vr\!'X	( +J}}[)--j9{3J?"+F"3 JE3cz,?,DF5M :@k*:6||H%$:A--/ ,6J 6X#]];7
CF~ ",,z2Cz->>@CD1qx6DD!#t,$Sk)&$7&,XF!'}'+,   $((,33HmZXC||H-&vs8X\]-/RSG$2&tT2 '%%MFE 28J1G1M20R0RS]0^M*-04M*-KE5N F6W66i  0 	",, %E  %L  %L0;/9(-	(+(+ %L %" -  	* Es   T"U""	U+)UU__main__N)
__future__r   r   r   r%   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.parser   ?ansible_collections.community.hrobot.plugins.module_utils.robotr   r	   r
   =ansible_collections.community.hrobot.plugins.module_utils.sshr   r   rV   ro   __name__rP       rn   <module>r|      s   A @Wr6
, 5 A  x A 
 g   A	   E    
 	 $  g   ,	   x   ,	" 5  FM7` zF r{   