def execute_module(self): """ Execute the module :rtype: A dictionary :returns: The result from module execution """ result = {'changed': False} warnings = list() requests = list() existing_guest_virtual_machines_facts = self.get_guest_virtual_machines_facts( ) requests.extend(self.set_config(existing_guest_virtual_machines_facts)) if requests: if not self._module.check_mode: send_requests(self._module, requests=requests) result['changed'] = True result['requests'] = requests changed_guest_virtual_machines_facts = self.get_guest_virtual_machines_facts( ) result['before'] = existing_guest_virtual_machines_facts if result['changed']: result['after'] = changed_guest_virtual_machines_facts result['warnings'] = warnings return result
def populate_facts(self, connection, ansible_facts, data=None): """ Populate the facts for interfaces :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ if not data: request = [{ "path": "/rest/restconf/data/openconfig-interfaces:interfaces", "method": "GET" }] data = send_requests(self._module, requests=request) objs = [] if data: for d in data[0]["openconfig-interfaces:interfaces"]["interface"]: obj = self.render_config(self.generated_spec, d) if obj: objs.append(obj) ansible_facts['ansible_network_resources'].pop('interfaces', None) facts = {} if objs: params = utils.validate_config(self.argument_spec, {'config': objs}) facts['interfaces'] = params['config'] ansible_facts['ansible_network_resources'].update(facts) return ansible_facts
def populate_facts(self, connection, ansible_facts, data=None): """ Populate the facts for lldp_global :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ if not data: request = { "path": "/rest/restconf/data/openconfig-lldp:lldp/config/", "method": "GET", } data = send_requests(self._module, request) obj = {} if data: lldp_obj = self.render_config(self.generated_spec, data[0]) if lldp_obj: obj = lldp_obj ansible_facts['ansible_network_resources'].pop('lldp_global', None) facts = {} params = utils.validate_config(self.argument_spec, {'config': obj}) facts['lldp_global'] = params['config'] ansible_facts['ansible_network_resources'].update(facts) return ansible_facts
def execute_module(self): """ Execute the module :rtype: A dictionary :returns: The result from module execution """ result = {'changed': False} warnings = list() requests = list() commands = list() existing_interfaces_facts = self.get_interfaces_facts() req, cmd = self.set_config(existing_interfaces_facts) requests.extend(req) commands.extend(cmd) if requests: if not self._module.check_mode: send_requests(self._module, requests=requests) result['changed'] = True result['requests'] = requests if commands: if not self._module.check_mode: run_commands(self._module, commands=commands) result['changed'] = True result['commands'] = commands changed_interfaces_facts = self.get_interfaces_facts() result['before'] = existing_interfaces_facts if result['changed']: result['after'] = changed_interfaces_facts result['warnings'] = warnings return result
def populate_facts(self, connection, ansible_facts, data=None): """ Populate the facts for guest_virtual_machines :param connection: the device connection :param ansible_facts: Facts dictionary :param data: previously collected conf :rtype: dictionary :returns: facts """ if not data: requests = [{ "path": "/rest/restconf/data/extreme-virtual-service:virtual-services-config/", "method": "GET" }, { "path": "/rest/restconf/data/extreme-virtual-service:virtual-services-state/", "method": "GET" }] data = send_requests(self._module, requests=requests) objs = [] if data: obj = self.render_config(self.generated_spec, data) if obj: objs.extend(obj) ansible_facts['ansible_network_resources'].pop( 'guest_virtual_machines', None) facts = {} if objs: params = utils.validate_config(self.argument_spec, {'config': objs}) facts['guest_virtual_machines'] = params['config'] ansible_facts['ansible_network_resources'].update(facts) return ansible_facts