Revision ab6d1a2f

b/snf-cyclades-app/synnefo/api/management/commands/network-create.py
157 157
        dhcp = parse_bool(options["dhcp"])
158 158

  
159 159
        if not name:
160
            raise CommandError("name is required")
160
            name=""
161

  
161 162
        if not flavor:
162 163
            raise CommandError("flavor is required")
163 164

  
164
        if (subnet is None) and (subnet6 is None):
165
            raise CommandError("subnet or subnet6 is required")
166 165
        if subnet is None and gateway is not None:
167 166
            raise CommandError("Can not use gateway without subnet")
168 167
        if subnet6 is None and gateway6 is not None:
169 168
            raise CommandError("Can not use gateway6 without subnet6")
170

  
171 169
        if public and not (backend_ids or floating_ip_pool):
172 170
            raise CommandError("backend-ids is required")
173 171
        if not userid and not public:
b/snf-cyclades-app/synnefo/api/management/commands/network-list.py
52 52
            dest='public',
53 53
            default=False,
54 54
            help="List only public networks"),
55
        make_option(
56
            '--ipv6',
57
            action='store_true',
58
            dest='ipv6',
59
            default=False,
60
            help="Include IPv6 information"),
61 55
    )
62 56

  
63 57
    object_class = Network
......
66 60
    astakos_url = ASTAKOS_BASE_URL
67 61
    astakos_token = ASTAKOS_TOKEN
68 62

  
63
    def get_subnets(network):
64

  
65
        def help_str((a, b)):
66
            return (str(a), b)
67
        lista = network.subnets.values_list("id", "cidr")
68
        lista = map(help_str, lista)
69
        lista = map(" ".join, lista)
70
        return " ".join(lista)
71

  
69 72
    def get_machines(network):
70 73
        return network.machines.filter(deleted=False).count()
71 74

  
......
79 82
        "public": ("public", "Whether network is public or private"),
80 83
        "flavor": ("flavor", "The network's flavor"),
81 84
        "state": ("state", "The network's state"),
82
        "dhcp": ("dhcp", "Whether network uses nfdhcpd or not"),
83
        "subnet.ipv4": ("subnet", "The IPv4 subnet of the network"),
84
        "gateway.ipv4": ("gateway", "The IPv4 gateway of the network"),
85
        "subnet.ipv6": ("subnet6", "The IPv6 subnet of the network"),
86
        "gateway.ipv6": ("gateway6", "The IPv6 gateway of the network"),
87 85
        "created": ("created", "The date the network was created"),
88 86
        "updated": ("updated", "The date the network was updated"),
89 87
        "deleted": ("deleted", "Whether the network is deleted or not"),
......
94 92
        "vms": (get_machines, "Number of connected servers"),
95 93
        "backends": (get_backends, "IDs of Ganeti backends that the network is"
96 94
                                   " connected to"),
95
        "subnets": (get_subnets, "IDs of subnets that the network is"
96
                                   " associated with"),
97 97
        "pool": ("floating_ip_pool", "Whether the network is a floating"
98 98
                                     " IP pool"),
99 99
    }
100 100

  
101
    fields = ["id", "name", "user.uuid", "state", "public", "subnet.ipv4",
102
              "gateway.ipv4", "link", "mac_prefix", "dhcp", "drained", "pool"]
101
    fields = ["id", "name", "user.uuid", "state", "public", "link",
102
              "mac_prefix", "drained", "pool", "subnets"]
103 103

  
104 104
    def handle_args(self, *args, **options):
105 105
        if options["public"]:
106 106
            self.filters["public"] = True
107
        if options["ipv6"]:
108
            self.fields.extend(["subnet.ipv6", "gateway.ipv6"])
b/snf-cyclades-app/synnefo/api/management/commands/network-modify.py
72 72
                 " conversation the network will be created to all"
73 73
                 " available Ganeti backends."),
74 74
        make_option(
75
            '--add-reserved-ips',
76
            dest="add_reserved_ips",
77
            help="Comma seperated list of IPs to externally reserve."),
78
        make_option(
79
            '--remove-reserved-ips',
80
            dest="remove_reserved_ips",
81
            help="Comma seperated list of IPs to externally release."),
82
        make_option(
83 75
            "--add-to-backend",
84 76
            dest="add_to_backend",
85 77
            metavar="BACKEND_ID",
......
148 140
                               " '%s'\n" % (network, backend))
149 141
                        self.stdout.write(msg)
150 142

  
151
        add_reserved_ips = options.get('add_reserved_ips')
152
        remove_reserved_ips = options.get('remove_reserved_ips')
153
        if add_reserved_ips or remove_reserved_ips:
154
            if add_reserved_ips:
155
                add_reserved_ips = add_reserved_ips.split(",")
156
            if remove_reserved_ips:
157
                remove_reserved_ips = remove_reserved_ips.split(",")
158

  
159
            for bnetwork in network.backend_networks.filter(offline=False):
160
                with pooled_rapi_client(bnetwork.backend) as c:
161
                    c.ModifyNetwork(network=network.backend_id,
162
                                    add_reserved_ips=add_reserved_ips,
163
                                    remove_reserved_ips=remove_reserved_ips)
164

  
165 143
        add_to_backend = options["add_to_backend"]
166 144
        if add_to_backend is not None:
167 145
            backend = get_backend(add_to_backend)

Also available in: Unified diff