PL Driver: 1st shot rebase of PL operations around the HRN tags of Slice/Person/Site
[sfa.git] / sfa / planetlab / pldriver.py
index 79c61f0..6fb8d60 100644 (file)
@@ -25,7 +25,7 @@ from sfa.planetlab.plshell import PlShell
 import sfa.planetlab.peers as peers
 from sfa.planetlab.plaggregate import PlAggregate
 from sfa.planetlab.plslices import PlSlices
-from sfa.planetlab.plxrn import PlXrn, slicename_to_hrn, hostname_to_hrn, hrn_to_pl_slicename, xrn_to_hostname, xrn_to_ext_slicename, top_auth
+from sfa.planetlab.plxrn import PlXrn, slicename_to_hrn, hostname_to_hrn, hrn_to_pl_slicename, xrn_to_hostname, top_auth, hash_loginbase
 
 
 def list_to_dict(recs, key):
@@ -767,12 +767,17 @@ class PlDriver (Driver):
 
     # set the 'enabled' tag to 0
     def shutdown (self, xrn, options={}):
-        hrn = urn_to_hrn(xrn)
+        hrn, _ = urn_to_hrn(xrn)
         top_auth_hrn = top_auth(hrn)
-        if top_auth_hrn == self.hrn:
-            slicename = hrn_to_pl_slicename(hrn)
+        site_hrn = '.'.join(hrn.split('.')[:-1])
+        slice_part = hrn.split('.')[-1]
+        if top_auth_hrn == self.driver.hrn:
+            login_base = slice_hrn.split('.')[-2][:12]
         else:
-            slicename = xrn_to_ext_slicename(hrn)
+            login_base = hash_loginbase(site_hrn)
+
+        slicename = '_'.join([login_base, slice_part])
+
         slices = self.shell.GetSlices({'name': slicename}, ['slice_id'])
         if not slices:
             raise RecordNotFound(slice_hrn)