Ejemplo n.º 1
0
    def facts(self):
        if hasattr(self, '_facts'):
            return self._facts

        facts = {}
        facts['vendor'] = self.vendor

        sh_version_output = self.show('show version')
        facts.update(
            convert_dict_by_key(sh_version_output,
                                eos_key_maps.BASIC_FACTS_KM))

        uptime = int(time.time() - sh_version_output['bootupTimestamp'])
        facts['uptime'] = uptime
        facts['uptime_string'] = self._uptime_to_string(uptime)

        sh_hostname_output = self.show('show hostname')
        facts.update(
            convert_dict_by_key(sh_hostname_output, {},
                                fill_in=True,
                                whitelist=['hostname', 'fqdn']))

        facts['interfaces'] = self._get_interface_list()
        facts['vlans'] = self._get_vlan_list()

        self._facts = facts
        return facts
Ejemplo n.º 2
0
    def facts(self):
        if hasattr(self, '_facts'):
            return self._facts

        facts = {}
        facts['vendor'] = self.vendor

        sh_version_output = self.show('show version')
        facts.update(
            convert_dict_by_key(
                sh_version_output, eos_key_maps.BASIC_FACTS_KM))

        uptime = int(time.time() - sh_version_output['bootupTimestamp'])
        facts['uptime'] = uptime
        facts['uptime_string'] = self._uptime_to_string(uptime)

        sh_hostname_output = self.show('show hostname')
        facts.update(
            convert_dict_by_key(
                sh_hostname_output, {}, fill_in=True, whitelist=['hostname', 'fqdn']))

        facts['interfaces'] = self._get_interface_list()
        facts['vlans'] = self._get_vlan_list()

        self._facts = facts
        return facts
Ejemplo n.º 3
0
    def facts(self):
        if hasattr(self, '_facts'):
            return self._facts

        facts = {}
        facts['vendor'] = self.vendor

        version_data = self._raw_version_data()
        show_version_facts = convert_dict_by_key(version_data,
                                                 ios_key_maps.BASIC_FACTS_KM)

        facts.update(show_version_facts)

        uptime_full_string = version_data['uptime']
        facts['uptime'] = self._uptime_to_seconds(uptime_full_string)
        facts['uptime_string'] = self._uptime_to_string(uptime_full_string)

        facts['fqdn'] = 'N/A'
        facts['interfaces'] = list(x['intf']
                                   for x in self._interfaces_detailed_list())

        if show_version_facts['model'].startswith('WS'):
            facts['vlans'] = list(str(x['vlan_id']) for x in self._show_vlan())
        else:
            facts['vlans'] = []

        # ios-specific facts
        ios_facts = facts[IOS_SSH_DEVICE_TYPE] = {}
        ios_facts['config_register'] = version_data['config_register']

        self._facts = facts
        return facts
Ejemplo n.º 4
0
    def facts(self):
        if hasattr(self, '_facts'):
            return self._facts

        facts = {}
        facts['vendor'] = self.vendor

        version_data = self._raw_version_data()
        show_version_facts = convert_dict_by_key(version_data, ios_key_maps.BASIC_FACTS_KM)

        facts.update(show_version_facts)

        uptime_full_string = version_data['uptime']
        facts['uptime'] = self._uptime_to_seconds(uptime_full_string)
        facts['uptime_string'] = self._uptime_to_string(uptime_full_string)

        facts['fqdn'] = 'N/A'
        facts['interfaces'] = list(x['intf'] for x in self._interfaces_detailed_list())

        if show_version_facts['model'].startswith('WS'):
            facts['vlans'] = list(str(x['vlan_id']) for x in self._show_vlan())
        else:
            facts['vlans'] = []

        # ios-specific facts
        ios_facts = facts[IOS_SSH_DEVICE_TYPE] = {}
        ios_facts['config_register'] = version_data['config_register']

        self._facts = facts
        return facts
Ejemplo n.º 5
0
    def facts(self):
        if self._facts is None:
            version_data = self._raw_version_data()
            self._facts = convert_dict_by_key(version_data,
                                              ios_key_maps.BASIC_FACTS_KM)
            self._facts["vendor"] = self.vendor

            uptime_full_string = version_data["uptime"]
            self._facts["uptime"] = self._uptime_to_seconds(uptime_full_string)
            self._facts["uptime_string"] = self._uptime_to_string(
                uptime_full_string)
            self._facts["fqdn"] = "N/A"
            self._facts["interfaces"] = list(
                x["intf"] for x in self._interfaces_detailed_list())

            if self._facts["model"].startswith("WS"):
                self._facts["vlans"] = list(
                    str(x["vlan_id"]) for x in self._show_vlan())
            else:
                self._facts["vlans"] = []

            # ios-specific facts
            self._facts[self.device_type] = {
                "config_register": version_data["config_register"]
            }

        return self._facts
Ejemplo n.º 6
0
    def facts(self):
        if self._facts is None:
            version_data = self._raw_version_data()
            self._facts = convert_dict_by_key(version_data,
                                              ios_key_maps.BASIC_FACTS_KM)
            self._facts['vendor'] = self.vendor

            uptime_full_string = version_data['uptime']
            self._facts['uptime'] = self._uptime_to_seconds(uptime_full_string)
            self._facts['uptime_string'] = self._uptime_to_string(
                uptime_full_string)

            self._facts['fqdn'] = 'N/A'
            self._facts['interfaces'] = list(
                x['intf'] for x in self._interfaces_detailed_list())

            if self._facts['model'].startswith('WS'):
                self._facts['vlans'] = list(
                    str(x['vlan_id']) for x in self._show_vlan())
            else:
                self._facts['vlans'] = []

            # ios-specific facts
            self._facts[self.device_type] = {
                'config_register': version_data['config_register']
            }

        return self._facts
Ejemplo n.º 7
0
    def get(self, vlan_id):
        vlan_not_in_range_error(vlan_id)

        vlan_id = str(vlan_id)
        native_vlan_response = self.native_vlans.get(vlan_id)
        converted = convert_dict_by_key(native_vlan_response, VLAN_KM)
        converted['id'] = vlan_id

        return strip_unicode(converted)
Ejemplo n.º 8
0
    def get(self, vlan_id):
        vlan_not_in_range_error(vlan_id)

        vlan_id = str(vlan_id)
        native_vlan_response = self.native_vlans.get(vlan_id)
        converted = convert_dict_by_key(native_vlan_response, VLAN_KM)
        converted['id'] = vlan_id

        return strip_unicode(converted)
Ejemplo n.º 9
0
    def facts(self):
        if self._facts is None:
            sh_version_output = self.show("show version")
            self._facts = convert_dict_by_key(sh_version_output, eos_key_maps.BASIC_FACTS_KM)
            self._facts["vendor"] = self.vendor

            uptime = int(time.time() - sh_version_output["bootupTimestamp"])
            self._facts["uptime"] = uptime
            self._facts["uptime_string"] = self._uptime_to_string(uptime)

            sh_hostname_output = self.show("show hostname")
            self._facts.update(
                convert_dict_by_key(sh_hostname_output, {}, fill_in=True, whitelist=["hostname", "fqdn"])
            )

            self._facts["interfaces"] = self._get_interface_list()
            self._facts["vlans"] = self._get_vlan_list()

        return self._facts