diff --git a/datasource/metadata/cloudsigma/server_context.go b/datasource/metadata/cloudsigma/server_context.go index 5d28900..b11bd96 100644 --- a/datasource/metadata/cloudsigma/server_context.go +++ b/datasource/metadata/cloudsigma/server_context.go @@ -73,12 +73,13 @@ func (scs *serverContextService) FetchMetadata() ([]byte, error) { UUID string `json:"uuid"` Meta map[string]string `json:"meta"` Nics []struct { - Runtime struct { + Mac string `json:"mac"` + IPv4Conf struct { InterfaceType string `json:"interface_type"` - IPv4 struct { - IP string `json:"uuid"` - } `json:"ip_v4"` - } `json:"runtime"` + IP struct { + UUID string `json:"uuid"` + } `json:"ip"` + } `json:"ip_v4_conf"` } `json:"nics"` } outputMetadata struct { @@ -112,12 +113,9 @@ func (scs *serverContextService) FetchMetadata() ([]byte, error) { } for _, nic := range inputMetadata.Nics { - if nic.Runtime.IPv4.IP != "" { - if nic.Runtime.InterfaceType == "public" { - outputMetadata.PublicIPv4 = nic.Runtime.IPv4.IP - } else { - outputMetadata.LocalIPv4 = nic.Runtime.IPv4.IP - } + if nic.IPv4Conf.IP.UUID != "" { + outputMetadata.PublicIPv4 = nic.IPv4Conf.IP.UUID + break } } diff --git a/datasource/metadata/cloudsigma/server_context_test.go b/datasource/metadata/cloudsigma/server_context_test.go index ef4073d..9c6f6d8 100644 --- a/datasource/metadata/cloudsigma/server_context_test.go +++ b/datasource/metadata/cloudsigma/server_context_test.go @@ -74,14 +74,41 @@ func TestServerContextFetchMetadata(t *testing.T) { "name": "coreos", "nics": [ { - "runtime": { - "interface_type": "public", - "ip_v4": { + "boot_order": null, + "ip_v4_conf": { + "conf": "dhcp", + "ip": { + "gateway": "31.171.244.1", + "meta": {}, + "nameservers": [ + "178.22.66.167", + "178.22.71.56", + "8.8.8.8" + ], + "netmask": 22, + "tags": [], "uuid": "31.171.251.74" - }, - "ip_v6": null + } }, + "ip_v6_conf": null, + "mac": "22:3d:09:6b:90:f3", + "model": "virtio", "vlan": null + }, + { + "boot_order": null, + "ip_v4_conf": null, + "ip_v6_conf": null, + "mac": "22:ae:4a:fb:8f:31", + "model": "virtio", + "vlan": { + "meta": { + "description": "", + "name": "CoreOS" + }, + "tags": [], + "uuid": "5dec030e-25b8-4621-a5a4-a3302c9d9619" + } } ], "smp": 2,