no longr build 31/sfapy2
[infrastructure.git] / scripts / vsys_vnet_admin.py
index 8786f80..52cdd96 100755 (executable)
@@ -50,16 +50,20 @@ if __name__ == "__main__":
     pl_url = "https://www.planet-lab.eu:443/PLCAPI/"
     pl_slice = os.environ.get('PL_SLICE')
 
-    usage = "usage: %prog -u <user> -p <password> -l <url>  -S <slice> --assign -b <base_address> -n <prefix>"
+    usage = """Usage: 
+   %prog : displays and check current assignments
+or %prog -a -S <slicename> : assigns a range to slice <slicename>"""
     parser = OptionParser(usage=usage)
     parser.add_option("-u", "--user", dest="pl_user", help="PlanetLab account user name", default=pl_user)
     parser.add_option("-p", "--password", dest="pl_pwd", help="PlanetLab account password", default=pl_pwd)
-    parser.add_option("-S", "--slice", dest="pl_slice", help="PlanetLab slice name", default=pl_slice)
     parser.add_option("-l", "--url", dest="pl_url", help="PlanetLab XMLRPC url", default=pl_url)
-    parser.add_option("-b", "--base", dest="basenet", help="Base network address to perform assignment (defaults to 10.0.0.0/8)", default="10.0.0.0/8")
+    parser.add_option("-b", "--base", dest="basenet",
+                      help="Base network address to perform assignment (defaults to 10.0.0.0/8)", default="10.0.0.0/8")
     parser.add_option("-n", "--prefix", dest="prefix", help="Network prefix for segments (defaults to 21)", default = "21")
     parser.add_option("-a", "--assign", action="store_true", dest="assign", default=False,
-        help="If specified, assign next available network segment as a vsys_vnet tag to the user slice")
+                      help="If specified, assign next available network segment as a vsys_vnet tag to the target slice")
+    parser.add_option("-S", "--slice", dest="pl_slice", default=pl_slice,
+                      help="target PlanetLab slice name, for --assign", )
 
     (options, args) = parser.parse_args()
    
@@ -85,9 +89,9 @@ if __name__ == "__main__":
             if not pl_slice:
                 pl_slice = raw_input ("Please, enter your slice name \n")
 
-                if pl_slice in assigned.values():
-                    print "Error: This slice already has a tag vsys_vnet assigned!!!"
-                    sys.exit(1)
+            if pl_slice in assigned.values():
+                print "Error: This slice already has a tag vsys_vnet assigned!!!"
+                sys.exit(1)
 
             slice_tag_id = assign_vsys_vent(api, auth, vsys_vnet, pl_slice)