split off GetSlices and GetNodes from GetConfiguration
authorsmbaker <smbaker@fc8-storktest.lan>
Wed, 30 Oct 2013 00:46:32 +0000 (17:46 -0700)
committersmbaker <smbaker@fc8-storktest.lan>
Wed, 30 Oct 2013 00:46:32 +0000 (17:46 -0700)
planetstack/core/views/legacyapi.py

index b6494e1..e70fa57 100644 (file)
@@ -237,19 +237,25 @@ def GetConfiguration(name):
             'sites': sites,
             'nodes': nodes}
 
-def DoGetConfiguration():
+def HandleGetConfiguration():
     find_multi_slicename("princeton_vcoblitz")
-    slices = GetSlices()
-    nodes = GetNodes()
     configs={}
     for slicename in ["princeton_vcoblitz"]:
         configs[slicename] = GetConfiguration({"name": slicename})
+    return configs
+
+def HandleGetNodes():
+    find_multi_slicename("princeton_vcoblitz")
+    return GetNodes()
+
+def HandleGetSlices():
+    find_multi_slicename("princeton_vcoblitz")
+    return GetSlices()
 
-    result = {"configs": configs,
-              "slices": slices,
-              "nodes": nodes}
 
-    return result
+FUNCS = {"GetConfiguration": HandleGetConfiguration,
+         "GetNodes": HandleGetNodes,
+         "GetSlices": HandleGetSlices}
 
 @csrf_exempt
 def LegacyXMLRPC(request):
@@ -257,8 +263,8 @@ def LegacyXMLRPC(request):
         try:
             (args, method) = xmlrpclib.loads(request.body)
             result = None
-            if (method == "GetConfiguration"):
-                result = DoGetConfiguration()
+            if method in FUNCS:
+                result = FUNCS[method]()
             return HttpResponse(xmlrpclib.dumps((result,), methodresponse=True, allow_none=1))
         except:
             traceback.print_exc()