コード例 #1
0
    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 []
        return remove_rsvd_interfaces(l3_interfaces_facts)
コード例 #2
0
    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
コード例 #3
0
    def get_l3_interfaces_facts(self, data=None):
        """ Get the 'facts' (the current configuration)

        :rtype: A dictionary
        :returns: The current configuration as a dictionary
        """
        if self.state not in self.ACTION_STATES:
            self.gather_subset = ["!all", "!min"]

        facts, _warnings = Facts(self._module).get_facts(
            self.gather_subset, self.gather_network_resources, data=data
        )

        l3_interfaces_facts = facts["ansible_network_resources"].get(
            "l3_interfaces"
        )
        self.platform = facts.get("ansible_net_platform", "")

        return remove_rsvd_interfaces(l3_interfaces_facts)