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 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_hsrp_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) hsrp_interfaces_facts = facts['ansible_network_resources'].get( 'hsrp_interfaces', []) return hsrp_interfaces_facts
def get_telemetry_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) telemetry_facts = facts['ansible_network_resources'].get('telemetry') if not telemetry_facts: return {} return telemetry_facts
def get_lacp_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) lacp_facts = facts['ansible_network_resources'].get('lacp') if not lacp_facts: return [] return lacp_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 """ 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 get_platform_type(self): default, _warnings = Facts( self._module).get_facts(legacy_facts_type=['default']) return default.get('ansible_net_platform', '')