in pkg/cloud/network.go [110:134]
func (c *client) AssociatePublicIpAddress(csCluster *infrav1.CloudStackCluster) (retErr error) {
publicAddress, err := c.ResolvePublicIPDetails(csCluster)
if err != nil {
return err
}
csCluster.Spec.ControlPlaneEndpoint.Host = publicAddress.Ipaddress
csCluster.Status.PublicIPID = publicAddress.Id
if publicAddress.Allocated != "" && publicAddress.Associatednetworkid == csCluster.Status.NetworkID {
// Address already allocated to network. Allocated is a timestamp -- not a boolean.
return nil
} // Address not yet allocated. Allocate now.
// Public IP found, but not yet allocated to network.
p := c.cs.Address.NewAssociateIpAddressParams()
p.SetNetworkid(csCluster.Status.NetworkID)
p.SetIpaddress(csCluster.Spec.ControlPlaneEndpoint.Host)
setIfNotEmpty(csCluster.Spec.Account, p.SetAccount)
setIfNotEmpty(csCluster.Status.DomainID, p.SetDomainid)
if _, err := c.cs.Address.AssociateIpAddress(p); err != nil {
return err
}
return nil
}