Files
awx/awx/network_ui/action_plugins/create_process.py
Ben Thomasson f8d83638b0 Adds inventory tracking and templating to network UI groups and hosts.
* Adds group_id to Group table
* Adds inventory_group_id to Group table
* Adds creation of inventory hosts and groups from the network UI
* Changes network UI variables to be under awx key
* Fixes variables initial value
* Adds group membership association/disassociation
* Removes items from the inventory toolbar when loaded by a snaphot
* Adds nunjucks dependency to package.json
* Adds templating to hosts
* Adds templating for racks
* Adds site templating
* Adds group associations for sites
* Squashes migrations for network_ui
* Flake8 migrations
* Changes reserved field type to device_type, group_type, and process_type
* Allows blank values for all CharFields in network_ui models
* Changes reserved field type to device_type, group_type, and process_type
2018-03-23 17:00:23 -04:00

52 lines
2.0 KiB
Python

#---- create_process
from ansible.plugins.action import ActionBase
import requests
import json
class ActionModule(ActionBase):
BYPASS_HOST_LOOP = True
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
server = self._task.args.get('server',
"{0}:{1}".format(self._play_context.remote_addr,
self._play_context.port))
user = self._task.args.get('user', self._play_context.remote_user)
password = self._task.args.get('password', self._play_context.password)
var = self._task.args.get('var', None)
the_list = self._task.args.get('list', None)
list_var = self._task.args.get('list_var', None)
device = self._task.args.get('device', None)
name = self._task.args.get('name', None)
process_type = self._task.args.get('process_type', None)
id = self._task.args.get('id', 0)
url = server + '/api/v2/canvas/process/'
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(dict(device=device,
name=name,
process_type=process_type,
id=id,
)),
verify=False,
auth=(user, password),
headers=headers)
if var is not None:
result['ansible_facts'] = {var: response.json()}
elif list_var is not None:
if the_list is None:
the_list = []
the_list.append(response.json())
result['ansible_facts'] = {list_var: the_list}
return result