コード例 #1
0
ファイル: network-inspect.py プロジェクト: antonis-m/synnefo
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a network ID.")

        network = common.get_network(args[0])
        displayname = options['displayname']

        pprint.pprint_network(network, display_mails=displayname,
                              stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_subnets(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_backends(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_in_ganeti(network, stdout=self.stdout)
コード例 #2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a network ID.")

        network = common.get_network(args[0])
        displayname = options['displayname']

        pprint.pprint_network(network,
                              display_mails=displayname,
                              stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_subnets(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_backends(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_in_ganeti(network, stdout=self.stdout)
コード例 #3
0
ファイル: network-inspect.py プロジェクト: AthinaB/synnefo
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a network ID.")

        network = common.get_resource("network", args[0])
        display_mails = options["displaymail"]

        pprint.pprint_network(network, display_mails=display_mails,
                              stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_subnets(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_backends(network, stdout=self.stdout)
        backends = parse_bool(options["backends"])
        if backends:
            self.stdout.write("\n\n")
            pprint.pprint_network_in_ganeti(network, stdout=self.stdout)
コード例 #4
0
ファイル: network-inspect.py プロジェクト: kins299/mycloud
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a network ID.")

        network = common.get_resource("network", args[0])
        display_mails = options["displaymail"]

        pprint.pprint_network(network,
                              display_mails=display_mails,
                              stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_subnets(network, stdout=self.stdout)
        self.stdout.write("\n\n")
        pprint.pprint_network_backends(network, stdout=self.stdout)
        backends = parse_bool(options["backends"])
        if backends:
            self.stdout.write("\n\n")
            pprint.pprint_network_in_ganeti(network, stdout=self.stdout)
コード例 #5
0
ファイル: network-create.py プロジェクト: grnet/synnefo
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        name = options['name']
        subnet = options['subnet']
        gateway = options['gateway']
        subnet6 = options['subnet6']
        gateway6 = options['gateway6']
        public = options['public']
        flavor = options['flavor']
        mode = options['mode']
        link = options['link']
        mac_prefix = options['mac_prefix']
        tags = options['tags']
        userid = options["user"]
        project = options['project']
        allocation_pools = options["allocation_pools"]
        floating_ip_pool = parse_bool(options["floating_ip_pool"])
        dhcp = parse_bool(options["dhcp"])
        drained = parse_bool(options["drained"])

        if name is None:
            name = ""
        if flavor is None:
            raise CommandError("flavor is required")

        if ((subnet is None) and (subnet6 is None)) and dhcp is not False:
            raise CommandError("Cannot set DHCP without subnet or subnet6")

        if subnet is None and gateway is not None:
            raise CommandError("Cannot use gateway without subnet")
        if subnet is None and allocation_pools is not None:
            raise CommandError("Cannot use allocation-pools without subnet")
        if subnet6 is None and gateway6 is not None:
            raise CommandError("Cannot use gateway6 without subnet6")
        if flavor == "IP_LESS_ROUTED" and not (subnet or subnet6):
            raise CommandError("Cannot create 'IP_LESS_ROUTED' network without"
                               " subnet")

        if not (userid or public):
            raise CommandError("'user' is required for private networks")
        if not project:
            project = userid

        network = networks.create(userid=userid, name=name, flavor=flavor,
                                  public=public, mode=mode, project=project,
                                  link=link, mac_prefix=mac_prefix, tags=tags,
                                  floating_ip_pool=floating_ip_pool,
                                  drained=drained)

        if subnet is not None:
            alloc = None
            if allocation_pools is not None:
                alloc = subnets.parse_allocation_pools(allocation_pools)
                alloc.sort()
            name = "IPv4 Subnet of Network %s" % network.id
            subnets.create_subnet(network.id, cidr=subnet, name=name,
                                  ipversion=4, gateway=gateway, dhcp=dhcp,
                                  user_id=userid,
                                  allocation_pools=alloc)

        if subnet6 is not None:
            name = "IPv6 Subnet of Network %s" % network.id
            subnets.create_subnet(network.id, cidr=subnet6, name=name,
                                  ipversion=6, gateway=gateway6,
                                  dhcp=dhcp, user_id=userid)

        self.stdout.write("Created network '%s' in DB:\n" % network)
        pprint.pprint_network(network, stdout=self.stdout)
        pprint.pprint_network_subnets(network, stdout=self.stdout)

        networks.create_network_in_backends(network)
        # TODO: Add --wait option to track job progress and report successful
        # creation in each backend.
        self.stdout.write("\nSuccessfully issued job to create network in"
                          " backends\n")
コード例 #6
0
ファイル: network-create.py プロジェクト: vgerak/synnefo
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        name = options['name']
        subnet = options['subnet']
        gateway = options['gateway']
        subnet6 = options['subnet6']
        gateway6 = options['gateway6']
        public = options['public']
        flavor = options['flavor']
        mode = options['mode']
        link = options['link']
        mac_prefix = options['mac_prefix']
        tags = options['tags']
        userid = options["user"]
        project = options['project']
        allocation_pools = options["allocation_pools"]
        floating_ip_pool = parse_bool(options["floating_ip_pool"])
        dhcp = parse_bool(options["dhcp"])
        drained = parse_bool(options["drained"])

        if name is None:
            name = ""
        if flavor is None:
            raise CommandError("flavor is required")

        if ((subnet is None) and (subnet6 is None)) and dhcp is not False:
            raise CommandError("Cannot set DHCP without subnet or subnet6")

        if subnet is None and gateway is not None:
            raise CommandError("Cannot use gateway without subnet")
        if subnet is None and allocation_pools is not None:
            raise CommandError("Cannot use allocation-pools without subnet")
        if subnet6 is None and gateway6 is not None:
            raise CommandError("Cannot use gateway6 without subnet6")
        if flavor == "IP_LESS_ROUTED" and not (subnet or subnet6):
            raise CommandError("Cannot create 'IP_LESS_ROUTED' network without"
                               " subnet")

        if not (userid or public):
            raise CommandError("'user' is required for private networks")
        if not project:
            project = userid

        network = networks.create(userid=userid,
                                  name=name,
                                  flavor=flavor,
                                  public=public,
                                  mode=mode,
                                  project=project,
                                  link=link,
                                  mac_prefix=mac_prefix,
                                  tags=tags,
                                  floating_ip_pool=floating_ip_pool,
                                  drained=drained)

        if subnet is not None:
            alloc = None
            if allocation_pools is not None:
                alloc = subnets.parse_allocation_pools(allocation_pools)
                alloc.sort()
            name = "IPv4 Subnet of Network %s" % network.id
            subnets.create_subnet(network.id,
                                  cidr=subnet,
                                  name=name,
                                  ipversion=4,
                                  gateway=gateway,
                                  dhcp=dhcp,
                                  user_id=userid,
                                  allocation_pools=alloc)

        if subnet6 is not None:
            name = "IPv6 Subnet of Network %s" % network.id
            subnets.create_subnet(network.id,
                                  cidr=subnet6,
                                  name=name,
                                  ipversion=6,
                                  gateway=gateway6,
                                  dhcp=dhcp,
                                  user_id=userid)

        self.stdout.write("Created network '%s' in DB:\n" % network)
        pprint.pprint_network(network, stdout=self.stdout)
        pprint.pprint_network_subnets(network, stdout=self.stdout)

        networks.create_network_in_backends(network)
        # TODO: Add --wait option to track job progress and report successful
        # creation in each backend.
        self.stdout.write("\nSuccessfully issued job to create network in"
                          " backends\n")