def fqdn_appliance(appliance, preconfigured): sp = SproutClient.from_config() available_providers = set(sp.call_method('available_providers')) required_providers = set(cfme_data['fqdn_providers']) usable_providers = available_providers & required_providers version = appliance.version.vstring stream = get_stream(appliance.version) for provider in usable_providers: try: apps, pool_id = sp.provision_appliances( count=1, preconfigured=preconfigured, version=version, stream=stream, provider=provider) break except Exception as e: logger.warning( "Couldn't provision appliance with following error:") logger.warning("{}".format(e)) continue else: logger.error("Couldn't provision an appliance at all") raise SproutException('No provision available') 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 = cfme_data["basic_info"][update_url] apps[0].ssh_client.run_command( "curl {} -o /etc/yum.repos.d/update.repo".format(urls)) logger.info( 'Appliance update.repo file: \n%s', apps[0].ssh_client.run_command( 'cat /etc/yum.repos.d/update.repo').output) 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(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 get_apps(appliance, old_version, count, preconfigured): """Requests appliance from sprout based on old_versions, edits partitions and adds repo file for update""" series = appliance.version.series() update_url = "update_url_{}".format(series.replace(".", "")) 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_sorted = sorted(usable, key=lambda o: o.version) apps = [] pool_id = None try: apps, pool_id = sp.provision_appliances( count=count, preconfigured=preconfigured, provider_type="rhevm", lease_time=180, version=str(usable_sorted[-1]), ) urls = cfme_data["basic_info"][update_url] for app in apps: app.db.extend_partition() app.ssh_client.run_command( "curl {} -o /etc/yum.repos.d/update.repo".format(urls)) yield apps except Exception as e: logger.error( "Couldn't provision appliance with following error:{}".format(e)) raise SproutException("Not able to configure provision request") finally: for app in apps: app.ssh_client.close() if pool_id: sp.destroy_pool(pool_id)