def appliance_preupdate(old_version, appliance): series = appliance.version.series() update_url = "update_url_{}".format(series.replace('.', '')) """Requests appliance from sprout based on old_versions, edits partitions and adds repo file for update""" usable = [] sp = SproutClient.from_config() available_versions = set(sp.call_method('available_cfme_versions')) for a in available_versions: if a.startswith(old_version): usable.append(Version(a)) usable.sort(reverse=True) try: apps, pool_id = sp.provision_appliances(count=1, preconfigured=True, lease_time=180, version=str(usable[0])) except Exception as e: logger.exception("Couldn't provision appliance with following error:{}".format(e)) raise SproutException('No provision available') apps[0].db.extend_partition() urls = process_url(conf.cfme_data['basic_info'][update_url]) output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) apps[0].ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') yield apps[0] apps[0].ssh_client.close() sp.destroy_pool(pool_id)
def appliance_preupdate(old_version, appliance): series = appliance.version.series() update_url = "update_url_{}".format(series.replace('.', '')) """Requests appliance from sprout based on old_versions, edits partitions and adds repo file for update""" usable = [] sp = SproutClient.from_config() available_versions = set(sp.call_method('available_cfme_versions')) for a in available_versions: if a.startswith(old_version): usable.append(Version(a)) usable.sort(reverse=True) try: apps, pool_id = sp.provision_appliances(count=1, preconfigured=True, lease_time=180, version=str(usable[0])) except Exception as e: logger.exception( "Couldn't provision appliance with following error:{}".format(e)) raise SproutException('No provision available') apps[0].db.extend_partition() urls = process_url(conf.cfme_data['basic_info'][update_url]) output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) apps[0].ssh_client.put_file(f.name, '/etc/yum.repos.d/update.repo') yield apps[0] apps[0].ssh_client.close() sp.destroy_pool(pool_id)
def upgrade_appliance(appliance_ip, cfme_only, update_to): """Upgrades an appliance""" supported_version_repo_map = { '5.8.z': 'update_url_58', '5.8.0': 'update_url_580', '5.8.1': 'update_url_581', '5.8.2': 'update_url_582', '5.9.z': 'update_url_59', '5.9.0': 'update_url_590', '5.9.1': 'update_url_591', '5.9.2': 'update_url_592' } assert update_to in supported_version_repo_map, "{} is not a supported version".format( update_to) update_url = supported_version_repo_map[update_to] if appliance_ip: print('Connecting to {}'.format(appliance_ip)) else: print('Fetching appliance from env.local.yaml') app = get_appliance(appliance_ip) assert app.version > '5.7', "{} is not supported, must be 5.7 or higher".format( app.version) print('Extending appliance partitions') app.db.extend_partition() urls = process_url(cfme_data['basic_info'][update_url]) output = build_file(urls) print('Adding update repo to appliance') with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) app.ssh_client.put_file(f.name, '/etc/yum.repos.d/update.repo') cfme = '-y' if cfme_only: cfme = 'cfme -y' print('Stopping EVM') app.evmserverd.stop() print('Running yum update') result = app.ssh_client.run_command('yum update {}'.format(cfme), timeout=3600) assert result.success, "update failed {}".format(result.output) print('Running database migration') app.db.migrate() app.db.automate_reset() print('Restarting postgres service') app.db.restart_db_service() print('Starting EVM') app.start_evm_service() print('Waiting for webui') app.wait_for_web_ui() print('Appliance upgrade completed')
def appliance_preupdate(temp_appliance_preconfig_funcscope_upgrade, appliance): """Reconfigure appliance partitions and adds repo file for upgrade""" update_url = ('update_url_' + ''.join([i for i in get_stream(appliance.version) if i.isdigit()])) temp_appliance_preconfig_funcscope_upgrade.db.extend_partition() urls = process_url(cfme_data['basic_info'][update_url]) output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') return temp_appliance_preconfig_funcscope_upgrade
def appliance_preupdate(temp_appliance_preconfig_funcscope_upgrade, appliance): """Reconfigure appliance partitions and adds repo file for upgrade""" update_url = ( 'update_url_' + ''.join([i for i in get_stream(appliance.version) if i.isdigit()])) temp_appliance_preconfig_funcscope_upgrade.db.extend_partition() urls = process_url(cfme_data['basic_info'][update_url]) output = build_file(urls) with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') return temp_appliance_preconfig_funcscope_upgrade
def upgrade_appliance(appliance_ip, cfme_only, update_to): """Upgrades an appliance""" supported_version_repo_map = { '5.8.z': 'update_url_58', '5.8.0': 'update_url_580', '5.8.1': 'update_url_581', '5.8.2': 'update_url_582', '5.9.z': 'update_url_59', '5.9.0': 'update_url_590', '5.9.1': 'update_url_591', '5.9.2': 'update_url_592' } assert update_to in supported_version_repo_map, "{} is not a supported version".format( update_to ) update_url = supported_version_repo_map[update_to] if appliance_ip: print('Connecting to {}'.format(appliance_ip)) else: print('Fetching appliance from env.local.yaml') app = get_appliance(appliance_ip) assert app.version > '5.7', "{} is not supported, must be 5.7 or higher".format(app.version) print('Extending appliance partitions') app.db.extend_partition() urls = process_url(cfme_data['basic_info'][update_url]) output = build_file(urls) print('Adding update repo to appliance') with tempfile.NamedTemporaryFile('w') as f: f.write(output) f.flush() os.fsync(f.fileno()) app.ssh_client.put_file( f.name, '/etc/yum.repos.d/update.repo') cfme = '-y' if cfme_only: cfme = 'cfme -y' print('Stopping EVM') app.evmserverd.stop() print('Running yum update') result = app.ssh_client.run_command('yum update {}'.format(cfme), timeout=3600) assert result.success, "update failed {}".format(result.output) print('Running database migration') app.db.migrate() app.db.automate_reset() print('Restarting postgres service') app.db.restart_db_service() print('Starting EVM') app.start_evm_service() print('Waiting for webui') app.wait_for_web_ui() print('Appliance upgrade completed')