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)
Hook called via 'sfi.py create'
"""
def CreateSliver(api, xrn, creds, xml, users, 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]
global cloud
hrn = urn_to_hrn(xrn)[0]
conn = getEucaConnection()
if not conn:
print >>sys.stderr, 'Error: Cannot create a connection to Eucalyptus'
conn = getEucaConnection()
if not conn:
print >>sys.stderr, 'Error: Cannot create a connection to Eucalyptus'
# Validate RSpec
schemaXML = ET.parse(EUCALYPTUS_RSPEC_SCHEMA)
# Validate RSpec
schemaXML = ET.parse(EUCALYPTUS_RSPEC_SCHEMA)
inst_type = instType)
eucaInst.reserveInstance(conn, pubKeys)
inst_type = instType)
eucaInst.reserveInstance(conn, pubKeys)
+ # xxx - should return altered rspec
+ # with enough data for the client to understand what's happened
+ return xml
def main():
init_server()
def main():
init_server()
def CreateSliver(api, xrn, creds, rspec_xml, users, 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]
global topology
hrn = urn_to_hrn(xrn)[0]
+ # 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 = []
def rspec_to_allocations(rspec):
ifs = []
if DEBUG: print "Received reset_slices call"
return msg_aggrMgr(SFA_RESET_SLICES)
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):
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"
hrn = urn_to_hrn(xrn)[0]
if DEBUG: print "Received CreateSliver call"
aggrMgr_sock.close()
if DEBUG: print "----------------"
aggrMgr_sock.close()
if DEBUG: print "----------------"
except socket.error, message:
print "Socket error"
except IOerror, message:
print "IO error"
except socket.error, message:
print "Socket error"
except IOerror, message:
print "IO error"
-# 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"
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.
"""
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)
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)
peer = None
slices = Slices(api)
peer = slices.get_peer(hrn)
api.plshell.BindObjectToPeer(api.plauth, 'slice', slice.id, peer,
slice.peer_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):
def renew_slice(api, xrn, creds, expiration_time):
Verify HRN and initialize the slice record in PLC if necessary.
"""
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
hrn, type = urn_to_hrn(xrn)
peer = None
api.plshell.DeleteSliceFromNodes(api.plauth, slice.name, deleted_nodes)
network.updateSliceTags()
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 ""
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)
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)