Skip to content

Commit

Permalink
Update storage connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptipowervs authored and michaelkad committed May 30, 2024
1 parent f19d2b8 commit eb03550
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 64 deletions.
12 changes: 1 addition & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.3

require (
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b
github.com/IBM-Cloud/power-go-client v1.6.0
github.com/IBM-Cloud/power-go-client v1.6.0-beta14
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down Expand Up @@ -77,7 +77,6 @@ require (
require (
cloud.google.com/go/kms v1.10.1 // indirect
cloud.google.com/go/monitoring v1.13.0 // indirect
github.com/Bowery/prompt v0.0.0-20190916142128-fa8279994f75 // indirect
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect
github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
Expand All @@ -96,7 +95,6 @@ require (
github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dchest/bcrypt_pbkdf v0.0.0-20150205184540-83f37f9c154a // indirect
github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/eapache/go-resiliency v1.4.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
Expand Down Expand Up @@ -129,7 +127,6 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -170,7 +167,6 @@ require (
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kardianos/govendor v1.0.9 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
Expand All @@ -182,8 +178,6 @@ require (
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/gox v1.0.1 // indirect
github.com/mitchellh/iochan v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/spdystream v0.2.0 // indirect
Expand Down Expand Up @@ -224,9 +218,6 @@ require (
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.16.1 // indirect
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect
golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
Expand All @@ -250,7 +241,6 @@ replace github.com/dgrijalva/jwt-go v3.2.0+incompatible => github.com/golang-jwt
// add sdk changes.
replace github.com/portworx/sched-ops v0.0.0-20200831185134-3e8010dc7056 => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by rook v1.7


exclude (
github.com/kubernetes-incubator/external-storage v0.20.4-openstorage-rc2
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
Expand Down
150 changes: 130 additions & 20 deletions go.sum

Large diffs are not rendered by default.

46 changes: 25 additions & 21 deletions ibm/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,37 +196,38 @@ var (
// For Power Colo

var (
Pi_auxiliary_volume_name string
Pi_cloud_instance_id string
Pi_dhcp_id string
Pi_image string
Pi_sap_image string
Pi_image_bucket_name string
Pi_image_bucket_file_name string
Pi_image_bucket_access_key string
Pi_image_bucket_secret_key string
Pi_image_bucket_file_name string
Pi_image_bucket_name string
Pi_image_bucket_region string
Pi_image_bucket_secret_key string
Pi_instance_name string
Pi_key_name string
Pi_volume_name string
Pi_volume_id string
Pi_network_name string
Pi_placement_group_name string
Pi_replication_volume_name string
Pi_volume_onboarding_source_crn string
Pi_auxiliary_volume_name string
Pi_volume_group_name string
Pi_resource_group_id string
Pi_sap_image string
Pi_shared_processor_pool_id string
Pi_snapshot_id string
Pi_spp_placement_group_id string
Pi_storage_connection string
Pi_target_storage_tier string
Pi_volume_clone_task_id string
Pi_volume_group_id string
Pi_volume_group_name string
Pi_volume_id string
Pi_volume_name string
Pi_volume_onboarding_id string
Pi_network_name string
Pi_cloud_instance_id string
Pi_snapshot_id string
Pi_instance_name string
Pi_dhcp_id string
Pi_volume_onboarding_source_crn string
PiCloudConnectionName string
PiSAPProfileID string
Pi_placement_group_name string
Pi_spp_placement_group_id string
PiStoragePool string
PiStorageType string
Pi_shared_processor_pool_id string
Pi_target_storage_tier string
Pi_volume_clone_task_id string
Pi_resource_group_id string
)

var (
Expand Down Expand Up @@ -1149,7 +1150,10 @@ func init() {
Pi_shared_processor_pool_id = "tf-pi-shared-processor-pool"
fmt.Println("[WARN] Set the environment variable PI_SHARED_PROCESSOR_POOL_ID for testing ibm_pi_shared_processor_pool resource else it is set to default value 'tf-pi-shared-processor-pool'")
}

Pi_storage_connection = os.Getenv("PI_STORAGE_CONNECTION")
if Pi_storage_connection == "" {
fmt.Println("[WARN] Set the environment variable PI_STORAGE_CONNECTION for testing pi_storage_connection resource else it is empty")
}
Pi_target_storage_tier = os.Getenv("PI_TARGET_STORAGE_TIER")
if Pi_target_storage_tier == "" {
Pi_target_storage_tier = "terraform-test-tier"
Expand Down
6 changes: 6 additions & 0 deletions ibm/service/power/data_source_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ func DataSourceIBMPIInstance() *schema.Resource {
Description: "The status of the instance.",
Type: schema.TypeString,
},
Attr_StorageConnection: {
Computed: true,
Description: "The storage connection type.",
Type: schema.TypeString,
},
Attr_StoragePool: {
Computed: true,
Description: "The storage Pool where server is deployed.",
Expand Down Expand Up @@ -250,6 +255,7 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
d.Set(Attr_SharedProcessorPool, powervmdata.SharedProcessorPool)
d.Set(Attr_SharedProcessorPoolID, powervmdata.SharedProcessorPoolID)
d.Set(Attr_Status, powervmdata.Status)
d.Set(Attr_StorageConnection, powervmdata.StorageConnection)
d.Set(Attr_StorageType, powervmdata.StorageType)
d.Set(Attr_StoragePool, powervmdata.StoragePool)
d.Set(Attr_StoragePoolAffinity, powervmdata.StoragePoolAffinity)
Expand Down
6 changes: 6 additions & 0 deletions ibm/service/power/data_source_ibm_pi_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func DataSourceIBMPIInstances() *schema.Resource {
Description: "The status of the instance.",
Type: schema.TypeString,
},
Attr_StorageConnection: {
Computed: true,
Description: "The storage connection type.",
Type: schema.TypeString,
},
Attr_StoragePool: {
Computed: true,
Description: "The storage Pool where server is deployed.",
Expand Down Expand Up @@ -241,6 +246,7 @@ func flattenPvmInstances(list []*models.PVMInstanceReference) []map[string]inter
Attr_SharedProcessorPool: i.SharedProcessorPool,
Attr_SharedProcessorPoolID: i.SharedProcessorPoolID,
Attr_Status: *i.Status,
Attr_StorageConnection: i.StorageConnection,
Attr_StoragePool: i.StoragePool,
Attr_StoragePoolAffinity: i.StoragePoolAffinity,
Attr_StorageType: i.StorageType,
Expand Down
12 changes: 11 additions & 1 deletion ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
Arg_IBMiPHA = "pi_ibmi_pha"
Arg_IBMiRDSUsers = "pi_ibmi_rds_users"
Arg_ImageName = "pi_image_name"
Arg_ImportDetails = "pi_image_import_details"
Arg_InstanceName = "pi_instance_name"
Arg_KeyName = "pi_key_name"
Arg_LanguageCode = "pi_language_code"
Expand Down Expand Up @@ -176,6 +177,7 @@ const (
Attr_LastUpdatedDate = "last_updated_date"
Attr_Leases = "leases"
Attr_LicenseRepositoryCapacity = "license_repository_capacity"
Attr_LicenseType = "license_type"
Attr_Location = "location"
Attr_MacAddress = "macaddress"
Attr_MasterChangedVolumeName = "master_changed_volume_name"
Expand Down Expand Up @@ -223,6 +225,7 @@ const (
Attr_PrimaryRole = "primary_role"
Attr_Processors = "processors"
Attr_ProcType = "proctype"
Attr_Product = "product"
Attr_ProfileID = "profile_id"
Attr_Profiles = "profiles"
Attr_Progress = "progress"
Expand Down Expand Up @@ -279,6 +282,7 @@ const (
Attr_Status = "status"
Attr_StatusDescriptionErrors = "status_description_errors"
Attr_StatusDetail = "status_detail"
Attr_StorageConnection = "storage_connection"
Attr_StoragePool = "storage_pool"
Attr_StoragePoolAffinity = "storage_pool_affinity"
Attr_StoragePoolsCapacity = "storage_pools_capacity"
Expand All @@ -305,6 +309,7 @@ const (
Attr_UsedIPPercent = "used_ip_percent"
Attr_UserIPAddress = "user_ip_address"
Attr_VCPUs = "vcpus"
Attr_Vendor = "vendor"
Attr_VirtualCoresAssigned = "virtual_cores_assigned"
Attr_VLanID = "vlan_id"
Attr_VolumeGroupName = "volume_group_name"
Expand All @@ -326,7 +331,9 @@ const (
Attr_WorkspaceStatus = "pi_workspace_status"
Attr_WorkspaceType = "pi_workspace_type"
Attr_WWN = "wwn"
OS_IBMI = "ibmi"

// OS Type
OS_IBMI = "ibmi"

// Affinty Values
Affinity = "affinity"
Expand Down Expand Up @@ -355,6 +362,9 @@ const (
State_Removed = "removed"
State_Retry = "retry"

// Allowed Values
MaxVolumeSupport = "maxVolumeSupport"
vSCSI = "vSCSI"
// Health
Health_OK = "OK"

Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func ResourceIBMPIInstance() *schema.Resource {
helpers.PIInstanceStorageConnection: {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.ValidateAllowedStringValues([]string{"vSCSI"}),
ValidateFunc: validate.ValidateAllowedStringValues([]string{vSCSI, MaxVolumeSupport}),
Description: "Storage Connectivity Group for server deployment",
},
PIInstanceStoragePoolAffinity: {
Expand Down
46 changes: 44 additions & 2 deletions ibm/service/power/resource_ibm_pi_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,31 @@ func testAccCheckIBMPIInstanceReplicantConfig(name string) string {
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_volume_name)
}

func testAccCheckIBMPIInstanceStorageConnectionConfig(name, instanceHealthStatus string) string {
return fmt.Sprintf(`
resource "ibm_pi_volume" "power_volume" {
pi_cloud_instance_id = "%[1]s"
pi_volume_size = 1
pi_volume_name = "%[2]s"
pi_volume_type = "tier3"
}
resource "ibm_pi_instance" "power_instance" {
pi_cloud_instance_id = "%[1]s"
pi_memory = "2"
pi_processors = "1"
pi_instance_name = "%[2]s"
pi_proc_type = "shared"
pi_image_id = "%[3]s"
pi_sys_type = "s922"
pi_network {
network_id = "%[4]s"
}
pi_storage_connection = "%[5]s"
pi_health_status = "%[6]s"
pi_volume_ids = [ibm_pi_volume.power_volume.volume_id]
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_storage_connection, instanceHealthStatus)
}
func testAccCheckIBMPIInstanceDestroy(s *terraform.State) error {
sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession()
if err != nil {
Expand Down Expand Up @@ -305,7 +329,25 @@ func TestAccIBMPIInstanceBasic(t *testing.T) {
},
})
}

func TestAccIBMPIInstanceStorageConnection(t *testing.T) {
instanceRes := "ibm_pi_instance.power_instance"
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPIInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIInstanceStorageConnectionConfig(name, helpers.PIInstanceHealthOk),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIInstanceExists(instanceRes),
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
resource.TestCheckResourceAttr(instanceRes, "pi_storage_connection", acc.Pi_storage_connection),
),
},
},
})
}
func TestAccIBMPIInstanceDeploymentType(t *testing.T) {
instanceRes := "ibm_pi_instance.power_instance"
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/power/resource_ibm_pi_shared_processor_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func resourceIBMPISharedProcessorPoolUpdate(ctx context.Context, d *schema.Resou
}
if d.HasChange(Arg_SharedProcessorPoolReservedCores) {
reservedCores := int64(d.Get(Arg_SharedProcessorPoolReservedCores).(int))
body.ReservedCores = reservedCores
body.ReservedCores = &reservedCores
}

_, err = client.Update(sppID, body)
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ In addition to all argument reference list, you can access the following attribu
- `shared_processor_pool`- (String) The name of the shared processor pool for the instance.
- `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance.
- `status` - (String) The status of the instance.
- `storage_connection` - (String) The storage connection type for the instance.
- `storage_pool` - (String) The storage Pool where server is deployed.
- `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool.
- `storage_type` - (String) The storage type where server is deployed.
Expand Down
13 changes: 7 additions & 6 deletions website/docs/d/pi_instances.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ In addition to all argument reference list, you can access the following attribu
- `networks` - (List) List of networks associated with this instance.

Nested scheme for `networks`:
- `external_ip` - (String) The external IP address of the instance.
- `ip` - (String) The IP address of the instance.
- `macaddress` - (String) The MAC address of the instance.
- `network_id` - (String) The network ID of the instance.
- `network_name` - (String) The network name of the instance.
- `type` - (String) The type of the network.
- `external_ip` - (String) The external IP address of the instance.
- `ip` - (String) The IP address of the instance.
- `macaddress` - (String) The MAC address of the instance.
- `network_id` - (String) The network ID of the instance.
- `network_name` - (String) The network name of the instance.
- `type` - (String) The type of the network.

- `pin_policy` - (String) The pinning policy of the instance.
- `placement_group_id`- (String) The ID of the placement group that the instance is a member.
Expand All @@ -83,6 +83,7 @@ In addition to all argument reference list, you can access the following attribu
- `shared_processor_pool`- (String) The name of the shared processor pool for the instance.
- `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance.
- `status` - (String) The status of the instance.
- `storage_connection` - (String) The storage connection type for the instance
- `storage_pool` - (String) The storage Pool where server is deployed.
- `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool.
- `storage_type` - (String) The storage type where server is deployed.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Review the argument references that you can specify for your resource.
- `pi_storage_pool` - (Optional, String) Storage Pool for server deployment; if provided then `pi_affinity_policy` will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage pool for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage pool the image was created in.
- `pi_storage_pool_affinity` - (Optional, Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `pi_volume_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool.
- `pi_storage_type` - (Optional, String) - Storage type for server deployment; If storage type is not provided the storage type will default to `tier3`.
- `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Only supported value is `vSCSI`.
- `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Supported values are `vSCSI`, `maxVolumeSupport`.
- `pi_sys_type` - (Optional, String) The type of system on which to create the VM (s922/e880/e980/s1022).
- Supported SAP system types are (e880/e980).
- `pi_user_data` - (Optional, String) The user data `cloud-init` to pass to the instance during creation. It can be a base64 encoded or an unencoded string. If it is an unencoded string, the provider will encode it before it passing it down.
Expand Down

0 comments on commit eb03550

Please sign in to comment.