From 61d1615ac57ab53e9bbbc69a0312ab8e699374c2 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Mon, 13 Apr 2009 01:57:45 +0000 Subject: [PATCH] added slices call --- geni/methods/__init__.py | 1 + geni/methods/slices.py | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 geni/methods/slices.py diff --git a/geni/methods/__init__.py b/geni/methods/__init__.py index 15bad5b0..198dceb4 100644 --- a/geni/methods/__init__.py +++ b/geni/methods/__init__.py @@ -7,5 +7,6 @@ register remove resolve resources +slices update """.split() diff --git a/geni/methods/slices.py b/geni/methods/slices.py new file mode 100644 index 00000000..fc569d00 --- /dev/null +++ b/geni/methods/slices.py @@ -0,0 +1,41 @@ +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 + +class slices(Method): + """ + Get a list of instantiated slices at this authority. + + @param cred credential string specifying the rights of the caller + @return list of human readable slice names (hrn). + """ + + interfaces = ['aggregate', 'slicemgr'] + + accepts = [ + Parameter(str, "Credential string"), + ] + + returns = [Parameter(str, "Human readable slice name (hrn)")] + + 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 -- 2.43.0