Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mtu and accessConfig flags to subnet create commands for terraform #4690

Merged
merged 15 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3
github.com/DataDog/zstd v1.4.4/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/IBM-Cloud/bluemix-go v0.0.0-20231017073329-75ebe90c98ba h1:8U4HByOYJiaGWBpGjdRIzyzu0NBzjywh//CZnSbEsPw=
github.com/IBM-Cloud/bluemix-go v0.0.0-20231017073329-75ebe90c98ba/go.mod h1:mt+O8ryLVANrBKlA4RxKdENp3q6Q7mKQIi2nkiibZbU=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230822142550-30562e113de9 h1:sXRzCK3Glxpyu66Tu2NjztLdT5sDwj4qly+MJKRhdWY=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230822142550-30562e113de9/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c h1:tRS4VuOG3lHNG+yrsh3vZZQDVNLuFJB0oZbTJp9YXds=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231106114255-c50117860a3c/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
Expand Down Expand Up @@ -157,10 +155,6 @@ github.com/IBM/keyprotect-go-client v0.12.2 h1:Cjxcqin9Pl0xz3MnxdiVd4v/eIa79xL3h
github.com/IBM/keyprotect-go-client v0.12.2/go.mod h1:yr8h2noNgU8vcbs+vhqoXp3Lmv73PI0zAc6VMgFvWwM=
github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCBmvdyqkA=
github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo=
github.com/IBM/platform-services-go-sdk v0.52.0 h1:hbf640xE8T0Rwy2IUf5Pu4OATabGS4IDMnEInXUXs4o=
github.com/IBM/platform-services-go-sdk v0.52.0/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU=
github.com/IBM/platform-services-go-sdk v0.52.1 h1:fUCtYMAekzsWO/ylZi31j6BpyJ1xKb39NG62zBXePbg=
github.com/IBM/platform-services-go-sdk v0.52.1/go.mod h1:6LxcUhIaSLP4SuQJXF9oLXBamSQogs5D9BcVwr4hmfU=
github.com/IBM/platform-services-go-sdk v0.53.1 h1:axpK4dzlf+C+KgHQZWXoKSUMoV2t6OrR5kGGumUEXrI=
github.com/IBM/platform-services-go-sdk v0.53.1/go.mod h1:CWSprvsCsXWvujmBzbtoJSmbRZS9FVV3O594b0t/GiM=
github.com/IBM/project-go-sdk v0.0.99 h1:rQU/uQLW83OsAUfP/d8fFSIjp8ooEQIFjalYQD4i4aY=
Expand Down
14 changes: 7 additions & 7 deletions ibm/service/power/data_source_ibm_pi_catalog_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,25 @@ func dataSourceIBMPICatalogImagesRead(ctx context.Context, d *schema.ResourceDat
}
if i.Specifications != nil {
s := i.Specifications
if &s.ImageType != nil {
if s.ImageType != "" {
image["image_type"] = s.ImageType
}
if &s.ContainerFormat != nil {
if s.ContainerFormat != "" {
image["container_format"] = s.ContainerFormat
}
if &s.DiskFormat != nil {
if s.DiskFormat != "" {
image["disk_format"] = s.DiskFormat
}
if &s.OperatingSystem != nil {
if s.OperatingSystem != "" {
image["operating_system"] = s.OperatingSystem
}
if &s.HypervisorType != nil {
if s.HypervisorType != "" {
image["hypervisor_type"] = s.HypervisorType
}
if &s.Architecture != nil {
if s.Architecture != "" {
image["architecture"] = s.Architecture
}
if &s.Endianness != nil {
if s.Endianness != "" {
image["endianness"] = s.Endianness
}
}
Expand Down
4 changes: 0 additions & 4 deletions ibm/service/power/data_source_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
if powervmdata.Addresses != nil {
pvmaddress := make([]map[string]interface{}, len(powervmdata.Addresses))
for i, pvmip := range powervmdata.Addresses {

p := make(map[string]interface{})
p["ip"] = pvmip.IPAddress
p["network_name"] = pvmip.NetworkName
Expand All @@ -257,13 +256,10 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
pvmaddress[i] = p
}
d.Set("addresses", pvmaddress)

}

if powervmdata.Health != nil {

d.Set("health_status", powervmdata.Health.Status)

}

return nil
Expand Down
12 changes: 10 additions & 2 deletions ibm/service/power/data_source_ibm_pi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ func DataSourceIBMPINetwork() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"type": {
Type: schema.TypeString,
Computed: true,
},

"vlan_id": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -79,6 +77,14 @@ func DataSourceIBMPINetwork() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"mtu": {
Type: schema.TypeInt,
Computed: true,
},
"access_config": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -124,6 +130,8 @@ func dataSourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, met
d.Set("dns", networkdata.DNSServers)
}
d.Set("jumbo", networkdata.Jumbo)
d.Set("mtu", networkdata.Mtu)
d.Set("access_config", networkdata.AccessConfig)

return nil

Expand Down
28 changes: 26 additions & 2 deletions ibm/service/power/resource_ibm_pi_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,25 @@ func ResourceIBMPINetwork() *schema.Resource {
Description: "PI network gateway",
},
helpers.PINetworkJumbo: {
Type: schema.TypeBool,
Type: schema.TypeBool,
Optional: true,
Computed: true,
Deprecated: "deprecated use pi_network_mtu instead",
ExactlyOneOf: []string{helpers.PINetworkMtu, helpers.PINetworkJumbo},
Description: "PI network enable MTU Jumbo option",
},
helpers.PINetworkMtu: {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ExactlyOneOf: []string{helpers.PINetworkMtu, helpers.PINetworkJumbo},
Description: "PI Maximum Transmission Unit",
},
helpers.PINetworkAccessConfig: {
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "PI network enable MTU Jumbo option",
Description: "PI network communication configuration",
},
helpers.PICloudInstanceId: {
Type: schema.TypeString,
Expand Down Expand Up @@ -145,6 +160,13 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met
if v, ok := d.GetOk(helpers.PINetworkJumbo); ok {
body.Jumbo = v.(bool)
}
if v, ok := d.GetOk(helpers.PINetworkMtu); ok {
var mtu int64 = int64(v.(int))
body.Mtu = &mtu
}
if v, ok := d.GetOk(helpers.PINetworkAccessConfig); ok {
body.AccessConfig = models.AccessConfig(v.(string))
}

if networktype == "vlan" {
var networkcidr string
Expand Down Expand Up @@ -216,6 +238,8 @@ func resourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, meta
d.Set(helpers.PINetworkName, networkdata.Name)
d.Set(helpers.PINetworkType, networkdata.Type)
d.Set(helpers.PINetworkJumbo, networkdata.Jumbo)
d.Set(helpers.PINetworkMtu, networkdata.Mtu)
d.Set(helpers.PINetworkAccessConfig, networkdata.AccessConfig)
d.Set(helpers.PINetworkGateway, networkdata.Gateway)
ipRangesMap := []map[string]interface{}{}
if networkdata.IPAddressRanges != nil {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_network_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func isIBMPINetworkPortRefreshFunc(client *st.IBMPINetworkClient, id, networknam
return nil, "", err
}

if &network.PortID != nil {
if network.PortID != nil {
//if network.State == "available" {
log.Printf(" The port has been created with the following ip address and attached to an instance ")
return network, "DOWN", nil
Expand Down
50 changes: 50 additions & 0 deletions ibm/service/power/resource_ibm_pi_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,43 @@ func TestAccIBMPINetworkGatewaybasic(t *testing.T) {
},
})
}

ismirlia marked this conversation as resolved.
Show resolved Hide resolved
func TestAccIBMPINetworkGatewaybasicSatellite(t *testing.T) {
name := fmt.Sprintf("tf-pi-network-%d", acctest.RandIntRange(10, 100))
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPINetworkDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPINetworkGatewayConfigSatellite(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPINetworkExists("ibm_pi_network.power_networks"),
resource.TestCheckResourceAttr(
"ibm_pi_network.power_networks", "pi_network_name", name),
resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "pi_gateway"),
resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "id"),
resource.TestCheckResourceAttrSet("ibm_pi_network.power_networks", "pi_ipaddress_range.#"),
),
},
{
Config: testAccCheckIBMPINetworkConfigGatewayUpdateDNS(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPINetworkExists("ibm_pi_network.power_networks"),
resource.TestCheckResourceAttr(
"ibm_pi_network.power_networks", "pi_network_name", name),
resource.TestCheckResourceAttr(
"ibm_pi_network.power_networks", "pi_gateway", "192.168.17.2"),
resource.TestCheckResourceAttr(
"ibm_pi_network.power_networks", "pi_ipaddress_range.0.pi_ending_ip_address", "192.168.17.254"),
resource.TestCheckResourceAttr(
"ibm_pi_network.power_networks", "pi_ipaddress_range.0.pi_starting_ip_address", "192.168.17.3"),
),
},
},
})
}

func testAccCheckIBMPINetworkDestroy(s *terraform.State) error {

sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession()
Expand Down Expand Up @@ -190,3 +227,16 @@ func testAccCheckIBMPINetworkConfigGatewayUpdateDNS(name string) string {
}
`, acc.Pi_cloud_instance_id, name)
}

func testAccCheckIBMPINetworkGatewayConfigSatellite(name string) string {
return fmt.Sprintf(`
resource "ibm_pi_network" "power_networks" {
pi_cloud_instance_id = "%s"
pi_network_name = "%s"
pi_network_type = "vlan"
pi_cidr = "192.168.17.0/24"
pi_network_mtu = 6500
pi_network_access_config = "outbound-only"
}
`, acc.Pi_cloud_instance_id, name)
}
4 changes: 3 additions & 1 deletion website/docs/d/pi_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ In addition to all argument reference list, you can access the following attribu
- `used_ip_count` - (Float) The number of used IP addresses.
- `used_ip_percent` - (Float) The percentage of IP addresses used.
- `vlan_id` - (String) The VLAN ID that the network is connected to.
- `jumbo` - (Bool) MTU Jumbo option of the network.
- `jumbo` - (Bool) MTU Jumbo option of the network (for multi-zone locations only). `deprecated`
- `mtu` - (Bool) Maximum Transmission Unit option of the network.
- `access_config` - (String) The network communication configuration option of the network (for satellite locations only).
4 changes: 3 additions & 1 deletion website/docs/r/pi_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ Review the argument references that you can specify for your resource.
The `pi_ipaddress_range` block supports:
- `pi_ending_ip_address` - (Required, String) The ending ip address.
- `pi_starting_ip_address` - (Required, String) The staring ip address. **Note** if the `pi_gateway` or `pi_ipaddress_range` is not provided, it will calculate the value based on CIDR respectively.
- `pi_network_jumbo` - (Optional, Bool) MTU Jumbo option of the network.
- `pi_network_jumbo` - (Optional, Bool) MTU Jumbo option of the network (for multi-zone locations only). `deprecated` use `pi_network_mtu` instead.
- `pi_network_mtu` - (Optional, Integer) Maximum Transmission Unit option of the network, min size = 1450 & max size = 9000.
- `pi_network_access_config` - (Optional, String) The network communication configuration option of the network (for satellite locations only).

## Attribute reference

Expand Down