From 0f8b7b3ee92d1178e1a726167b3a7290e5d23400 Mon Sep 17 00:00:00 2001 From: Josh Karlin Date: Wed, 12 May 2010 18:42:57 +0000 Subject: [PATCH] modified verify_slice.. need to work on getting 'persons' --- sfa/managers/geni_am_pl.py | 27 +++++++++++++++++++++------ sfa/plc/slices.py | 18 ++++++++++++------ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/sfa/managers/geni_am_pl.py b/sfa/managers/geni_am_pl.py index 16f6475d..87d8a959 100644 --- a/sfa/managers/geni_am_pl.py +++ b/sfa/managers/geni_am_pl.py @@ -2,7 +2,7 @@ from sfa.util.namespace import * from sfa.util.rspec import * from sfa.util.specdict import * from sfa.util.faults import * - +from sfa.trust.credential import Credential from sfa.util.record import * from sfa.plc.slices import * @@ -10,6 +10,7 @@ from sfa.util.sfalogging import * from sfa.util.record import SfaRecord from lxml import etree from StringIO import StringIO +from time import mktime def GetVersion(): version = {} @@ -54,23 +55,37 @@ def ListResources(api, creds, options): def CreateSliver(api, slice_xrn, creds, rspec): - reg_objects = {} hrn, type = urn_to_hrn(slice_xrn) hrn_auth = get_authority(hrn) - #site = SfaRecord(hrn=hrn_auth, type='authority') + # Build up objects that an SFA registry would return if SFA + # could contact the slice's registry directly + reg_objects = {} + site = {} site['site_id'] = 0 - site['name'] = 'geni.%s' % slice_xrn + site['name'] = 'geni.%s' % hrn_auth site['enabled'] = True site['max_slices'] = 100 + + # Note: + # Is it okay if this login base is the same as one already at this myplc site? + # Do we need uniqueness? Should use hrn_auth instead of just the leaf perhaps? site['login_base'] = get_leaf(hrn_auth) site['abbreviated_name'] = hrn - site['max_slivers'] = 1000 - + site['max_slivers'] = 1000 reg_objects['site'] = site + slice = {} + slice['expires'] = int(mktime(Credential(string=creds[0]).get_lifetime().timetuple())) + slice['hrn'] = hrn + slice['name'] = site['login_base'] + "_" + get_leaf(hrn) + slice['url'] = hrn + slice['description'] = hrn + slice['pointer'] = 0 + reg_objects['slice_record'] = slice + manager_base = 'sfa.managers' mgr_type = 'pl' manager_module = manager_base + ".aggregate_manager_%s" % mgr_type diff --git a/sfa/plc/slices.py b/sfa/plc/slices.py index f4977a31..bc1e0a55 100644 --- a/sfa/plc/slices.py +++ b/sfa/plc/slices.py @@ -211,13 +211,19 @@ class Slices: slice = {} slice_record = None authority = get_authority(slice_hrn) - slice_records = registry.resolve(credential, slice_hrn) - for record in slice_records: - if record['type'] in ['slice']: - slice_record = record - if not slice_record: - raise RecordNotFound(hrn) + if reg_objects: + slice_record = reg_objects['slice_record'] + else: + slice_records = registry.resolve(credential, slice_hrn) + + for record in slice_records: + if record['type'] in ['slice']: + slice_record = record + if not slice_record: + raise RecordNotFound(hrn) + + slicename = hrn_to_pl_slicename(slice_hrn) parts = slicename.split("_") login_base = parts[0] -- 2.47.0