Add fuelmenu-rsync command
* fuelmenu-rsync is now available. It allows to rsync code from root of fuel-menu repository to master node. * Refactored RsyncCommand - moved it from docker module to command module, so it can be used not only for docker-related rsyncing. Change-Id: I3dcfa2d00a22368ce40e8457c3aacb72700bc54f Closes-bug: #1522441
This commit is contained in:
parent
77ce986dba
commit
2e455346a8
|
@ -12,10 +12,49 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from cliff import command
|
||||
|
||||
from fuel_dev_tools import debug
|
||||
from fuel_dev_tools import rsync
|
||||
|
||||
|
||||
class BaseCommand(debug.DebugMixin, command.Command):
|
||||
pass
|
||||
|
||||
|
||||
class RsyncCommand(rsync.RsyncMixin, BaseCommand):
|
||||
def pre_sync(self, parsed_args):
|
||||
pass
|
||||
|
||||
def post_sync(self, parsed_args):
|
||||
pass
|
||||
|
||||
@property
|
||||
def source_path(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def target_path(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
def base_target_dir(self):
|
||||
return '/'
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.pre_sync(parsed_args)
|
||||
|
||||
source_dir = parsed_args.source
|
||||
|
||||
base_target_dir = self.base_target_dir
|
||||
source = os.path.join(source_dir, self.source_path)
|
||||
# target is on the remote
|
||||
target = os.path.join(base_target_dir, self.target_path)
|
||||
|
||||
target, args = self.build_app_args_target(target)
|
||||
|
||||
self.rsync(source, target, *args)
|
||||
|
||||
self.post_sync(parsed_args)
|
||||
|
|
|
@ -203,40 +203,13 @@ class RestartCommand(command.BaseCommand):
|
|||
|
||||
class RsyncCommand(rsync.RsyncMixin,
|
||||
command.BaseCommand):
|
||||
def pre_sync(self, parsed_args):
|
||||
pass
|
||||
|
||||
def post_sync(self, parsed_args):
|
||||
pass
|
||||
|
||||
@property
|
||||
def source_path(self):
|
||||
return ''
|
||||
|
||||
@property
|
||||
def target_path(self):
|
||||
return ''
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.pre_sync(parsed_args)
|
||||
|
||||
source_dir = parsed_args.source
|
||||
|
||||
base_target_dir = os.path.join(
|
||||
def base_target_dir(self):
|
||||
return os.path.join(
|
||||
self.get_container_directory(),
|
||||
'rootfs'
|
||||
)
|
||||
|
||||
source = os.path.join(source_dir, self.source_path)
|
||||
# target is on the remote
|
||||
target = os.path.join(base_target_dir, self.target_path)
|
||||
|
||||
target, args = self.build_app_args_target(target)
|
||||
|
||||
self.rsync(source, target, *args)
|
||||
|
||||
self.post_sync(parsed_args)
|
||||
|
||||
|
||||
class ShellCommand(command.BaseCommand):
|
||||
default_command = None
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from fuel_dev_tools import command
|
||||
|
||||
|
||||
class Rsync(command.RsyncCommand):
|
||||
@property
|
||||
def source_path(self):
|
||||
return 'fuelmenu/'
|
||||
|
||||
@property
|
||||
def target_path(self):
|
||||
return 'usr/lib/python2.6/site-packages/fuelmenu'
|
||||
|
||||
def build_app_args_target(self, target):
|
||||
target, args = super(Rsync, self).build_app_args_target(target)
|
||||
|
||||
return target, ['--exclude=*.pyc', '--exclude=test'] + args
|
|
@ -35,6 +35,7 @@ from fuel_dev_tools.docker import postgres
|
|||
from fuel_dev_tools.docker import rabbitmq
|
||||
from fuel_dev_tools import exc
|
||||
from fuel_dev_tools import info
|
||||
from fuel_dev_tools.master import fuelmenu
|
||||
from fuel_dev_tools import puppet
|
||||
from fuel_dev_tools import pythonclient
|
||||
from fuel_dev_tools.slaves import mcagent
|
||||
|
@ -102,6 +103,8 @@ COMMANDS = {
|
|||
'rabbitmq-stop': rabbitmq.Stop,
|
||||
'rabbitmq-tail': rabbitmq.Tail,
|
||||
'rabbitmq-volumes': rabbitmq.Volumes,
|
||||
|
||||
'fuelmenu-rsync': fuelmenu.Rsync
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue