add missing ResolveSlices in 4.3
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 22 Apr 2009 06:40:08 +0000 (06:40 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 22 Apr 2009 06:40:08 +0000 (06:40 +0000)
PLC/Methods/ResolveSlices.py [new file with mode: 0644]
PLC/Methods/__init__.py

diff --git a/PLC/Methods/ResolveSlices.py b/PLC/Methods/ResolveSlices.py
new file mode 100644 (file)
index 0000000..17a1290
--- /dev/null
@@ -0,0 +1,43 @@
+# $Id: ResolveSlices.py 12217 2009-02-24 17:28:54Z thierry $
+
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Filter import Filter
+from PLC.Auth import Auth
+from PLC.Slices import Slice, Slices
+
+class ResolveSlices(Method):
+    """
+    This method is similar to GetSlices, except that (1) the returned
+    columns are restricted to 'name' and 'slice_id', and (2) it
+    returns expired slices too. This method is designed to help
+    third-party software solve slice names from their slice_id
+    (e.g. PlanetFlow Central). For this reason it is accessible with
+    anonymous authentication (among others).
+    """
+
+    roles = ['admin', 'pi', 'user', 'tech', 'anonymous' ]
+
+    applicable_fields = { 
+        'slice_id' : Slice.fields['slice_id'],
+        'name' : Slice.fields['name'],
+        }
+
+    accepts = [
+        Auth(),
+        Mixed([Mixed(Slice.fields['slice_id'],
+                     Slice.fields['name'])],
+              Parameter(str,"name"),
+              Parameter(int,"slice_id"),
+              Filter(applicable_fields))
+        ]
+
+    returns = [applicable_fields]
+
+    def call(self, auth, slice_filter = None):
+
+        # Must query at least slice_id (see below)
+        return_fields = self.applicable_fields.keys()
+        # pass expires=0
+        slices = Slices(self.api, slice_filter, return_fields, 0)
+        return slices
index f371aa6..9f6743d 100644 (file)
@@ -135,6 +135,7 @@ RebootNodeWithPCU
 RefreshPeer
 ReportRunlevel
 ResetPassword
+ResolveSlices
 SetPersonPrimarySite
 SliceCreate
 SliceDelete