From 59180a830aa7cb2b3e0ce30072db0ae411c0391c Mon Sep 17 00:00:00 2001 From: Ondrej Ezr Date: Mon, 9 Oct 2023 18:09:21 +0200 Subject: [PATCH] feat(HMS-2439): Add private IP address in Azure details Fetch Azure private IP address as well as public one. --- api/openapi.gen.json | 2 +- api/openapi.gen.yaml | 2 +- cmd/spec/example_reservation.go | 5 +++-- internal/clients/http/azure/create_vms.go | 5 +++++ internal/jobs/launch_instance_azure.go | 3 ++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/openapi.gen.json b/api/openapi.gen.json index ccd15c19..f3777086 100644 --- a/api/openapi.gen.json +++ b/api/openapi.gen.json @@ -82,7 +82,7 @@ "instances": [ { "detail": { - "privateipv4": "", + "privateipv4": "172.22.0.1", "privateipv6": "", "publicdns": "", "publicipv4": "10.0.0.88" diff --git a/api/openapi.gen.yaml b/api/openapi.gen.yaml index b85d65b4..3729e8f1 100644 --- a/api/openapi.gen.yaml +++ b/api/openapi.gen.yaml @@ -675,7 +675,7 @@ components: instance_size: Basic_A0 instances: - detail: - privateipv4: "" + privateipv4: 172.22.0.1 privateipv6: "" publicdns: "" publicipv4: 10.0.0.88 diff --git a/cmd/spec/example_reservation.go b/cmd/spec/example_reservation.go index bb0a0184..8b0b23a9 100644 --- a/cmd/spec/example_reservation.go +++ b/cmd/spec/example_reservation.go @@ -157,8 +157,9 @@ var AzureReservationResponsePayloadDoneExample = payloads.AzureReservationRespon Instances: []payloads.InstanceResponse{{ InstanceID: "/subscriptions/4b9d213f-712f-4d17-a483-8a10bbe9df3a/resourceGroups/redhat-deployed/providers/Microsoft.Compute/images/composer-api-92ea98f8-7697-472e-80b1-7454fa0e7fa7", Detail: models.ReservationInstanceDetail{ - PublicDNS: "", - PublicIPv4: "10.0.0.88", + PublicDNS: "", + PublicIPv4: "10.0.0.88", + PrivateIPv4: "172.22.0.1", }, }}, } diff --git a/internal/clients/http/azure/create_vms.go b/internal/clients/http/azure/create_vms.go index 4b6067b0..4ac8a113 100644 --- a/internal/clients/http/azure/create_vms.go +++ b/internal/clients/http/azure/create_vms.go @@ -38,6 +38,11 @@ func (c *client) CreateVMs(ctx context.Context, vmParams clients.AzureInstancePa } vmDescriptions[i].IPv4 = *publicIP.Properties.IPAddress + // can be nil if IPv6 is default in the future + privateIPv4 := networkInterface.Properties.IPConfigurations[0].Properties.PrivateIPAddress + if privateIPv4 != nil { + vmDescriptions[i].PrivateIPv4 = *privateIPv4 + } resumeTokens[i], err = c.BeginCreateVM(ctx, networkInterface, vmParams, vmName) if err != nil { diff --git a/internal/jobs/launch_instance_azure.go b/internal/jobs/launch_instance_azure.go index 1e99efc2..cde132c8 100644 --- a/internal/jobs/launch_instance_azure.go +++ b/internal/jobs/launch_instance_azure.go @@ -190,7 +190,8 @@ func DoLaunchInstanceAzure(ctx context.Context, args *LaunchInstanceAzureTaskArg ReservationID: args.ReservationID, InstanceID: instanceDescription.ID, Detail: models.ReservationInstanceDetail{ - PublicIPv4: instanceDescription.IPv4, + PublicIPv4: instanceDescription.IPv4, + PrivateIPv4: instanceDescription.PrivateIPv4, }, }) if err != nil {