From 4856fa63b7fb14e4cf88b16a983d3cbc9f54978d Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Wed, 6 Nov 2024 15:33:17 -0600 Subject: [PATCH] Refactor shared-processor-pool resource --- ibm/service/power/ibm_pi_constants.go | 673 ++++++++---------- .../resource_ibm_pi_shared_processor_pool.go | 314 ++++---- ...ource_ibm_pi_shared_processor_pool_test.go | 15 +- .../r/pi_shared_processor_pool.html.markdown | 74 +- 4 files changed, 520 insertions(+), 556 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index aac2683c62..77ae403ce0 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -64,9 +64,6 @@ const ( Arg_Processors = "pi_processors" Arg_ProcType = "pi_proc_type" Arg_Protocol = "pi_protocol" - Arg_PVMInstanceActionType = "pi_action" - Arg_PVMInstanceHealthStatus = "pi_health_status" - Arg_PVMInstanceId = "pi_instance_id" Arg_Remote = "pi_remote" Arg_Remove = "pi_remove" Arg_Replicants = "pi_replicants" @@ -84,6 +81,7 @@ const ( Arg_SharedProcessorPoolID = "pi_shared_processor_pool_id" Arg_SharedProcessorPoolName = "pi_shared_processor_pool_name" Arg_SharedProcessorPoolPlacementGroupID = "pi_shared_processor_pool_placement_group_id" + Arg_SharedProcessorPoolPlacementGroups = "pi_shared_processor_pool_placement_groups" Arg_SharedProcessorPoolReservedCores = "pi_shared_processor_pool_reserved_cores" Arg_SnapshotID = "pi_snapshot_id" Arg_SnapShotName = "pi_snap_shot_name" @@ -119,340 +117,316 @@ const ( Arg_VolumeType = "pi_volume_type" Arg_VTL = "vtl" - // Duplicate Arguments, will be removed as refactoring take course. - PIVolumeGroupID = "pi_volume_group_id" - PIVolumeOnboardingID = "pi_volume_onboarding_id" - // Attributes - Attr_Access = "access" - Attr_AccessConfig = "access_config" - Attr_Action = "action" - Attr_Addresses = "addresses" - Attr_AllocatedCores = "allocated_cores" - Attr_Architecture = "architecture" - Attr_AsynchronousReplication = "asynchronous_replication" - Attr_Auxiliary = "auxiliary" - Attr_AuxiliaryChangedVolumeName = "auxiliary_changed_volume_name" - Attr_AuxiliaryVolumeName = "auxiliary_volume_name" - Attr_AvailabilityZone = "availability_zone" - Attr_AvailableCores = "available_cores" - Attr_AvailableHosts = "available_hosts" - Attr_AvailableIPCount = "available_ip_count" - Attr_AvailableMemory = "available_memory" - Attr_Bootable = "bootable" - Attr_BootVolumeID = "boot_volume_id" - Attr_Capabilities = "capabilities" - Attr_CapabilityDetails = "capability_details" - Attr_Capacity = "capacity" - Attr_Certified = "certified" - Attr_CIDR = "cidr" - Attr_ClassicEnabled = "classic_enabled" - Attr_ClonedVolumes = "clone_volumes" - Attr_CloneVolumeID = "clone_volume_id" - Attr_CloudConnectionID = "cloud_connection_id" - Attr_CloudInstanceID = "cloud_instance_id" - Attr_CloudInstances = "cloud_instances" - Attr_Code = "code" - Attr_ConnectionMode = "connection_mode" - Attr_Connections = "connections" - Attr_ConsistencyGroupName = "consistency_group_name" - Attr_ConsoleLanguages = "console_languages" - Attr_ContainerFormat = "container_format" - Attr_CopyRate = "copy_rate" - Attr_CopyType = "copy_type" - Attr_CoreMemoryRatio = "core_memory_ratio" - Attr_Cores = "cores" - Attr_Count = "count" - Attr_CPUs = "cpus" - Attr_Created = "created" - Attr_CreateTime = "create_time" - Attr_CreationDate = "creation_date" - Attr_CRN = "crn" - Attr_CyclePeriodSeconds = "cycle_period_seconds" - Attr_CyclingMode = "cycling_mode" - Attr_DatacenterCapabilities = "pi_datacenter_capabilities" - Attr_DatacenterHref = "pi_datacenter_href" - Attr_DatacenterLocation = "pi_datacenter_location" - Attr_Datacenters = "datacenters" - Attr_DatacenterStatus = "pi_datacenter_status" - Attr_DatacenterType = "pi_datacenter_type" - Attr_Dedicated = "dedicated" - Attr_Default = "default" - Attr_DeleteOnTermination = "delete_on_termination" - Attr_DeploymentType = "deployment_type" - Attr_Description = "description" - Attr_DestinationPort = "destination_port" - Attr_Details = "details" - Attr_DhcpID = "dhcp_id" - Attr_DhcpManaged = "dhcp_managed" - Attr_Direction = "direction" - Attr_DisasterRecovery = "disaster_recovery" - Attr_DisasterRecoveryLocations = "disaster_recovery_locations" - Attr_DiskFormat = "disk_format" - Attr_DiskType = "disk_type" - Attr_DisplayName = "display_name" - Attr_DNS = "dns" - Attr_Enabled = "enabled" - Attr_Endianness = "endianness" - Attr_ExternalIP = "external_ip" - Attr_FailureMessage = "failure_message" - Attr_FailureReason = "failure_reason" - Attr_Fault = "fault" - Attr_Flag = "flag" - Attr_FlashCopyMappings = "flash_copy_mappings" - Attr_FlashCopyName = "flash_copy_name" - Attr_FreezeTime = "freeze_time" - Attr_FullSystemProfile = "full_system_profile" - Attr_Gateway = "gateway" - Attr_General = "general" - Attr_GlobalRouting = "global_routing" - Attr_GreDestinationAddress = "gre_destination_address" - Attr_GreSourceAddress = "gre_source_address" - Attr_GroupID = "group_id" - Attr_HealthStatus = "health_status" - Attr_HostGroup = "host_group" - Attr_HostGroupID = "host_group_id" - Attr_HostGroups = "host_groups" - Attr_HostID = "host_id" - Attr_Hosts = "hosts" - Attr_Href = "href" - Attr_Hypervisor = "hypervisor" - Attr_HypervisorType = "hypervisor_type" - Attr_IBMiCSS = "ibmi_css" - Attr_IBMIPAddress = "ibm_ip_address" - Attr_IBMiPHA = "ibmi_pha" - Attr_IBMiRDS = "ibmi_rds" - Attr_IBMiRDSUsers = "ibmi_rds_users" - Attr_ICMPType = "icmp_type" - Attr_ID = "id" - Attr_ImageID = "image_id" - Attr_ImageInfo = "image_info" - Attr_Images = "images" - Attr_ImageType = "image_type" - Attr_InputVolumes = "input_volumes" - Attr_Instance = "instance" - Attr_InstanceID = "instance_id" - Attr_InstanceIP = "instance_ip" - Attr_InstanceMac = "instance_mac" - Attr_Instances = "instances" - Attr_InstanceSnapshots = "instance_snapshots" - Attr_InstanceVolumes = "instance_volumes" - Attr_Interfaces = "interfaces" - Attr_IOThrottleRate = "io_throttle_rate" - Attr_IP = "ip" - Attr_IPAddress = "ip_address" - Attr_IPaddress = "ipaddress" - Attr_IPOctet = "ipoctet" - Attr_IsActive = "is_active" - Attr_Jumbo = "jumbo" - Attr_Key = "key" - Attr_KeyCreationDate = "creation_date" - Attr_KeyID = "key_id" - Attr_Keys = "keys" - Attr_Language = "language" - Attr_LastUpdateDate = "last_update_date" - Attr_LastUpdatedDate = "last_updated_date" - Attr_Leases = "leases" - Attr_LicenseRepositoryCapacity = "license_repository_capacity" - Attr_LicenseType = "license_type" - Attr_Location = "location" - Attr_MacAddress = "mac_address" - Attr_Macaddress = "macaddress" - Attr_MasterChangedVolumeName = "master_changed_volume_name" - Attr_MasterVolumeName = "master_volume_name" - Attr_Max = "max" - Attr_MaxAllocationSize = "max_allocation_size" - Attr_MaxAvailable = "max_available" - Attr_MaxCoresAvailable = "max_cores_available" - Attr_Maximum = "maximum" - Attr_MaximumStorageAllocation = "max_storage_allocation" - Attr_MaxMem = "maxmem" - Attr_MaxMemory = "max_memory" - Attr_MaxMemoryAvailable = "max_memory_available" - Attr_MaxProc = "maxproc" - Attr_MaxProcessors = "max_processors" - Attr_MaxVirtualCores = "max_virtual_cores" - Attr_Members = "members" - Attr_Memory = "memory" - Attr_Message = "message" - Attr_Metered = "metered" - Attr_MigrationStatus = "migration_status" - Attr_Min = "min" - Attr_Minimum = "minimum" - Attr_MinMem = "minmem" - Attr_MinMemory = "min_memory" - Attr_MinProc = "minproc" - Attr_MinProcessors = "min_processors" - Attr_MinVirtualCores = "min_virtual_cores" - Attr_MirroringState = "mirroring_state" - Attr_MTU = "mtu" - Attr_Name = "name" - Attr_NetworkAddressGroupID = "network_address_group_id" - Attr_NetworkAddressGroupMemberID = "network_address_group_member_id" - Attr_NetworkAddressGroups = "network_address_groups" - Attr_NetworkID = "network_id" - Attr_NetworkInterfaceID = "network_interface_id" - Attr_NetworkName = "network_name" - Attr_NetworkPorts = "network_ports" - Attr_Networks = "networks" - Attr_NetworkSecurityGroupID = "network_security_group_id" - Attr_NetworkSecurityGroupMemberID = "network_security_group_member_id" - Attr_NetworkSecurityGroups = "network_security_groups" - Attr_NumberOfVolumes = "number_of_volumes" - Attr_Onboardings = "onboardings" - Attr_OperatingSystem = "operating_system" - Attr_OSType = "os_type" - Attr_PercentComplete = "percent_complete" - Attr_PinPolicy = "pin_policy" - Attr_PlacementGroupID = "placement_group_id" - Attr_PlacementGroups = "placement_groups" - Attr_Policy = "policy" - Attr_Pool = "pool" - Attr_PoolName = "pool_name" - Attr_Port = "port" - Attr_PortID = "portid" - Attr_PowerEdgeRouter = "power_edge_router" - Attr_Primary = "primary" - Attr_PrimaryRole = "primary_role" - Attr_Processors = "processors" - Attr_ProcType = "proctype" - Attr_Product = "product" - Attr_ProfileID = "profile_id" - Attr_Profiles = "profiles" - Attr_Progress = "progress" - Attr_Protocol = "protocol" - Attr_PublicIP = "public_ip" - Attr_PVMInstanceID = "pvm_instance_id" - Attr_PVMInstances = "pvm_instances" - Attr_PVMSnapshots = "pvm_snapshots" - Attr_Region = "region" - Attr_RegionStorageTiers = "region_storage_tiers" - Attr_Remote = "remote" - Attr_RemoteCopyID = "remote_copy_id" - Attr_RemoteCopyRelationshipNames = "remote_copy_relationship_names" - Attr_RemoteCopyRelationships = "remote_copy_relationships" - Attr_RemotePool = "remote_pool" - Attr_ReplicationEnabled = "replication_enabled" - Attr_ReplicationPoolMap = "replication_pool_map" - Attr_ReplicationServices = "replication_services" - Attr_ReplicationSites = "replication_sites" - Attr_ReplicationStatus = "replication_status" - Attr_ReplicationType = "replication_type" - Attr_ReservedCore = "reserved_core" - Attr_ReservedCores = "reserved_cores" - Attr_ReservedMemory = "reserved_memory" - Attr_ResultsOnboardedVolumes = "results_onboarded_volumes" - Attr_ResultsVolumeOnboardingFailures = "results_volume_onboarding_failures" - Attr_Rules = "rules" - Attr_SAPS = "saps" - Attr_Secondaries = "secondaries" - Attr_ServerName = "server_name" - Attr_Servers = "servers" - Attr_Shareable = "shreable" - Attr_SharedCoreRatio = "shared_core_ratio" - Attr_SharedProcessorPool = "shared_processor_pool" - Attr_SharedProcessorPoolAllocatedCores = "allocated_cores" - Attr_SharedProcessorPoolAvailableCores = "available_cores" - Attr_SharedProcessorPoolHostID = "host_id" - Attr_SharedProcessorPoolID = "shared_processor_pool_id" - Attr_SharedProcessorPoolInstanceAvailabilityZone = "availability_zone" - Attr_SharedProcessorPoolInstanceCpus = "cpus" - Attr_SharedProcessorPoolInstanceId = "id" - Attr_SharedProcessorPoolInstanceMemory = "memory" - Attr_SharedProcessorPoolInstanceName = "name" - Attr_SharedProcessorPoolInstances = "instances" - Attr_SharedProcessorPoolInstanceUncapped = "uncapped" - Attr_SharedProcessorPoolInstanceVcpus = "vcpus" - Attr_SharedProcessorPoolName = "name" - Attr_SharedProcessorPoolPlacementGroups = "spp_placement_groups" - Attr_SharedProcessorPoolReservedCores = "reserved_cores" - Attr_SharedProcessorPools = "shared_processor_pools" - Attr_SharedProcessorPoolStatusDetail = "status_detail" - Attr_Size = "size" - Attr_SnapshotID = "snapshot_id" - Attr_SourceChecksum = "source_checksum" - Attr_SourcePort = "source_port" - Attr_SourceVolumeID = "source_volume_id" - Attr_SourceVolumeName = "source_volume_name" - Attr_Speed = "speed" - Attr_SPPPlacementGroupID = "spp_placement_group_id" - Attr_SPPPlacementGroupMembers = "members" - Attr_SPPPlacementGroupName = "name" - Attr_SPPPlacementGroupPolicy = "policy" - Attr_SPPPlacementGroups = "spp_placement_groups" - Attr_SSHKey = "ssh_key" - Attr_StartTime = "start_time" - Attr_State = "state" - 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" - Attr_StorageType = "storage_type" - Attr_StorageTypesCapacity = "storage_types_capacity" - Attr_SupportedSystems = "supported_systems" - Attr_Synchronized = "synchronized" - Attr_SynchronousReplication = "synchronous_replication" - Attr_SystemPoolName = "system_pool_name" - Attr_SystemPools = "system_pools" - Attr_Systems = "systems" - Attr_SysType = "sys_type" - Attr_Systype = "systype" - Attr_Target = "target" - Attr_TargetLocations = "target_locations" - Attr_TargetVolumeName = "target_volume_name" - Attr_TaskID = "task_id" - Attr_TCPFlags = "tcp_flags" - Attr_TenantID = "tenant_id" - Attr_TenantName = "tenant_name" - Attr_TotalCapacity = "total_capacity" - Attr_TotalCore = "total_core" - Attr_TotalInstances = "total_instances" - Attr_TotalMemory = "total_memory" - Attr_TotalMemoryConsumed = "total_memory_consumed" - Attr_TotalProcessorsConsumed = "total_processors_consumed" - Attr_TotalSSDStorageConsumed = "total_ssd_storage_consumed" - Attr_TotalStandardStorageConsumed = "total_standard_storage_consumed" - Attr_Type = "type" - Attr_Uncapped = "uncapped" - Attr_UpdatedDate = "updated_date" - Attr_URL = "url" - Attr_UsedCore = "used_core" - Attr_UsedIPCount = "used_ip_count" - Attr_UsedIPPercent = "used_ip_percent" - Attr_UsedMemory = "used_memory" - Attr_UserIPAddress = "user_ip_address" - Attr_UserTags = "user_tags" - Attr_VCPUs = "vcpus" - Attr_Vendor = "vendor" - Attr_VirtualCoresAssigned = "virtual_cores_assigned" - Attr_VLanID = "vlan_id" - Attr_VolumeGroupID = "volume_group_id" - Attr_VolumeGroupName = "volume_group_name" - Attr_VolumeGroups = "volume_groups" - Attr_VolumeGroupStatus = "volume_group_status" - Attr_VolumeID = "volume_id" - Attr_VolumeIDs = "volume_ids" - Attr_VolumePool = "volume_pool" - Attr_Volumes = "volumes" - Attr_VolumeSnapshots = "volume_snapshots" - Attr_VolumesSnapshots = "volume_snapshots" - Attr_VolumeStatus = "volume_status" - Attr_VPCCRNs = "vpc_crns" - Attr_VPCEnabled = "vpc_enabled" - Attr_WorkloadType = "workload_type" - Attr_Workspace = "workspace" - Attr_WorkspaceCapabilities = "pi_workspace_capabilities" - Attr_WorkspaceDetails = "pi_workspace_details" - Attr_WorkspaceID = "pi_workspace_id" - Attr_WorkspaceLocation = "pi_workspace_location" - Attr_WorkspaceName = "pi_workspace_name" - Attr_Workspaces = "workspaces" - Attr_WorkspaceStatus = "pi_workspace_status" - Attr_WorkspaceType = "pi_workspace_type" - Attr_WWN = "wwn" + Attr_Access = "access" + Attr_AccessConfig = "access_config" + Attr_Action = "action" + Attr_AllocatedCores = "allocated_cores" + Attr_Architecture = "architecture" + Attr_AsynchronousReplication = "asynchronous_replication" + Attr_Auxiliary = "auxiliary" + Attr_AuxiliaryChangedVolumeName = "auxiliary_changed_volume_name" + Attr_AuxiliaryVolumeName = "auxiliary_volume_name" + Attr_AvailabilityZone = "availability_zone" + Attr_AvailableCores = "available_cores" + Attr_AvailableHosts = "available_hosts" + Attr_AvailableIPCount = "available_ip_count" + Attr_AvailableMemory = "available_memory" + Attr_Bootable = "bootable" + Attr_BootVolumeID = "boot_volume_id" + Attr_Capabilities = "capabilities" + Attr_CapabilityDetails = "capability_details" + Attr_Capacity = "capacity" + Attr_Certified = "certified" + Attr_CIDR = "cidr" + Attr_ClassicEnabled = "classic_enabled" + Attr_ClonedVolumes = "clone_volumes" + Attr_CloneVolumeID = "clone_volume_id" + Attr_CloudConnectionID = "cloud_connection_id" + Attr_CloudInstanceID = "cloud_instance_id" + Attr_CloudInstances = "cloud_instances" + Attr_Code = "code" + Attr_ConnectionMode = "connection_mode" + Attr_Connections = "connections" + Attr_ConsistencyGroupName = "consistency_group_name" + Attr_ConsoleLanguages = "console_languages" + Attr_ContainerFormat = "container_format" + Attr_CopyRate = "copy_rate" + Attr_CopyType = "copy_type" + Attr_CoreMemoryRatio = "core_memory_ratio" + Attr_Cores = "cores" + Attr_Count = "count" + Attr_CPUs = "cpus" + Attr_Created = "created" + Attr_CreateTime = "create_time" + Attr_CreationDate = "creation_date" + Attr_CRN = "crn" + Attr_CyclePeriodSeconds = "cycle_period_seconds" + Attr_CyclingMode = "cycling_mode" + Attr_DatacenterCapabilities = "pi_datacenter_capabilities" + Attr_DatacenterHref = "pi_datacenter_href" + Attr_DatacenterLocation = "pi_datacenter_location" + Attr_Datacenters = "datacenters" + Attr_DatacenterStatus = "pi_datacenter_status" + Attr_DatacenterType = "pi_datacenter_type" + Attr_Dedicated = "dedicated" + Attr_Default = "default" + Attr_DeleteOnTermination = "delete_on_termination" + Attr_DeploymentType = "deployment_type" + Attr_Description = "description" + Attr_DestinationPort = "destination_port" + Attr_Details = "details" + Attr_DhcpID = "dhcp_id" + Attr_DhcpManaged = "dhcp_managed" + Attr_DisasterRecovery = "disaster_recovery" + Attr_DisasterRecoveryLocations = "disaster_recovery_locations" + Attr_DiskFormat = "disk_format" + Attr_DiskType = "disk_type" + Attr_DisplayName = "display_name" + Attr_DNS = "dns" + Attr_Enabled = "enabled" + Attr_Endianness = "endianness" + Attr_ExternalIP = "external_ip" + Attr_FailureMessage = "failure_message" + Attr_FailureReason = "failure_reason" + Attr_Fault = "fault" + Attr_Flag = "flag" + Attr_FlashCopyMappings = "flash_copy_mappings" + Attr_FlashCopyName = "flash_copy_name" + Attr_FreezeTime = "freeze_time" + Attr_FullSystemProfile = "full_system_profile" + Attr_Gateway = "gateway" + Attr_General = "general" + Attr_GlobalRouting = "global_routing" + Attr_GreDestinationAddress = "gre_destination_address" + Attr_GreSourceAddress = "gre_source_address" + Attr_GroupID = "group_id" + Attr_HealthStatus = "health_status" + Attr_HostGroup = "host_group" + Attr_HostGroupID = "host_group_id" + Attr_HostGroups = "host_groups" + Attr_HostID = "host_id" + Attr_Hosts = "hosts" + Attr_Href = "href" + Attr_Hypervisor = "hypervisor" + Attr_HypervisorType = "hypervisor_type" + Attr_IBMiCSS = "ibmi_css" + Attr_IBMIPAddress = "ibm_ip_address" + Attr_IBMiPHA = "ibmi_pha" + Attr_IBMiRDS = "ibmi_rds" + Attr_IBMiRDSUsers = "ibmi_rds_users" + Attr_ICMPType = "icmp_type" + Attr_ID = "id" + Attr_ImageID = "image_id" + Attr_ImageInfo = "image_info" + Attr_Images = "images" + Attr_ImageType = "image_type" + Attr_InputVolumes = "input_volumes" + Attr_Instance = "instance" + Attr_InstanceID = "instance_id" + Attr_InstanceIP = "instance_ip" + Attr_InstanceMac = "instance_mac" + Attr_Instances = "instances" + Attr_InstanceSnapshots = "instance_snapshots" + Attr_InstanceVolumes = "instance_volumes" + Attr_Interfaces = "interfaces" + Attr_IOThrottleRate = "io_throttle_rate" + Attr_IP = "ip" + Attr_IPAddress = "ip_address" + Attr_IPaddress = "ipaddress" + Attr_IPOctet = "ipoctet" + Attr_IsActive = "is_active" + Attr_Jumbo = "jumbo" + Attr_Key = "key" + Attr_Keys = "keys" + Attr_Language = "language" + Attr_LastUpdateDate = "last_update_date" + Attr_LastUpdatedDate = "last_updated_date" + Attr_Leases = "leases" + Attr_LicenseRepositoryCapacity = "license_repository_capacity" + Attr_LicenseType = "license_type" + Attr_Location = "location" + Attr_MacAddress = "mac_address" + Attr_Macaddress = "macaddress" + Attr_MasterChangedVolumeName = "master_changed_volume_name" + Attr_MasterVolumeName = "master_volume_name" + Attr_Max = "max" + Attr_MaxAllocationSize = "max_allocation_size" + Attr_MaxAvailable = "max_available" + Attr_MaxCoresAvailable = "max_cores_available" + Attr_Maximum = "maximum" + Attr_MaximumStorageAllocation = "max_storage_allocation" + Attr_MaxMem = "maxmem" + Attr_MaxMemory = "max_memory" + Attr_MaxMemoryAvailable = "max_memory_available" + Attr_MaxProc = "maxproc" + Attr_MaxProcessors = "max_processors" + Attr_MaxVirtualCores = "max_virtual_cores" + Attr_Members = "members" + Attr_Memory = "memory" + Attr_Message = "message" + Attr_Metered = "metered" + Attr_MigrationStatus = "migration_status" + Attr_Min = "min" + Attr_Minimum = "minimum" + Attr_MinMem = "minmem" + Attr_MinMemory = "min_memory" + Attr_MinProc = "minproc" + Attr_MinProcessors = "min_processors" + Attr_MinVirtualCores = "min_virtual_cores" + Attr_MirroringState = "mirroring_state" + Attr_MTU = "mtu" + Attr_Name = "name" + Attr_NetworkAddressGroupID = "network_address_group_id" + Attr_NetworkAddressGroups = "network_address_groups" + Attr_NetworkID = "network_id" + Attr_NetworkInterfaceID = "network_interface_id" + Attr_NetworkName = "network_name" + Attr_NetworkPorts = "network_ports" + Attr_Networks = "networks" + Attr_NetworkSecurityGroupID = "network_security_group_id" + Attr_NetworkSecurityGroupMemberID = "network_security_group_member_id" + Attr_NetworkSecurityGroups = "network_security_groups" + Attr_NumberOfVolumes = "number_of_volumes" + Attr_Onboardings = "onboardings" + Attr_OperatingSystem = "operating_system" + Attr_OSType = "os_type" + Attr_PercentComplete = "percent_complete" + Attr_PinPolicy = "pin_policy" + Attr_PlacementGroupID = "placement_group_id" + Attr_PlacementGroups = "placement_groups" + Attr_Policy = "policy" + Attr_Pool = "pool" + Attr_PoolName = "pool_name" + Attr_Port = "port" + Attr_PortID = "portid" + Attr_PowerEdgeRouter = "power_edge_router" + Attr_Primary = "primary" + Attr_PrimaryRole = "primary_role" + Attr_Processors = "processors" + Attr_ProcType = "proctype" + Attr_Product = "product" + Attr_ProfileID = "profile_id" + Attr_Profiles = "profiles" + Attr_Progress = "progress" + Attr_Protocol = "protocol" + Attr_PublicIP = "public_ip" + Attr_PVMInstanceID = "pvm_instance_id" + Attr_PVMInstances = "pvm_instances" + Attr_PVMSnapshots = "pvm_snapshots" + Attr_Region = "region" + Attr_RegionStorageTiers = "region_storage_tiers" + Attr_Remote = "remote" + Attr_RemoteCopyID = "remote_copy_id" + Attr_RemoteCopyRelationshipNames = "remote_copy_relationship_names" + Attr_RemoteCopyRelationships = "remote_copy_relationships" + Attr_RemotePool = "remote_pool" + Attr_ReplicationEnabled = "replication_enabled" + Attr_ReplicationPoolMap = "replication_pool_map" + Attr_ReplicationSites = "replication_sites" + Attr_ReplicationStatus = "replication_status" + Attr_ReplicationType = "replication_type" + Attr_ReservedCore = "reserved_core" + Attr_ReservedCores = "reserved_cores" + Attr_ReservedMemory = "reserved_memory" + Attr_ResultsOnboardedVolumes = "results_onboarded_volumes" + Attr_ResultsVolumeOnboardingFailures = "results_volume_onboarding_failures" + Attr_Rules = "rules" + Attr_SAPS = "saps" + Attr_Secondaries = "secondaries" + Attr_ServerName = "server_name" + Attr_Servers = "servers" + Attr_Shareable = "shreable" + Attr_SharedCoreRatio = "shared_core_ratio" + Attr_SharedProcessorPool = "shared_processor_pool" + Attr_SharedProcessorPoolID = "shared_processor_pool_id" + Attr_SharedProcessorPoolPlacementGroups = "spp_placement_groups" + Attr_SharedProcessorPools = "shared_processor_pools" + Attr_Size = "size" + Attr_SnapshotID = "snapshot_id" + Attr_SourceChecksum = "source_checksum" + Attr_SourcePort = "source_port" + Attr_SourceVolumeID = "source_volume_id" + Attr_SourceVolumeName = "source_volume_name" + Attr_Speed = "speed" + Attr_SPPPlacementGroupID = "spp_placement_group_id" + Attr_SPPPlacementGroupMembers = "members" + Attr_SPPPlacementGroupName = "name" + Attr_SPPPlacementGroupPolicy = "policy" + Attr_SPPPlacementGroups = "spp_placement_groups" + Attr_SSHKey = "ssh_key" + Attr_StartTime = "start_time" + Attr_State = "state" + 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" + Attr_StorageType = "storage_type" + Attr_StorageTypesCapacity = "storage_types_capacity" + Attr_SupportedSystems = "supported_systems" + Attr_Synchronized = "synchronized" + Attr_SynchronousReplication = "synchronous_replication" + Attr_SystemPoolName = "system_pool_name" + Attr_SystemPools = "system_pools" + Attr_Systems = "systems" + Attr_SysType = "sys_type" + Attr_Systype = "systype" + Attr_Target = "target" + Attr_TargetLocations = "target_locations" + Attr_TargetVolumeName = "target_volume_name" + Attr_TaskID = "task_id" + Attr_TCPFlags = "tcp_flags" + Attr_TenantID = "tenant_id" + Attr_TenantName = "tenant_name" + Attr_TotalCapacity = "total_capacity" + Attr_TotalCore = "total_core" + Attr_TotalInstances = "total_instances" + Attr_TotalMemory = "total_memory" + Attr_TotalMemoryConsumed = "total_memory_consumed" + Attr_TotalProcessorsConsumed = "total_processors_consumed" + Attr_TotalSSDStorageConsumed = "total_ssd_storage_consumed" + Attr_TotalStandardStorageConsumed = "total_standard_storage_consumed" + Attr_Type = "type" + Attr_Uncapped = "uncapped" + Attr_UpdatedDate = "updated_date" + Attr_URL = "url" + Attr_UsedCore = "used_core" + Attr_UsedIPCount = "used_ip_count" + Attr_UsedIPPercent = "used_ip_percent" + Attr_UsedMemory = "used_memory" + Attr_UserIPAddress = "user_ip_address" + Attr_UserTags = "user_tags" + Attr_VCPUs = "vcpus" + Attr_Vendor = "vendor" + Attr_VirtualCoresAssigned = "virtual_cores_assigned" + Attr_VLanID = "vlan_id" + Attr_VolumeGroupID = "volume_group_id" + Attr_VolumeGroupName = "volume_group_name" + Attr_VolumeGroups = "volume_groups" + Attr_VolumeGroupStatus = "volume_group_status" + Attr_VolumeID = "volume_id" + Attr_VolumeIDs = "volume_ids" + Attr_VolumePool = "volume_pool" + Attr_Volumes = "volumes" + Attr_VolumeSnapshots = "volume_snapshots" + Attr_VolumesSnapshots = "volume_snapshots" + Attr_VolumeStatus = "volume_status" + Attr_VPCCRNs = "vpc_crns" + Attr_VPCEnabled = "vpc_enabled" + Attr_WorkloadType = "workload_type" + Attr_Workspace = "workspace" + Attr_WorkspaceCapabilities = "pi_workspace_capabilities" + Attr_WorkspaceDetails = "pi_workspace_details" + Attr_WorkspaceID = "pi_workspace_id" + Attr_WorkspaceLocation = "pi_workspace_location" + Attr_WorkspaceName = "pi_workspace_name" + Attr_Workspaces = "workspaces" + Attr_WorkspaceStatus = "pi_workspace_status" + Attr_WorkspaceType = "pi_workspace_type" + Attr_WWN = "wwn" // Duplicate Attributes, will be removed as refactoring take course. PICloudConnectionClassicGreSource = "gre_source_address" @@ -461,9 +435,6 @@ const ( PICloudConnectionId = "cloud_connection_id" PICloudConnectionPort = "port" PICloudConnectionUserIPAddress = "user_ip_address" - PIDRLocation = "location" - PIPlacementGroupID = "placement_group_id" - PIPlacementGroupMembers = "members" PIVPNConnectionDeadPeerDetectionAction = "action" // OS Type @@ -568,11 +539,6 @@ const ( State_Up = "up" State_Updating = "updating" State_VerifyResize = "verify_resize" - Status_Active = "ACTIVE" - Status_Deleting = "deleting" - Status_Error = "ERROR" - Status_Pending = "PENDING" - Status_Shutoff = "SHUTOFF" // Timeout values Timeout_Active = 2 * time.Minute @@ -581,18 +547,9 @@ const ( // TODO: Second Half Cleanup, remove extra variables - PIConsoleLanguageCode = "pi_language_code" - PIInstanceMigratable = "pi_migratable" - - // Volume Clone - PIVolumeCloneName = "pi_volume_clone_name" - PIVolumeCloneTaskID = "pi_volume_clone_task_id" - PITargetStorageTier = "pi_target_storage_tier" - // IBM PI Volume Group - PIVolumeGroupName = "pi_volume_group_name" - PIVolumeGroupConsistencyGroupName = "pi_consistency_group_name" - PIVolumeGroupAction = "pi_volume_group_action" + PIVolumeGroupAction = "pi_volume_group_action" + PIVolumeGroupID = "pi_volume_group_id" // VPN PIVPNConnectionId = "connection_id" @@ -605,10 +562,4 @@ const ( // Cloud Connections PICloudConnectionTransitEnabled = "pi_cloud_connection_transit_enabled" - - // IBM PI Workspace - PIWorkspaceName = "pi_name" - PIWorkspaceDatacenter = "pi_datacenter" - PIWorkspaceResourceGroup = "pi_resource_group_id" - PIWorkspacePlan = "pi_plan" ) diff --git a/ibm/service/power/resource_ibm_pi_shared_processor_pool.go b/ibm/service/power/resource_ibm_pi_shared_processor_pool.go index a636931b90..ccd4b9371c 100644 --- a/ibm/service/power/resource_ibm_pi_shared_processor_pool.go +++ b/ibm/service/power/resource_ibm_pi_shared_processor_pool.go @@ -10,13 +10,13 @@ import ( "strings" "time" - st "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/power-go-client/helpers" - models "github.com/IBM-Cloud/power-go-client/power/models" + "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/power-go-client/ibmpisession" + "github.com/IBM-Cloud/power-go-client/power/models" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -35,42 +35,47 @@ func ResourceIBMPISharedProcessorPool() *schema.Resource { }, Schema: map[string]*schema.Schema{ - - // Required Arguments - Arg_SharedProcessorPoolName: { - Type: schema.TypeString, + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, Required: true, - Description: "Name of the shared processor pool", + Type: schema.TypeString, }, - - Arg_SharedProcessorPoolHostGroup: { + Arg_HostID: { + Description: "The host id of a host in a host group (only available for dedicated hosts).", + Optional: true, Type: schema.TypeString, - Required: true, - Description: "Host group of the shared processor pool", }, - - Arg_SharedProcessorPoolReservedCores: { - Type: schema.TypeInt, + Arg_SharedProcessorPoolHostGroup: { + Description: "Host group of the shared processor pool. Valid values are 's922', 'e980' and 's1022'.", + ForceNew: true, Required: true, - Description: "The amount of reserved cores for the shared processor pool", - }, - - Arg_CloudInstanceID: { Type: schema.TypeString, - Required: true, - Description: "PI cloud instance ID", }, - Arg_HostID: { - Description: "The host id of a host in a host group (only available for dedicated hosts)", - Optional: true, + Arg_SharedProcessorPoolName: { + Description: "The name of the shared processor pool.", + Required: true, Type: schema.TypeString, }, - - // Optional Arguments Arg_SharedProcessorPoolPlacementGroupID: { - Type: schema.TypeString, - Optional: true, - Description: "Placement group the shared processor pool is created in", + ConflictsWith: []string{Arg_SharedProcessorPoolPlacementGroups}, + Deprecated: "This field is deprecated, use pi_shared_processor_pool_placement_groups instead", + Description: "The ID of the placement group the shared processor pool is created in.", + Optional: true, + Type: schema.TypeString, + }, + Arg_SharedProcessorPoolPlacementGroups: { + ConflictsWith: []string{Arg_SharedProcessorPoolPlacementGroupID, Attr_SharedProcessorPoolPlacementGroups}, + Description: "The list of shared processor pool placement groups that the shared processor pool is in.", + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Type: schema.TypeList, + }, + Arg_SharedProcessorPoolReservedCores: { + Description: "The amount of reserved cores for the shared processor pool.", + Required: true, + Type: schema.TypeInt, }, Arg_UserTags: { Description: "The user tags attached to this resource.", @@ -81,102 +86,97 @@ func ResourceIBMPISharedProcessorPool() *schema.Resource { }, // Attributes - Attr_CRN: { + Attr_AllocatedCores: { Computed: true, - Description: "The CRN of this resource.", - Type: schema.TypeString, + Description: "The allocated cores in the shared processor pool.", + Type: schema.TypeFloat, }, - Attr_SharedProcessorPoolID: { - Type: schema.TypeString, + Attr_AvailableCores: { Computed: true, - Description: "Shared processor pool ID", - }, - - Attr_SharedProcessorPoolAvailableCores: { + Description: "The available cores in the shared processor pool.", Type: schema.TypeInt, - Computed: true, - Description: "Shared processor pool available cores", - }, - - Attr_SharedProcessorPoolAllocatedCores: { - Type: schema.TypeFloat, - Computed: true, - Description: "Shared processor pool allocated cores", }, - - Attr_SharedProcessorPoolHostID: { - Type: schema.TypeInt, + Attr_CRN: { Computed: true, - Description: "The host ID where the shared processor pool resides", - }, - - Attr_Status: { + Description: "The CRN of this resource.", Type: schema.TypeString, - Computed: true, - Description: "The status of the shared processor pool", }, - - Attr_StatusDetail: { - Type: schema.TypeString, + Attr_HostID: { Computed: true, - Description: "The status details of the shared processor pool", - }, - - Attr_SharedProcessorPoolPlacementGroups: { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: "SPP placement groups the shared processor pool are in", + Description: "The host ID where the shared processor pool resides.", + Type: schema.TypeInt, }, - - Attr_SharedProcessorPoolInstances: { - Type: schema.TypeList, + Attr_Instances: { Computed: true, - Description: "List of server instances deployed in the shared processor pool", + Description: "The list of server instances that are deployed in the shared processor pool.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - Attr_SharedProcessorPoolInstanceCpus: { - Type: schema.TypeInt, + Attr_AvailabilityZone: { Computed: true, - Description: "The amount of cpus for the server instance", + Description: "Availability zone for the server instances.", + Type: schema.TypeString, }, - Attr_SharedProcessorPoolInstanceUncapped: { - Type: schema.TypeBool, + Attr_CPUs: { Computed: true, - Description: "Identifies if uncapped or not", + Description: "The amount of cpus for the server instance.", + Type: schema.TypeInt, }, - Attr_SharedProcessorPoolInstanceAvailabilityZone: { - Type: schema.TypeString, + Attr_ID: { Computed: true, - Description: "Availability zone for the server instances", - }, - Attr_SharedProcessorPoolInstanceId: { + Description: "The server instance ID.", Type: schema.TypeString, - Computed: true, - Description: "The server instance ID", }, - Attr_SharedProcessorPoolInstanceMemory: { - Type: schema.TypeInt, + Attr_Memory: { Computed: true, - Description: "The amount of memory for the server instance", + Description: "The amount of memory for the server instance.", + Type: schema.TypeInt, }, - Attr_SharedProcessorPoolInstanceName: { - Type: schema.TypeString, + Attr_Name: { Computed: true, - Description: "The server instance name", + Description: "The server instance name.", + Type: schema.TypeString, }, Attr_Status: { + Computed: true, + Description: "Status of the instance.", Type: schema.TypeString, + }, + Attr_Uncapped: { Computed: true, - Description: "Status of the server", + Description: "Identifies if uncapped or not.", + Type: schema.TypeBool, }, - Attr_SharedProcessorPoolInstanceVcpus: { - Type: schema.TypeFloat, + Attr_VCPUs: { Computed: true, - Description: "The amout of vcpus for the server instance", + Description: "The amout of vcpus for the server instance.", + Type: schema.TypeFloat, }, }, }, + Type: schema.TypeList, + }, + Attr_SharedProcessorPoolID: { + Computed: true, + Description: "The shared processor pool's unique ID.", + Type: schema.TypeString, + }, + Attr_SharedProcessorPoolPlacementGroups: { + ConflictsWith: []string{Arg_SharedProcessorPoolPlacementGroups}, + Deprecated: "This field is deprecated, use pi_shared_processor_pool_placement_groups instead", + Description: "The list of shared processor pool placement groups that the shared processor pool is in.", + Elem: &schema.Schema{Type: schema.TypeString}, + Optional: true, + Type: schema.TypeList, + }, + Attr_Status: { + Computed: true, + Description: "The status of the shared processor pool.", + Type: schema.TypeString, + }, + Attr_StatusDetail: { + Computed: true, + Description: "The status details of the shared processor pool.", + Type: schema.TypeString, }, }, } @@ -188,13 +188,13 @@ func resourceIBMPISharedProcessorPoolCreate(ctx context.Context, d *schema.Resou return diag.FromErr(err) } - cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string) - name := d.Get(Arg_SharedProcessorPoolName).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) hostGroup := d.Get(Arg_SharedProcessorPoolHostGroup).(string) hostID := d.Get(Arg_HostID).(string) + name := d.Get(Arg_SharedProcessorPoolName).(string) reservedCores := d.Get(Arg_SharedProcessorPoolReservedCores).(int) cores := int64(reservedCores) - client := st.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) body := &models.SharedProcessorPoolCreate{ HostGroup: &hostGroup, HostID: hostID, @@ -214,13 +214,17 @@ func resourceIBMPISharedProcessorPoolCreate(ctx context.Context, d *schema.Resou return diag.Errorf("error creating the shared processor pool: %v", err) } - var sharedProcessorPoolReadyStatus string d.SetId(fmt.Sprintf("%s/%s", cloudInstanceID, *spp.ID)) - _, err = isWaitForPISharedProcessorPoolAvailable(ctx, d, client, *spp.ID, sharedProcessorPoolReadyStatus) + _, err = isWaitForPISharedProcessorPoolAvailable(ctx, d, client, *spp.ID) if err != nil { return diag.FromErr(err) } + diagErr := detectSPPPlacementGroupChange(ctx, sess, cloudInstanceID, d, *spp.ID) + if diagErr != nil { + return diagErr + } + if _, ok := d.GetOk(Arg_UserTags); ok { if spp.Crn != "" { oldList, newList := d.GetChange(Arg_UserTags) @@ -232,16 +236,15 @@ func resourceIBMPISharedProcessorPoolCreate(ctx context.Context, d *schema.Resou } return resourceIBMPISharedProcessorPoolRead(ctx, d, meta) - } -func isWaitForPISharedProcessorPoolAvailable(ctx context.Context, d *schema.ResourceData, client *st.IBMPISharedProcessorPoolClient, id string, sharedProcessorPoolReadyStatus string) (interface{}, error) { +func isWaitForPISharedProcessorPoolAvailable(ctx context.Context, d *schema.ResourceData, client *instance.IBMPISharedProcessorPoolClient, id string) (interface{}, error) { log.Printf("Waiting for PISharedProcessorPool (%s) to be active ", id) - stateConf := &resource.StateChangeConf{ - Pending: []string{"configuring"}, - Target: []string{"active", "failed", ""}, - Refresh: isPISharedProcessorPoolRefreshFunc(client, id, sharedProcessorPoolReadyStatus), + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Configuring}, + Target: []string{State_Active, State_Failed, ""}, + Refresh: isPISharedProcessorPoolRefreshFunc(client, id), Delay: 20 * time.Second, MinTimeout: Timeout_Active, Timeout: d.Timeout(schema.TimeoutCreate), @@ -250,23 +253,20 @@ func isWaitForPISharedProcessorPoolAvailable(ctx context.Context, d *schema.Reso return stateConf.WaitForStateContext(ctx) } -func isPISharedProcessorPoolRefreshFunc(client *st.IBMPISharedProcessorPoolClient, id, sharedProcessorPoolReadyStatus string) resource.StateRefreshFunc { +func isPISharedProcessorPoolRefreshFunc(client *instance.IBMPISharedProcessorPoolClient, id string) retry.StateRefreshFunc { return func() (interface{}, string, error) { - pool, err := client.Get(id) if err != nil { return nil, "", err } - // Check for `sharedProcessorPoolReadyStatus` status - if pool.SharedProcessorPool.Status == "active" { - return pool, "active", nil + if pool.SharedProcessorPool.Status == State_Active { + return pool, State_Active, nil } - if pool.SharedProcessorPool.Status == "failed" { + if pool.SharedProcessorPool.Status == State_Failed { err = fmt.Errorf("failed to create the shared processor pool") return pool, pool.SharedProcessorPool.Status, err } - - return pool, "configuring", nil + return pool, State_Configuring, nil } } @@ -282,7 +282,7 @@ func resourceIBMPISharedProcessorPoolRead(ctx context.Context, d *schema.Resourc } cloudInstanceID := parts[0] - client := st.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) response, err := client.Get(parts[1]) if err != nil || response == nil { @@ -306,48 +306,49 @@ func resourceIBMPISharedProcessorPoolRead(ctx context.Context, d *schema.Resourc if response.SharedProcessorPool.ID != nil { d.Set(Attr_SharedProcessorPoolID, response.SharedProcessorPool.ID) } - if response.SharedProcessorPool.ReservedCores != nil { - d.Set(Arg_SharedProcessorPoolReservedCores, response.SharedProcessorPool.ReservedCores) - } if response.SharedProcessorPool.AllocatedCores != nil { - d.Set(Attr_SharedProcessorPoolAllocatedCores, response.SharedProcessorPool.AllocatedCores) + d.Set(Attr_AllocatedCores, response.SharedProcessorPool.AllocatedCores) } if response.SharedProcessorPool.AvailableCores != nil { - d.Set(Attr_SharedProcessorPoolAvailableCores, response.SharedProcessorPool.AvailableCores) + d.Set(Attr_AvailableCores, response.SharedProcessorPool.AvailableCores) } - if response.SharedProcessorPool.AvailableCores != nil { - d.Set(Attr_SharedProcessorPoolAvailableCores, response.SharedProcessorPool.AvailableCores) + if response.SharedProcessorPool.ReservedCores != nil { + d.Set(Arg_SharedProcessorPoolReservedCores, response.SharedProcessorPool.ReservedCores) } if response.SharedProcessorPool.SharedProcessorPoolPlacementGroups != nil { pgIDs := make([]string, len(response.SharedProcessorPool.SharedProcessorPoolPlacementGroups)) for i, pg := range response.SharedProcessorPool.SharedProcessorPoolPlacementGroups { pgIDs[i] = *pg.ID } - d.Set(Attr_SharedProcessorPoolPlacementGroups, pgIDs) + if _, ok := d.GetOk(Attr_SharedProcessorPoolPlacementGroups); ok { + d.Set(Attr_SharedProcessorPoolPlacementGroups, pgIDs) + } else { + d.Set(Arg_SharedProcessorPoolPlacementGroups, pgIDs) + } } - d.Set(Attr_SharedProcessorPoolHostID, response.SharedProcessorPool.HostID) + d.Set(Attr_HostID, response.SharedProcessorPool.HostID) d.Set(Attr_Status, response.SharedProcessorPool.Status) - d.Set(Attr_SharedProcessorPoolStatusDetail, response.SharedProcessorPool.StatusDetail) + d.Set(Attr_StatusDetail, response.SharedProcessorPool.StatusDetail) serversMap := []map[string]interface{}{} if response.Servers != nil { for _, s := range response.Servers { if s != nil { v := map[string]interface{}{ - Attr_SharedProcessorPoolInstanceCpus: s.Cpus, - Attr_SharedProcessorPoolInstanceUncapped: s.Uncapped, - Attr_SharedProcessorPoolInstanceAvailabilityZone: s.AvailabilityZone, - Attr_SharedProcessorPoolInstanceId: s.ID, - Attr_SharedProcessorPoolInstanceMemory: s.Memory, - Attr_SharedProcessorPoolInstanceName: s.Name, - Attr_Status: s.Status, - Attr_SharedProcessorPoolInstanceVcpus: s.Vcpus, + Attr_AvailabilityZone: s.AvailabilityZone, + Attr_CPUs: s.Cpus, + Attr_ID: s.ID, + Attr_Memory: s.Memory, + Attr_Name: s.Name, + Attr_Status: s.Status, + Attr_Uncapped: s.Uncapped, + Attr_VCPUs: s.Vcpus, } serversMap = append(serversMap, v) } } } - d.Set(Attr_SharedProcessorPoolInstances, serversMap) + d.Set(Attr_Instances, serversMap) return nil } @@ -363,7 +364,7 @@ func resourceIBMPISharedProcessorPoolUpdate(ctx context.Context, d *schema.Resou return diag.FromErr(err) } - client := st.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) body := &models.SharedProcessorPoolUpdate{} if d.HasChange(Arg_SharedProcessorPoolName) { @@ -380,11 +381,35 @@ func resourceIBMPISharedProcessorPoolUpdate(ctx context.Context, d *schema.Resou return diag.Errorf("error updating the shared processor pool: %v", err) } - if d.HasChange(Attr_SharedProcessorPoolPlacementGroups) { + diagErr := detectSPPPlacementGroupChange(ctx, sess, cloudInstanceID, d, sppID) + if diagErr != nil { + return diagErr + } - pgClient := st.NewIBMPISPPPlacementGroupClient(ctx, sess, cloudInstanceID) + if d.HasChange(Arg_UserTags) { + if crn, ok := d.GetOk(Attr_CRN); ok { + oldList, newList := d.GetChange(Arg_UserTags) + err := flex.UpdateGlobalTagsUsingCRN(oldList, newList, meta, crn.(string), "", UserTagType) + if err != nil { + log.Printf("Error on update of pi shared processor pool (%s) pi_user_tags: %s", sppID, err) + } + } + } + + return resourceIBMPISharedProcessorPoolRead(ctx, d, meta) +} - oldRaw, newRaw := d.GetChange(Attr_SharedProcessorPoolPlacementGroups) +func detectSPPPlacementGroupChange(ctx context.Context, sess *ibmpisession.IBMPISession, cloudInstanceID string, d *schema.ResourceData, sppID string) diag.Diagnostics { + if d.HasChanges(Arg_SharedProcessorPoolPlacementGroups, Attr_SharedProcessorPoolPlacementGroups) { + + pgClient := instance.NewIBMPISPPPlacementGroupClient(ctx, sess, cloudInstanceID) + + var oldRaw, newRaw interface{} + if d.HasChange(Arg_SharedProcessorPoolPlacementGroups) { + oldRaw, newRaw = d.GetChange(Arg_SharedProcessorPoolPlacementGroups) + } else { + oldRaw, newRaw = d.GetChange(Attr_SharedProcessorPoolPlacementGroups) + } old := oldRaw.([]interface{}) new := newRaw.([]interface{}) @@ -427,18 +452,7 @@ func resourceIBMPISharedProcessorPoolUpdate(ctx context.Context, d *schema.Resou } } } - - if d.HasChange(Arg_UserTags) { - if crn, ok := d.GetOk(Attr_CRN); ok { - oldList, newList := d.GetChange(Arg_UserTags) - err := flex.UpdateGlobalTagsUsingCRN(oldList, newList, meta, crn.(string), "", UserTagType) - if err != nil { - log.Printf("Error on update of pi shared processor pool (%s) pi_user_tags: %s", sppID, err) - } - } - } - - return resourceIBMPISharedProcessorPoolRead(ctx, d, meta) + return nil } // returns the elements in string array a that are not in array z @@ -466,7 +480,7 @@ func resourceIBMPISharedProcessorPoolDelete(ctx context.Context, d *schema.Resou return diag.FromErr(err) } cloudInstanceID := parts[0] - client := st.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPISharedProcessorPoolClient(ctx, sess, cloudInstanceID) err = client.Delete(parts[1]) if err != nil { diff --git a/ibm/service/power/resource_ibm_pi_shared_processor_pool_test.go b/ibm/service/power/resource_ibm_pi_shared_processor_pool_test.go index 1e7e572b63..4b9d19dbb1 100644 --- a/ibm/service/power/resource_ibm_pi_shared_processor_pool_test.go +++ b/ibm/service/power/resource_ibm_pi_shared_processor_pool_test.go @@ -129,9 +129,9 @@ func testAccCheckIBMPISPPExists(n string) resource.TestCheckFunc { func testAccCheckIBMPISPPConfig(name string) string { return fmt.Sprintf(` resource "ibm_pi_shared_processor_pool" "power_shared_processor_pool" { - pi_cloud_instance_id = "%[2]s" - pi_shared_processor_pool_host_group = "s922" - pi_shared_processor_pool_name = "%[1]s" + pi_cloud_instance_id = "%[2]s" + pi_shared_processor_pool_host_group = "s922" + pi_shared_processor_pool_name = "%[1]s" pi_shared_processor_pool_reserved_cores = "1" }`, name, acc.Pi_cloud_instance_id) } @@ -139,11 +139,10 @@ func testAccCheckIBMPISPPConfig(name string) string { func testAccCheckIBMPISPPUserTagsConfig(name string, userTagsString string) string { return fmt.Sprintf(` resource "ibm_pi_shared_processor_pool" "power_shared_processor_pool" { - pi_cloud_instance_id = "%[2]s" - pi_shared_processor_pool_host_group = "s922" - pi_shared_processor_pool_name = "%[1]s" + pi_cloud_instance_id = "%[2]s" + pi_shared_processor_pool_host_group = "s922" + pi_shared_processor_pool_name = "%[1]s" pi_shared_processor_pool_reserved_cores = "1" - pi_user_tags = %[3]s - + pi_user_tags = %[3]s }`, name, acc.Pi_cloud_instance_id, userTagsString) } diff --git a/website/docs/r/pi_shared_processor_pool.html.markdown b/website/docs/r/pi_shared_processor_pool.html.markdown index be21015050..24250d17a7 100644 --- a/website/docs/r/pi_shared_processor_pool.html.markdown +++ b/website/docs/r/pi_shared_processor_pool.html.markdown @@ -1,5 +1,4 @@ --- - subcategory: "Power Systems" layout: "ibm" page_title: "IBM: pi_shared_processor_pool" @@ -17,21 +16,21 @@ The following example enables you to create a shared processor pool with a group ```terraform resource "ibm_pi_shared_processor_pool" "testacc_shared_processor_pool" { - pi_shared_processor_pool_name = "my_spp" - pi_shared_processor_pool_host_group = "s922" + pi_cloud_instance_id = "" + pi_shared_processor_pool_host_group = "s922" + pi_shared_processor_pool_name = "my_spp" pi_shared_processor_pool_reserved_cores = "2" - pi_cloud_instance_id = "" } ``` ### Notes -* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. -* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: - * `region` - `lon` - * `zone` - `lon04` +- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + - `region` - `lon` + - `zone` - `lon04` - Example usage: +Example usage: ```terraform provider "ibm" { @@ -44,48 +43,49 @@ resource "ibm_pi_shared_processor_pool" "testacc_shared_processor_pool" { ibm_pi_shared_processor_pool provides the following [timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options: -* **create** - (Default 60 minutes) Used for creating a shared processor pool placement group. -* **delete** - (Default 60 minutes) Used for deleting a shared processor pool placement group. -* **update** - (Default 60 minutes) Used for updating a shared processor pool placement group. +- **create** - (Default 60 minutes) Used for creating a shared processor pool. +- **delete** - (Default 60 minutes) Used for deleting a shared processor pool. +- **update** - (Default 60 minutes) Used for updating a shared processor pool. ## Argument reference Review the argument references that you can specify for your resource. -* `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. -* `pi_host_id` - (Optional, String) The host id of a host in a host group (only available for dedicated hosts). -* `pi_shared_processor_pool_host_group` - (Required, String) Host group of the shared processor pool. Valid values are 's922', 'e980' and 's1022'. -* `pi_shared_processor_pool_name` - (Required, String) The name of the shared processor pool. -* `pi_shared_processor_pool_reserved_cores` - (Required, Integer) The amount of reserved cores for the shared processor pool. -* `pi_shared_processor_pool_placement_group_id` - (Optional, String) The ID of the placement group the shared processor pool is created in. -* `pi_user_tags` - (Optional, List) The user tags attached to this resource. +- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. +- `pi_host_id` - (Optional, String) The host id of a host in a host group (only available for dedicated hosts). +- `pi_shared_processor_pool_host_group` - (Required, String) Host group of the shared processor pool. Valid values are 's922', 'e980' and 's1022'. +- `pi_shared_processor_pool_name` - (Required, String) The name of the shared processor pool. +- `pi_shared_processor_pool_placement_group_id` - (Deprecated, Optional, String) The ID of the placement group the shared processor pool is created in. Please use pi_shared_processor_pool_placement_groups instead. +- `pi_shared_processor_pool_placement_groups` - (Optional, List) The list of shared processor pool placement groups that the shared processor pool is in. +- `pi_shared_processor_pool_reserved_cores` - (Required, Integer) The amount of reserved cores for the shared processor pool. +- `pi_user_tags` - (Optional, List) The user tags attached to this resource. ## Attribute reference - In addition to all argument reference list, you can access the following attribute reference after your resource is created. +In addition to all argument reference list, you can access the following attribute reference after your resource is created. -* `allocated_cores` - (Float) The allocated cores in the shared processor pool. -* `available_cores` - (Integer) The available cores in the shared processor pool. -* `crn` - (String) The CRN of this resource. -* `host_id` - (Integer) The host ID where the shared processor pool resides. -* `instances` - (List of Map) The list of server instances that are deployed in the shared processor pool. +- `allocated_cores` - (Float) The allocated cores in the shared processor pool. +- `available_cores` - (Integer) The available cores in the shared processor pool. +- `crn` - (String) The CRN of this resource. +- `host_id` - (Integer) The host ID where the shared processor pool resides. +- `instances` - (List of Map) The list of server instances that are deployed in the shared processor pool. Nested scheme for `instances`: - * `availability_zone` - (String) Availability zone for the server instances. - * `cpus` - (Integer) The amount of cpus for the server instance. - * `id` - (String) The server instance ID. - * `memory` - (Integer) The amount of memory for the server instance. - * `name` - (String) The server instance name. - * `status` - (String) Status of the instance. - * `uncapped` - (Bool) Identifies if uncapped or not. - * `vcpus` - (Float) The amout of vcpus for the server instance. -* `shared_processor_pool_id` - (String) The shared processor pool's unique ID. -* `status` - (String) The status of the shared processor pool. -* `status_detail` - (String) The status details of the shared processor pool. + - `availability_zone` - (String) Availability zone for the server instances. + - `cpus` - (Integer) The amount of cpus for the server instance. + - `id` - (String) The server instance ID. + - `memory` - (Integer) The amount of memory for the server instance. + - `name` - (String) The server instance name. + - `status` - (String) Status of the instance. + - `uncapped` - (Bool) Identifies if uncapped or not. + - `vcpus` - (Float) The amout of vcpus for the server instance. +- `shared_processor_pool_id` - (String) The shared processor pool's unique ID. +- `status` - (String) The status of the shared processor pool. +- `status_detail` - (String) The status details of the shared processor pool. ## Import -The `ibm_pi_shared_processor_pool` resource can be imported by using `power_instance_id` and `shared_processor_pool_id`. +The `ibm_pi_shared_processor_pool` resource can be imported by using `pi_cloud_instance_id` and `shared_processor_pool_id`. ### Example