def nodes(self, setup_node_controller): controller = setup_node_controller nodes = Nodes(controller, env_variables["private_ssh_key_path"]) nodes.set_correct_boot_order(start_nodes=False) yield nodes nodes.shutdown_all() nodes.format_all_disks()
def waiting_for_installation_completion(controller): vm_ip = controller.master_ips[0][0] try: logging.info("Configuring /etc/hosts...") utils.config_etc_hosts(cluster_name=controller.cluster_name, base_dns_domain=controller.cluster_domain, api_vip=vm_ip) logging.info("Waiting for installation to complete...") waiting.wait(all_operators_up, sleep_seconds=20, timeout_seconds=60 * 60, waiting_for="all operators to get up") logging.info("Installation completed successfully!") finally: logging.info("Gathering sosreport data from host...") node = Nodes(controller, private_ssh_key_path=SSH_KEY)[0] gather_sosreport_data(node) logging.info("Gathering information via installer-gather...") utils.recreate_folder(INSTALLER_GATHER_DIR, force_recreate=True) installer_gather(ip=vm_ip, ssh_key=SSH_KEY, out_dir=INSTALLER_GATHER_DIR) logging.info("Gathering information via must-gather...") utils.recreate_folder(MUST_GATHER_DIR) download_must_gather(KUBE_CONFIG, MUST_GATHER_DIR)
def get_nodes_func(tf_config: BaseTerraformConfig, infraenv_config: InfraEnvConfig): if "nodes" in nodes_data: return nodes_data["nodes"] nodes_data["configs"] = infraenv_config, tf_config net_asset = LibvirtNetworkAssets() tf_config.net_asset = net_asset.get() nodes_data["net_asset"] = net_asset controller = TerraformController(tf_config, entity_config=infraenv_config) nodes = Nodes(controller) nodes_data["nodes"] = nodes nodes.prepare_nodes() interfaces = BaseTest.nat_interfaces(tf_config) nat = NatController( interfaces, NatController.get_namespace_index(interfaces[0])) nat.add_nat_rules() nodes_data["nat"] = nat return nodes
def log_collection(controller, vm_ip): etype, _value, _tb = sys.exc_info() logging.info( f"Collecting logs after a {('failed', 'successful')[etype is None]} installation" ) try: logging.info("Gathering sosreport data from host...") node = Nodes(controller, private_ssh_key_path=SSH_KEY)[0] gather_sosreport_data(node) except Exception: logging.exception("sosreport gathering failed!") utils.retry() try: logging.info("Gathering information via installer-gather...") utils.recreate_folder(INSTALLER_GATHER_DIR, force_recreate=True) installer_gather(ip=vm_ip, ssh_key=SSH_KEY, out_dir=INSTALLER_GATHER_DIR) except Exception: logging.exception("installer-gather failed!") try: logging.info("Gathering information via must-gather...") utils.recreate_folder(MUST_GATHER_DIR) download_must_gather(KUBE_CONFIG, MUST_GATHER_DIR) except Exception: logging.exception("must-gather failed!")
def nodes(self, setup_node_controller, request): if hasattr(request, 'param'): node_vars = self.override_node_parameters(**request.param) else: node_vars = env_variables net_asset = None needs_nat = node_vars.get("platform") == consts.Platforms.NONE try: if not qe_env: net_asset = NetworkAssets() node_vars["net_asset"] = net_asset.get() controller = setup_node_controller(**node_vars) nodes = Nodes(controller, node_vars["private_ssh_key_path"]) nodes.prepare_nodes() if needs_nat: nodes.configure_nat() yield nodes if env_variables['test_teardown']: logging.info('--- TEARDOWN --- node controller\n') nodes.destroy_all_nodes() if needs_nat: nodes.unconfigure_nat() finally: if not qe_env: net_asset.release_all()
def get_nodes_func(config: TerraformConfig = TerraformConfig()): if "nodes" in nodes_data: return nodes_data["nodes"] nodes_data["needs_nat"] = config.platform == consts.Platforms.NONE nodes_data["net_asset"] = NetworkAssets() config.net_asset = nodes_data["net_asset"].get() nodes = Nodes(TerraformController(config), config.private_ssh_key_path) nodes.prepare_nodes() if nodes_data["needs_nat"]: nodes.configure_nat() nodes_data["nodes"] = nodes return nodes
def nodes(self, setup_node_controller): net_asset = None try: if not qe_env: net_asset = NetworkAssets() env_variables["net_asset"] = net_asset.get() controller = setup_node_controller(**env_variables) nodes = Nodes(controller, env_variables["private_ssh_key_path"]) nodes.prepare_nodes() yield nodes logging.info(f'--- TEARDOWN --- node controller\n') nodes.destroy_all_nodes() finally: if not qe_env: net_asset.release_all()
def get_nodes_func(config: TerraformConfig = TerraformConfig()): if "nodes" in nodes_data: return nodes_data["nodes"] net_asset = NetworkAssets() config.net_asset = net_asset.get() nodes = Nodes(TerraformController(config), config.private_ssh_key_path, net_asset, config.platform == consts.Platforms.NONE) nodes.prepare_nodes() nodes_data["nodes"] = nodes return nodes
def nodes(self, setup_node_controller, request): if hasattr(request, 'param'): node_vars = self.override_node_parameters(**request.param) else: node_vars = env_variables net_asset = None try: if not qe_env: net_asset = NetworkAssets() node_vars["net_asset"] = net_asset.get() controller = setup_node_controller(**node_vars) nodes = Nodes(controller, node_vars["private_ssh_key_path"]) nodes.prepare_nodes() yield nodes logging.info('--- TEARDOWN --- node controller\n') nodes.destroy_all_nodes() finally: if not qe_env: net_asset.release_all()
def get_nodes_func(tf_config: TerraformConfig, cluster_config: ClusterConfig): if "nodes" in nodes_data: return nodes_data["nodes"] nodes_data["configs"] = cluster_config, tf_config net_asset = LibvirtNetworkAssets() tf_config.net_asset = net_asset.get() nodes_data["net_asset"] = net_asset controller = TerraformController(tf_config, cluster_config=cluster_config) nodes = Nodes(controller, tf_config.private_ssh_key_path) nodes_data["nodes"] = nodes nodes.prepare_nodes() interfaces = BaseTest.nat_interfaces(tf_config) nat = NatController(interfaces, NatController.get_namespace_index(interfaces[0])) nat.add_nat_rules() nodes_data["nat"] = nat return nodes
def get_nodes_func(config: Optional[TerraformConfig] = None): if not config: config = TerraformConfig() if "nodes" in nodes_data: return nodes_data["nodes"] net_asset = LibvirtNetworkAssets() config.net_asset = net_asset.get() controller = TerraformController(config) nodes = Nodes(controller, config.private_ssh_key_path) nodes.prepare_nodes() interfaces = BaseTest.nat_interfaces(config) nat = NatController( interfaces, NatController.get_namespace_index(interfaces[0])) nat.add_nat_rules() nodes_data["nodes"] = nodes nodes_data["config"] = config nodes_data["net_asset"] = net_asset nodes_data["nat"] = nat return nodes
def infraenv_nodes(self, infraenv_controller: NodeController) -> Nodes: return Nodes(infraenv_controller)
def nodes(self, controller: NodeController) -> Nodes: return Nodes(controller)