def cluster( self, api_client: InventoryClient, request: FixtureRequest, infra_env_configuration: InfraEnvConfig, proxy_server, prepare_nodes_network: Nodes, cluster_configuration: ClusterConfig, ipxe_server, ): log.debug( f"--- SETUP --- Creating cluster for test: {request.node.name}\n") cluster = Cluster( api_client=api_client, config=cluster_configuration, infra_env_config=infra_env_configuration, nodes=prepare_nodes_network, ) if self._does_need_proxy_server(prepare_nodes_network): self.__set_up_proxy_server(cluster, cluster_configuration, proxy_server) if global_variables.ipxe_boot: infra_env = cluster.generate_infra_env() ipxe_server_controller = ipxe_server(name="ipxe_controller", api_client=cluster.api_client) ipxe_server_controller.start(infra_env_id=infra_env.id, cluster_name=cluster.name) ipxe_server_url = f"http://{consts.DEFAULT_IPXE_SERVER_IP}:{consts.DEFAULT_IPXE_SERVER_PORT}/{cluster.name}" network_name = cluster.nodes.get_cluster_network() libvirt_controller = LibvirtController( config=cluster.nodes.controller, entity_config=cluster_configuration) libvirt_controller.set_ipxe_url(network_name=network_name, ipxe_url=ipxe_server_url) yield cluster if self._is_test_failed(request): log.info( f"--- TEARDOWN --- Collecting Logs for test: {request.node.name}\n" ) self.collect_test_logs(cluster, api_client, request, cluster.nodes) if global_variables.test_teardown: if cluster.is_installing() or cluster.is_finalizing(): cluster.cancel_install() if global_variables.test_teardown: with SuppressAndLog(ApiException): cluster.deregister_infraenv() with suppress(ApiException): log.info( f"--- TEARDOWN --- deleting created cluster {cluster.id}\n" ) cluster.delete()
def cluster( self, api_client: InventoryClient, request: FixtureRequest, infra_env_configuration: InfraEnvConfig, proxy_server, prepare_nodes_network: Nodes, cluster_configuration: ClusterConfig, ipxe_server: Callable, tang_server: Callable, ): log.debug( f"--- SETUP --- Creating cluster for test: {request.node.name}\n") if cluster_configuration.disk_encryption_mode == consts.DiskEncryptionMode.TANG: self._start_tang_server(tang_server, cluster_configuration) cluster = Cluster( api_client=api_client, config=cluster_configuration, infra_env_config=infra_env_configuration, nodes=prepare_nodes_network, ) if self._does_need_proxy_server(prepare_nodes_network): self.__set_up_proxy_server(cluster, cluster_configuration, proxy_server) if global_variables.ipxe_boot: infra_env = cluster.generate_infra_env() ipxe_server_controller = ipxe_server(name="ipxe_controller", api_client=cluster.api_client) ipxe_server_controller.run(infra_env_id=infra_env.id, cluster_name=cluster.name) cluster_configuration.iso_download_path = utils.get_iso_download_path( infra_env_configuration.entity_name.get()) yield cluster if self._is_test_failed(request): log.info( f"--- TEARDOWN --- Collecting Logs for test: {request.node.name}\n" ) self.collect_test_logs(cluster, api_client, request, cluster.nodes) if global_variables.test_teardown: if cluster.is_installing() or cluster.is_finalizing(): cluster.cancel_install() if global_variables.test_teardown: with SuppressAndLog(ApiException): cluster.deregister_infraenv() with suppress(ApiException): log.info( f"--- TEARDOWN --- deleting created cluster {cluster.id}\n" ) cluster.delete()