Update in import packages.
[sfa.git] / sfa / senslab / slabaggregate.py
index e35bc9c..5b1eeed 100644 (file)
@@ -9,7 +9,7 @@ import json
 
 from sfa.util.config import Config
 from sfa.util.xrn import hrn_to_urn, urn_to_hrn, urn_to_sliver_id
-from sfa.util.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename
+from sfa.planetlab.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename
 
 from sfa.rspecs.rspec import RSpec
 from sfa.rspecs.elements.location import Location
@@ -24,7 +24,7 @@ from sfa.rspecs.version_manager import VersionManager
 from sfa.util.sfatime import datetime_to_epoch
 
 def hostname_to_hrn(root_auth,login_base,hostname):
-    return PlXrn(auth=root_auth,hostname=login_base+'_'+hostname).get_hrn()
+    return PlXrn(auth=root_auth,hostname=login_base + '_'+hostname).get_hrn()
 
 class SlabAggregate:
 
@@ -54,7 +54,7 @@ class SlabAggregate:
         slice_hrn, _ = urn_to_hrn(slice_xrn)
         slice_name = slice_hrn
         print >>sys.stderr,"\r\n \r\n \t\t_____________ Slabaggregate api get_slice_and_slivers "
-        slices = self.driver.GetSlices(slice_filter= str(slice_name), filter_type = 'slice_hrn')
+        slices = self.driver.GetSlices(slice_filter= str(slice_name), slice_filter_type = 'slice_hrn')
         print >>sys.stderr,"\r\n \r\n \t\t_____________ Slabaggregate api get_slice_and_slivers  slices %s " %(slices)
         if not slices:
             return (slice, slivers)
@@ -121,7 +121,6 @@ class SlabAggregate:
        
         #filter.update({'peer_id': None})
         #nodes = self.driver.GetNodes(filter['hostname'])
-        #print>>sys.stderr, "\r\n \r\n \t get_nodes nodes %s" %(nodes)
         
         #site_ids = []
         #interface_ids = []
@@ -176,9 +175,12 @@ class SlabAggregate:
             # assumes that sites, interfaces and tags have already been prepared.
             #site = sites_dict[node['site_id']]
          
-            if node['posx'] and node['posy']:  
-                location = Location({'longitude':node['posx'], 'latitude': node['posy']})
-                rspec_node['location'] = location
+            try:
+                if node['posx'] and node['posy']:  
+                    location = Location({'longitude':node['posx'], 'latitude': node['posy']})
+                    rspec_node['location'] = location
+            except KeyError:
+                    pass
             #rspec_node['interfaces'] = []
             #if_count=0
             #for if_id in node['interface_ids']: