Skip to content

Commit 8a6e4fe

Browse files
Add Ipaddresses to the csMachine status
1 parent 2bcce63 commit 8a6e4fe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/cloud/instance.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ func setMachineDataFromVMMetrics(vmResponse *cloudstack.VirtualMachinesMetric, c
4444
csMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("cloudstack:///%s", vmResponse.Id))
4545
// InstanceID is later used as required parameter to destroy VM.
4646
csMachine.Spec.InstanceID = ptr.To(vmResponse.Id)
47-
csMachine.Status.Addresses = []corev1.NodeAddress{{Type: corev1.NodeInternalIP, Address: vmResponse.Ipaddress}}
47+
csMachine.Status.Addresses = []corev1.NodeAddress{}
48+
for _, nic := range vmResponse.Nic {
49+
if nic.Ipaddress != "" {
50+
csMachine.Status.Addresses = append(csMachine.Status.Addresses, corev1.NodeAddress{
51+
Type: corev1.NodeInternalIP,
52+
Address: nic.Ipaddress,
53+
})
54+
}
55+
}
4856
newInstanceState := vmResponse.State
4957
if newInstanceState != csMachine.Status.InstanceState || (newInstanceState != "" && csMachine.Status.InstanceStateLastUpdated.IsZero()) {
5058
csMachine.Status.InstanceState = newInstanceState

0 commit comments

Comments
 (0)