X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Ftests%2FGetConfiguration.py;h=55d24671b05f59c9d6fff777a3d452cb33d3bae4;hb=90ecab134bf44662886576bea76c48d0aea316b7;hp=b3193f48095add6f3a770cca9fd86a8a22ad97c9;hpb=f4b1995dca983f5820f12c009d2f2f0c4434be95;p=plstackapi.git diff --git a/planetstack/tests/GetConfiguration.py b/planetstack/tests/GetConfiguration.py index b3193f4..55d2467 100644 --- a/planetstack/tests/GetConfiguration.py +++ b/planetstack/tests/GetConfiguration.py @@ -10,6 +10,8 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings") from openstack.manager import OpenStackManager from core.models import Slice, Sliver, ServiceClass, Reservation, Tag, Network, User, Node, Image, Deployment, Site, NetworkTemplate, NetworkSlice +slice_name_map = {} + def ps_id_to_pl_id(x): # Since we don't want the PlanetStack object IDs to conflict with existing # PlanetLab object IDs in the CMI, just add 100000 to the PlanetStack object @@ -20,12 +22,15 @@ def pl_id_to_ps_id(x): return x - 100000 def pl_slice_id(slice): - if slice.name == "princeton_vcoblitz": + if slice.name.startswith("princeton_vcoblitz"): # 70 is the slice id of princeton_vcoblitz on vicci return 70 else: return ps_id_to_pl_id(slice.id) +def ps_slicename_to_pl_slicename(x): + return slice_name_map.get(x,x) + def filter_fields(src, fields): dest = {} for (key,value) in src.items(): @@ -51,7 +56,7 @@ def GetSlices(filter={}): "slice_tag_ids": [], "peer_id": None, "site_id": ps_id_to_pl_id(ps_slice.site_id), - "name": ps_slice.name} + "name": ps_slicename_to_pl_slicename(ps_slice.name)} # creator_person_id, person_ids, expires, created @@ -159,6 +164,22 @@ def GetInterfaces(slicename, node_ids): interfaces.append(interface) return interfaces +def find_multi_slicename(orig_slicename): + """ + Because we sometimes have issues deleting a slice in planetstack and + creating a new one, allow us to use a prefix match, that way someone + can put a version number of the end of the slicename + """ + global slice_name_map + slices = Slice.objects.filter() + for slice in slices: + if slice.name.startswith(orig_slicename): + slice_name_map[slice.name] = orig_slicename + return slice.name + + return orig_slicename + + def GetConfiguration(name): slicename = name["name"] if "node_id" in name: @@ -166,6 +187,8 @@ def GetConfiguration(name): else: node_id = 0 + slicename = find_multi_slicename(slicename) + node_sliver_tags = GetTags(slicename, node_id) slices = GetSlices({"name": slicename}) @@ -215,11 +238,13 @@ def GetConfiguration(name): 'nodes': nodes} if __name__ == '__main__': + find_multi_slicename("princeton_vcoblitz") # set up the mapping for princeton_vcoblitz2 -> princeton_vcoblitz + slices = GetSlices() nodes = GetNodes() if ("-d" in sys.argv): - config = GetConfiguration({"name": "princeton_coblitz"}) + config = GetConfiguration({"name": "princeton_vcoblitz"}) print config print slices print nodes