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]
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)
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()
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]
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 = []
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"
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"
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)
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):
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
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 ""
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)