X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fplanetlab%2Fnode.py;h=c6f7bde861087ddd15ae19df13fc122da88ca7e4;hb=6285ca51026efb69642eea9dfc7c480e722d84a9;hp=1f706a8d0431e102d490705b55fb8906bfdb3274;hpb=1e2eb157cb569e9c28a5b7888ed97076d27414cb;p=nepi.git diff --git a/src/nepi/resources/planetlab/node.py b/src/nepi/resources/planetlab/node.py index 1f706a8d..c6f7bde8 100644 --- a/src/nepi/resources/planetlab/node.py +++ b/src/nepi/resources/planetlab/node.py @@ -3,9 +3,8 @@ # 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 @@ -20,7 +19,7 @@ from nepi.execution.attribute import Attribute, Flags, Types from nepi.execution.resource import ResourceManager, clsinit_copy, \ - ResourceState, reschedule_delay + ResourceState from nepi.resources.linux.node import LinuxNode from nepi.resources.planetlab.plcapi import PLCAPIFactory from nepi.util.execfuncs import lexec @@ -28,6 +27,7 @@ from nepi.util import sshfuncs from random import randint import re +import os import time import socket import threading @@ -36,10 +36,10 @@ import weakref @clsinit_copy class PlanetlabNode(LinuxNode): - _rtype = "PlanetlabNode" + _rtype = "planetlab::Node" _help = "Controls a PlanetLab host accessible using a SSH key " \ "associated to a PlanetLab user account" - _backend = "planetlab" + _platform = "planetlab" lock = threading.Lock() @@ -171,7 +171,6 @@ class PlanetlabNode(LinuxNode): default = False, flags = Flags.Global) - cls._register_attribute(ip) cls._register_attribute(pl_url) cls._register_attribute(pl_ptn) @@ -206,6 +205,18 @@ class PlanetlabNode(LinuxNode): self.set("gateway", None) self.set("gatewayUser", None) + # Blacklist file + nepi_home = os.path.join(os.path.expanduser("~"), ".nepi") + plblacklist_file = os.path.join(nepi_home, "plblacklist.txt") + if not os.path.exists(plblacklist_file): + if os.path.isdir(nepi_home): + with open(plblacklist_file, 'w') as clear: + pass + else: + os.makedirs(nepi_home) + with open(plblacklist_file, 'w') as clear: + pass + def _skip_provision(self): pl_user = self.get("pluser") pl_pass = self.get("plpassword") @@ -390,7 +401,7 @@ class PlanetlabNode(LinuxNode): def do_release(self): super(PlanetlabNode, self).do_release() - if self.state == ResourceState.RELEASED: + if self.state == ResourceState.RELEASED and not self._skip_provision(): self.debug(" Releasing PLC API ") self.plapi.release() @@ -650,24 +661,24 @@ class PlanetlabNode(LinuxNode): 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, hostname=None): msg = "Node %s not alive" % hostname - raise RuntimeError, msg + raise RuntimeError(msg) def fail_node_not_available(self, hostname): msg = "Node %s not available for provisioning" % hostname - raise RuntimeError, msg + raise RuntimeError(msg) def fail_not_enough_nodes(self): msg = "Not enough nodes available for provisioning" - raise RuntimeError, msg + raise RuntimeError(msg) def fail_plapi(self): msg = "Failing while trying to instanciate the PLC API.\nSet the" + \ " attributes pluser and plpassword." - raise RuntimeError, msg + raise RuntimeError(msg) def valid_connection(self, guid): # TODO: Validate!