def day2_nodes_flow(client, cluster_name, cluster, image_path, num_worker_nodes, api_vip_ip, api_vip_dnsname, namespace, install_cluster_flag): tf_network_name, total_num_nodes = apply_day2_tf_configuration( cluster_name, num_worker_nodes, api_vip_ip, api_vip_dnsname, namespace) with utils.file_lock_context(): utils.run_command(f'make _apply_terraform CLUSTER_NAME={cluster_name}') time.sleep(5) utils.wait_till_nodes_are_ready(nodes_count=total_num_nodes, network_name=tf_network_name) waiting.wait( lambda: utils.are_libvirt_nodes_in_cluster_hosts( client, cluster.id, num_worker_nodes), timeout_seconds=consts.NODES_REGISTERED_TIMEOUT, sleep_seconds=10, waiting_for="Nodes to be registered in inventory service", ) utils.wait_till_all_hosts_are_in_status( client=client, cluster_id=cluster.id, nodes_count=num_worker_nodes, statuses=[consts.NodesStatus.KNOWN], interval=30, ) if install_cluster_flag: log.info("Start installing all known nodes in the cluster %s", cluster.id) config_etc_hosts(api_vip_ip, api_vip_dnsname) ocp_orig_ready_nodes = get_ocp_cluster_ready_nodes_num() client.install_day2_cluster(cluster.id) log.info( "Start waiting until all nodes of cluster %s have been installed( reached added-to-existing-clustertate)", cluster.id) utils.wait_till_all_hosts_are_in_status( client=client, cluster_id=cluster.id, nodes_count=num_worker_nodes, statuses=[consts.NodesStatus.DAY2_INSTALLED], interval=30, ) log.info( "Start waiting until installed nodes has actually been added to the OCP cluster" ) waiting.wait( lambda: wait_nodes_join_ocp_cluster(ocp_orig_ready_nodes, num_worker_nodes), timeout_seconds=consts.NODES_REGISTERED_TIMEOUT, sleep_seconds=30, waiting_for="Day2 nodes to be added to OCP cluster", ) log.info("%d worker nodes were successfully added to OCP cluster", num_worker_nodes)
def _try_to_delete_nodes(tf_folder): log.info('Start running terraform delete') with utils.file_lock_context(): utils.run_command_with_output(f'cd {tf_folder} && ' 'terraform destroy ' '-auto-approve ' '-input=false ' '-state=terraform.tfstate ' '-state-out=terraform.tfstate ' '-var-file=terraform.tfvars.json')
def create_nodes(cluster_name, image_path, storage_path, master_count, nodes_details, tf): log.info("Creating tfvars") fill_tfvars(image_path=image_path, storage_path=storage_path, master_count=master_count, nodes_details=nodes_details, tf_folder=tf.working_dir) log.info('Start running terraform') with utils.file_lock_context(): return tf.apply()
def create_nodes(cluster_name, image_path, storage_path, master_count, nodes_details, tf_folder): log.info("Creating tfvars") fill_tfvars(image_path=image_path, storage_path=storage_path, master_count=master_count, nodes_details=nodes_details, tf_folder=tf_folder) log.info('Start running terraform') with utils.file_lock_context(): return utils.run_command( f'make _run_terraform CLUSTER_NAME={cluster_name}')
def day2_nodes_flow(client, cluster_name, cluster, image_path, num_worker_nodes, api_vip_ip, api_vip_dnsname, namespace, install_cluster_flag): tf_network_name, total_num_nodes = apply_day2_tf_configuration( cluster_name, num_worker_nodes, api_vip_ip, api_vip_dnsname, namespace) with utils.file_lock_context(): utils.run_command(f'make _apply_terraform CLUSTER_NAME={cluster_name}') time.sleep(5) utils.wait_till_nodes_are_ready(nodes_count=total_num_nodes, network_name=tf_network_name) waiting.wait( lambda: utils.are_libvirt_nodes_in_cluster_hosts( client, cluster.id, num_worker_nodes), timeout_seconds=consts.NODES_REGISTERED_TIMEOUT, sleep_seconds=10, waiting_for="Nodes to be registered in inventory service", ) utils.wait_till_all_hosts_are_in_status( client=client, cluster_id=cluster.id, nodes_count=num_worker_nodes, statuses=[consts.NodesStatus.KNOWN], interval=30, ) if install_cluster_flag: client.install_day2_cluster(cluster.id) utils.wait_till_all_hosts_are_in_status( client=client, cluster_id=cluster.id, nodes_count=num_worker_nodes, statuses=[consts.NodesStatus.DAY2_INSTALLED], interval=30, )
def clean_virsh_resources(skip_list, resource_filter): with utils.file_lock_context(): clean_domains(skip_list, resource_filter) clean_pools(skip_list, resource_filter) clean_networks(skip_list, resource_filter)