X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddSlice.py;h=0d6c1c6e08d23fec380c90ae5aa40fbac544f95b;hb=36de11f1c6e35ae81eb4774a395f3507cd44feb3;hp=0274e0191627252fab90d310d6cfbff69c6a9d4d;hpb=4e770b3cf4e6b16150fd479ace9854eaee3399b6;p=plcapi.git diff --git a/PLC/Methods/AddSlice.py b/PLC/Methods/AddSlice.py index 0274e01..0d6c1c6 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.Debug import log + can_update = ['name', 'instantiation', 'url', 'description', 'max_nodes'] class AddSlice(Method): @@ -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}): @@ -100,6 +106,15 @@ class AddSlice(Method): else: UpdateSliceTag(self.api).__call__(auth,slice_tags[0]['slice_tag_id'],value) + # take PLC_VSYS_DEFAULTS into account for convenience + try: + values= [ y for y in [ x.strip() for x in self.api.config.PLC_VSYS_DEFAULTS.split(',') ] if y ] + for value in values: + AddSliceTag(self.api).__call__(auth,slice['slice_id'],'vsys',value) + except: + print >> log, "Could not set vsys tags as configured in PLC_VSYS_DEFAULTS" + import traceback + traceback.print_exc(file=log) self.event_objects = {'Slice': [slice['slice_id']]} self.message = "Slice %d created" % slice['slice_id']