return self.hostname_value
def is_local(self):
- return utils.is_local (self.hostname())
+ return TestSsh.is_local (self.hostname())
def tar_logs(self):
if os.path.isdir("nodeslogs"):
return self.plc_spec['hostname']
def is_local (self):
- return utils.is_local(self.hostname())
+ return TestSsh.is_local(self.hostname())
# define the API methods on this object through xmlrpc
# would help, but not strictly necessary
if self.vserver:
return "vserver %s exec %s"%(self.vservername,command)
else:
- return "chroot /plc/root %s"%utils.backslash_shell_specials(command)
+ return "chroot /plc/root %s"%TestSsh.backslash_shell_specials(command)
# copy a file to the myplc root image - pass in_data=True if the file must go in /plc/data
def copy_in_guest (self, localfile, remotefile, in_data=False):
class TestSsh:
+ # inserts a backslash before each occurence of the following chars
+ # \ " ' < > & | ; ( ) $ * ~
+ @staticmethod
+ def backslash_shell_specials (command):
+ result=''
+ for char in command:
+ if char in "\\\"'<>&|;()$*~":
+ result +='\\'+char
+ else:
+ result +=char
+ return result
+
+ # check main IP address against the provided hostname
+ @staticmethod
+ def is_local (hostname):
+ if hostname == "localhost":
+ return True
+ import socket
+ try:
+ local_ip = socket.gethostbyname(socket.gethostname())
+ remote_ip = socket.gethostbyname(hostname)
+ return local_ip==remote_ip
+ except:
+ header("WARNING : something wrong in is_local with hostname=%s"%hostname)
+ return False
+
def __init__(self,caller):
self.caller=caller
-
- def hostanme(self):
+ def hostname(self):
return self.caller.hostname()
def is_local(self):
return self.caller.is_local()
if self.caller.is_local():
return command
else:
- return "ssh %s %s"%(self.hostname(),utils.backslash_shell_specials(command))
+ return "ssh %s %s"%(self.hostname(),TestSsh.backslash_shell_specials(command))
def full_command(self,command):
return self.to_host(self.caller.host_to_guest(command))
ssh_comand="ssh "
if self.caller.key:
ssh_comand += "-i %s.rsa "%(self.caller.key)
- ssh_command += "%s/%s"%(self.buildname,utils.backslash_shell_specials(command))
+ ssh_command += "%s/%s"%(self.buildname,TestSsh.backslash_shell_specials(command))
return utils.system(ssh_command)
def copy (self,local_file,recursive=False):
def nodes():
nodes= [{'node_fields': {'hostname': 'lysithea.inria.fr',
'model':'qemu/minhw', } ,
- 'host_box': 'test.one-lab.org',
+ 'host_box': 'testbox1.one-lab.org',
'owner' : 'pi',
'network_fields': { 'method':'static',
'type':'ipv4',
},
{'node_fields': {'hostname': 'pluton.inria.fr',
'model':'qemu/minhw', } ,
- 'host_box': 'test.one-lab.org',
+ 'host_box': 'testbox1.one-lab.org',
'owner' : 'pi',
'network_fields': { 'method':'static',
'type':'ipv4',
(status,output) = commands.getstatusoutput(command)
return status == 0
-# inserts a backslash before each occurence of the following chars
-# \ " ' < > & | ; ( ) $ * ~
-def backslash_shell_specials (command):
- result=''
- for char in command:
- if char in "\\\"'<>&|;()$*~":
- result +='\\'+char
- else:
- result +=char
- return result
-
-# check main IP address against the provided hostname
-def is_local (hostname):
- if hostname == "localhost":
- return True
- import socket
- try:
- local_ip = socket.gethostbyname(socket.gethostname())
- remote_ip = socket.gethostbyname(hostname)
- return local_ip==remote_ip
- except:
- header("WARNING : something wrong in is_local with hostname=%s"%hostname)
- return False