X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=sfa%2Fmanagers%2Faggregate_manager_vini.py;h=92e0bdc416cd4e36f3bb64b67d518c96d096b972;hb=725c637b3d6f4e41773b83f7977e2ba962b5b1b7;hp=e79dcf421c263658ac57c23fbf2070ca2fae034b;hpb=f5a6829ab1fd58a695c3e6a92bfbf905223c4693;p=sfa.git diff --git a/sfa/managers/aggregate_manager_vini.py b/sfa/managers/aggregate_manager_vini.py index e79dcf42..92e0bdc4 100644 --- a/sfa/managers/aggregate_manager_vini.py +++ b/sfa/managers/aggregate_manager_vini.py @@ -4,7 +4,7 @@ import traceback import sys from types import StringTypes -from sfa.util.xrn import urn_to_hrn +from sfa.util.xrn import urn_to_hrn, Xrn from sfa.util.plxrn import hrn_to_pl_slicename from sfa.util.rspec import * from sfa.util.specdict import * @@ -21,27 +21,24 @@ from sfa.plc.api import SfaAPI from sfa.plc.slices import * from sfa.managers.aggregate_manager_pl import __get_registry_objects, __get_hostnames from sfa.util.version import version_core +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 ( -start_slice, stop_slice, renew_slice, reset_slice, get_slices, get_ticket) +start_slice, stop_slice, RenewSliver, reset_slice, ListSlices, get_ticket, slice_status) def GetVersion(api): + xrn=Xrn(api.hrn) return version_core({'interface':'aggregate', - 'testbed':'myplc.vini'}) + 'testbed':'myplc.vini', + 'hrn':xrn.get_hrn(), + }) -def slice_status(api, slice_xrn, creds): - result = {} - result['geni_urn'] = slice_xrn - result['geni_status'] = 'unknown' - result['geni_resources'] = {} - return result - - -def delete_slice(api, xrn, creds): - hrn, type = urn_to_hrn(xrn) +def DeleteSliver(api, xrn, creds, call_id): + if Callids().already_handled(call_id): return "" + (hrn, type) = urn_to_hrn(xrn) slicename = hrn_to_pl_slicename(hrn) slices = api.plshell.GetSlices(api.plauth, {'name': slicename}) if not slices: @@ -51,11 +48,13 @@ def delete_slice(api, xrn, creds): api.plshell.DeleteSliceFromNodes(api.plauth, slicename, slice['node_ids']) return 1 -def create_slice(api, xrn, creds, xml, users): +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 "" + hrn, type = urn_to_hrn(xrn) peer = None reg_objects = __get_registry_objects(xrn, creds, users) @@ -89,11 +88,11 @@ def create_slice(api, xrn, creds, xml, users): 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 get_rspec(api, creds, options): +def ListResources(api, creds, options,call_id): + if Callids().already_handled(call_id): return "" # get slice's hrn from options xrn = options.get('geni_slice_urn', '') hrn, type = urn_to_hrn(xrn) @@ -120,14 +119,14 @@ def get_rspec(api, creds, options): def main(): api = SfaAPI() """ - #rspec = get_rspec(api, None, None) - rspec = get_rspec(api, "plc.princeton.iias", None) + #rspec = ListResources(api, None, None,) + rspec = ListResources(api, "plc.princeton.iias", None, 'vini_test') print rspec """ f = open(sys.argv[1]) xml = f.read() f.close() - create_slice(api, "plc.princeton.iias", xml) + CreateSliver(api, "plc.princeton.iias", xml, 'call-id-iias') if __name__ == "__main__": main()