still making both branches closer
[nepi.git] / src / nepi / resources / omf / wilabt_node.py
index eecbe45..8ce3e21 100644 (file)
@@ -3,9 +3,8 @@
 #    Copyright (C) 2013 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
 #    Copyright (C) 2013 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,7 +18,7 @@
 
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
 
 from nepi.execution.attribute import Attribute, Flags, Types
 from nepi.execution.resource import ResourceManager, clsinit_copy, \
-        ResourceState, reschedule_delay 
+        ResourceState 
 from nepi.resources.omf.node import OMFNode
 from nepi.util.sfaapi import SFAAPIFactory 
 from nepi.util.execfuncs import lexec
 from nepi.resources.omf.node import OMFNode
 from nepi.util.sfaapi import SFAAPIFactory 
 from nepi.util.execfuncs import lexec
@@ -35,10 +34,10 @@ import datetime
 
 @clsinit_copy
 class WilabtSfaNode(OMFNode):
 
 @clsinit_copy
 class WilabtSfaNode(OMFNode):
-    _rtype = "WilabtSfaNode"
+    _rtype = "wilabt::sfa::Node"
     _help = "Controls a Wilabt host accessible using a SSH key " \
             "and provisioned using SFA"
     _help = "Controls a Wilabt host accessible using a SSH key " \
             "and provisioned using SFA"
-    _backend = "omf"
+    _platform = "omf"
 
     @classmethod
     def _register_attributes(cls):
 
     @classmethod
     def _register_attributes(cls):
@@ -71,8 +70,8 @@ class WilabtSfaNode(OMFNode):
         host = Attribute("host", "Name of the physical machine",
                 flags = Flags.Design)
 
         host = Attribute("host", "Name of the physical machine",
                 flags = Flags.Design)
 
-        #disk_image = Attribute("disk_image", "Specify a specific disk image for a node",
-        #        flags = Flags.Design)
+        disk_image = Attribute("disk_image", "Specify a specific disk image for a node",
+                flags = Flags.Design)
         
         cls._register_attribute(username)
         cls._register_attribute(identity)
         
         cls._register_attribute(username)
         cls._register_attribute(identity)
@@ -83,7 +82,7 @@ class WilabtSfaNode(OMFNode):
         cls._register_attribute(gateway_user)
         cls._register_attribute(gateway)
         cls._register_attribute(host)
         cls._register_attribute(gateway_user)
         cls._register_attribute(gateway)
         cls._register_attribute(host)
-        #cls._register_attribute(disk_image)
+        cls._register_attribute(disk_image)
 
     def __init__(self, ec, guid):
         super(WilabtSfaNode, self).__init__(ec, guid)
 
     def __init__(self, ec, guid):
         super(WilabtSfaNode, self).__init__(ec, guid)
@@ -130,10 +129,6 @@ class WilabtSfaNode(OMFNode):
         Based on the attributes defined by the user, discover the suitable 
         node for provision.
         """
         Based on the attributes defined by the user, discover the suitable 
         node for provision.
         """
-        if self._skip_provision():
-            super(WilabtSfaNode, self).do_discover()
-            return
-
         nodes = self.sfaapi.get_resources_hrn()
 
         host = self._get_host()
         nodes = self.sfaapi.get_resources_hrn()
 
         host = self._get_host()
@@ -159,10 +154,6 @@ class WilabtSfaNode(OMFNode):
         Add node to user's slice and verifing that the node is functioning
         correctly. Check ssh, omf rc running, hostname, file system.
         """
         Add node to user's slice and verifing that the node is functioning
         correctly. Check ssh, omf rc running, hostname, file system.
         """
-        if self._skip_provision():
-            super(WilabtSfaNode, self).do_provision()
-            return
-
         provision_ok = False
         ssh_ok = False
         proc_ok = False
         provision_ok = False
         ssh_ok = False
         proc_ok = False
@@ -170,10 +161,10 @@ class WilabtSfaNode(OMFNode):
 
         while not provision_ok:
             node = self._node_to_provision
 
         while not provision_ok:
             node = self._node_to_provision
-            if self._slicenode:
-                self._delete_from_slice()
-                self.debug("Waiting 300 sec for re-adding to slice")
-                time.sleep(300) # Timout for the testbed to allow a new reservation
+            #if self._slicenode:
+            #    self._delete_from_slice()
+            #    self.debug("Waiting 480 sec for re-adding to slice")
+            #    time.sleep(480) # Timout for the testbed to allow a new reservation
             self._add_node_to_slice(node)
             t = 0
             while not self._check_if_in_slice([node]) and t < timeout \
             self._add_node_to_slice(node)
             t = 0
             while not self._check_if_in_slice([node]) and t < timeout \
@@ -368,11 +359,11 @@ class WilabtSfaNode(OMFNode):
         """
         self.info(" Adding node to slice ")
         slicename = self.get("slicename")
         """
         self.info(" Adding node to slice ")
         slicename = self.get("slicename")
-        #disk_image = self.get("disk_image")
-        #if disk_image is not None:
-        #    properties = {'disk_image': disk_image}
-        #else: properties = None
-        properties = None
+        disk_image = self.get("disk_image")
+        if disk_image is not None:
+            properties = {'disk_image': disk_image}
+        else: properties = None
+        #properties = None
         self.sfaapi.add_resource_to_slice_batch(slicename, host_hrn, properties=properties)
 
     def _delete_from_slice(self):
         self.sfaapi.add_resource_to_slice_batch(slicename, host_hrn, properties=properties)
 
     def _delete_from_slice(self):
@@ -402,7 +393,7 @@ class WilabtSfaNode(OMFNode):
         attribute hostname, it will over write the previous value.
         """
         hosts_hrn = self.sfaapi.get_resources_hrn()
         attribute hostname, it will over write the previous value.
         """
         hosts_hrn = self.sfaapi.get_resources_hrn()
-        for host, hrn  in hosts_hrn.iteritems():
+        for host, hrn  in hosts_hrn.items():
             if hrn == node:
                 host = host + '.wilab2.ilabt.iminds.be'
                 self.set("host", host)
             if hrn == node:
                 host = host + '.wilab2.ilabt.iminds.be'
                 self.set("host", host)
@@ -453,23 +444,23 @@ class WilabtSfaNode(OMFNode):
     def fail_discovery(self):
         msg = "Discovery failed. No candidates found for node"
         self.error(msg)
     def fail_discovery(self):
         msg = "Discovery failed. No candidates found for node"
         self.error(msg)
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_node_not_alive(self, host=None):
         msg = "Node %s not alive" % host
 
     def fail_node_not_alive(self, host=None):
         msg = "Node %s not alive" % host
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
     
     def fail_node_not_available(self, host):
         msg = "Some nodes not available for provisioning"
     
     def fail_node_not_available(self, host):
         msg = "Some nodes not available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_not_enough_nodes(self):
         msg = "Not enough nodes available for provisioning"
 
     def fail_not_enough_nodes(self):
         msg = "Not enough nodes available for provisioning"
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def fail_sfaapi(self):
         msg = "Failing while trying to instanciate the SFA API."
 
     def fail_sfaapi(self):
         msg = "Failing while trying to instanciate the SFA API."
-        raise RuntimeError, msg
+        raise RuntimeError(msg)
 
     def valid_connection(self, guid):
         # TODO: Validate!
 
     def valid_connection(self, guid):
         # TODO: Validate!