def get_bfd_interfaces_facts(self): """ Get the 'facts' (the current configuration) :returns: A list of interface configs and a platform string """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources) bfd_interfaces_facts = facts['ansible_network_resources'].get( 'bfd_interfaces', []) platform = facts.get('ansible_net_platform', '') return bfd_interfaces_facts, platform
def __init__(self, module): super(Snmp, self).__init__(empty_fact_val={}, facts_module=Facts(module), module=module, resource='snmp', tmplt=SnmpTemplate()) self.want = self.want
def get_interfaces_facts(self, get_default_interfaces=False): """ Get the 'facts' (the current configuration) :get_default_interfaces: boolean - when True include a list of existing-but-default interface names in the facts dict. - The defaults list is primarily used to detect non-existent virtual interfaces. :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources) interfaces_facts = facts['ansible_network_resources'].get('interfaces') interfaces_facts = remove_rsvd_interfaces(interfaces_facts) if get_default_interfaces: default_interfaces = facts['ansible_network_resources'].get( 'default_interfaces', []) interfaces_facts.append(default_interfaces) self.intf_defs = facts.get('intf_defs', {}) return interfaces_facts
def get_interfaces_facts(self): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts(self.gather_subset, self.gather_network_resources) interfaces_facts = facts['ansible_network_resources'].get('interfaces') if not interfaces_facts: return [] return interfaces_facts
def get_acls_facts(self, data=None): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data) acls_facts = facts['ansible_network_resources'].get('acls') if not acls_facts: return [] return acls_facts
def get_lldp_global_facts(self): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources) lldp_global_facts = facts['ansible_network_resources'].get( 'lldp_global') if not lldp_global_facts: return {} return lldp_global_facts
def get_l3_interfaces_facts(self): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts(self.gather_subset, self.gather_network_resources) l3_interfaces_facts = facts['ansible_network_resources'].get('l3_interfaces') if not l3_interfaces_facts: return [] self.platform = self.get_platform_type() return remove_rsvd_interfaces(l3_interfaces_facts)
def get_vlans_facts(self): """ Get the 'facts' (the current configuration) :rtype: A dictionary :returns: The current configuration as a dictionary """ facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources) vlans_facts = facts['ansible_network_resources'].get('vlans') if not vlans_facts: return [] # Remove vlan 1 from facts list vlans_facts = [i for i in vlans_facts if (int(i['vlan_id'])) != 1] return vlans_facts
def main(): """ Main entry point for module execution :returns: ansible_facts """ module = AnsibleModule(argument_spec=FactsArgs.argument_spec, supports_check_mode=True) warnings = ['default value for `gather_subset` ' 'will be changed to `min` from `!config` v2.11 onwards'] result = Facts(module).get_facts() ansible_facts, additional_warnings = result warnings.extend(additional_warnings) module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
def main(): """ Main entry point for module execution :returns: ansible_facts """ argument_spec = FactsArgs.argument_spec argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = [] if module.params["gather_subset"] == "!config": warnings.append('default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards') result = Facts(module).get_facts() ansible_facts, additional_warnings = result warnings.extend(additional_warnings) module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
def __init__(self, module): super(Acls, self).__init__(empty_fact_val=[], facts_module=Facts(module), module=module, resource='acls', tmplt=ACLsTemplate())
def get_platform_type(self): default, _warnings = Facts(self._module).get_facts(legacy_facts_type=['default']) return default.get('ansible_net_platform', '')