def main(actions=None): # NOTE(agordeev): get its own process group by calling setpgrp. # Process group is used to distribute signals to subprocesses. os.setpgrp() signal.signal(signal.SIGTERM, handle_sigterm) CONF(sys.argv[1:], project='bareon', version=version.version_info.release_string()) logging.setup('bareon') LOG = logging.getLogger(__name__) try: if CONF.input_data: data = yaml.safe_load(CONF.input_data) else: with open(CONF.input_data_file) as f: data = yaml.safe_load(f) LOG.debug('Input data: %s', data) data_driver_class = utils.get_data_driver(CONF.data_driver) data_driver = data_driver_class(data) deploy_driver_class = utils.get_deploy_driver(CONF.deploy_driver) deploy_driver = deploy_driver_class(data_driver) if actions: for action in actions: getattr(deploy_driver, action)() except Exception as exc: handle_exception(exc)
def main(actions=None): # NOTE(agordeev): get its own process group by calling setpgrp. # Process group is used to distribute signals to subprocesses. os.setpgrp() signal.signal(signal.SIGTERM, handle_sigterm) CONF(sys.argv[1:], project='bareon', version=version.version_info.release_string()) logging.setup('bareon') LOG = logging.getLogger(__name__) try: if CONF.input_data: data = yaml.safe_load(CONF.input_data) else: with open(CONF.input_data_file) as f: data = yaml.safe_load(f) LOG.debug('Input data: %s', data) data_driver_class = utils.get_data_driver(CONF.data_driver) data_driver = data_driver_class(data) deploy_driver_class = utils.get_deploy_driver(CONF.deploy_driver) deploy_driver = deploy_driver_class(data_driver) if actions: for action in actions: getattr(deploy_driver, action)() except Exception as exc: handle_exception(exc)
# 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. import os import six from contextlib import contextmanager from bareon import errors from bareon.openstack.common import log as logging from bareon.utils import fs as fu from bareon.utils import partition as pu from bareon.utils import utils LOG = logging.getLogger(__name__) class MountableMixin(object): def _mount_target(self, mount_dir, os_id=None, pseudo=True, treat_mtab=True): LOG.debug('Mounting target file systems: %s', mount_dir) # Here we are going to mount all file systems in partition schema. for fs in self.driver.partition_scheme.fs_sorted_by_depth(os_id): if fs.mount == 'swap': continue mount = os.path.join(mount_dir, fs.mount.strip(os.sep)) utils.makedirs_if_not_exists(mount) fu.mount_fs(fs.type, str(fs.device), mount)
# # 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. import os from bareon.drivers.deploy.generic import GenericDeployDriver from bareon.openstack.common import log as logging from bareon.utils import utils LOG = logging.getLogger(__name__) class Rsync(GenericDeployDriver): def do_copyimage(self, os_id): os_path = '/tmp/target/' with self.mount_target(os_path, os_id, pseudo=False, treat_mtab=False): for image in self.driver.image_scheme.get_os_images(os_id): target_image_path = os.path.join( os_path, image.target_device.strip(os.sep)) LOG.debug('Starting rsync from %s to %s', image.uri, target_image_path) rsync_flags = image.deployment_flags.get( 'rsync_flags', '-a -A -X') utils.execute('rsync',
def handle_exception(exc): LOG = logging.getLogger(__name__) LOG.exception(exc) print_err('Unexpected error') print_err(exc) sys.exit(-1)
def handle_exception(exc): LOG = logging.getLogger(__name__) LOG.exception(exc) print_err('Unexpected error') print_err(exc) sys.exit(-1)