preserve nodes full hostname in hrn/urn
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 24 Jan 2011 21:34:51 +0000 (16:34 -0500)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 24 Jan 2011 21:34:51 +0000 (16:34 -0500)
sfa/plc/sfa-import-plc.py
sfa/plc/sfaImport.py

index 7077eb6..7b96c35 100755 (executable)
@@ -26,6 +26,7 @@ from sfa.util.config import Config
 from sfa.trust.certificate import convert_public_key, Keypair
 from sfa.trust.trustedroot import *
 from sfa.trust.hierarchy import *
+from sfa.util.xrn import Xrn
 from sfa.plc.api import *
 from sfa.trust.gid import create_uuid
 from sfa.plc.sfaImport import sfaImport
@@ -161,7 +162,7 @@ def main():
             hrn =  hostname_to_hrn(interface_hrn, site['login_base'], node['hostname'])
             if hrn not in existing_hrns or \
                (hrn, 'node') not in existing_records:
-                sfaImporter.import_node(site_hrn, node)
+                sfaImporter.import_node(hrn, node)
 
         # import slices
         for slice_id in site['slice_ids']:
@@ -241,11 +242,11 @@ def main():
  
         elif type == 'node':
             login_base = get_leaf(get_authority(record_hrn))
-            nodename = get_leaf(record_hrn)
+            nodename = Xrn.unescape(get_leaf(record_hrn))
             if login_base in sites_dict:
                 site = sites_dict[login_base]
                 for node in nodes:
-                    tmp_nodename = node['hostname'].split(".")[0]
+                    tmp_nodename = node['hostname']
                     if tmp_nodename == nodename and \
                        node['site_id'] == site['site_id'] and \
                        node['node_id'] == record['pointer']:
index 117a220..238b5e1 100644 (file)
@@ -187,15 +187,7 @@ class sfaImport:
             slice_record['record_id'] = existing_record['record_id']
             table.update(slice_record)
 
-    def import_node(self, parent_hrn, node):
-        nodename = node['hostname'].split(".")[0]
-        nodename = _cleanup_string(nodename)
-        
-        if not nodename:
-            self.logger.error("Import: failed to parse node %s" %node['hostname'])
-            return
-
-        hrn = parent_hrn + "." + nodename
+    def import_node(self, hrn, node):
         self.logger.info("Import: node %s" % hrn)
         # ASN.1 will have problems with hrn's longer than 64 characters
         if len(hrn) > 64: