Ejemplo n.º 1
0
    def _generate_radvd_conf(self, router_ports):
        radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs,
                                              self._router_id,
                                              'radvd.conf',
                                              True)
        buf = six.StringIO()
        for p in router_ports:
            subnets = p.get('subnets', [])
            v6_subnets = [subnet for subnet in subnets if
                    netaddr.IPNetwork(subnet['cidr']).version == 6]
            if not v6_subnets:
                continue
            ra_modes = {subnet['ipv6_ra_mode'] for subnet in v6_subnets}
            auto_config_prefixes = [subnet['cidr'] for subnet in v6_subnets if
                    subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC or
                    subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS]
            interface_name = self._dev_name_helper(p['id'])
            buf.write('%s' % CONFIG_TEMPLATE.render(
                ra_modes=list(ra_modes),
                interface_name=interface_name,
                prefixes=auto_config_prefixes,
                constants=constants))

        utils.replace_file(radvd_conf, buf.getvalue())
        return radvd_conf
Ejemplo n.º 2
0
    def _generate_radvd_conf(self, router_ports):
        radvd_conf = utils.get_conf_file_name(self._agent_conf.ra_confs,
                                              self._router_id,
                                              'radvd.conf',
                                              True)
        buf = six.StringIO()
        for p in router_ports:
            subnets = p.get('subnets', [])
            v6_subnets = [subnet for subnet in subnets if
                    netaddr.IPNetwork(subnet['cidr']).version == 6]
            if not v6_subnets:
                continue
            ra_modes = {subnet['ipv6_ra_mode'] for subnet in v6_subnets}
            auto_config_prefixes = [subnet['cidr'] for subnet in v6_subnets if
                    subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC or
                    subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS]
            stateful_config_prefixes = [subnet['cidr'] for subnet in v6_subnets
                    if subnet['ipv6_ra_mode'] == constants.DHCPV6_STATEFUL]
            interface_name = self._dev_name_helper(p['id'])
            slaac_subnets = [subnet for subnet in v6_subnets if
                subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC]
            dns_servers = list(iter_chain(*[subnet['dns_nameservers'] for
                subnet in slaac_subnets if subnet.get('dns_nameservers')]))
            buf.write('%s' % CONFIG_TEMPLATE.render(
                ra_modes=list(ra_modes),
                interface_name=interface_name,
                auto_config_prefixes=auto_config_prefixes,
                stateful_config_prefixes=stateful_config_prefixes,
                dns_servers=dns_servers[0:MAX_RDNSS_ENTRIES],
                constants=constants,
                min_rtr_adv_interval=self._agent_conf.min_rtr_adv_interval,
                max_rtr_adv_interval=self._agent_conf.max_rtr_adv_interval))

        common_utils.replace_file(radvd_conf, buf.getvalue())
        return radvd_conf
 def get_pid_file_name(self):
     """Returns the file name for a given kind of config file."""
     if self.pid_file:
         return self.pid_file
     else:
         return utils.get_conf_file_name(self.pids_path,
                                         self.uuid,
                                         self.service_pid_fname)
    def _assert_harouter_fip_is_set(self, router_info, fip_pf):
        (interface_name, namespace,
         iptables_manager) = self.fip_pf_ext._get_resource_by_router(
            router_info)
        keepalived_pm = router_info.keepalived_manager.get_process()
        utils.get_conf_file_name(keepalived_pm.pids_path,
                                 keepalived_pm.uuid,
                                 keepalived_pm.service_pid_fname)

        conf_path = os.path.join(keepalived_pm.pids_path, keepalived_pm.uuid,
                                 'keepalived.conf')

        regex = "%s dev %s" % (fip_pf, interface_name)
        pattern = re.compile(regex)

        def check_harouter_fip_is_set():
            if re.findall(pattern, utils.get_value_from_file(conf_path)):
                return True
            return False

        common_utils.wait_until_true(check_harouter_fip_is_set)
Ejemplo n.º 5
0
    def _generate_dibbler_conf(self, ex_gw_ifname, lla):
        dcwa = self.dibbler_client_working_area
        script_path = utils.get_conf_file_name(dcwa, 'notify', 'sh', True)
        buf = six.StringIO()
        buf.write('%s' % SCRIPT_TEMPLATE.render(
                             prefix_path=self.prefix_path,
                             l3_agent_pid=os.getpid()))
        utils.replace_file(script_path, buf.getvalue())
        os.chmod(script_path, 0o744)

        dibbler_conf = utils.get_conf_file_name(dcwa, 'client', 'conf', False)
        buf = six.StringIO()
        buf.write('%s' % CONFIG_TEMPLATE.render(
                             enterprise_number=cfg.CONF.vendor_pen,
                             va_id='0x%s' % self.converted_subnet_id,
                             script_path='"%s/notify.sh"' % dcwa,
                             interface_name='"%s"' % ex_gw_ifname,
                             bind_address='%s' % lla))

        utils.replace_file(dibbler_conf, buf.getvalue())
        return dcwa
Ejemplo n.º 6
0
def _generate_radvd_conf(router_id, router_ports, dev_name_helper):
    radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs, router_id, "radvd.conf", True)
    buf = six.StringIO()
    for p in router_ports:
        prefix = p["subnet"]["cidr"]
        if netaddr.IPNetwork(prefix).version == 6:
            interface_name = dev_name_helper(p["id"])
            ra_mode = p["subnet"]["ipv6_ra_mode"]
            buf.write(
                "%s"
                % CONFIG_TEMPLATE.render(
                    ra_mode=ra_mode, interface_name=interface_name, prefix=prefix, constants=constants
                )
            )

    utils.replace_file(radvd_conf, buf.getvalue())
    return radvd_conf
Ejemplo n.º 7
0
def _generate_radvd_conf(router_id, router_ports, dev_name_helper):
    radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs, router_id,
                                          'radvd.conf', True)
    buf = six.StringIO()
    for p in router_ports:
        prefix = p['subnet']['cidr']
        if netaddr.IPNetwork(prefix).version == 6:
            interface_name = dev_name_helper(p['id'])
            ra_mode = p['subnet']['ipv6_ra_mode']
            buf.write('%s' %
                      CONFIG_TEMPLATE.render(ra_mode=ra_mode,
                                             interface_name=interface_name,
                                             prefix=prefix,
                                             constants=constants))

    utils.replace_file(radvd_conf, buf.getvalue())
    return radvd_conf
Ejemplo n.º 8
0
    def _generate_radvd_conf(self, router_ports):
        radvd_conf = utils.get_conf_file_name(self._agent_conf.ra_confs,
                                              self._router_id, 'radvd.conf',
                                              True)
        buf = six.StringIO()
        for p in router_ports:
            subnets = p.get('subnets', [])
            v6_subnets = [
                subnet for subnet in subnets
                if netaddr.IPNetwork(subnet['cidr']).version == 6
            ]
            if not v6_subnets:
                continue
            ra_modes = {subnet['ipv6_ra_mode'] for subnet in v6_subnets}
            auto_config_prefixes = [
                subnet['cidr'] for subnet in v6_subnets
                if subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC
                or subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS
            ]
            stateful_config_prefixes = [
                subnet['cidr'] for subnet in v6_subnets
                if subnet['ipv6_ra_mode'] == constants.DHCPV6_STATEFUL
            ]
            interface_name = self._dev_name_helper(p['id'])
            slaac_subnets = [
                subnet for subnet in v6_subnets
                if subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC
            ]
            dns_servers = list(
                iter_chain(*[
                    subnet['dns_nameservers'] for subnet in slaac_subnets
                    if subnet.get('dns_nameservers')
                ]))
            buf.write('%s' % CONFIG_TEMPLATE.render(
                ra_modes=list(ra_modes),
                interface_name=interface_name,
                auto_config_prefixes=auto_config_prefixes,
                stateful_config_prefixes=stateful_config_prefixes,
                dns_servers=dns_servers[0:MAX_RDNSS_ENTRIES],
                constants=constants,
                min_rtr_adv_interval=self._agent_conf.min_rtr_adv_interval,
                max_rtr_adv_interval=self._agent_conf.max_rtr_adv_interval))

        common_utils.replace_file(radvd_conf, buf.getvalue())
        return radvd_conf
Ejemplo n.º 9
0
def _generate_radvd_conf(router_id, router_ports, dev_name_helper):
    radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs,
                                          router_id,
                                          'radvd.conf',
                                          True)
    buf = six.StringIO()
    for p in router_ports:
        if netaddr.IPNetwork(p['subnet']['cidr']).version == 6:
            interface_name = dev_name_helper(p['id'])
            if _is_slaac(p['subnet']['ipv6_ra_mode']):
                conf_str = prefix_fmt % (interface_name,
                                         p['subnet']['cidr'])
            else:
                conf_str = default_fmt % interface_name
            buf.write('%s' % conf_str)

    utils.replace_file(radvd_conf, buf.getvalue())
    return radvd_conf
Ejemplo n.º 10
0
Archivo: ra.py Proyecto: afori/neutron
    def _generate_radvd_conf(self, router_ports):
        radvd_conf = utils.get_conf_file_name(cfg.CONF.ra_confs,
                                              self._router_id,
                                              'radvd.conf',
                                              True)
        buf = six.StringIO()
        for p in router_ports:
            prefix = p['subnet']['cidr']
            if netaddr.IPNetwork(prefix).version == 6:
                interface_name = self._dev_name_helper(p['id'])
                ra_mode = p['subnet']['ipv6_ra_mode']
                buf.write('%s' % CONFIG_TEMPLATE.render(
                    ra_mode=ra_mode,
                    interface_name=interface_name,
                    prefix=prefix,
                    constants=constants))

        utils.replace_file(radvd_conf, buf.getvalue())
        return radvd_conf
Ejemplo n.º 11
0
 def get_pid_file_name(self, ensure_pids_dir=False):
     """Returns the file name for a given kind of config file."""
     return utils.get_conf_file_name(self.pids_path, self.uuid,
                                     self.service_pid_fname,
                                     ensure_pids_dir)
Ejemplo n.º 12
0
 def get_pid_file_name(self, ensure_pids_dir=False):
     """Returns the file name for a given kind of config file."""
     return utils.get_conf_file_name(self.pids_path,
                                     self.uuid,
                                     self.service_pid_fname,
                                     ensure_pids_dir)