�
�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 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_bysb
---
module: cpm_user
version_added: "2.7"
author: "Western Telematic Inc. (@wtinetworkgear)"
short_description: Get various status and parameters from WTI OOB and PDU devices
description:
- "Get/Add/Edit Delete Users from WTI OOB and PDU devices"
options:
cpm_action:
description:
- This is the Action to send the module.
required: true
choices: [ "getuser", "adduser", "edituser", "deleteuser" ]
cpm_url:
description:
- This is the URL of the WTI device to send the module.
required: true
cpm_username:
description:
- This is the Basic Authentication Username of the WTI device to send the module.
required: true
cpm_password:
description:
- This is the Basic Authentication Password of the WTI device to send the module.
required: true
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
user_name:
description:
- This is the User Name that needs to be create/modified/deleted
required: true
user_pass:
description:
- This is the User Password that needs to be create/modified/deleted
- If the user is being Created this parameter is required
required: false
user_accesslevel:
description:
- This is the access level that needs to be create/modified/deleted
- 0 View, 1 User, 2 SuperUser, 3 Administrator
required: false
choices: [ 0, 1, 2, 3 ]
user_accessssh:
description:
- If the user has access to the WTI device via SSH
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_accessserial:
description:
- If the user has access to the WTI device via Serial ports
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_accessweb:
description:
- If the user has access to the WTI device via Web
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_accessapi:
description:
- If the user has access to the WTI device via RESTful APIs
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_accessmonitor:
description:
- If the user has ability to monitor connection sessions
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_accessoutbound:
description:
- If the user has ability to initiate Outbound connection
- 0 No , 1 Yes
required: false
choices: [ 0, 1 ]
user_portaccess:
description:
- If AccessLevel is lower than Administrator, which ports the user has access
required: false
user_plugaccess:
description:
- If AccessLevel is lower than Administrator, which plugs the user has access
required: false
user_groupaccess:
description:
- If AccessLevel is lower than Administrator, which Groups the user has access
required: false
user_callbackphone:
description:
- This is the Call Back phone number used for POTS modem connections
required: false
s�
# Get User Parameters
- name: Get the User Parameters for the given user of a WTI device
cpm_user:
cpm_action: "getuser"
cpm_url: "rest.wti.com"
cpm_username: "restuser"
cpm_password: "restfuluserpass12"
use_https: true
validate_certs: true
user_name: "usernumberone"
# Create User
- name: Create a User on a given WTI device
cpm_user:
cpm_action: "adduser"
cpm_url: "rest.wti.com"
cpm_username: "restuser"
cpm_password: "restfuluserpass12"
use_https: true
validate_certs: false
user_name: "usernumberone"
user_pass: "complicatedpassword"
user_accesslevel: 2
user_accessssh: 1
user_accessserial: 1
user_accessweb: 0
user_accessapi: 1
user_accessmonitor: 0
user_accessoutbound: 0
user_portaccess: "10011111"
user_plugaccess: "00000111"
user_groupaccess: "00000000"
# Edit User
- name: Edit a User on a given WTI device
cpm_user:
cpm_action: "edituser"
cpm_url: "rest.wti.com"
cpm_username: "restuser"
cpm_password: "restfuluserpass12"
use_https: true
validate_certs: false
user_name: "usernumberone"
user_pass: "newpasswordcomplicatedpassword"
# Delete User
- name: Delete a User from a given WTI device
cpm_user:
cpm_action: "deleteuser"
cpm_url: "rest.wti.com"
cpm_username: "restuser"
cpm_password: "restfuluserpass12"
use_https: true
validate_certs: true
user_name: "usernumberone"
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 t | j d � } | j d d k rc t | j d � d k rc d | t | j d � f } n | j d d k r� d | t | j d � f } n | j d d k r� d | t | j d � f } n | j d
d k r� d | t | j d
� f } n | j d d k r/d
| t | j d � f } n | j d d k rbd | t | j d � f } n | j d d k r�d | t | j d � f } n | j d d k r�d | t | j d � f } n | j d d k r�d | t | j d � f } n | j d d k r.d | t | j d � f } n | j d d k rad | t | j d � f } n | j d d k r�d | t | j d � f } n d | } | S( Ns {"users":{"username": "%s"t user_namet user_passi s %s,"newpasswd": "%s"t user_accesslevels %s,"accesslevel": %st user_portaccesss %s,"portaccess": %st user_plugaccesss %s,"plugaccess": %st user_groupaccesss %s,"groupaccess": %st user_accessserials %s,"accessserial": %st user_accesssshs %s,"accessssh": %st user_accesswebs %s,"accessweb": %st user_accessoutbounds %s,"accessoutbound": %st user_accessapis %s,"accessapi": %st user_accessmonitors %s,"accessmonitor": %st user_callbackphones %s,"callbackphone": "%s"s %s}}( R t paramst Nonet len( t cpmmodulet json_load( ( sR /usr/lib/python2.7/site-packages/ansible/modules/remote_management/cpm/cpm_user.pyt
assemble_json� s6 ,
c - C` s 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 d
t � d t d d
d t � d t d d
d t d d d
t � d t d d d t d d d d d d d g � d t d d d t d d d d d g � d t d d d t d d d d d g � d t d d d t d d d d d g � d t d d d t d d d d d g � d t d d d t d d d d d g � d t d d d t d d d d d g � d t d d
d t d d � d t d d
d t d d � d t d d
d t d d � d t d d
d t d d � d! t d d"