diff --git a/ibm/service/power/data_source_ibm_pi_catalog_images.go b/ibm/service/power/data_source_ibm_pi_catalog_images.go index eb505ac070..62adf75a8e 100644 --- a/ibm/service/power/data_source_ibm_pi_catalog_images.go +++ b/ibm/service/power/data_source_ibm_pi_catalog_images.go @@ -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 } } diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index f6dd4d2d9b..354cfe951b 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -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 @@ -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 diff --git a/ibm/service/power/data_source_ibm_pi_network.go b/ibm/service/power/data_source_ibm_pi_network.go index a080f5a022..3a04453ca7 100644 --- a/ibm/service/power/data_source_ibm_pi_network.go +++ b/ibm/service/power/data_source_ibm_pi_network.go @@ -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, @@ -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, + }, }, } } @@ -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 diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 113e5f9176..49e85d9aa5 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -75,10 +75,26 @@ func ResourceIBMPINetwork() *schema.Resource { Description: "PI network gateway", }, helpers.PINetworkJumbo: { - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "PI network enable MTU Jumbo option", + 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: { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validate.ValidateAllowedStringValues([]string{"internal-only", "outbound-only", "bidirectional-static-route", "bidirectional-bgp", "bidirectional-l2out"}), + Description: "PI network communication configuration", }, helpers.PICloudInstanceId: { Type: schema.TypeString, @@ -145,6 +161,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 @@ -216,6 +239,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 { diff --git a/ibm/service/power/resource_ibm_pi_network_port.go b/ibm/service/power/resource_ibm_pi_network_port.go index 703686eb0b..6b1ffb0cf7 100644 --- a/ibm/service/power/resource_ibm_pi_network_port.go +++ b/ibm/service/power/resource_ibm_pi_network_port.go @@ -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 diff --git a/ibm/service/power/resource_ibm_pi_network_test.go b/ibm/service/power/resource_ibm_pi_network_test.go index 517bf87118..249ce65615 100644 --- a/ibm/service/power/resource_ibm_pi_network_test.go +++ b/ibm/service/power/resource_ibm_pi_network_test.go @@ -88,6 +88,43 @@ func TestAccIBMPINetworkGatewaybasic(t *testing.T) { }, }) } + +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() @@ -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) +} diff --git a/website/docs/d/pi_network.html.markdown b/website/docs/d/pi_network.html.markdown index eea249a557..c4f03cb824 100644 --- a/website/docs/d/pi_network.html.markdown +++ b/website/docs/d/pi_network.html.markdown @@ -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). \ No newline at end of file diff --git a/website/docs/r/pi_network.html.markdown b/website/docs/r/pi_network.html.markdown index 23da3c3de9..4abefe7694 100644 --- a/website/docs/r/pi_network.html.markdown +++ b/website/docs/r/pi_network.html.markdown @@ -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