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):
# 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"
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}):
# take PLC_VSYS_DEFAULTS into account for convenience
try:
- values= [ value for value in api.config.PLC_VSYS_DEFAULTS.split(',') if value ]
+ 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 "Could not set vsys tags as configured in PLC_VSYS_DEFAULTS"
+ 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']