git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
939c231
)
get_slices is now ListSlices and supports call_id
author
Thierry Parmentelat
<thierry.parmentelat@sophia.inria.fr>
Thu, 14 Apr 2011 10:28:17 +0000
(12:28 +0200)
committer
Thierry Parmentelat
<thierry.parmentelat@sophia.inria.fr>
Thu, 14 Apr 2011 10:28:17 +0000
(12:28 +0200)
sfa/client/sfi.py
patch
|
blob
|
history
sfa/managers/aggregate_manager_pl.py
patch
|
blob
|
history
sfa/managers/aggregate_manager_vini.py
patch
|
blob
|
history
sfa/managers/component_manager_default.py
patch
|
blob
|
history
sfa/managers/component_manager_pl.py
patch
|
blob
|
history
sfa/managers/slice_manager_pl.py
patch
|
blob
|
history
sfa/methods/ListSlices.py
patch
|
blob
|
history
tests/testInterfaces.py
patch
|
blob
|
history
diff --git
a/sfa/client/sfi.py
b/sfa/client/sfi.py
index
a6f80f6
..
0107142
100755
(executable)
--- a/
sfa/client/sfi.py
+++ b/
sfa/client/sfi.py
@@
-796,7
+796,7
@@
class Sfi:
delegated_cred = self.delegate_cred(user_cred, get_authority(self.authority))
creds.append(delegated_cred)
server = self.get_server_from_opts(opts)
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
display_list(results)
return
diff --git
a/sfa/managers/aggregate_manager_pl.py
b/sfa/managers/aggregate_manager_pl.py
index
8a39c0b
..
5355f97
100644
(file)
--- a/
sfa/managers/aggregate_manager_pl.py
+++ b/
sfa/managers/aggregate_manager_pl.py
@@
-278,9
+278,13
@@
def DeleteSliver(api, xrn, creds, call_id):
api.plshell.BindObjectToPeer(api.plauth, 'slice', slice['slice_id'], peer, slice['peer_slice_id'])
return 1
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
# look in cache first
- if api.cache:
+ if
caching and
api.cache:
slices = api.cache.get('slices')
if slices:
return slices
slices = api.cache.get('slices')
if slices:
return slices
@@
-291,14
+295,11
@@
def get_slices(api, creds):
slice_urns = [hrn_to_urn(slice_hrn, 'slice') for slice_hrn in slice_hrns]
# cache the result
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
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
def ListResources(api, creds, options,call_id):
if Callids().already_handled(call_id): return ""
# get slice's hrn from options
diff --git
a/sfa/managers/aggregate_manager_vini.py
b/sfa/managers/aggregate_manager_vini.py
index
f4e919b
..
92e0bdc
100644
(file)
--- a/
sfa/managers/aggregate_manager_vini.py
+++ b/
sfa/managers/aggregate_manager_vini.py
@@
-26,7
+26,7
@@
from sfa.util.callids import Callids
# 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 (
# 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_s
lices, get_ticket, slice_status)
+start_slice, stop_slice, RenewSliver, reset_slice,
ListS
lices, get_ticket, slice_status)
def GetVersion(api):
def GetVersion(api):
diff --git
a/sfa/managers/component_manager_default.py
b/sfa/managers/component_manager_default.py
index
bf7b852
..
b79c7cc
100644
(file)
--- a/
sfa/managers/component_manager_default.py
+++ b/
sfa/managers/component_manager_default.py
@@
-11,8
+11,8
@@
def DeleteSliver(api, slicename, call_id):
def reset_slice(api, slicename):
return
def reset_slice(api, slicename):
return
-def
get_s
lices(api):
- return
+def
ListS
lices(api):
+ return
[]
def reboot():
return
def reboot():
return
diff --git
a/sfa/managers/component_manager_pl.py
b/sfa/managers/component_manager_pl.py
index
961c035
..
3d4f76a
100644
(file)
--- a/
sfa/managers/component_manager_pl.py
+++ b/
sfa/managers/component_manager_pl.py
@@
-46,7
+46,8
@@
def reset_slice(api, xrn):
raise SliverDoesNotExist(slicename)
api.nodemanager.ReCreate(slicename)
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
# 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
diff --git
a/sfa/managers/slice_manager_pl.py
b/sfa/managers/slice_manager_pl.py
index
9676fe9
..
44b1a5e
100644
(file)
--- a/
sfa/managers/slice_manager_pl.py
+++ b/
sfa/managers/slice_manager_pl.py
@@
-288,10
+288,15
@@
def status(api, xrn, creds):
"""
return 1
"""
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
# look in cache first
- if api.cache:
+ if
caching and
api.cache:
slices = api.cache.get('slices')
if slices:
return slices
slices = api.cache.get('slices')
if slices:
return slices
@@
-312,7
+317,7
@@
def get_slices(api, creds):
if caller_hrn == aggregate and aggregate != api.hrn:
continue
server = api.aggregates[aggregate]
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()
# combime results
results = threads.get_results()
@@
-321,20
+326,15
@@
def get_slices(api, creds):
slices.extend(result)
# cache the result
slices.extend(result)
# cache the result
- if api.cache:
+ if
caching and
api.cache:
api.cache.add('slices', slices)
return slices
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):
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', '')
# get slice's hrn from options
xrn = options.get('geni_slice_urn', '')
diff --git
a/sfa/methods/ListSlices.py
b/sfa/methods/ListSlices.py
index
271bf9e
..
78a1f6b
100644
(file)
--- a/
sfa/methods/ListSlices.py
+++ b/
sfa/methods/ListSlices.py
@@
-17,17
+17,17
@@
class ListSlices(Method):
accepts = [
Mixed(Parameter(str, "Credential string"),
Parameter(type([str]), "List of credentials")),
accepts = [
Mixed(Parameter(str, "Credential string"),
Parameter(type([str]), "List of credentials")),
+ Parameter(str, "call_id"),
]
returns = Parameter(list, "List of slice names")
]
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))
#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()
manager = self.api.get_interface_manager()
- return manager.
get_slices(self.api, creds
)
+ return manager.
ListSlices(self.api, creds, call_id
)
diff --git
a/tests/testInterfaces.py
b/tests/testInterfaces.py
index
4aa905a
..
4d49d08
100755
(executable)
--- a/
tests/testInterfaces.py
+++ b/
tests/testInterfaces.py
@@
-184,7
+184,7
@@
class AggregateTest(BasicTestCase):
BasicTestCase.setUp(self)
def testGetSlices(self):
BasicTestCase.setUp(self)
def testGetSlices(self):
- self.aggregate.
get_s
lices(self.credential)
+ self.aggregate.
ListS
lices(self.credential)
def testGetResources(self):
# available resources
def testGetResources(self):
# available resources
@@
-240,7
+240,7
@@
class ComponentTest(BasicTestCase):
self.cm.restart_slice(self.slice_cred, self.slice['hrn'])
def testGetSlices(self):
self.cm.restart_slice(self.slice_cred, self.slice['hrn'])
def testGetSlices(self):
- self.cm.
get_s
lices(self.slice_cred, self.slice['hrn'])
+ self.cm.
ListS
lices(self.slice_cred, self.slice['hrn'])
def testRedeemTicket(self):
rspec = self.aggregate.get_resources(self.credential)
def testRedeemTicket(self):
rspec = self.aggregate.get_resources(self.credential)