5 def get_remote_command(self, command):
6 if 'chroot' in self and self['chroot']:
7 command = " chroot %s %s" % (self['chroot'], command)
8 if 'vserver' in self and self['vserver']:
9 command = " vserver %s exec '%s' " % (self['vserver'], command)
10 if 'host' in self and self['host'] not in ['localhost']:
12 if 'rootkey' in self and self['rootkey']:
13 options = "-i %s " % self['rootkey']
14 command = "ssh %s root@%s \"%s\" " % (options, self['host'], command)
18 def popen(self, command, fatal = True):
19 command = self.get_remote_command(command)
20 #utils.header(command)
21 return utils.popen(command, fatal)
23 def commands(self, command, fatal = True):
24 command = self.get_remote_command(command)
25 #utils.header(command)
26 return utils.commands(command, fatal)
28 def scp(self, src, dest):
30 if 'rootkey' in self and self['rootkey'] is not None:
31 options += " -i %s " % (self['rootkey'])
33 if 'chroot' in self and self['chroot'] is not None:
35 if 'vserver' in self and self['vserver'] is not None:
36 path += '/vservers/%s/' % self['vserver']
39 src_parts = src.split(":")
41 dest_parts = dest.split(":")
43 if len(src_parts) == 1:
45 elif src_parts[0].find('localhost') != -1:
46 src_cmd = src_parts[1]
48 host, file = src_parts[0], src_parts[1]
49 src_cmd = 'root@%(host)s:%(path)s%(file)s ' % locals()
51 if len(dest_parts) == 1:
53 elif dest_parts[0].find('localhost') != -1:
54 dest_cmd = dest_parts[1]
56 host, file = dest_parts[0], dest_parts[1]
57 dest_cmd = 'root@%(host)s:%(path)s%(file)s' % locals()
60 command = 'scp %(options)s %(src_cmd)s %(dest_cmd)s' % locals()
62 return utils.commands(command)