def _cfg_exists(self, cfg_str):
        """Check a partial config string exists in the running config.

        :param cfg_str: config string to check
        :return : True or False
        """
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        cfg_raw = parse.find_lines("^" + cfg_str)
        LOG.debug("_cfg_exists(): Found lines %s", cfg_raw)
        return len(cfg_raw) > 0
    def _cfg_exists(self, cfg_str):
        """Check a partial config string exists in the running config.

        :param cfg_str: config string to check
        :return : True or False
        """
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        cfg_raw = parse.find_lines("^" + cfg_str)
        LOG.debug("_cfg_exists(): Found lines %s", cfg_raw)
        return len(cfg_raw) > 0
    def _get_interfaces(self):
        """Get a list of interfaces on this hosting device.

        :return: List of the interfaces
        """
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        itfcs_raw = parse.find_lines("^interface GigabitEthernet")
        itfcs = [raw_if.strip().split(' ')[1] for raw_if in itfcs_raw]
        LOG.debug("Interfaces on hosting device: %s", itfcs)
        return itfcs
    def _get_interfaces(self):
        """Get a list of interfaces on this hosting device.

        :return: List of the interfaces
        """
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        itfcs_raw = parse.find_lines("^interface GigabitEthernet")
        itfcs = [raw_if.strip().split(" ")[1] for raw_if in itfcs_raw]
        LOG.debug("Interfaces on hosting device: %s", itfcs)
        return itfcs
    def _get_interfaces(self):
        """Get a list of interfaces on this hosting device.

        :return: List of the interfaces
        """
        ioscfg = self._get_running_config()
        parse = HTParser(ioscfg)
        intfs_raw = parse.find_lines("^interface GigabitEthernet")
        intfs = [raw_if.strip().split(' ')[1] for raw_if in intfs_raw]
        LOG.info(_LI("Interfaces:%s"), intfs)
        return intfs
    def _get_vrfs(self):
        """Get the current VRFs configured in the device.

        :return: A list of vrf names as string
        """
        vrfs = []
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        vrfs_raw = parse.find_lines("^vrf definition")
        for line in vrfs_raw:
            #  raw format ['ip vrf <vrf-name>',....]
            vrf_name = line.strip().split(' ')[2]
            vrfs.append(vrf_name)
        LOG.info("VRFs:%s", vrfs)
        return vrfs
    def _get_vrfs(self):
        """Get the current VRFs configured in the device.

        :return: A list of vrf names as string
        """
        vrfs = []
        ios_cfg = self._get_running_config()
        parse = HTParser(ios_cfg)
        vrfs_raw = parse.find_lines("^vrf definition")
        for line in vrfs_raw:
            #  raw format ['ip vrf <vrf-name>',....]
            vrf_name = line.strip().split(" ")[2]
            vrfs.append(vrf_name)
        LOG.info(_LI("VRFs:%s"), vrfs)
        return vrfs
 def _get_static_route_cfg(self):
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     return parse.find_lines('ip route')
 def _get_floating_ip_cfg(self):
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     res = parse.find_lines('ip nat inside source static')
     return res
 def _interface_exists(self, interface):
     """Check whether interface exists."""
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     itfcs_raw = parse.find_lines("^interface " + interface)
     return len(itfcs_raw) > 0
Esempio n. 11
0
 def _get_config_by_regionid(self, regionid):
     """Get all config lines with the regionid."""
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     regid_raw = parse.find_lines("^.*" + regionid)
     return regid_raw
 def _get_static_route_cfg(self):
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     return parse.find_lines("ip route")
 def _get_floating_ip_cfg(self):
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     res = parse.find_lines("ip nat inside source static")
     return res
 def _interface_exists(self, interface):
     """Check whether interface exists."""
     ios_cfg = self._get_running_config()
     parse = HTParser(ios_cfg)
     itfcs_raw = parse.find_lines("^interface " + interface)
     return len(itfcs_raw) > 0