Rsync: rewrite to use raw commands, not fabric

This is because we will be using SSH hops to rsync into slave nodes.
Fabric doesn't seem to support this out of the box.

Change-Id: Idf43d7b6c35324ade9be3467cee7c664833a38a8
This commit is contained in:
Przemyslaw Kaminski 2015-05-15 11:32:14 +02:00
parent 99ce652037
commit b47fa271d7
5 changed files with 45 additions and 12 deletions

View File

@ -0,0 +1,22 @@
class CmdParserMixin(object):
"""Mixin for parsing fuel CLI output."""
def parse_output(self, output):
ret = []
header = []
lines = output.split('\n')
# brutal
lines = [line for line in lines
if not line.startswith('DEPRECATION WARNING')]
for name in lines[0].split('|'):
header.append(name.strip())
# lines[1] is just '----'
for line in lines[2:]:
values = [v.strip() for v in line.split('|')]
ret.append(dict(zip(header, values)))
return ret

View File

@ -241,7 +241,9 @@ class RsyncCommand(DockerMixin,
# target is on the remote
target = os.path.join(base_target_dir, self.target_path)
self.rsync(source, target)
target, args = self.build_app_args_target(target)
self.rsync(source, target, *args)
self.post_sync(parsed_args)

View File

@ -57,7 +57,11 @@ class Rsync(DockerNginxMixin, docker.RsyncCommand):
source = os.path.join(source_dir, source_path)
self.rsync(source, target_dir)
target, args = self.build_app_args_target(target_dir)
self.rsync(source, target, *args)
self.rsync(source, target)
def build_gulp_static(self, source_dir):
cwd = os.path.join(source_dir, 'nailgun')

View File

@ -12,9 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
import subprocess
from fuel_dev_tools import docker
from fuel_dev_tools import info

View File

@ -12,18 +12,26 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from fabric.contrib import project
import subprocess
class RsyncMixin(object):
def rsync(self, source, target):
def build_app_args_target(self, target):
target = '{}@{}:{}'.format(self.app_args.user, self.app_args.ip, target)
args = ['-e', 'ssh -p {}'.format(self.app_args.port)]
return target, args
def rsync(self, source, target, *args):
self.print_debug('RSYNC: %s --> %s' % (source, target))
result = project.rsync_project(
local_dir=source,
remote_dir=target
#result = project.rsync_project(
# local_dir=source,
# remote_dir=target
#)
result = subprocess.check_output(
['rsync', 'avz'] + list(args) + [source, target]
)
self.print_debug(result.decode('utf-8'))