Set Site/Slice HRN when new Site/Slice is created
authorMohamed Larabi <mohamed.larabi@inria.fr>
Thu, 14 Nov 2013 16:45:10 +0000 (17:45 +0100)
committerMohamed Larabi <mohamed.larabi@inria.fr>
Thu, 14 Nov 2013 16:45:10 +0000 (17:45 +0100)
PLC/Methods/AddSite.py
PLC/Methods/AddSlice.py

index 13ac1fd..2150a91 100644 (file)
@@ -4,6 +4,8 @@ from PLC.Parameter import Parameter, Mixed
 from PLC.Sites import Site, Sites
 from PLC.Auth import Auth
 
+from PLC.Methods.AddSiteTag import AddSiteTag
+
 can_update = lambda (field, value): field in \
              ['name', 'abbreviated_name', 'login_base',
               'is_public', 'latitude', 'longitude', 'url',
@@ -38,4 +40,11 @@ class AddSite(Method):
         self.event_objects = {'Site': [site['site_id']]}
         self.message = 'Site %d created' % site['site_id']
 
+        # Set Site HRN
+        root_auth = self.api.config.PLC_HRN_ROOT
+        tagname = 'hrn'
+        tagvalue = '.'.join([root_auth, site['login_base']])
+        AddSiteTag(self.api).__call__(auth,site['site_id'],tagname,tagvalue)
+
+
         return site['site_id']
index 4802517..bcae122 100644 (file)
@@ -90,6 +90,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}):