From e2c2fc5701ad2a43b3de5503cf66a2331af9f080 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Sat, 9 Apr 2011 13:49:50 +0200 Subject: [PATCH] CreateSliver method returns possibly altered rspec the PL and VINI aggregate start to use this, need to check how useful/accurate this currently is (the other aggregates currently return their input rspec, so no change for them in this changeset) --- sfa/managers/aggregate_manager_eucalyptus.py | 8 +++++--- sfa/managers/aggregate_manager_max.py | 6 ++++-- sfa/managers/aggregate_manager_openflow.py | 9 +++++---- sfa/managers/aggregate_manager_pl.py | 9 ++++----- sfa/managers/aggregate_manager_vini.py | 7 +++---- sfa/methods/CreateSliver.py | 7 ++----- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sfa/managers/aggregate_manager_eucalyptus.py b/sfa/managers/aggregate_manager_eucalyptus.py index e187a56d..68669bd9 100644 --- a/sfa/managers/aggregate_manager_eucalyptus.py +++ b/sfa/managers/aggregate_manager_eucalyptus.py @@ -491,7 +491,7 @@ def ListResources(api, creds, options, call_id): Hook called via 'sfi.py create' """ def CreateSliver(api, xrn, creds, xml, users, call_id): - if Callids().already_handled(call_id): return False + if Callids().already_handled(call_id): return "" global cloud hrn = urn_to_hrn(xrn)[0] @@ -499,7 +499,7 @@ def CreateSliver(api, xrn, creds, xml, users, call_id): conn = getEucaConnection() if not conn: print >>sys.stderr, 'Error: Cannot create a connection to Eucalyptus' - return False + return "" # Validate RSpec schemaXML = ET.parse(EUCALYPTUS_RSPEC_SCHEMA) @@ -563,7 +563,9 @@ def CreateSliver(api, xrn, creds, xml, users, call_id): inst_type = instType) eucaInst.reserveInstance(conn, pubKeys) - return True + # xxx - should return altered rspec + # with enough data for the client to understand what's happened + return xml def main(): init_server() diff --git a/sfa/managers/aggregate_manager_max.py b/sfa/managers/aggregate_manager_max.py index f289e7d0..9f99bcf5 100644 --- a/sfa/managers/aggregate_manager_max.py +++ b/sfa/managers/aggregate_manager_max.py @@ -272,7 +272,7 @@ def ListResources(api, creds, options, call_id): def CreateSliver(api, xrn, creds, rspec_xml, users, call_id): - if Callids().already_handled(call_id): return False + if Callids().already_handled(call_id): return "" global topology hrn = urn_to_hrn(xrn)[0] @@ -320,7 +320,9 @@ def CreateSliver(api, xrn, creds, rspec_xml, users, call_id): unlock_state_file() - return True + # xxx - should return altered rspec + # with enough data for the client to understand what's happened + return rspec_xml def rspec_to_allocations(rspec): ifs = [] diff --git a/sfa/managers/aggregate_manager_openflow.py b/sfa/managers/aggregate_manager_openflow.py index 7a965dc0..a31c11e2 100755 --- a/sfa/managers/aggregate_manager_openflow.py +++ b/sfa/managers/aggregate_manager_openflow.py @@ -111,8 +111,9 @@ def reset_slices(cred, xrn): if DEBUG: print "Received reset_slices call" return msg_aggrMgr(SFA_RESET_SLICES) +### Thierry: xxx this should ahve api as a first arg - probably outdated def CreateSliver(cred, xrn, rspec, call_id): - if Callids().already_handled(call_id): return False + if Callids().already_handled(call_id): return "" hrn = urn_to_hrn(xrn)[0] if DEBUG: print "Received CreateSliver call" @@ -128,14 +129,14 @@ def CreateSliver(cred, xrn, rspec, call_id): aggrMgr_sock.close() if DEBUG: print "----------------" - return 1 + return rspec except socket.error, message: print "Socket error" except IOerror, message: print "IO error" - return 0 + return "" -# Thierry : this would need to handle call_id like the other AMs but is outdated... +# Thierry : xxx this would need to handle call_id like the other AMs but is outdated... def ListResources(cred, xrn=None): hrn = urn_to_hrn(xrn)[0] if DEBUG: print "Received ListResources call" diff --git a/sfa/managers/aggregate_manager_pl.py b/sfa/managers/aggregate_manager_pl.py index 9e0aa27f..e71fc674 100644 --- a/sfa/managers/aggregate_manager_pl.py +++ b/sfa/managers/aggregate_manager_pl.py @@ -159,11 +159,11 @@ def CreateSliver(api, slice_xrn, creds, rspec, users, call_id): Create the sliver[s] (slice) at this aggregate. Verify HRN and initialize the slice record in PLC if necessary. """ - if Callids().already_handled(call_id): return False + if Callids().already_handled(call_id): return "" reg_objects = __get_registry_objects(slice_xrn, creds, users) - hrn, type = urn_to_hrn(slice_xrn) + (hrn, type) = urn_to_hrn(slice_xrn) peer = None slices = Slices(api) peer = slices.get_peer(hrn) @@ -205,9 +205,8 @@ def CreateSliver(api, slice_xrn, creds, rspec, users, call_id): api.plshell.BindObjectToPeer(api.plauth, 'slice', slice.id, peer, slice.peer_id) - # print network.toxml() - - return True + # xxx - check this holds enough data for the client to understand what's happened + return network.toxml() def renew_slice(api, xrn, creds, expiration_time): diff --git a/sfa/managers/aggregate_manager_vini.py b/sfa/managers/aggregate_manager_vini.py index b1a7044e..40ed258d 100644 --- a/sfa/managers/aggregate_manager_vini.py +++ b/sfa/managers/aggregate_manager_vini.py @@ -52,7 +52,7 @@ def CreateSliver(api, xrn, creds, xml, users, call_id): Verify HRN and initialize the slice record in PLC if necessary. """ - if Callids().already_handled(call_id): return False + if Callids().already_handled(call_id): return "" hrn, type = urn_to_hrn(xrn) peer = None @@ -87,9 +87,8 @@ def CreateSliver(api, xrn, creds, xml, users, call_id): api.plshell.DeleteSliceFromNodes(api.plauth, slice.name, deleted_nodes) network.updateSliceTags() - # print network.toxml() - - return True + # xxx - check this holds enough data for the client to understand what's happened + return network.toxml() def ListResources(api, creds, options,call_id): if Callids().already_handled(call_id): return "" diff --git a/sfa/methods/CreateSliver.py b/sfa/methods/CreateSliver.py index 96b535db..e62e6f45 100644 --- a/sfa/methods/CreateSliver.py +++ b/sfa/methods/CreateSliver.py @@ -46,8 +46,5 @@ class CreateSliver(Method): chain_name = 'FORWARD-INCOMING' self.api.logger.debug("CreateSliver: sfatables on chain %s"%chain_name) rspec = run_sfatables(chain_name, hrn, origin_hrn, rspec) - # the aggregate's CreateSliver returns false if call_id was already handled - if manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id): - return rspec - else: - return "" + + return manager.CreateSliver(self.api, slice_xrn, creds, rspec, users, call_id) -- 2.43.0