X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nepi%2Fresources%2Flinux%2Fnode.py;h=32b590e2fa1af308068ffc7b3d6d46852b3bc273;hb=0e04a6d963d4f06b7af85c91bf3a2eb0d3725d6f;hp=375ff3a62669f8e7f87116485995225dcce6df6b;hpb=941fd7f54114b824fa26563d389a7ae07426fe14;p=nepi.git diff --git a/nepi/resources/linux/node.py b/nepi/resources/linux/node.py index 375ff3a6..32b590e2 100644 --- a/nepi/resources/linux/node.py +++ b/nepi/resources/linux/node.py @@ -149,81 +149,74 @@ class LinuxNode(ResourceManager): @classmethod def _register_attributes(cls): - cls._register_attribute(Attribute( - "hostname", "Hostname of the machine", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "username", "Local account username", - flags = Flags.Credential)) - - cls._register_attribute(Attribute( - "port", "SSH port", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "home", - "Experiment home directory to store all experiment related files", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "identity", "SSH identity file", - flags = Flags.Credential)) - - cls._register_attribute(Attribute( - "serverKey", "Server public key", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "cleanHome", - "Remove all nepi files and directories " - " from node home folder before starting experiment", - type = Types.Bool, - default = False, - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "cleanExperiment", "Remove all files and directories " - " from a previous same experiment, before the new experiment starts", - type = Types.Bool, - default = False, - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "cleanProcesses", - "Kill all running processes before starting experiment", - type = Types.Bool, - default = False, - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "cleanProcessesAfter", - """Kill all running processes after starting experiment - This might be dangerous when using user root""", - type = Types.Bool, - default = True, - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "tearDown", - "Bash script to be executed before releasing the resource", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "gatewayUser", - "Gateway account username", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "gateway", - "Hostname of the gateway machine", - flags = Flags.Design)) - - cls._register_attribute(Attribute( - "ip", - "Linux host public IP address. " - "Must not be modified by the user unless hostname is 'localhost'", + cls._register_attribute( + Attribute("hostname", + "Hostname of the machine", + flags = Flags.Design)) + cls._register_attribute( + Attribute("username", + "Local account username", + flags = Flags.Credential)) + cls._register_attribute( + Attribute("port", + "SSH port", + flags = Flags.Design)) + cls._register_attribute( + Attribute("home", + "Experiment home directory to store all experiment related files", + flags = Flags.Design)) + cls._register_attribute( + Attribute("identity", + "SSH identity file", + flags = Flags.Credential)) + cls._register_attribute( + Attribute("serverKey", + "Server public key", + flags = Flags.Design)) + cls._register_attribute( + Attribute("cleanHome", + "Remove all nepi files and directories " + " from node home folder before starting experiment", + type = Types.Bool, + default = False, flags = Flags.Design)) + cls._register_attribute( + Attribute("cleanExperiment", + "Remove all files and directories " + " from a previous same experiment, before the new experiment starts", + type = Types.Bool, + default = False, + flags = Flags.Design)) + cls._register_attribute( + Attribute("cleanProcesses", + "Kill all running processes before starting experiment", + type = Types.Bool, + default = False, + flags = Flags.Design)) + cls._register_attribute( + Attribute("cleanProcessesAfter", + "Kill all running processes after starting experiment" + "NOTE: This might be dangerous when using user root", + type = Types.Bool, + default = True, + flags = Flags.Design)) + cls._register_attribute( + Attribute("tearDown", + "Bash script to be executed before releasing the resource", + flags = Flags.Design)) + cls._register_attribute( + Attribute("gatewayUser", + "Gateway account username", + flags = Flags.Design)) + cls._register_attribute( + Attribute("gateway", + "Hostname of the gateway machine", + flags = Flags.Design)) + cls._register_attribute( + Attribute("ip", + "Linux host public IP address. " + "Must not be modified by the user unless hostname is 'localhost'", + flags = Flags.Design)) def __init__(self, ec, guid): super(LinuxNode, self).__init__(ec, guid) @@ -1189,7 +1182,10 @@ class LinuxNode(ResourceManager): (out, err), proc = self.execute(command, retry = 1, with_lock = True) - for d in dests: + # avoid RuntimeError that would result from + # changing loop subject during iteration + keys = list(dests.keys()) + for d in keys: if out.find(d) > -1: del dests[d] @@ -1199,4 +1195,3 @@ class LinuxNode(ResourceManager): retcod = dests.values() if PY3: retcod = list(retcod) return retcod -