6 def get_remote_command(self, command):
7 if 'chroot' in self and self['chroot']:
8 command = " chroot %s %s" % (self['chroot'], command)
9 if 'vserver' in self and self['vserver']:
10 command = " vserver %s exec %s " % (self['vserver'], command)
11 if 'host' in self and self['host'] not in ['localhost', self.config.hostname]:
13 if 'rootkey' in self and self['rootkey']:
14 options = "-i %s " % self['rootkey']
15 command = "ssh %s root@%s \"%s\" " % (options, self['host'], command)
19 def popen(self, command, fatal = True):
20 command = self.get_remote_command(command)
21 if self.config.verbose:
23 return utils.popen(command, fatal)
25 def popen3(self, command):
26 command = self.get_remote_command(command)
27 if self.config.verbose:
29 return utils.popen3(command)
31 def commands(self, command, fatal = True):
32 command = self.get_remote_command(command)
33 if self.config.verbose:
35 return utils.commands(command, fatal)
37 def scp(self, src, dest):
39 if 'rootkey' in self and self['rootkey'] is not None:
40 options += " -i %s " % (self['rootkey'])
42 if 'chroot' in self and self['chroot'] is not None:
44 if 'vserver' in self and self['vserver'] is not None:
45 path += '/vservers/%s/' % self['vserver']
48 src_parts = src.split(":")
50 dest_parts = dest.split(":")
52 if len(src_parts) == 1:
54 elif src_parts[0].find('localhost') != -1:
55 src_cmd = path + os.sep + src_parts[1]
57 host, file = src_parts[0], src_parts[1]
58 src_cmd = 'root@%(host)s:%(path)s%(file)s ' % locals()
60 if len(dest_parts) == 1:
62 elif dest_parts[0].find('localhost') != -1:
63 dest_cmd = path +os.sep+ dest_parts[1]
65 host, file = dest_parts[0], dest_parts[1]
66 dest_cmd = 'root@%(host)s:%(path)s%(file)s' % locals()
68 command = 'scp %(options)s %(src_cmd)s %(dest_cmd)s' % locals()
69 if self.config.verbose:
71 return utils.commands(command)