diff --git a/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interface.go b/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interface.go index c202ce6be5..74ea794ccf 100644 --- a/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interface.go +++ b/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interface.go @@ -18,6 +18,7 @@ import ( const ( isBareMetalServerNicEnableInfraNAT = "enable_infrastructure_nat" isBareMetalServerNicFloatingIPs = "floating_ips" + isBareMetalServerNicFloatingIPId = "id" isBareMetalServerNicIpAddress = "address" isBareMetalServerNicIpCRN = "crn" isBareMetalServerNicIpHref = "href" @@ -91,8 +92,15 @@ func DataSourceIBMIsBareMetalServerNetworkInterface() *schema.Resource { isBareMetalServerNicIpID: { Type: schema.TypeString, Computed: true, + Deprecated: "This field is deprecated - replaced by id", Description: "The unique identifier for this floating IP", }, + isBareMetalServerNicFloatingIPId: { + Type: schema.TypeString, + Computed: true, + Description: "The unique identifier for this floating IP", + }, + isBareMetalServerNicIpName: { Type: schema.TypeString, Computed: true, @@ -243,8 +251,9 @@ func dataSourceIBMISBareMetalServerNetworkInterfaceRead(context context.Context, if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicIpID: *ip.ID, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } @@ -316,8 +325,9 @@ func dataSourceIBMISBareMetalServerNetworkInterfaceRead(context context.Context, if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicIpID: *ip.ID, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } diff --git a/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interfaces.go b/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interfaces.go index c64cd8e384..aa80d14c7d 100644 --- a/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interfaces.go +++ b/ibm/service/vpc/data_source_ibm_is_bare_metal_server_network_interfaces.go @@ -67,6 +67,12 @@ func DataSourceIBMIsBareMetalServerNetworkInterfaces() *schema.Resource { Description: "The URL for this floating IP", }, isBareMetalServerNicIpID: { + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated - replaced by id", + Description: "The unique identifier for this floating IP", + }, + isBareMetalServerNicFloatingIPId: { Type: schema.TypeString, Computed: true, Description: "The unique identifier for this floating IP", @@ -231,8 +237,9 @@ func dataSourceIBMISBareMetalServerNetworkInterfacesRead(context context.Context floatingIPList := make([]map[string]interface{}, 0) for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicIpID: *ip.ID, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } @@ -297,8 +304,9 @@ func dataSourceIBMISBareMetalServerNetworkInterfacesRead(context context.Context floatingIPList := make([]map[string]interface{}, 0) for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicIpID: *ip.ID, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } diff --git a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface.go b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface.go index d9c0fc0d53..25216d71b1 100644 --- a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface.go +++ b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface.go @@ -85,6 +85,11 @@ func ResourceIBMIsBareMetalServerNetworkInterface() *schema.Resource { Computed: true, Description: "The globally unique IP address", }, + isBareMetalServerNicFloatingIPId: { + Type: schema.TypeString, + Computed: true, + Description: "The globally unique IP identifier", + }, }, }, }, @@ -403,12 +408,12 @@ func resourceIBMISBareMetalServerNetworkInterfaceCreate(context context.Context, } log.Printf("[INFO] Bare Metal Server Network Interface : %s", d.Id()) - _, err = isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) + nicAfterWait, err := isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) if err != nil { return diag.FromErr(err) } - err = bareMetalServerNICGet(d, meta, sess, nic, bareMetalServerId) + err = bareMetalServerNICGet(d, meta, sess, nicAfterWait, bareMetalServerId) if err != nil { return diag.FromErr(err) } @@ -543,16 +548,16 @@ func createVlanTypeNetworkInterface(context context.Context, d *schema.ResourceD } } - err = bareMetalServerNICGet(d, meta, sess, nic, bareMetalServerId) + _, nicId, err := ParseNICTerraformID(d.Id()) if err != nil { return err } - _, nicId, err := ParseNICTerraformID(d.Id()) + log.Printf("[INFO] Bare Metal Server Network Interface : %s", d.Id()) + nicAfterWait, err := isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) if err != nil { return err } - log.Printf("[INFO] Bare Metal Server Network Interface : %s", d.Id()) - _, err = isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) + err = bareMetalServerNICGet(d, meta, sess, nicAfterWait, bareMetalServerId) if err != nil { return err } @@ -602,8 +607,8 @@ func bareMetalServerNICGet(d *schema.ResourceData, meta interface{}, sess *vpcv1 if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } @@ -680,8 +685,8 @@ func bareMetalServerNICGet(d *schema.ResourceData, meta interface{}, sess *vpcv1 if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } @@ -1046,6 +1051,9 @@ func isBareMetalServerNetworkInterfaceRefreshFunc(client *vpcv1.VpcV1, bareMetal nic := bmsNic.(*vpcv1.BareMetalServerNetworkInterfaceByVlan) status = *nic.Status d.Set(isBareMetalServerNicStatus, *nic.Status) + if *nic.PrimaryIP.Address == "0.0.0.0" { + return bmsNic, "pending", nil + } } } diff --git a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float.go b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float.go index a90b0a2f80..60c096c054 100644 --- a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float.go +++ b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float.go @@ -77,6 +77,11 @@ func ResourceIBMIsBareMetalServerNetworkInterfaceAllowFloat() *schema.Resource { Computed: true, Description: "The globally unique IP address", }, + isBareMetalServerNicFloatingIPId: { + Type: schema.TypeString, + Computed: true, + Description: "The globally unique IP identifier", + }, }, }, }, @@ -324,12 +329,12 @@ func createVlanTypeNetworkInterfaceAllowFloat(context context.Context, d *schema } log.Printf("[INFO] Bare Metal Server Network Interface : %s", d.Id()) - _, err = isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) + nicAfterWait, err := isWaitForBareMetalServerNetworkInterfaceAvailable(sess, bareMetalServerId, nicId, d.Timeout(schema.TimeoutCreate), d) if err != nil { return err } - err = bareMetalServerNICAllowFloatGet(d, meta, sess, nic, bareMetalServerId) + err = bareMetalServerNICAllowFloatGet(d, meta, sess, nicAfterWait, bareMetalServerId) if err != nil { return err } @@ -429,8 +434,8 @@ func bareMetalServerNICAllowFloatGet(d *schema.ResourceData, meta interface{}, s if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } @@ -502,8 +507,8 @@ func bareMetalServerNICAllowFloatGet(d *schema.ResourceData, meta interface{}, s if nic.FloatingIps != nil { for _, ip := range nic.FloatingIps { currentIP := map[string]interface{}{ - isBareMetalServerNicIpID: *ip.ID, - isBareMetalServerNicIpAddress: *ip.Address, + isBareMetalServerNicFloatingIPId: *ip.ID, + isBareMetalServerNicIpAddress: *ip.Address, } floatingIPList = append(floatingIPList, currentIP) } diff --git a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float_test.go b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float_test.go index a3af18216d..a595005f32 100644 --- a/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float_test.go +++ b/ibm/service/vpc/resource_ibm_is_bare_metal_server_network_interface_allow_float_test.go @@ -60,7 +60,7 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE return nil }), resource.TestCheckResourceAttrSet( - "ibm_is_bare_metal_server.testacc_bms", "floating_bare_metal_server"), + "ibm_is_bare_metal_server_network_interface_allow_float.bms_nic", "floating_bare_metal_server"), resource.TestCheckResourceAttrWith("ibm_is_bare_metal_server_network_interface_allow_float.bms_nic", "floating_bare_metal_server", func(v string) error { if v == "" { return fmt.Errorf("Attribute 'floating_bare_metal_server' %s is not populated", v) @@ -108,7 +108,7 @@ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCKVmnMOlHKcZK8tpt3MP1lqOLAcqcJzhsvJcjscgVE return nil }), resource.TestCheckResourceAttrSet( - "ibm_is_bare_metal_server.testacc_bms", "floating_bare_metal_server"), + "ibm_is_bare_metal_server_network_interface_allow_float.bms_nic", "floating_bare_metal_server"), resource.TestCheckResourceAttrWith("ibm_is_bare_metal_server_network_interface_allow_float.bms_nic", "floating_bare_metal_server", func(v string) error { if v == "" { return fmt.Errorf("Attribute 'floating_bare_metal_server' %s is not populated", v)