added more methods
authorTony Mack <tmack@cs.princeton.edu>
Tue, 14 Apr 2009 02:44:30 +0000 (02:44 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 14 Apr 2009 02:44:30 +0000 (02:44 +0000)
geni/methods/__init__.py
geni/methods/create_slice.py [new file with mode: 0644]
geni/methods/delete_slice.py [new file with mode: 0644]
geni/methods/reset_slice.py [new file with mode: 0644]
geni/methods/slices.py
geni/methods/start_slice.py [new file with mode: 0644]
geni/methods/stop_slice.py [new file with mode: 0644]

index 198dceb..9e871f5 100644 (file)
@@ -1,12 +1,17 @@
 methods="""
 create_gid
+create_slice
+delete_slice
 get_credential
 get_ticket
 list
 register
 remove
+reset_slice
 resolve
 resources
 slices
+start_slice
+stop_slice
 update
 """.split()
diff --git a/geni/methods/create_slice.py b/geni/methods/create_slice.py
new file mode 100644 (file)
index 0000000..ace5a8b
--- /dev/null
@@ -0,0 +1,35 @@
+from geni.util.faults import *
+from geni.util.excep import *
+from geni.util.misc import *
+from geni.util.method import Method
+from geni.util.parameter import Parameter, Mixed
+from geni.util.auth import Auth
+from geni.util.slices import Slices
+
+class create_slices(Method):
+    """
+    Instantiate the specified slice according to whats defined in the specified rspec      
+
+    @param cred credential string specifying the rights of the caller
+    @param hrn human readable name of slice to instantiate
+    @param rspec resource specification
+    @return 1 is successful, faults otherwise  
+    """
+
+    interfaces = ['aggregate', 'slicemgr']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Parameter(str, "Human readable name of slice to instantiate"),
+        Parameter(str, "Resource specification"),
+        ]
+
+    returns = [Parameter(int, "1 if successful")]
+    
+    def call(self, cred, hrn, rspec):
+       
+        self.api.auth.check(cred, 'createslice')
+        slices = Slices(self.api)
+        slices.create_slice(hrn, rspec):
+        
+        return 1 
diff --git a/geni/methods/delete_slice.py b/geni/methods/delete_slice.py
new file mode 100644 (file)
index 0000000..7aecc1e
--- /dev/null
@@ -0,0 +1,33 @@
+from geni.util.faults import *
+from geni.util.excep import *
+from geni.util.misc import *
+from geni.util.method import Method
+from geni.util.parameter import Parameter, Mixed
+from geni.util.auth import Auth
+from geni.aggregate import Aggregates
+from geni.util.slices import Slices
+
+class delete_slice(Method):
+    """
+    Remove the slice from all nodes.      
+
+    @param cred credential string specifying the rights of the caller
+    @param hrn human readable name specifying the slice to delete
+    @return 1 if successful, faults otherwise  
+    """
+
+    interfaces = ['aggregate', 'slicemgr']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Parameter(str, "Human readable name of slice to delete"),
+        ]
+
+    returns = [Parameter(int, "1 if successful")]
+    
+    def call(self, cred, hrn):
+       
+        self.api.auth.check(cred, 'deleteslice')
+        slices = Slices(self.api)
+        slices.delete_slice(hrn)
+        return 1
diff --git a/geni/methods/reset_slice.py b/geni/methods/reset_slice.py
new file mode 100644 (file)
index 0000000..4b84942
--- /dev/null
@@ -0,0 +1,32 @@
+from geni.util.faults import *
+from geni.util.excep import *
+from geni.util.misc import *
+from geni.util.method import Method
+from geni.util.parameter import Parameter, Mixed
+from geni.util.auth import Auth
+from geni.util.slices import Slices
+
+class reset_slices(Method):
+    """
+    Reset the specified slice      
+
+    @param cred credential string specifying the rights of the caller
+    @param hrn human readable name of slice to instantiate
+    @return 1 is successful, faults otherwise  
+    """
+
+    interfaces = ['aggregate', 'slicemgr']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Parameter(str, "Human readable name of slice to instantiate"),
+        ]
+
+    returns = [Parameter(int, "1 if successful")]
+    
+    def call(self, cred, hrn):
+       
+        self.api.auth.check(cred, 'resetslice')
+        ## XX Not yet implemented
+        return 1 
index fc569d0..91134ce 100644 (file)
@@ -4,7 +4,7 @@ from geni.util.misc import *
 from geni.util.method import Method
 from geni.util.parameter import Parameter, Mixed
 from geni.util.auth import Auth
-from geni.aggregate import Aggregates
+from geni.util.slices import Slices
 
 class slices(Method):
     """
@@ -25,17 +25,6 @@ class slices(Method):
     def call(self, cred):
        
         self.api.auth.check(cred, 'listslices')
-        slice_hrns = []
-
-        if self.api.interface in ['aggregate']:
-            slices = self.api.plshell.GetSlices(self.api.plauth, {}, ['name'])
-            slice_hrns = [slicename_to_hrn(self.api.hrn, slice['name']) for slice in slices]
-        
-        else:
-            aggregates = Aggregates()
-            credential = self.api.getCredential()
-            for aggregate in aggregates:
-                slices = aggregates[aggregate].slices(credential)
-                slice_hrns.extend(slices)    
-            
-        return slice_hrns
+        slices = Slices(self.api)
+        slices.refresh()    
+        return slices['hrn']
diff --git a/geni/methods/start_slice.py b/geni/methods/start_slice.py
new file mode 100644 (file)
index 0000000..d3023d3
--- /dev/null
@@ -0,0 +1,33 @@
+from geni.util.faults import *
+from geni.util.excep import *
+from geni.util.misc import *
+from geni.util.method import Method
+from geni.util.parameter import Parameter, Mixed
+from geni.util.auth import Auth
+from geni.util.slices import Slices
+
+class start_slices(Method):
+    """
+    Start the specified slice      
+
+    @param cred credential string specifying the rights of the caller
+    @param hrn human readable name of slice to instantiate
+    @return 1 is successful, faults otherwise  
+    """
+
+    interfaces = ['aggregate', 'slicemgr']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Parameter(str, "Human readable name of slice to instantiate"),
+        ]
+
+    returns = [Parameter(int, "1 if successful")]
+    
+    def call(self, cred, hrn):
+       
+        self.api.auth.check(cred, 'startslice')
+        slices = Slices(self.api)
+        slices.stop_slice(hrn):
+        
+        return 1 
diff --git a/geni/methods/stop_slice.py b/geni/methods/stop_slice.py
new file mode 100644 (file)
index 0000000..ab5e165
--- /dev/null
@@ -0,0 +1,33 @@
+from geni.util.faults import *
+from geni.util.excep import *
+from geni.util.misc import *
+from geni.util.method import Method
+from geni.util.parameter import Parameter, Mixed
+from geni.util.auth import Auth
+from geni.util.slices import Slices
+
+class stop_slice(Method):
+    """
+    Stop the specified slice      
+
+    @param cred credential string specifying the rights of the caller
+    @param hrn human readable name of slice to instantiate
+    @return 1 is successful, faults otherwise  
+    """
+
+    interfaces = ['aggregate', 'slicemgr']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        Parameter(str, "Human readable name of slice to instantiate"),
+        ]
+
+    returns = [Parameter(int, "1 if successful")]
+    
+    def call(self, cred, hrn):
+       
+        self.api.auth.check(cred, 'startslice')
+        slices = Slices(self.api)
+        slices.stop_slice(hrn):
+        
+        return 1