Merge branch 'upstreammaster'
[sfa.git] / sfa / plc / plaggregate.py
index d581210..b84dac4 100644 (file)
@@ -127,14 +127,21 @@ class PlAggregate:
             # most likely a default/global sliver attribute (node_id == None)
             if tag['node_id'] not in slivers:
                 sliver = Sliver({'sliver_id': urn_to_sliver_id(slice_urn, slice['slice_id'], ""),
-                                 'name': 'plab-vserver',
+                                 'name': slice['name'],
+                                 'type': 'plab-vserver',
                                  'tags': []})
                 slivers[tag['node_id']] = sliver
             slivers[tag['node_id']]['tags'].append(tag)
         
         return (slice, slivers)
 
-    def get_nodes_and_links(self, slice=None,slivers=[], options={}):
+    def get_nodes_and_links(self, slice_xrn, slice=None,slivers=[], options={}):
+        # if we are dealing with a slice that has no node just return 
+        # and empty list    
+        if slice_xrn:
+            if not slice or not slice['node_ids']:
+                return ([],[])
+
         filter = {}
         tags_filter = {}
         if slice and 'node_ids' in slice and slice['node_ids']:
@@ -221,7 +228,7 @@ class PlAggregate:
                 rspec_node['slivers'] = [sliver]
                 
                 # slivers always provide the ssh service
-                login = Login({'authentication': 'ssh-keys', 'hostname': node['hostname'], 'port':'22'})
+                login = Login({'authentication': 'ssh-keys', 'hostname': node['hostname'], 'port':'22', 'username': sliver['name']})
                 service = Services({'login': login})
                 rspec_node['services'] = [service]
             rspec_nodes.append(rspec_node)
@@ -242,7 +249,7 @@ class PlAggregate:
         if slice and 'expires' in slice:
             rspec.xml.set('expires',  datetime_to_string(utcparse(slice['expires'])))
 
-        nodes, links = self.get_nodes_and_links(slice, slivers)
+        nodes, links = self.get_nodes_and_links(slice_xrn, slice, slivers)
         rspec.version.add_nodes(nodes)
         rspec.version.add_links(links)