Exemplo n.º 1
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a subnet ID.")

        subnet = common.get_resource("subnet", args[0])

        pprint.pprint_subnet_in_db(subnet, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_ippool(subnet, stdout=self.stdout)
Exemplo n.º 2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a subnet ID.")

        subnet = common.get_subnet(args[0])

        pprint.pprint_subnet_in_db(subnet, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_ippool(subnet, stdout=self.stdout)
Exemplo n.º 3
0
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        network_id = options["network_id"]
        cidr = options["cidr"]

        if not network_id:
            raise CommandError("network-id is mandatory")
        if not cidr:
            raise CommandError("cidr is mandatory")

        user_id = common.get_network(network_id).userid
        name = options["name"] or ""
        allocation_pools = options["allocation_pools"]
        ipversion = options["ipversion"] or 4
        ipversion = int(ipversion)
        gateway = options["gateway"]
        dhcp = parse_bool(options["dhcp"])
        dns = options["dns"]
        host_routes = options["host_routes"]

        alloc = None
        if allocation_pools is not None:
            alloc = subnets.parse_allocation_pools(allocation_pools)
            alloc.sort()

        sub = subnets.create_subnet(name=name,
                                    network_id=network_id,
                                    cidr=cidr,
                                    allocation_pools=alloc,
                                    gateway=gateway,
                                    ipversion=ipversion,
                                    dhcp=dhcp,
                                    slaac=dhcp,
                                    dns_nameservers=dns,
                                    host_routes=host_routes,
                                    user_id=user_id)

        pprint.pprint_subnet_in_db(sub, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_ippool(sub, stdout=self.stdout)
Exemplo n.º 4
0
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        network_id = options["network_id"]
        cidr = options["cidr"]

        if not network_id:
            raise CommandError("network is mandatory")
        if not cidr:
            raise CommandError("cidr is mandatory")

        user_id = common.get_resource("network", network_id).userid
        name = options["name"] or ""
        allocation_pools = options["allocation_pools"]
        ipversion = options["ipversion"] or 4
        ipversion = int(ipversion)
        gateway = options["gateway"]
        dhcp = parse_bool(options["dhcp"])
        dns = options["dns"]
        host_routes = options["host_routes"]

        alloc = None
        if allocation_pools is not None:
            alloc = subnets.parse_allocation_pools(allocation_pools)
            alloc.sort()

        sub = subnets.create_subnet(name=name,
                                    network_id=network_id,
                                    cidr=cidr,
                                    allocation_pools=alloc,
                                    gateway=gateway,
                                    ipversion=ipversion,
                                    dhcp=dhcp,
                                    slaac=dhcp,
                                    dns_nameservers=dns,
                                    host_routes=host_routes,
                                    user_id=user_id)

        pprint.pprint_subnet_in_db(sub, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_ippool(sub, stdout=self.stdout)