X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddSlice.py;h=7542cf079d6550aa3f1310f10807637cde1a8fa3;hb=e70e20fdbececafef842ec7b330fd48db42e614e;hp=48025178f8cde0f47e902946a3b75b395651641d;hpb=abc6f792c80eb98ab9032a69c526d48efe8075cc;p=plcapi.git diff --git a/PLC/Methods/AddSlice.py b/PLC/Methods/AddSlice.py index 4802517..7542cf0 100644 --- a/PLC/Methods/AddSlice.py +++ b/PLC/Methods/AddSlice.py @@ -13,6 +13,8 @@ from PLC.SliceTags import SliceTags from PLC.Methods.AddSliceTag import AddSliceTag from PLC.Methods.UpdateSliceTag import UpdateSliceTag +from PLC.Logger import logger + can_update = ['name', 'instantiation', 'url', 'description', 'max_nodes'] class AddSlice(Method): @@ -61,7 +63,7 @@ class AddSlice(Method): # 3. Then single underscore after login_base. # 4. Then letters, numbers, or underscores. name = slice_fields['name'] - good_name = r'^[a-z0-9]+_[a-zA-Z0-9_]+$' + good_name = r'^[a-z0-9\.]+_[a-zA-Z0-9_\.]+$' if not name or \ not re.match(good_name, name): raise PLCInvalidArgument, "Invalid slice name" @@ -90,6 +92,10 @@ class AddSlice(Method): slice['site_id'] = site['site_id'] slice.sync() + # Set Slice HRN + root_auth = self.api.config.PLC_HRN_ROOT + tags['hrn'] = '.'.join([root_auth, login_base, name.split("_")[1]]) + for (tagname,value) in tags.iteritems(): # the tagtype instance is assumed to exist, just check that if not TagTypes(self.api,{'tagname':tagname}): @@ -106,9 +112,7 @@ class AddSlice(Method): for value in values: AddSliceTag(self.api).__call__(auth,slice['slice_id'],'vsys',value) except: - print "Could not set vsys tags as configured in PLC_VSYS_DEFAULTS" - import traceback - traceback.print_exc() + logger.exception("Could not set vsys tags as configured in PLC_VSYS_DEFAULTS") self.event_objects = {'Slice': [slice['slice_id']]} self.message = "Slice %d created" % slice['slice_id']