this change is designed for illustrative purposes only
[sfa.git] / sfa / rspecs / elements / versions / pgv2Node.py
index 8266f96..2784fcf 100644 (file)
@@ -15,6 +15,7 @@ from sfa.rspecs.elements.versions.pgv2Interface import PGv2Interface
 from sfa.rspecs.elements.versions.sfav1PLTag import SFAv1PLTag
 from sfa.rspecs.elements.granularity import Granularity
 from sfa.rspecs.elements.attribute import Attribute
+from sfa.rspecs.elements.memory import Memory
 
 
 class PGv2Node:
@@ -55,7 +56,11 @@ class PGv2Node:
             slivers = node.get('slivers', [])
             if not slivers:
                 # we must still advertise the available sliver types
-                slivers = Sliver({'type': 'plab-vserver'})
+                if node.get('sliver_type'):
+                    slivers = Sliver({'type': node['sliver_type']})
+                else:
+                # Planet lab
+                    slivers = Sliver({'type': 'plab-vserver'})
                 # we must also advertise the available initscripts
                 slivers['tags'] = []
                 if node.get('pl_initscripts'): 
@@ -63,6 +68,10 @@ class PGv2Node:
                         slivers['tags'].append({'name': 'initscript', 'value': initscript['name']})
             PGv2SliverType.add_slivers(node_elem, slivers)
 
+            # render the memory tag; it will be placed at this point in the xml output
+            if node.get('memory'):
+                node_elem.add_instance('memory',node['memory'],Memory.fields)
+
             # advertise the node tags
             tags = node.get('tags', [])
             if tags:
@@ -71,20 +80,22 @@ class PGv2Node:
                     node_elem.add_instance('{%s}attribute' % xml.namespaces['planetlab'], tag, ['name', 'value'])
 
             # add sliver tag in Request Rspec
-            if rspec_content_type == "request":
-                node_elem.add_instance('sliver', '', [])
+            #if rspec_content_type == "request":
+            #    node_elem.add_instance('sliver', '', [])
 
         return node_elems
 
 
     @staticmethod
-    def get_nodes(xml, filter={}):
+    def get_nodes(xml, filter=None):
+        if filter is None: filter={}
         xpath = '//node%s | //default:node%s' % (XpathFilter.xpath(filter), XpathFilter.xpath(filter))
         node_elems = xml.xpath(xpath)
         return PGv2Node.get_node_objs(node_elems)
 
     @staticmethod
-    def get_nodes_with_slivers(xml, filter={}):
+    def get_nodes_with_slivers(xml, filter=None):
+        if filter is None: filter={}
         xpath = '//node[count(sliver_type)>0] | //default:node[count(default:sliver_type) > 0]' 
         node_elems = xml.xpath(xpath)        
         return PGv2Node.get_node_objs(node_elems)