delegated_cred = self.delegate_cred(user_cred, get_authority(self.authority))
creds.append(delegated_cred)
server = self.get_server_from_opts(opts)
- results = server.ListSlices(creds)
+ results = server.ListSlices(creds, unique_call_id())
display_list(results)
return
api.plshell.BindObjectToPeer(api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
return 1
-def get_slices(api, creds):
+# xxx Thierry : caching at the aggregate level sounds wrong...
+caching=True
+#caching=False
+def ListSlices(api, creds, call_id):
+ if Callids().already_handled(call_id): return []
# look in cache first
- if api.cache:
+ if caching and api.cache:
slices = api.cache.get('slices')
if slices:
return slices
slice_urns = [hrn_to_urn(slice_hrn, 'slice') for slice_hrn in slice_hrns]
# cache the result
- if api.cache:
+ if caching and api.cache:
api.cache.add('slices', slice_urns)
return slice_urns
-# xxx Thierry : caching at the aggregate level sounds wrong...
-caching=True
-#caching=False
def ListResources(api, creds, options,call_id):
if Callids().already_handled(call_id): return ""
# get slice's hrn from options
# VINI aggregate is almost identical to PLC aggregate for many operations,
# so lets just import the methods form the PLC manager
from sfa.managers.aggregate_manager_pl import (
-start_slice, stop_slice, RenewSliver, reset_slice, get_slices, get_ticket, slice_status)
+start_slice, stop_slice, RenewSliver, reset_slice, ListSlices, get_ticket, slice_status)
def GetVersion(api):
def reset_slice(api, slicename):
return
-def get_slices(api):
- return
+def ListSlices(api):
+ return []
def reboot():
return
raise SliverDoesNotExist(slicename)
api.nodemanager.ReCreate(slicename)
-def get_slices(api):
+# xxx outdated - this should accept a credential & call_id
+def ListSlices(api):
# this returns a tuple, the data we want is at index 1
xids = api.nodemanager.GetXIDs()
# unfortunately the data we want is given to us as
"""
return 1
-def get_slices(api, creds):
+# Thierry : caching at the slicemgr level makes sense to some extent
+caching=True
+#caching=False
+def ListSlices(api, creds, call_id):
+
+ if Callids().already_handled(call_id): return []
# look in cache first
- if api.cache:
+ if caching and api.cache:
slices = api.cache.get('slices')
if slices:
return slices
if caller_hrn == aggregate and aggregate != api.hrn:
continue
server = api.aggregates[aggregate]
- threads.run(server.ListSlices, credential)
+ threads.run(server.ListSlices, credential, call_id)
# combime results
results = threads.get_results()
slices.extend(result)
# cache the result
- if api.cache:
+ if caching and api.cache:
api.cache.add('slices', slices)
return slices
-# Thierry : caching at the slicemgr level makes sense to some extent
-caching=True
-#caching=False
def ListResources(api, creds, options, call_id):
- if Callids().already_handled(call_id):
- api.logger.info("%d received ListResources with known call_id %s"%(api.interface,call_id))
- return ""
+ if Callids().already_handled(call_id): return ""
# get slice's hrn from options
xrn = options.get('geni_slice_urn', '')
accepts = [
Mixed(Parameter(str, "Credential string"),
Parameter(type([str]), "List of credentials")),
+ Parameter(str, "call_id"),
]
returns = Parameter(list, "List of slice names")
- def call(self, creds):
- valid_creds = self.api.auth.checkCredentials(creds, 'listslices')
-
+ def call(self, creds, call_id=""):
#log the call
origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
self.api.logger.info("interface: %s\tcaller-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, self.name))
+ valid_creds = self.api.auth.checkCredentials(creds, 'listslices')
manager = self.api.get_interface_manager()
- return manager.get_slices(self.api, creds)
+ return manager.ListSlices(self.api, creds, call_id)
BasicTestCase.setUp(self)
def testGetSlices(self):
- self.aggregate.get_slices(self.credential)
+ self.aggregate.ListSlices(self.credential)
def testGetResources(self):
# available resources
self.cm.restart_slice(self.slice_cred, self.slice['hrn'])
def testGetSlices(self):
- self.cm.get_slices(self.slice_cred, self.slice['hrn'])
+ self.cm.ListSlices(self.slice_cred, self.slice['hrn'])
def testRedeemTicket(self):
rspec = self.aggregate.get_resources(self.credential)