Skip to content

Commit

Permalink
Update resource constant variables
Browse files Browse the repository at this point in the history
These files are included in this PR because they had their previous
constant variables removed and the code will not compile otherwise.
  • Loading branch information
ismirlia committed Dec 22, 2023
1 parent 6db1622 commit 5c81458
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 103 deletions.
38 changes: 19 additions & 19 deletions ibm/service/power/resource_ibm_pi_cloud_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func ResourceIBMPICloudConnection() *schema.Resource {
},

Schema: map[string]*schema.Schema{
// Required Attributes
helpers.PICloudInstanceId: {
// Arguments
Arg_CloudInstanceID: {
Type: schema.TypeString,
Required: true,
Description: "PI cloud instance ID",
Expand Down Expand Up @@ -124,38 +124,38 @@ func ResourceIBMPICloudConnection() *schema.Resource {
Description: "Enable transit gateway for this cloud connection",
},

//Computed Attributes
PICloudConnectionId: {
// Attributes
Attr_CloudConnectionID: {
Type: schema.TypeString,
Computed: true,
Description: "Cloud connection ID",
},
PICloudConnectionStatus: {
Attr_Status: {
Type: schema.TypeString,
Computed: true,
Description: "Link status",
},
PICloudConnectionIBMIPAddress: {
Attr_IBMIPAddress: {
Type: schema.TypeString,
Computed: true,
Description: "IBM IP address",
},
PICloudConnectionUserIPAddress: {
Attr_UserIPAddress: {
Type: schema.TypeString,
Computed: true,
Description: "User IP address",
},
PICloudConnectionPort: {
Attr_Port: {
Type: schema.TypeString,
Computed: true,
Description: "Port",
},
PICloudConnectionClassicGreSource: {
Attr_GreSourceAddress: {
Type: schema.TypeString,
Computed: true,
Description: "GRE auto-assigned source IP address",
},
PICloudConnectionConnectionMode: {
Attr_ConnectionMode: {
Type: schema.TypeString,
Computed: true,
Description: "Type of service the gateway is attached to",
Expand All @@ -170,7 +170,7 @@ func resourceIBMPICloudConnectionCreate(ctx context.Context, d *schema.ResourceD
return diag.FromErr(err)
}

cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string)
cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
name := d.Get(helpers.PICloudConnectionName).(string)
speed := int64(d.Get(helpers.PICloudConnectionSpeed).(int))

Expand Down Expand Up @@ -437,17 +437,17 @@ func resourceIBMPICloudConnectionRead(ctx context.Context, d *schema.ResourceDat
return diag.FromErr(err)
}

d.Set(PICloudConnectionId, cloudConnection.CloudConnectionID)
d.Set(Attr_CloudConnectionID, cloudConnection.CloudConnectionID)
d.Set(helpers.PICloudConnectionName, cloudConnection.Name)
d.Set(helpers.PICloudConnectionGlobalRouting, cloudConnection.GlobalRouting)
d.Set(helpers.PICloudConnectionMetered, cloudConnection.Metered)
d.Set(PICloudConnectionIBMIPAddress, cloudConnection.IbmIPAddress)
d.Set(PICloudConnectionUserIPAddress, cloudConnection.UserIPAddress)
d.Set(PICloudConnectionStatus, cloudConnection.LinkStatus)
d.Set(PICloudConnectionPort, cloudConnection.Port)
d.Set(Attr_IBMIPAddress, cloudConnection.IbmIPAddress)
d.Set(Attr_UserIPAddress, cloudConnection.UserIPAddress)
d.Set(Attr_Status, cloudConnection.LinkStatus)
d.Set(Attr_Port, cloudConnection.Port)
d.Set(helpers.PICloudConnectionSpeed, cloudConnection.Speed)
d.Set(helpers.PICloudInstanceId, cloudInstanceID)
d.Set(PICloudConnectionConnectionMode, cloudConnection.ConnectionMode)
d.Set(Arg_CloudInstanceID, cloudInstanceID)
d.Set(Attr_ConnectionMode, cloudConnection.ConnectionMode)
if cloudConnection.Networks != nil {
networks := make([]string, 0)
for _, ccNetwork := range cloudConnection.Networks {
Expand All @@ -461,7 +461,7 @@ func resourceIBMPICloudConnectionRead(ctx context.Context, d *schema.ResourceDat
d.Set(helpers.PICloudConnectionClassicEnabled, cloudConnection.Classic.Enabled)
if cloudConnection.Classic.Gre != nil {
d.Set(helpers.PICloudConnectionClassicGreDest, cloudConnection.Classic.Gre.DestIPAddress)
d.Set(PICloudConnectionClassicGreSource, cloudConnection.Classic.Gre.SourceIPAddress)
d.Set(Attr_GreSourceAddress, cloudConnection.Classic.Gre.SourceIPAddress)
}
}
if cloudConnection.Vpc != nil {
Expand Down
50 changes: 24 additions & 26 deletions ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func ResourceIBMPIInstance() *schema.Resource {

Schema: map[string]*schema.Schema{

helpers.PICloudInstanceId: {
Arg_CloudInstanceID: {
Type: schema.TypeString,
ForceNew: true,
Required: true,
Description: "This is the Power Instance id that is assigned to the account",
},
helpers.PIInstanceLicenseRepositoryCapacity: {
PIInstanceLicenseRepositoryCapacity: {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Expand All @@ -56,7 +56,7 @@ func ResourceIBMPIInstance() *schema.Resource {
Computed: true,
Description: "PI instance status",
},
"pi_migratable": {
PIInstanceMigratable: {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Expand All @@ -82,22 +82,20 @@ func ResourceIBMPIInstance() *schema.Resource {
Computed: true,
Description: "Maximum memory size",
},
helpers.PIInstanceVolumeIds: {
PIInstanceVolumeIds: {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
DiffSuppressFunc: flex.ApplyOnce,
Description: "List of PI volumes",
},

helpers.PIInstanceUserData: {
PIInstanceUserData: {
Type: schema.TypeString,
Optional: true,
Description: "Base64 encoded data to be passed in for invoking a cloud init script",
},

helpers.PIInstanceStorageType: {
PIInstanceStorageType: {
Type: schema.TypeString,
Optional: true,
Computed: true,
Expand Down Expand Up @@ -141,7 +139,7 @@ func ResourceIBMPIInstance() *schema.Resource {
Description: "List of pvmInstances to base storage anti-affinity policy against; required if requesting anti-affinity and pi_anti_affinity_volumes is not provided",
ConflictsWith: []string{PIAntiAffinityVolumes},
},
helpers.PIInstanceStorageConnection: {
PIInstanceStorageConnection: {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validate.ValidateAllowedStringValues([]string{"vSCSI"}),
Expand Down Expand Up @@ -193,7 +191,7 @@ func ResourceIBMPIInstance() *schema.Resource {
Optional: true,
Description: "Placement group ID",
},
Arg_PIInstanceSharedProcessorPool: {
PIInstanceSharedProcessorPool: {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Expand Down Expand Up @@ -362,7 +360,7 @@ func resourceIBMPIInstanceCreate(ctx context.Context, d *schema.ResourceData, me
if err != nil {
return diag.FromErr(err)
}
cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string)
cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
client := st.NewIBMPIInstanceClient(ctx, sess, cloudInstanceID)
sapClient := st.NewIBMPISAPInstanceClient(ctx, sess, cloudInstanceID)
imageClient := st.NewIBMPIImageClient(ctx, sess, cloudInstanceID)
Expand Down Expand Up @@ -436,23 +434,23 @@ func resourceIBMPIInstanceRead(ctx context.Context, d *schema.ResourceData, meta
}
d.Set(helpers.PIInstanceProcType, powervmdata.ProcType)
if powervmdata.Migratable != nil {
d.Set("pi_migratable", powervmdata.Migratable)
d.Set(PIInstanceMigratable, powervmdata.Migratable)
}
d.Set("min_processors", powervmdata.Minproc)
d.Set(helpers.PIInstanceProgress, powervmdata.Progress)
if powervmdata.StorageType != nil {
d.Set(helpers.PIInstanceStorageType, powervmdata.StorageType)
d.Set(PIInstanceStorageType, powervmdata.StorageType)
}
d.Set(PIInstanceStoragePool, powervmdata.StoragePool)
d.Set(PIInstanceStoragePoolAffinity, powervmdata.StoragePoolAffinity)
d.Set(helpers.PICloudInstanceId, cloudInstanceID)
d.Set(Arg_CloudInstanceID, cloudInstanceID)
d.Set("instance_id", powervmdata.PvmInstanceID)
d.Set(helpers.PIInstanceName, powervmdata.ServerName)
d.Set(helpers.PIInstanceImageId, powervmdata.ImageID)
if *powervmdata.PlacementGroup != "none" {
d.Set(helpers.PIPlacementGroupID, powervmdata.PlacementGroup)
}
d.Set(Arg_PIInstanceSharedProcessorPool, powervmdata.SharedProcessorPool)
d.Set(PIInstanceSharedProcessorPool, powervmdata.SharedProcessorPool)
d.Set(Attr_PIInstanceSharedProcessorPoolID, powervmdata.SharedProcessorPoolID)

networksMap := []map[string]interface{}{}
Expand Down Expand Up @@ -598,7 +596,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
}

// Start of the change for Memory and Processors
if d.HasChange(helpers.PIInstanceMemory) || d.HasChange(helpers.PIInstanceProcessors) || d.HasChange("pi_migratable") {
if d.HasChange(helpers.PIInstanceMemory) || d.HasChange(helpers.PIInstanceProcessors) || d.HasChange(PIInstanceMigratable) {

maxMemLpar := d.Get("max_memory").(float64)
maxCPULpar := d.Get("max_processors").(float64)
Expand Down Expand Up @@ -627,7 +625,7 @@ func resourceIBMPIInstanceUpdate(ctx context.Context, d *schema.ResourceData, me
Memory: mem,
Processors: procs,
}
if m, ok := d.GetOk("pi_migratable"); ok {
if m, ok := d.GetOk(PIInstanceMigratable); ok {
migratable := m.(bool)
body.Migratable = &migratable
}
Expand Down Expand Up @@ -1063,7 +1061,7 @@ func createSAPInstance(d *schema.ResourceData, sapClient *st.IBMPISAPInstanceCli
if v, ok := d.GetOk(PISAPInstanceDeploymentType); ok {
body.DeploymentType = v.(string)
}
if v, ok := d.GetOk(helpers.PIInstanceVolumeIds); ok {
if v, ok := d.GetOk(PIInstanceVolumeIds); ok {
volids := flex.ExpandStringList((v.(*schema.Set)).List())
if len(volids) > 0 {
body.VolumeIDs = volids
Expand All @@ -1080,15 +1078,15 @@ func createSAPInstance(d *schema.ResourceData, sapClient *st.IBMPISAPInstanceCli
sshkey := v.(string)
body.SSHKeyName = sshkey
}
if u, ok := d.GetOk(helpers.PIInstanceUserData); ok {
if u, ok := d.GetOk(PIInstanceUserData); ok {
userData := u.(string)
body.UserData = encodeBase64(userData)
}
if sys, ok := d.GetOk(helpers.PIInstanceSystemType); ok {
body.SysType = sys.(string)
}

if st, ok := d.GetOk(helpers.PIInstanceStorageType); ok {
if st, ok := d.GetOk(PIInstanceStorageType); ok {
body.StorageType = st.(string)
}
if sp, ok := d.GetOk(PIInstanceStoragePool); ok {
Expand Down Expand Up @@ -1169,7 +1167,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
pvmNetworks := expandPVMNetworks(d.Get(PIInstanceNetwork).([]interface{}))

var volids []string
if v, ok := d.GetOk(helpers.PIInstanceVolumeIds); ok {
if v, ok := d.GetOk(PIInstanceVolumeIds); ok {
volids = flex.ExpandStringList((v.(*schema.Set)).List())
}
var replicants float64
Expand All @@ -1185,7 +1183,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
replicationNamingScheme = r.(string)
}
var migratable bool
if m, ok := d.GetOk("pi_migratable"); ok {
if m, ok := d.GetOk(PIInstanceMigratable); ok {
migratable = m.(bool)
}

Expand All @@ -1198,7 +1196,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
}

var userData string
if u, ok := d.GetOk(helpers.PIInstanceUserData); ok {
if u, ok := d.GetOk(PIInstanceUserData); ok {
userData = u.(string)
}

Expand Down Expand Up @@ -1235,7 +1233,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
body.VirtualCores = &models.VirtualCores{Assigned: &assignedVirtualCores}
}

if st, ok := d.GetOk(helpers.PIInstanceStorageType); ok {
if st, ok := d.GetOk(PIInstanceStorageType); ok {
body.StorageType = st.(string)
}
if sp, ok := d.GetOk(PIInstanceStoragePool); ok {
Expand Down Expand Up @@ -1274,15 +1272,15 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
body.StorageAffinity = affinity
}

if sc, ok := d.GetOk(helpers.PIInstanceStorageConnection); ok {
if sc, ok := d.GetOk(PIInstanceStorageConnection); ok {
body.StorageConnection = sc.(string)
}

if pg, ok := d.GetOk(helpers.PIPlacementGroupID); ok {
body.PlacementGroup = pg.(string)
}

if spp, ok := d.GetOk(Arg_PIInstanceSharedProcessorPool); ok {
if spp, ok := d.GetOk(PIInstanceSharedProcessorPool); ok {
body.SharedProcessorPool = spp.(string)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func ResourceIBMPIInstanceConsoleLanguage() *schema.Resource {

Schema: map[string]*schema.Schema{
// Required Attributes
helpers.PICloudInstanceId: {
Arg_CloudInstanceID: {
Type: schema.TypeString,
Required: true,
Description: "PI cloud instance ID",
Expand All @@ -61,7 +61,7 @@ func resourceIBMPIInstanceConsoleLanguageCreate(ctx context.Context, d *schema.R
return diag.FromErr(err)
}

cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string)
cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
instanceName := d.Get(helpers.PIInstanceName).(string)
code := d.Get(PIConsoleLanguageCode).(string)

Expand Down Expand Up @@ -93,8 +93,8 @@ func resourceIBMPIInstanceConsoleLanguageUpdate(ctx context.Context, d *schema.R
return diag.FromErr(err)
}

if d.HasChange(ConsoleLanguageCode) {
cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string)
if d.HasChange(Attr_ConsoleLanguages) {
cloudInstanceID := d.Get(Arg_CloudInstanceID).(string)
instanceName := d.Get(helpers.PIInstanceName).(string)
code := d.Get(PIConsoleLanguageCode).(string)

Expand Down
Loading

0 comments on commit 5c81458

Please sign in to comment.