X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FMethods%2FAddSlice.py;h=0d6c1c6e08d23fec380c90ae5aa40fbac544f95b;hb=36de11f1c6e35ae81eb4774a395f3507cd44feb3;hp=a7fb5b989cfcb76998e5a9ec41ceb07030a58922;hpb=f7ce7ce813d4c44502629820a3583f32a99a98f7;p=plcapi.git diff --git a/PLC/Methods/AddSlice.py b/PLC/Methods/AddSlice.py index a7fb5b9..0d6c1c6 100644 --- a/PLC/Methods/AddSlice.py +++ b/PLC/Methods/AddSlice.py @@ -1,5 +1,3 @@ -# $Id$ -# $URL$ import re from PLC.Faults import * @@ -15,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): @@ -92,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}): @@ -102,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']