commit ab6d1a2facca7d01c92c3095f15a5e16c5012641
Author: Marios Kogias <marioskogias@grnet.gr>
Date:   Sun Oct 13 21:40:51 2013 +0300

    cyclades: Modify snf-manage network commands
    
    Modifications according to the new API

diff --git a/snf-cyclades-app/synnefo/api/management/commands/network-create.py b/snf-cyclades-app/synnefo/api/management/commands/network-create.py
index 74f93cd..531f692 100644
--- a/snf-cyclades-app/synnefo/api/management/commands/network-create.py
+++ b/snf-cyclades-app/synnefo/api/management/commands/network-create.py
@@ -157,17 +157,15 @@ class Command(BaseCommand):
         dhcp = parse_bool(options["dhcp"])
 
         if not name:
-            raise CommandError("name is required")
+            name=""
+
         if not flavor:
             raise CommandError("flavor is required")
 
-        if (subnet is None) and (subnet6 is None):
-            raise CommandError("subnet or subnet6 is required")
         if subnet is None and gateway is not None:
             raise CommandError("Can not use gateway without subnet")
         if subnet6 is None and gateway6 is not None:
             raise CommandError("Can not use gateway6 without subnet6")
-
         if public and not (backend_ids or floating_ip_pool):
             raise CommandError("backend-ids is required")
         if not userid and not public:
diff --git a/snf-cyclades-app/synnefo/api/management/commands/network-list.py b/snf-cyclades-app/synnefo/api/management/commands/network-list.py
index 68af79a..94ada40 100644
--- a/snf-cyclades-app/synnefo/api/management/commands/network-list.py
+++ b/snf-cyclades-app/synnefo/api/management/commands/network-list.py
@@ -52,12 +52,6 @@ class Command(ListCommand):
             dest='public',
             default=False,
             help="List only public networks"),
-        make_option(
-            '--ipv6',
-            action='store_true',
-            dest='ipv6',
-            default=False,
-            help="Include IPv6 information"),
     )
 
     object_class = Network
@@ -66,6 +60,15 @@ class Command(ListCommand):
     astakos_url = ASTAKOS_BASE_URL
     astakos_token = ASTAKOS_TOKEN
 
+    def get_subnets(network):
+
+        def help_str((a, b)):
+            return (str(a), b)
+        lista = network.subnets.values_list("id", "cidr")
+        lista = map(help_str, lista)
+        lista = map(" ".join, lista)
+        return " ".join(lista)
+
     def get_machines(network):
         return network.machines.filter(deleted=False).count()
 
@@ -79,11 +82,6 @@ class Command(ListCommand):
         "public": ("public", "Whether network is public or private"),
         "flavor": ("flavor", "The network's flavor"),
         "state": ("state", "The network's state"),
-        "dhcp": ("dhcp", "Whether network uses nfdhcpd or not"),
-        "subnet.ipv4": ("subnet", "The IPv4 subnet of the network"),
-        "gateway.ipv4": ("gateway", "The IPv4 gateway of the network"),
-        "subnet.ipv6": ("subnet6", "The IPv6 subnet of the network"),
-        "gateway.ipv6": ("gateway6", "The IPv6 gateway of the network"),
         "created": ("created", "The date the network was created"),
         "updated": ("updated", "The date the network was updated"),
         "deleted": ("deleted", "Whether the network is deleted or not"),
@@ -94,15 +92,15 @@ class Command(ListCommand):
         "vms": (get_machines, "Number of connected servers"),
         "backends": (get_backends, "IDs of Ganeti backends that the network is"
                                    " connected to"),
+        "subnets": (get_subnets, "IDs of subnets that the network is"
+                                   " associated with"),
         "pool": ("floating_ip_pool", "Whether the network is a floating"
                                      " IP pool"),
     }
 
-    fields = ["id", "name", "user.uuid", "state", "public", "subnet.ipv4",
-              "gateway.ipv4", "link", "mac_prefix", "dhcp", "drained", "pool"]
+    fields = ["id", "name", "user.uuid", "state", "public", "link",
+              "mac_prefix", "drained", "pool", "subnets"]
 
     def handle_args(self, *args, **options):
         if options["public"]:
             self.filters["public"] = True
-        if options["ipv6"]:
-            self.fields.extend(["subnet.ipv6", "gateway.ipv6"])
diff --git a/snf-cyclades-app/synnefo/api/management/commands/network-modify.py b/snf-cyclades-app/synnefo/api/management/commands/network-modify.py
index c9ef431..3c874b3 100644
--- a/snf-cyclades-app/synnefo/api/management/commands/network-modify.py
+++ b/snf-cyclades-app/synnefo/api/management/commands/network-modify.py
@@ -72,14 +72,6 @@ class Command(BaseCommand):
                  " conversation the network will be created to all"
                  " available Ganeti backends."),
         make_option(
-            '--add-reserved-ips',
-            dest="add_reserved_ips",
-            help="Comma seperated list of IPs to externally reserve."),
-        make_option(
-            '--remove-reserved-ips',
-            dest="remove_reserved_ips",
-            help="Comma seperated list of IPs to externally release."),
-        make_option(
             "--add-to-backend",
             dest="add_to_backend",
             metavar="BACKEND_ID",
@@ -148,20 +140,6 @@ class Command(BaseCommand):
                                " '%s'\n" % (network, backend))
                         self.stdout.write(msg)
 
-        add_reserved_ips = options.get('add_reserved_ips')
-        remove_reserved_ips = options.get('remove_reserved_ips')
-        if add_reserved_ips or remove_reserved_ips:
-            if add_reserved_ips:
-                add_reserved_ips = add_reserved_ips.split(",")
-            if remove_reserved_ips:
-                remove_reserved_ips = remove_reserved_ips.split(",")
-
-            for bnetwork in network.backend_networks.filter(offline=False):
-                with pooled_rapi_client(bnetwork.backend) as c:
-                    c.ModifyNetwork(network=network.backend_id,
-                                    add_reserved_ips=add_reserved_ips,
-                                    remove_reserved_ips=remove_reserved_ips)
-
         add_to_backend = options["add_to_backend"]
         if add_to_backend is not None:
             backend = get_backend(add_to_backend)
