Пример #1
0
            for route in sorted(new_routes - current_routes):
                cmd = ['ip', '-6', 'route', 'add', 'dev', iface]
                cmd.extend(route.split(' '))
                check_call(cmd)

    def configure(self):
        self.configure_vlans()

        self.configure_ipv4_addresses()
        self.configure_ipv4_routes()
        self.configure_ipv4_proxyarp()

        self.configure_ipv6_addresses()
        self.configure_ipv6_routes()

##############################################

parser = westspec.setup('Inter-VLAN router')
parser.add_argument('--apply', action='store_true')
parser.add_argument('--mode', choices=['public', 'private'], required=True,
                    help="Whether the router should route public IPv4/IPv6 or RFC1918")
parser.add_argument('--iface', required=True,
                    help="Which interface the code should create customer vlans on")

spec, args = westspec.load(parser)
dry_run = not args.apply

##############################################

IntervlanRouter(args.iface, args.mode == 'public').configure()
Пример #2
0
                '-cf', self.configfile,
                '-pf', self.pidfile,
                '-lf', self.leasefile]
        args += interfaces
        check_call(args)

    def configure(self):
        """Make sure that dhcpd runs according to the given configuration"""
        configuration, interfaces = self.get_config()

        config_changed = self.update_config(configuration)
        dhcpd_status = self.dhcpd_status()

        if config_changed or dhcpd_status != interfaces or self.restart:
            if dhcpd_status is not False:
                self.stop_dhcpd()
            self.start_dhcpd(interfaces)

##############################################

parser = westspec.setup('DHCP Setup')
parser.add_argument('--restart', action='store_true')
parser.add_argument('--iface', required=True,
                    help="Which interface the customer vlans are on")

spec, script_args = westspec.load(parser)

##############################################

DhcpSetup(script_args.iface, script_args.restart).configure()