�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l Z d d l m
Z
d d
l m Z m Z m Z d d l m Z m Z d d l m Z m Z m Z d � Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: cpm_plugcontrol
version_added: "2.8"
author: "Western Telematic Inc. (@wtinetworkgear)"
short_description: Get and Set Plug actions on WTI OOB and PDU power devices
description:
- "Get and Set Plug actions on WTI OOB and PDU devices"
options:
cpm_action:
description:
- This is the Action to send the module.
required: true
choices: [ "getplugcontrol", "setplugcontrol" ]
cpm_url:
description:
- This is the URL of the WTI device to send the module.
required: true
cpm_username:
description:
- This is the Username of the WTI device to send the module.
cpm_password:
description:
- This is the Password of the WTI device to send the module.
use_https:
description:
- Designates to use an https connection or http connection.
required: false
type: bool
default: true
validate_certs:
description:
- If false, SSL certificates will not be validated. This should only be used
- on personally controlled sites using self-signed certificates.
required: false
type: bool
default: true
use_proxy:
description: Flag to control if the lookup will observe HTTP proxy environment variables when present.
required: false
type: bool
default: false
plug_id:
description:
- This is the plug number or the plug name that is to be manipulated
For the plugget command, the plug_id 'all' will return the status of all the plugs the
user has rights to access.
required: true
plug_state:
description:
- This is what action to take on the plug.
required: false
choices: [ "on", "off", "boot", "default" ]
so
# Get Plug status for all ports
- name: Get the Plug status for ALL ports of a WTI device
cpm_plugcontrol:
cpm_action: "getplugcontrol"
cpm_url: "rest.wti.com"
cpm_username: "restpower"
cpm_password: "restfulpowerpass12"
use_https: true
validate_certs: true
plug_id: "all"
# Get Plug status for port 2
- name: Get the Plug status for the given port of a WTI device
cpm_plugcontrol:
cpm_action: "getplugcontrol"
cpm_url: "rest.wti.com"
cpm_username: "restpower"
cpm_password: "restfulpowerpass12"
use_https: true
validate_certs: false
plug_id: "2"
# Reboot plug 5
- name: Reboot Plug 5 on a given WTI device
cpm_plugcontrol:
cpm_action: "setplugcontrol"
cpm_url: "rest.wti.com"
cpm_username: "restpower"
cpm_password: "restfulpowerpass12"
use_https: true
plug_id: "5"
plug_state: "boot"
sk
data:
description: The output JSON returned from the commands sent
returned: always
type: str
N( t
AnsibleModule( t to_textt to_bytest to_native( t HTTPErrort URLError( t open_urlt ConnectionErrort SSLValidationErrorc C` s� d } | j d j d � } x� | D]� } | j � t k rT d | t | � f } n d | t | � f } | j d d k r� d | t | j d � f } n d | } q# W| S( Nt t plug_idt ,s %s{"plug": "%s"s %s{"plugname": "%s"t
plug_states %s,"state": "%s"s %s}( t paramst splitt isdigitt TrueR t None( t cpmmodulet cpmresultt json_loadt plugspassedt val( ( sY /usr/lib/python2.7/site-packages/ansible/modules/remote_management/cpm/cpm_plugcontrol.pyt
assemble_json� s
c C` s� t d t d d d g d t � d t d d d t � d t d d d t � d
t d d d t d t � d t d d d t � d
t d d d d d g d t � d t d d d t � d t d d d t � d t d d d t � � } t d t d d � } t d | d t � } | j r| St t j t d j t
| j d � t
| j d
� � d d �� � } | j d t k rxd } n d } d } | j d d k r�d | t
| j d � f } | j d j
� d! k r�d"