X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fmanagers%2Faggregate_manager_pl.py;h=6b362842d2093561d1eb9d5274d8a0295e877b81;hb=c1623056cb0a51c3817425ceee85aec3c62c57f3;hp=11c90a989d5f5360622d76cd90fb78a9a9898ea0;hpb=5519554e0dc4cb758363c524cf410977947dc1e6;p=sfa.git diff --git a/sfa/managers/aggregate_manager_pl.py b/sfa/managers/aggregate_manager_pl.py index 11c90a98..6b362842 100644 --- a/sfa/managers/aggregate_manager_pl.py +++ b/sfa/managers/aggregate_manager_pl.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import datetime import time import traceback @@ -23,19 +25,24 @@ from sfa.plc.aggregate import Aggregate from sfa.plc.slices import * from sfa.util.version import version_core from sfa.rspecs.rspec_version import RSpecVersion +from sfa.rspecs.sfa_rspec import sfa_rspec_version +from sfa.rspecs.pg_rspec import pg_rspec_version from sfa.rspecs.rspec_parser import parse_rspec from sfa.util.sfatime import utcparse from sfa.util.callids import Callids def GetVersion(api): xrn=Xrn(api.hrn) - return version_core({'interface':'aggregate', - 'testbed':'myplc', - 'hrn':xrn.get_hrn(), - 'input_rspec' : ['PG 2', 'SFA 1'], - 'output_rspec' : ["SFA 1"], - 'ad_rspec' : ["PG 2", "SFA 1"], - }) + + supported_rspecs = [dict(pg_rspec_version), dict(sfa_rspec_version)] + version_more = {'interface':'aggregate', + 'testbed':'myplc', + 'hrn':xrn.get_hrn(), + 'request_rspec_versions': supported_rspecs, + 'ad_rspec_versions': supported_rspecs, + 'default_ad_rspec': dict(sfa_rspec_version) + } + return version_core(version_more) def __get_registry_objects(slice_xrn, creds, users): """ @@ -181,8 +188,7 @@ def CreateSliver(api, slice_xrn, creds, rspec_string, users, call_id): nodes = api.plshell.GetNodes(api.plauth, slice['node_ids'], ['hostname']) current_slivers = [node['hostname'] for node in nodes] rspec = parse_rspec(rspec_string) - requested_slivers = rspec.get_nodes_with_slivers() - + requested_slivers = [str(host) for host in rspec.get_nodes_with_slivers()] # remove nodes not in rspec deleted_nodes = list(set(current_slivers).difference(requested_slivers)) @@ -204,7 +210,7 @@ def CreateSliver(api, slice_xrn, creds, rspec_string, users, call_id): api.plshell.BindObjectToPeer(api.plauth, 'slice', slice.id, peer, slice.peer_id) - return aggregate.get_rspec(slice_xrn=slice_xrn) + return aggregate.get_rspec(slice_xrn=slice_xrn, version=rspec.version) def RenewSliver(api, xrn, creds, expiration_time, call_id): @@ -277,8 +283,8 @@ def DeleteSliver(api, xrn, creds, call_id): return 1 # xxx Thierry : caching at the aggregate level sounds wrong... -caching=True -#caching=False +#caching=True +caching=False def ListSlices(api, creds, call_id): if Callids().already_handled(call_id): return [] # look in cache first @@ -305,8 +311,14 @@ def ListResources(api, creds, options,call_id): (hrn, type) = urn_to_hrn(xrn) # get the rspec's return format from options - rspec_version = RSpecVersion(options.get('rspec_version', 'SFA 1')) - version_string = "rspec_%s_%s" % (rspec_version.format, rspec_version.version) + rspec_version = RSpecVersion(options.get('rspec_version')) + version_string = "rspec_%s" % (rspec_version.get_version_name()) + + #panos adding the info option to the caching key (can be improved) + if options.get('info'): + version_string = version_string + "_"+options.get('info') + + print "[aggregate] version string = ",version_string # look in cache first if caching and api.cache and not xrn: @@ -315,14 +327,12 @@ def ListResources(api, creds, options,call_id): api.logger.info("aggregate.ListResources: returning cached value for hrn %s"%hrn) return rspec - aggregate = Aggregate(api) + #aggregate = Aggregate(api) + #panos: passing user-defined options + #print "manager options = ",options + aggregate = Aggregate(api, options) - if xrn: - # get this rspec for the specified slice - rspec = aggregate.get_rspec(slice_xrn=hrn, version=rspec_version) - else: - # generate rspec in both pg and sfa formats - rspec = aggregate.get_rspec(version=rspec_version) + rspec = aggregate.get_rspec(slice_xrn=xrn, version=rspec_version) # cache the result if caching and api.cache and not xrn: