some occurrences of items() that need being converted into list()
[sfa.git] / sfa / rspecs / versions / iotlabv1.py
index a4a8300..0d39323 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import print_function
+
 from copy import deepcopy
 
 
@@ -19,7 +21,7 @@ class Iotlabv1(RSpecVersion):
     valid Iotlab XML Rspec.
     """
     #enabled = True
-    type = 'Slab'
+    type = 'Iotlab'
     content_type = 'ad'
     version = '1'
     #template = '<RSpec type="%s"></RSpec>' % type
@@ -30,7 +32,7 @@ class Iotlabv1(RSpecVersion):
         'flack': "http://www.protogeni.net/resources/rspec/ext/flack/1",
         'planetlab': "http://www.planet-lab.org/resources/sfa/ext/planetlab/1",
     }
-    namespaces = dict(extensions.items() + [('default', namespace)])
+    namespaces = dict(list(extensions.items()) + [('default', namespace)])
     elements = []
 
     # Network
@@ -64,8 +66,8 @@ class Iotlabv1(RSpecVersion):
     def add_connection_information(self, ldap_username, sites_set):
         return Iotlabv1Node.add_connection_information(self.xml,ldap_username, sites_set)
 
-    def add_nodes(self, nodes, check_for_dupes=False):
-        return Iotlabv1Node.add_nodes(self.xml,nodes )
+    def add_nodes(self, nodes, check_for_dupes=False, rspec_content_type=None):
+        return Iotlabv1Node.add_nodes(self.xml,nodes, rspec_content_type)
 
     def merge_node(self, source_node_tag, network, no_dupes = False):
         logger.debug("SLABV1 merge_node")
@@ -78,10 +80,10 @@ class Iotlabv1(RSpecVersion):
     # Slivers
 
     def get_sliver_attributes(self, hostname, node, network=None):
-        print>>sys.stderr, "\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes hostname %s " %(hostname)
+        print("\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes hostname %s " %(hostname), file=sys.stderr)
         nodes = self.get_nodes({'component_id': '*%s*' %hostname})
         attribs = []
-        print>>sys.stderr, "\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes-----------------nodes %s  " %(nodes)
+        print("\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes-----------------nodes %s  " %(nodes), file=sys.stderr)
         if nodes is not None and isinstance(nodes, list) and len(nodes) > 0:
             node = nodes[0]
         #if node :
@@ -93,7 +95,7 @@ class Iotlabv1(RSpecVersion):
                 sliver = sliver[0]
                 attribs = sliver
                 #attribs = self.attributes_list(sliver)
-                print>>sys.stderr, "\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes----------NN------- sliver %s self.namespaces %s attribs %s " %(sliver, self.namespaces,attribs)
+                print("\r\n \r\n \r\n \t\t SLABV1.PY  get_sliver_attributes----------NN------- sliver %s self.namespaces %s attribs %s " %(sliver, self.namespaces,attribs), file=sys.stderr)
         return attribs
 
     def get_slice_attributes(self, network=None):
@@ -139,10 +141,11 @@ class Iotlabv1(RSpecVersion):
     def add_default_sliver_attribute(self, name, value, network=None):
         pass
 
-    def add_slivers(self, hostnames, attributes=[], sliver_urn=None, append=False):
+    def add_slivers(self, hostnames, attributes=None, sliver_urn=None, append=False):
+        if attributes is None: attributes=[]
         # all nodes hould already be present in the rspec. Remove all
         # nodes that done have slivers
-        print>>sys.stderr, "\r\n \r\n \r\n \t\t\t Iotlabv1.PY add_slivers  ----->get_node "
+        print("\r\n \r\n \r\n \t\t\t Iotlabv1.PY add_slivers  ----->get_node ", file=sys.stderr)
         for hostname in hostnames:
             node_elems = self.get_nodes({'component_id': '*%s*' % hostname})
             if not node_elems:
@@ -162,7 +165,7 @@ class Iotlabv1(RSpecVersion):
                 continue
             sliver = {'type': requested_sliver_type,
                      'pl_tags': attributes}
-            print>>sys.stderr, "\r\n \r\n \r\n \t\t\t Iotlabv1.PY add_slivers  node_elem %s sliver_type %s \r\n \r\n " %(node_elem, sliver_type)
+            print("\r\n \r\n \r\n \t\t\t Iotlabv1.PY add_slivers  node_elem %s sliver_type %s \r\n \r\n " %(node_elem, sliver_type), file=sys.stderr)
             # remove available element
             for available_elem in node_elem.xpath('./default:available | ./available'):
                 node_elem.remove(available_elem)
@@ -245,6 +248,28 @@ class Iotlabv1(RSpecVersion):
         SFAv1Lease.add_leases(self.xml, leases)
         #Iotlabv1Lease.add_leases(self.xml, leases)
 
+    # Spectrum
+
+    def get_channels(self, filter=None):
+        return []
+
+    def add_channels(self, channels, network = None, no_dupes=False):
+        pass
+
+    # Links
+
+    def get_links(self, network=None):
+        return []
+
+    def get_link_requests(self):
+        return []
+
+    def add_links(self, links):
+        pass
+    def add_link_requests(self, links):
+        pass
+
+
     def cleanup(self):
         # remove unncecessary elements, attributes
         if self.type in ['request', 'manifest']:
@@ -280,4 +305,4 @@ if __name__ == '__main__':
     r = RSpec('/tmp/iotlab.rspec')
     r.load_rspec_elements(Iotlabv1.elements)
     r.namespaces = Iotlabv1.namespaces
-    print r.get(RSpecElements.NODE)
+    print(r.get(RSpecElements.NODE))