예제 #1
0
파일: link.py 프로젝트: rkerr/ifupdown2
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)

        self.check_physical_port_existance = utils.get_boolean_from_string(
            policymanager.policymanager_api.get_module_globals(
                self.__class__.__name__, 'warn_on_physdev_not_present'))
예제 #2
0
    def __init__(self, *args, **kargs):
        moduleBase.__init__(self, *args, **kargs)
        self.ipcmd = None
        self.bondcmd = None
        self.dhclientcmd = None
        self.name = self.__class__.__name__
        self.vrf_mgmt_devname = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-mgmt-devname')

        self.user_reserved_vrf_table = []

        if (ifupdownflags.flags.PERFMODE and
            not (self.vrf_mgmt_devname and os.path.exists('/sys/class/net/%s'
            %self.vrf_mgmt_devname))):
            # if perf mode is set (PERFMODE is set at boot), and this is the first
            # time we are calling ifup at boot (check for mgmt vrf existance at
            # boot, make sure this is really the first invocation at boot.
            # ifup is called with PERFMODE at boot multiple times (once for mgmt vrf
            # and the second time with all auto interfaces). We want to delete
            # the map file only the first time. This is to avoid accidently
            # deleting map file with a valid mgmt vrf entry
            if os.path.exists(self.iproute2_vrf_filename):
                try:
                    self.logger.info('vrf: removing file %s'
                                     %self.iproute2_vrf_filename)
                    os.remove(self.iproute2_vrf_filename)
                except Exception, e:
                    self.logger.debug('vrf: removing file failed (%s)'
                                      %str(e))
예제 #3
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        self.dhclientcmd = dhclient(**kargs)

        vrf_id = self._get_vrf_context()
        if vrf_id and vrf_id == 'mgmt':
            self.mgmt_vrf_context = True
        else:
            self.mgmt_vrf_context = False
        self.logger.info('mgmt vrf_context = %s' % self.mgmt_vrf_context)

        try:
            self.dhclient_retry_on_failure = int(
                policymanager.policymanager_api.get_module_globals(
                    module_name=self.__class__.__name__,
                    attr="dhclient_retry_on_failure"))
        except Exception:
            self.dhclient_retry_on_failure = self.DHCLIENT_RETRY_ON_FAILURE

        if self.dhclient_retry_on_failure < 0:
            self.dhclient_retry_on_failure = 0

        self.logger.info("dhclient: dhclient_retry_on_failure set to %s" %
                         self.dhclient_retry_on_failure)
예제 #4
0
    def __init__(self, *args, **kargs):
        moduleBase.__init__(self, *args, **kargs)
        self.ipcmd = None
        self.bondcmd = None
        self.dhclientcmd = None
        self.name = self.__class__.__name__
        self.vrf_mgmt_devname = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-mgmt-devname')

        self.user_reserved_vrf_table = []

        if (ifupdownflags.flags.PERFMODE and
            not (self.vrf_mgmt_devname and os.path.exists('/sys/class/net/%s'
            %self.vrf_mgmt_devname))):
            # if perf mode is set (PERFMODE is set at boot), and this is the first
            # time we are calling ifup at boot (check for mgmt vrf existance at
            # boot, make sure this is really the first invocation at boot.
            # ifup is called with PERFMODE at boot multiple times (once for mgmt vrf
            # and the second time with all auto interfaces). We want to delete
            # the map file only the first time. This is to avoid accidently
            # deleting map file with a valid mgmt vrf entry
            if os.path.exists(self.iproute2_vrf_filename):
                try:
                    self.logger.info('vrf: removing file %s'
                                     %self.iproute2_vrf_filename)
                    os.remove(self.iproute2_vrf_filename)
                except Exception, e:
                    self.logger.debug('vrf: removing file failed (%s)'
                                      %str(e))
예제 #5
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        self._bridge_fdb_query_cache = {}
        self.addressvirtual_with_route_metric = utils.get_boolean_from_string(
            policymanager.policymanager_api.get_module_globals(
                module_name=self.__class__.__name__,
                attr='addressvirtual_with_route_metric'
            ),
            default=True
        )

        self.address_virtual_ipv6_addrgen_value_dict = {'on': 0, 'yes': 0, '0': 0, 'off': 1, 'no': 1, '1': 1}

        if addressvirtual.ADDR_METRIC_SUPPORT is None:
            try:
                cmd = [utils.ip_cmd, 'addr', 'help']
                self.logger.info('executing %s addr help' % utils.ip_cmd)

                process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                stdout, stderr = process.communicate()
                addressvirtual.ADDR_METRIC_SUPPORT = '[ metric METRIC ]' in stderr.decode() or ''
                self.logger.info('address metric support: %s' % ('OK' if addressvirtual.ADDR_METRIC_SUPPORT else 'KO'))
            except Exception:
                addressvirtual.ADDR_METRIC_SUPPORT = False
                self.logger.info('address metric support: KO')
예제 #6
0
    def __init__(self, *args, **kargs):
        moduleBase.__init__(self, *args, **kargs)
        self.ipcmd = None
        self.bondcmd = None

        if not os.path.exists('/sys/class/net/bonding_masters'):
            try:
                utils.exec_command('modprobe -q bonding')
            except Exception as e:
                self.logger.info("bond: error while loading bonding module: %s" % str(e))
예제 #7
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        self.dhclientcmd = dhclient(**kargs)

        vrf_id = self._get_vrf_context()
        if vrf_id and vrf_id == 'mgmt':
            self.mgmt_vrf_context = True
        else:
            self.mgmt_vrf_context = False
        self.logger.info('mgmt vrf_context = %s' % self.mgmt_vrf_context)
예제 #8
0
    def __init__(self, *args, **kargs):
        moduleBase.__init__(self, *args, **kargs)
        self.ipcmd = None
        self.bondcmd = None

        if not os.path.exists('/sys/class/net/bonding_masters'):
            try:
                utils.exec_command('modprobe -q bonding')
            except Exception as e:
                self.logger.info(
                    "bond: error while loading bonding module: %s" % str(e))
예제 #9
0
    def __init__ (self, *args, **kargs):
        moduleBase.__init__ (self, *args, **kargs)
        self.ipcmd = None

        for longname, entry in self._modinfo['attrs'].items ():
            if entry.get ('batman-attr', False) == False:
                continue

            attr = longname.replace ("batman-", "")
            self._batman_attrs[attr] = {
                 'filename' : attr.replace ("-", "_"),
            }
예제 #10
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)

        if not os.path.exists('/sys/class/net/bonding_masters'):
            try:
                utils.exec_command('modprobe -q bonding')
            except Exception as e:
                self.logger.info("bond: error while loading bonding module: %s" % str(e))

        self._bond_attr_ifquery_check_translate_func[Link.IFLA_BOND_PRIMARY] = self.cache.get_ifindex
        self._bond_attr_set_list = self._bond_attr_set_list + (('bond-primary', Link.IFLA_BOND_PRIMARY, self.cache.get_ifindex),)
예제 #11
0
    def __init__(self, *args, **kargs):
        moduleBase.__init__(self, *args, **kargs)
        self.ipcmd = None

        for longname, entry in self._modinfo['attrs'].items():
            if entry.get('batman-attr', False) == False:
                continue

            attr = longname.replace("batman-", "")
            self._batman_attrs[attr] = {
                'filename': attr.replace("-", "_"),
            }
예제 #12
0
파일: ethtool.py 프로젝트: rkerr/ifupdown2
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        if not os.path.exists(utils.ethtool_cmd):
            raise moduleNotSupported('module init failed: %s: not found' %
                                     utils.ethtool_cmd)
        # keep a list of iface objects who have modified link attributes
        self.ifaceobjs_modified_configs = []
        # Cache for features
        self.feature_cache = None

        self.ethtool_ignore_errors = policymanager.policymanager_api.get_module_globals(
            module_name=self.__class__.__name__, attr='ethtool_ignore_errors')
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        if not os.path.exists('/usr/sbin/batctl'):
            raise moduleNotSupported(
                'module init failed: no /usr/sbin/batctl found')

        for longname, entry in self._modinfo['attrs'].items():
            if entry.get('batman-attr', False):
                attr = longname.replace("batman-", "")
                self._batman_attrs[attr] = {
                    'filename': attr.replace("-", "_"),
                }
예제 #14
0
    def __init__ (self, *args, **kargs):
        moduleBase.__init__ (self, *args, **kargs)
        if not os.path.exists('/usr/sbin/batctl'):
            raise moduleNotSupported('module init failed: no /usr/sbin/batctl found')
        self.ipcmd = None

        for longname, entry in self._modinfo['attrs'].items ():
            if entry.get ('batman-attr', False) == False:
                continue

            attr = longname.replace ("batman-", "")
            self._batman_attrs[attr] = {
                 'filename' : attr.replace ("-", "_"),
            }
예제 #15
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)

        self._vxlan_purge_remotes = utils.get_boolean_from_string(
            policymanager.policymanager_api.get_module_globals(
                module_name=self.__class__.__name__,
                attr="vxlan-purge-remotes"))
        self._vxlan_local_tunnelip = None
        self._clagd_vxlan_anycast_ip = ""

        # If mcastgrp is specified we need to rely on a user-configred device (via physdev)
        # or via a policy variable "vxlan-physdev_mcastgrp". If the device doesn't exist we
        # create it as a dummy device. We need to keep track of the user configuration to
        # know when to delete this dummy device (when user remove mcastgrp from it's config)
        self.vxlan_mcastgrp_ref = False
        self.vxlan_physdev_mcast = policymanager.policymanager_api.get_module_globals(
            module_name=self.__class__.__name__, attr="vxlan-physdev-mcastgrp"
        ) or self.VXLAN_PHYSDEV_MCASTGRP_DEFAULT
예제 #16
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)

        if not os.path.exists('/sys/class/net/bonding_masters'):
            try:
                utils.exec_command('modprobe -q bonding')
            except Exception as e:
                self.logger.info(
                    "bond: error while loading bonding module: %s" % str(e))

        self._bond_attr_ifquery_check_translate_func[
            Link.IFLA_BOND_PRIMARY] = self.cache.get_ifindex
        self._bond_attr_set_list = self._bond_attr_set_list + (
            ('bond-primary', Link.IFLA_BOND_PRIMARY, self.cache.get_ifindex), )

        self.bond_mac_mgmt = utils.get_boolean_from_string(
            policymanager.policymanager_api.get_module_globals(
                module_name=self.__class__.__name__, attr="bond_mac_mgmt"),
            True)
예제 #17
0
 def __init__(self, *args, **kargs):
     moduleBase.__init__(self, *args, **kargs)
     self.brctlcmd = None
     self.ipcmd = None
예제 #18
0
 def __init__(self, *args, **kargs):
     moduleBase.__init__(self, *args, **kargs)
     Addon.__init__(self)
     if not os.path.exists('/usr/bin/ovs-vsctl'):
         raise moduleNotSupported(
             'module init failed: no /usr/bin/ovs-vsctl found')
예제 #19
0
 def __init__(self, *args, **kargs):
     Addon.__init__(self)
     moduleBase.__init__(self, *args, **kargs)
     if not os.path.exists('/usr/bin/pon'):
         raise moduleNotSupported(
             'module init failed: no /usr/bin/pon found')
예제 #20
0
 def __init__(self, *args, **kargs):
     Addon.__init__(self)
     moduleBase.__init__(self, *args, **kargs)
예제 #21
0
 def __init__(self, *args, **kargs):
     moduleBase.__init__(self, *args, **kargs)
예제 #22
0
 def __init__(self, *args, **kargs):
     moduleBase.__init__(self, *args, **kargs)
     self.brctlcmd = None
     self.ipcmd = None
예제 #23
0
파일: vrrpd.py 프로젝트: rkerr/ifupdown2
 def __init__(self, *args, **kargs):
     moduleBase.__init__(self, *args, **kargs)
예제 #24
0
    def __init__(self, *args, **kargs):
        Addon.__init__(self)
        moduleBase.__init__(self, *args, **kargs)
        self.dhclientcmd = None
        self.name = self.__class__.__name__
        self.vrf_mgmt_devname = policymanager.policymanager_api.get_module_globals(
            module_name=self.__class__.__name__,
            attr="vrf-mgmt-devname"
        )

        self.at_exit = False

        self.user_reserved_vrf_table = []

        if (ifupdownflags.flags.PERFMODE and
            not (self.vrf_mgmt_devname and os.path.exists('/sys/class/net/%s'
            %self.vrf_mgmt_devname))):
            # if perf mode is set (PERFMODE is set at boot), and this is the first
            # time we are calling ifup at boot (check for mgmt vrf existance at
            # boot, make sure this is really the first invocation at boot.
            # ifup is called with PERFMODE at boot multiple times (once for mgmt vrf
            # and the second time with all auto interfaces). We want to delete
            # the map file only the first time. This is to avoid accidently
            # deleting map file with a valid mgmt vrf entry
            if os.path.exists(self.iproute2_vrf_filename):
                try:
                    self.logger.info('vrf: removing file %s'
                                     %self.iproute2_vrf_filename)
                    os.remove(self.iproute2_vrf_filename)
                except Exception as e:
                    self.logger.debug('vrf: removing file failed (%s)'
                                      %str(e))
        try:
            ip_rules = utils.exec_command('%s rule show'
                                          %utils.ip_cmd).splitlines()
            self.ip_rule_cache = [' '.join(r.split()) for r in ip_rules]
        except Exception as e:
            self.ip_rule_cache = []
            self.logger.warning('vrf: cache v4: %s' % str(e))

        try:
            ip_rules = utils.exec_command('%s -6 rule show'
                                          %utils.ip_cmd).splitlines()
            self.ip6_rule_cache = [' '.join(r.split()) for r in ip_rules]
        except Exception as e:
            self.ip6_rule_cache = []
            self.logger.warning('vrf: cache v6: %s' % str(e))

        #self.logger.debug("vrf: ip rule cache")
        #self.logger.info(self.ip_rule_cache)

        #self.logger.info("vrf: ip -6 rule cache")
        #self.logger.info(self.ip6_rule_cache)

        self.l3mdev_checked = False
        self.l3mdev4_rule = False
        if self._l3mdev_rule(self.ip_rule_cache):
            self.l3mdev4_rule = True
            self.l3mdev_checked = True
        self.l3mdev6_rule = False
        if self._l3mdev_rule(self.ip6_rule_cache):
            self.l3mdev6_rule = True
            self.l3mdev_checked = True
        self._iproute2_vrf_map_initialized = False
        self.iproute2_vrf_map = {}
        self.iproute2_vrf_map_sync_to_disk = False

        self.vrf_table_id_start = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-table-id-start')
        if not self.vrf_table_id_start:
            self.vrf_table_id_start = self.VRF_TABLE_START
        self.vrf_table_id_end = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-table-id-end')
        if not self.vrf_table_id_end:
            self.vrf_table_id_end = self.VRF_TABLE_END

        self._modinfo['attrs']['vrf-table']['validrange'] = [
            str(self.vrf_table_id_start),
            str(self.vrf_table_id_end)
        ]

        self.vrf_max_count = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-max-count')

        self.vrf_fix_local_table = True
        self.vrf_count = 0
        self.vrf_helper = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-helper')
        self.vrf_close_socks_on_down = policymanager.policymanager_api.get_module_globals(module_name=self.__class__.__name__, attr='vrf-close-socks-on-down')
        self.warn_on_vrf_map_write_err = True