Skip to content

Commit

Permalink
NO-ISSUE: Set OCI bucket name to include cluster name. Upload terrafo…
Browse files Browse the repository at this point in the history
…rm output to the generated bucket.
  • Loading branch information
eliorerz authored and dudyas6 committed Jan 13, 2025
1 parent 1b79116 commit 8edb97e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,16 @@ def _create_bucket(
# Need the namespace and bucket name
return namespace

def _upload_iso_to_bucket(self, file_path: str, namespace: str, bucket_name: str) -> None:
log.info(f"Upload iso file to bucket object storage {file_path}")
def _upload_data_to_bucket(self, data: str, filename: str, namespace: str, bucket_name: str):
file_path = f"/tmp/{filename}"

with os.path.open(file_path, "w") as f:
f.write(data)

return self._upload_file_to_bucket(file_path, namespace, bucket_name)

def _upload_file_to_bucket(self, file_path: str, namespace: str, bucket_name: str):
log.info(f"Upload file to bucket object storage {file_path}")
if os.path.isfile(file_path):
try:
self._object_storage_client.put_object(
Expand Down Expand Up @@ -444,11 +452,11 @@ def setup_time(self) -> str:

def prepare_nodes(self) -> None:
log.info("OCI prepare all nodes")
bucket_name = random_name("bucket-")
bucket_name = f"bucket-{self._entity_config.cluster_id}"
namespace = self._create_bucket(bucket_name)
self._upload_iso_to_bucket(self._entity_config.iso_download_path, namespace, bucket_name)
self._upload_file_to_bucket(self._entity_config.iso_download_path, namespace, bucket_name)
url_path = self._create_pre_authenticated(
random_name("preauth-"), self._entity_config.iso_download_path, namespace, bucket_name
f"preauth-{self._entity_config.cluster_id}", self._entity_config.iso_download_path, namespace, bucket_name
)

terraform_variables = self._terraform_variables(
Expand All @@ -460,9 +468,16 @@ def prepare_nodes(self) -> None:
base_dns=self._entity_config.base_dns_domain,
)
stack_id = self._create_stack(
random_name("stack-"), namespace, bucket_name, self._config.oci_infrastructure_zip_file, terraform_variables
f"stack-{self._entity_config.cluster_id}",
namespace,
bucket_name,
self._config.oci_infrastructure_zip_file,
terraform_variables,
)
terraform_output = self._apply_job_from_stack(stack_id, random_name("job-"))
self._upload_data_to_bucket(
terraform_output, f"terraform-output-{self._entity_config.cluster_id}.yaml", namespace, bucket_name
)
self.cloud_provider = terraform_output

def is_active(self, node_name) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class BaseClusterConfig(BaseEntityConfig, ABC):
All arguments must default to None and be type annotated.
"""

cluster_id: str = None
cluster_tags: str = None
olm_operators: List[str] = None
vip_dhcp_allocation: bool = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ class BaseEntityConfig(BaseConfig, ABC):
is_bonded: bool = None
num_bonded_slaves: int = None
bonding_mode: str = None
cluster_id: str = None
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class BaseInfraEnvConfig(BaseEntityConfig, ABC):
"""

infra_env_id: str = None
cluster_id: str = None
static_network_config: List[dict] = None
ignition_config_override: str = None
verify_download_iso_ssl: bool = None
Expand Down

0 comments on commit 8edb97e

Please sign in to comment.