Make network-create --with-dhcp option a flag
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Wed, 20 Feb 2013 16:58:21 +0000 (18:58 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Wed, 20 Feb 2013 16:58:21 +0000 (18:58 +0200)
kamaki/cli/commands/cyclades_cli.py
kamaki/clients/cyclades.py

index e15a879..692132d 100644 (file)
@@ -594,7 +594,7 @@ class network_create(_init_cyclades):
     arguments = dict(
         cidr=ValueArgument('explicitly set cidr', '--with-cidr'),
         gateway=ValueArgument('explicitly set gateway', '--with-gateway'),
-        dhcp=ValueArgument('explicitly set dhcp', '--with-dhcp'),
+        dhcp=FlagArgument('Use dhcp (default: off)', '--with-dhcp'),
         type=ValueArgument('explicitly set type', '--with-type')
     )
 
index b201ab1..7cfe681 100644 (file)
@@ -147,7 +147,7 @@ class CycladesClient(CycladesClientApi):
 
     def create_network(
             self, name,
-            cidr=None, gateway=None, type=None, dhcp=None):
+            cidr=None, gateway=None, type=None, dhcp=False):
         """
         :param name: (str)
 
@@ -157,7 +157,7 @@ class CycladesClient(CycladesClientApi):
 
         :param type: (str)
 
-        :param dhcp: (str)
+        :param dhcp: (bool)
 
         :returns: (dict) network detailed info
         """
@@ -168,8 +168,7 @@ class CycladesClient(CycladesClientApi):
             net['gateway'] = gateway
         if type:
             net['type'] = type
-        if dhcp:
-            net['dhcp'] = dhcp
+        net['dhcp'] = True if dhcp else False
         req = dict(network=net)
         r = self.networks_post(json_data=req, success=202)
         return r.json['network']