def modify_scaleup_repo(self): """ Modify the scale-up repo. Considering the user experience, removing the access and secret keys and variable from appropriate location in the scale-up repo """ # remove access and secret key from constants.SCALEUP_VSPHERE_MAIN access_key = 'access_key = "${var.aws_access_key}"' secret_key = 'secret_key = "${var.aws_secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{secret_key}", " ") # remove access and secret key from constants.SCALEUP_VSPHERE_ROUTE53 route53_access_key = 'access_key = "${var.access_key}"' route53_secret_key = 'secret_key = "${var.secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_secret_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, "us-east-1", f"{config.ENV_DATA.get('region')}") # remove access and secret variables from scale-up repo remove_keys_from_tf_variable_file(constants.SCALEUP_VSPHERE_VARIABLES, ['aws_access_key', 'aws_secret_key']) remove_keys_from_tf_variable_file( constants.SCALEUP_VSPHERE_ROUTE53_VARIABLES, ['access_key', 'secret_key'])
def modify_scaleup_repo(self): """ Modify the scale-up repo. Considering the user experience, removing the access and secret keys and variable from appropriate location in the scale-up repo """ # importing here to avoid circular dependancy from ocs_ci.deployment.vmware import change_vm_root_disk_size if self.folder_structure: logger.info("Modifying scaleup repo for folder structure") # modify default_map.yaml default_map_path = os.path.join( constants.CLUSTER_LAUNCHER_VSPHERE_DIR, f"aos-{self.ocp_version}", "default_map.yaml") dict_data = load_yaml(default_map_path) dict_data['cluster_domain'] = config.ENV_DATA['base_domain'] dict_data['vsphere']['vcsa-qe']['datacenter'] = ( config.ENV_DATA['vsphere_datacenter']) dict_data['vsphere']['vcsa-qe']['datastore'] = ( config.ENV_DATA['vsphere_datastore']) dict_data['vsphere']['vcsa-qe']['network'] = ( config.ENV_DATA['vm_network']) dict_data['vsphere']['vcsa-qe']['cpus'] = ( config.ENV_DATA['rhel_num_cpus']) dict_data['vsphere']['vcsa-qe']['memory'] = ( config.ENV_DATA['rhel_memory']) dict_data['vsphere']['vcsa-qe']['root_volume_size'] = ( config.ENV_DATA.get('root_disk_size', '120')) dict_data['vsphere']['vcsa-qe']['image'] = ( config.ENV_DATA['rhel_template']) dump_data_to_temp_yaml(dict_data, default_map_path) else: # remove access and secret key from constants.SCALEUP_VSPHERE_MAIN access_key = 'access_key = "${var.aws_access_key}"' secret_key = 'secret_key = "${var.aws_secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{secret_key}", " ") # remove access and secret key from constants.SCALEUP_VSPHERE_ROUTE53 route53_access_key = 'access_key = "${var.access_key}"' route53_secret_key = 'secret_key = "${var.secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_secret_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, "us-east-1", f"{config.ENV_DATA.get('region')}") # remove access and secret variables from scale-up repo remove_keys_from_tf_variable_file( constants.SCALEUP_VSPHERE_VARIABLES, ['aws_access_key', 'aws_secret_key']) remove_keys_from_tf_variable_file( constants.SCALEUP_VSPHERE_ROUTE53_VARIABLES, ['access_key', 'secret_key']) # change root disk size change_vm_root_disk_size(constants.SCALEUP_VSPHERE_MACHINE_CONF)
def modify_scaleup_repo(self): """ Modify the scale-up repo. Considering the user experience, removing the access and secret keys and variable from appropriate location in the scale-up repo """ # importing here to avoid circular dependancy from ocs_ci.deployment.vmware import change_vm_root_disk_size if self.folder_structure: logger.info("Modifying scaleup repo for folder structure") # modify default_map.yaml default_map_path = os.path.join( constants.CLUSTER_LAUNCHER_VSPHERE_DIR, f"aos-{self.ocp_version}", "default_map.yaml", ) dict_data = load_yaml(default_map_path) dict_data["cluster_domain"] = config.ENV_DATA["base_domain"] dict_data["vsphere"]["vcsa-qe"]["datacenter"] = config.ENV_DATA[ "vsphere_datacenter"] dict_data["vsphere"]["vcsa-qe"]["datastore"] = config.ENV_DATA[ "vsphere_datastore"] dict_data["vsphere"]["vcsa-qe"]["network"] = config.ENV_DATA[ "vm_network"] dict_data["vsphere"]["vcsa-qe"]["cpus"] = config.ENV_DATA[ "rhel_num_cpus"] dict_data["vsphere"]["vcsa-qe"]["memory"] = config.ENV_DATA[ "rhel_memory"] dict_data["vsphere"]["vcsa-qe"][ "root_volume_size"] = config.ENV_DATA.get( "root_disk_size", "120") if version.get_semantic_ocp_version_from_config( ) >= version.VERSION_4_9: dict_data["vsphere"]["vcsa-qe"]["image_7"] = config.ENV_DATA[ "rhel_template"] else: dict_data["vsphere"]["vcsa-qe"]["image"] = config.ENV_DATA[ "rhel_template"] dump_data_to_temp_yaml(dict_data, default_map_path) else: # remove access and secret key from constants.SCALEUP_VSPHERE_MAIN access_key = 'access_key = "${var.aws_access_key}"' secret_key = 'secret_key = "${var.aws_secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_MAIN, f"{secret_key}", " ") # remove access and secret key from constants.SCALEUP_VSPHERE_ROUTE53 route53_access_key = 'access_key = "${var.access_key}"' route53_secret_key = 'secret_key = "${var.secret_key}"' replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_access_key}", " ") replace_content_in_file(constants.SCALEUP_VSPHERE_ROUTE53, f"{route53_secret_key}", " ") replace_content_in_file( constants.SCALEUP_VSPHERE_ROUTE53, "us-east-1", f"{config.ENV_DATA.get('region')}", ) # remove access and secret variables from scale-up repo remove_keys_from_tf_variable_file( constants.SCALEUP_VSPHERE_VARIABLES, ["aws_access_key", "aws_secret_key"], ) remove_keys_from_tf_variable_file( constants.SCALEUP_VSPHERE_ROUTE53_VARIABLES, ["access_key", "secret_key"], ) # change root disk size change_vm_root_disk_size(constants.SCALEUP_VSPHERE_MACHINE_CONF)