
    Vh                     t    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 Zed	k(  r e        y
y
)    )absolute_importdivisionprint_functiona+  
module: reset
short_description: Reset a dedicated server
version_added: 1.2.0
author:
  - Felix Fontein (@felixfontein)
description:
  - Reset a dedicated server with a software or hardware reset, or by requesting a manual reset.
seealso:
  - module: community.hrobot.reset_info
    description: Retrieve information on resetter.
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: none
    details:
      - This module performs an action on every invocation.

options:
  server_number:
    description:
      - The server number of the server to reset.
    type: int
    required: true
  reset_type:
    description:
      - How to reset the server.
      - V(software) is a software reset. This should be similar to pressing Ctrl+Alt+Del on the keyboard.
      - V(power) is a hardware reset similar to pressing the Power button. An ACPI signal is sent, and if the server is configured
        correctly, this will trigger a regular shutdown.
      - V(hardware) is a hardware reset similar to pressing the Restart button. The power is cycled for the server.
      - V(manual) is a manual reset. This requests a technician to manually do the shutdown while looking at the screen output.
        B(Be careful) and only use this when really necessary!
      - "Note that not every server supports every reset method! You can query the supported reset methods by using the
         RV(community.hrobot.reset_info#module:reset.type) return value of the M(community.hrobot.reset_info) module."
    type: str
    required: true
    choices:
      - software
      - hardware
      - power
      - manual
a)  
---
- name: Send ACPI signal to server to request controlled shutdown
  community.hrobot.reset:
    hetzner_user: foo
    hetzner_password: bar
    server_number: 1234
    state: power

- name: Make sure that the server supports manual reset
  community.hrobot.reset:
    hetzner_user: foo
    hetzner_password: bar
    server_number: 1234
    reset_type: manual
  check_mode: true

- name: Request a manual reset (by a technican)
  community.hrobot.reset:
    hetzner_user: foo
    hetzner_password: bar
    server_number: 1234
    reset_type: manual
#)AnsibleModule)	urlencode)BASE_URLROBOT_DEFAULT_ARGUMENT_SPECfetch_url_jsonc            	      X   t        t        dd      t        ddg d            } | j                  t               t        | d      }|j                  d	   }d
dddd|j                  d      }|j
                  rHdj                  t        |      }t        ||ddg      \  }}|s{||d   d   vrq|j                  d       n^ddi}t        |      }dj                  t        |      }t        ||t        |      |dg d      \  }}|r|dk(  r|j                  d       |rv|dk(  r|j                  d       |dk(  r|j                  d       |d k(  r|j                  d!       |d"k(  r|j                  d#       t        d$j                  |            |j                  d%       y )&NintT)typerequiredstr)softwarehardwarepowermanual)r   r   choices)server_number
reset_type)argument_specsupports_check_moder   swhwr   manr   z{0}/reset/{1}SERVER_NOT_FOUNDRESET_NOT_AVAILABLE)accept_errorsresetr   z8The chosen reset method is not supported for this server)msgzContent-typez!application/x-www-form-urlencoded)r   POST)INVALID_INPUTr   r   RESET_MANUAL_ACTIVERESET_FAILED)dataheadersmethodr   r#   zCThis server does not exist, or you do not have access rights for itz(The server has no reset option availabler$   z!A manual reset is already runningr%   z4The reset failed due to an internal error at HetznerzUnexpected error {0})changed)dictupdater
   r   params
check_modeformatr	   r   	fail_jsonr   AssertionError	exit_json)	r   moduler   r   urlresulterrorr'   r&   s	            j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/hrobot/plugins/modules/reset.pymainr7   g   s   5UT;fgM 45# F
 MM/2M	
 mmL!#J $$X}=&vsCUWlBmn6'?6+BB![\!#FG
 $$X}=&4}
 Uo-![\&&!fg))!KL))!DEN"!WX3::5ABB
T"    __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   r7   __name__ r8   r6   <module>rD      sS    A @4l2 
 4 A 3#l zF r8   