Skip to content

Commit

Permalink
NO-ISSUE: Fix local auto VIPs allocation flow on Nutanix
Browse files Browse the repository at this point in the history
  • Loading branch information
eliorerz committed May 28, 2024
1 parent 719230b commit 907d6b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packer_files/vsphere_centos_template/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ variable "iso_url" {

variable "iso_checksum" {
type = string
default = "9602c69c52d93f51295c0199af395ca0edbe35e36506e32b8e749ce6c8f5b60a"
default = "9602c69c52d93f51295c0199af395ca0edbe35e3650632b8e749ce6c8f5b60a"
description = "The Centos8 ISO checksum"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ def restart_node(self, node_name: str) -> None:
vm.power_on()

def get_ingress_and_api_vips(self):
if not self._entity_config.vip_dhcp_allocation:
"""
Need to distinguish between 3 cases:
1) vip_dhcp_allocation is set to False: Need to provide API and Ingress VIPs - raise an exception if
one or more are empty.
2) vip_dhcp_allocation is set to True: No need to provide API and Ingress VIP, return None.
3) vip_dhcp_allocation is not being set at all and its value is equal to None: In this case, search free IPs
and set them as VIPs. The behavior is the same as vip_dhcp_allocation = False but getting the IPs first.
Note that (3) is supposed to happen only locally due to the face that vip_dhcp_allocation is set in CI to some
value.
"""
if self._entity_config.vip_dhcp_allocation is False:
if self._entity_config.api_vips is None or len(self._entity_config.api_vips) == 0:
raise ValueError("API VIP is not set")
if self._entity_config.ingress_vips is None or len(self._entity_config.ingress_vips) == 0:
Expand All @@ -66,6 +76,10 @@ def get_ingress_and_api_vips(self):
"ingress_vips": self._entity_config.ingress_vips,
}

elif self._entity_config.vip_dhcp_allocation is True:
return None

# If VIP DHCP Allocation is not set at all - search for free IPs and select addresses for VIPs
nutanix_subnet = next(
s for s in NutanixSubnet.list_entities(self._provider_client) if s.name == self._config.nutanix_subnet
)
Expand All @@ -91,7 +105,7 @@ def get_ingress_and_api_vips(self):
raise ConnectionError("Failed to locate free API and Ingress VIPs")

log.info(f"Found 2 optional VIPs: {free_ips}")
return {"api_vips": [free_ips.pop()], "ingress_vips": [free_ips.pop()]}
return {"api_vips": [{"ip": free_ips.pop()}], "ingress_vips": [{"ip": free_ips.pop()}]}

def set_boot_order(self, node_name, cd_first=False, cdrom_iso_path=None) -> None:
vm = self._get_provider_vm(tf_vm_name=node_name)
Expand Down

0 comments on commit 907d6b1

Please sign in to comment.