parent
							
								
									f5e0a53364
								
							
						
					
					
						commit
						af82decadd
					
				| @ -1,11 +1,56 @@ | ||||
| ### Version 3.4.3 | ||||
| ### Version 3.5.0 | ||||
| 
 | ||||
| ### Features | ||||
| ## Features | ||||
| 
 | ||||
| - Change field type disksize from int to float in: | ||||
|   - resource decort_resgroup | ||||
|   - resource decort_account | ||||
|   - data source decort_rg | ||||
|   - data source decort_account | ||||
|   - data source decort_account_rg_list | ||||
| - Models of the resources | ||||
| #### Resgroup | ||||
| - Add data source rg_affinity_group_computes | ||||
| - Add data source rg_affinity_groups_get | ||||
| - Add data source rg_affinity_groups_list | ||||
| - Add data source rg_audits | ||||
| - Add data source rg_list | ||||
| - Add data source rg_list_computes | ||||
| - Add data source rg_list_deleted | ||||
| - Add data source rg_list_lb | ||||
| - Add data source rg_list_pfw | ||||
| - Add data source rg_list_vins | ||||
| - Add data source rg_usage | ||||
| - Update data source rg | ||||
| - Update block 'qouta' to change resource limits | ||||
| - Add block 'access' to access/revoke rights for rg | ||||
| - Add block 'def_net' to set default network in rg | ||||
| - Add field 'enable' to disable/enable rg | ||||
| - Add processing of input parameters (account_id, gid, ext_net_id) when creating and updating a resource | ||||
| 
 | ||||
| #### Kvmvm | ||||
| - Update data source decort_kvmvm | ||||
| - Add data source decort_kvmvm_list | ||||
| - Add data source decort_kvmvm_audits | ||||
| - Add data source decort_kvmvm_get_audits | ||||
| - Add data source decort_kvmvm_get_console_url | ||||
| - Add data source decort_kvmvm_get_log | ||||
| - Add data source decort_kvmvm_pfw_list | ||||
| - Add data source decort_kvmvm_user_list | ||||
| - Update block 'disks' in the resource decort_kvmvm | ||||
| - Add block 'tags' to add/delete tags | ||||
| - Add block 'port_forwarding' to add/delete pfws | ||||
| - Add block 'user_access' to access/revoke user rights for comptue | ||||
| - Add block 'snapshot' to create/delete snapshots | ||||
| - Add block 'rollback' to rollback in snapshot | ||||
| - Add block 'cd' to insert/Eject cdROM disks | ||||
| - Add field 'pin_to_stack' to pin compute to stack | ||||
| - Add field 'pause' to pause/resume compute | ||||
| - Add field 'reset' to reset compute | ||||
| - Add the ability to redeploy the compute when changing the image_id | ||||
| - Add field 'data_disks' to redeploy compute | ||||
| - Add field 'auto_start' to redeploy compute | ||||
| - Add field 'force_stop' to redeploy compute | ||||
| - Add warnings in Create resource decort_kvmvm | ||||
| - Add processing of input parameters (rg_id, image_id and all vins_id's in blocks 'network') when creating and updating a resource | ||||
| 
 | ||||
| ## Bug Fix | ||||
| 
 | ||||
| - When deleting the 'quote' block, the limits are not set to the default value | ||||
| - Block 'disks' in resource decort_kvmvm breaks the state | ||||
| - Import decort_resgroup resource breaks the state | ||||
| - Import decort_kvmvm resource breaks the state | ||||
| - If the boot_disk_size is not specified at creation, further changing it leads to an error | ||||
|  | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -0,0 +1,74 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeAudits, err := utilityComputeAuditsCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenComputeAudits(computeAudits)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputeAuditsSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"call": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"responsetime": { | ||||
| 						Type:     schema.TypeFloat, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"statuscode": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"timestamp": { | ||||
| 						Type:     schema.TypeFloat, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"user": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeAudits() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeAuditsRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputeAuditsSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,62 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeGetAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeAudits, err := utilityComputeGetAuditsCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenComputeGetAudits(computeAudits)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputeGetAuditsSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"epoch": { | ||||
| 						Type:     schema.TypeFloat, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"message": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeGetAudits() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeGetAuditsRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputeGetAuditsSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,52 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeGetConsoleUrlRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeConsoleUrl, err := utilityComputeGetConsoleUrlCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	result := strings.ReplaceAll(string(computeConsoleUrl), "\"", "") | ||||
| 	result = strings.ReplaceAll(string(result), "\\", "") | ||||
| 	d.Set("console_url", result) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputeGetConsoleUrlSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 		"console_url": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeGetConsoleUrl() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeGetConsoleUrlRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputeGetConsoleUrlSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,53 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeGetLogRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeGetLog, err := utilityComputeGetLogCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("log", computeGetLog) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputeGetLogSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 		"path": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 		"log": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeGetLog() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeGetLogRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputeGetLogSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,335 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeList, err := utilityDataComputeListCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenComputeList(computeList)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func computeDisksSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"disk_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"pci_slot": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| func itemComputeSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"acl": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeListACLSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"account_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"account_name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"affinity_label": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"affinity_rules": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeListRulesSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"affinity_weight": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"anti_affinity_rules": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeListRulesSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"arch": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"boot_order": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Schema{ | ||||
| 				Type: schema.TypeString, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"bootdisk_size": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"clone_reference": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"clones": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Schema{ | ||||
| 				Type: schema.TypeInt, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"computeci_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"cpus": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"created_by": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"created_time": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"custom_fields": { //NEED
 | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"deleted_by": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"deleted_time": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"desc": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"devices": { //NEED
 | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"disks": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeDisksSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"driver": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"gid": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"image_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"interfaces": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeInterfacesSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"lock_status": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"manager_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"manager_type": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"migrationjob": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"milestones": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"pinned": { | ||||
| 			Type:     schema.TypeBool, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"ram": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"reference_id": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"registered": { | ||||
| 			Type:     schema.TypeBool, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"res_name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"rg_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"rg_name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"snap_sets": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: computeSnapSetsSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"stateless_sep_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"stateless_sep_type": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"status": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"tags": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"key": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"val": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"tech_status": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"total_disk_size": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"updated_by": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"updated_time": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"user_managed": { | ||||
| 			Type:     schema.TypeBool, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"vgpus": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Schema{ | ||||
| 				Type: schema.TypeInt, | ||||
| 			}, | ||||
| 		}, | ||||
| 		"vins_connected": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"virtual_image_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func dataSourceCompputeListSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"includedeleted": { | ||||
| 			Type:     schema.TypeBool, | ||||
| 			Optional: true, | ||||
| 		}, | ||||
| 		"page": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Optional: true, | ||||
| 		}, | ||||
| 		"size": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Optional: true, | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: itemComputeSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeList() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeListRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceCompputeListSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,81 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputePfwListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computePfwList, err := utilityComputePfwListCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenPfwList(computePfwList)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputePfwListSchemaMake() map[string]*schema.Schema { | ||||
| 	return map[string]*schema.Schema{ | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"pfw_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"local_ip": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"local_port": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"protocol": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"public_port_end": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"public_port_start": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vm_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputePfwList() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputePfwListRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputePfwListSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,45 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceComputeUserListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computeUserList, err := utilityComputeUserListCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	flattenUserList(d, computeUserList) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceComputeUserListSchemaMake() map[string]*schema.Schema { | ||||
| 	res := computeACLSchemaMake() | ||||
| 	res["compute_id"] = &schema.Schema{ | ||||
| 		Type:     schema.TypeInt, | ||||
| 		Required: true, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceComputeUserList() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceComputeUserListRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceComputeUserListSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,106 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| 	log "github.com/sirupsen/logrus" | ||||
| ) | ||||
| 
 | ||||
| func existRgID(ctx context.Context, d *schema.ResourceData, m interface{}) bool { | ||||
| 	log.Debugf("resourceComputeCreate: check access for RG ID: %v", d.Get("rg_id").(int)) | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	rgList := []struct { | ||||
| 		ID int `json:"id"` | ||||
| 	}{} | ||||
| 
 | ||||
| 	rgListAPI := "/restmachine/cloudapi/rg/list" | ||||
| 	urlValues.Add("includedeleted", "false") | ||||
| 	rgListRaw, err := c.DecortAPICall(ctx, "POST", rgListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(rgListRaw), &rgList) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	rgId := d.Get("rg_id").(int) | ||||
| 	for _, rg := range rgList { | ||||
| 		if rg.ID == rgId { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
| func existImageId(ctx context.Context, d *schema.ResourceData, m interface{}) bool { | ||||
| 	log.Debugf("resourceComputeCreate: check access for image ID: %v", d.Get("image_id").(int)) | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	imageList := []struct { | ||||
| 		ID int `json:"id"` | ||||
| 	}{} | ||||
| 	imageListAPI := "/restmachine/cloudapi/image/list" | ||||
| 	imageListRaw, err := c.DecortAPICall(ctx, "POST", imageListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(imageListRaw), &imageList) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	imageId := d.Get("image_id").(int) | ||||
| 	for _, image := range imageList { | ||||
| 		if image.ID == imageId { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
| func existVinsIdInList(vinsId int, vinsList []struct { | ||||
| 	ID int `json:"id"` | ||||
| }) bool { | ||||
| 	for _, vins := range vinsList { | ||||
| 		if vinsId == vins.ID { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
| func existVinsId(ctx context.Context, d *schema.ResourceData, m interface{}) (int, bool) { | ||||
| 	log.Debugf("resourceComputeCreate: check access for vinses IDs") | ||||
| 
 | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	vinsListAPI := "/restmachine/cloudapi/vins/list" | ||||
| 	urlValues.Add("includeDeleted", "false") | ||||
| 	vinsList := []struct { | ||||
| 		ID int `json:"id"` | ||||
| 	}{} | ||||
| 	vinsListRaw, err := c.DecortAPICall(ctx, "POST", vinsListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return 0, false | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(vinsListRaw), &vinsList) | ||||
| 	if err != nil { | ||||
| 		return 0, false | ||||
| 	} | ||||
| 
 | ||||
| 	networks := d.Get("network").(*schema.Set).List() | ||||
| 
 | ||||
| 	for _, networkInterface := range networks { | ||||
| 
 | ||||
| 		networkItem := networkInterface.(map[string]interface{}) | ||||
| 		if !existVinsIdInList(networkItem["net_id"].(int), vinsList) { | ||||
| 			return networkItem["net_id"].(int), false | ||||
| 		} | ||||
| 	} | ||||
| 	return 0, true | ||||
| } | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -0,0 +1,29 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListAudits, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	computeAudits := &ListAudits{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computeAuditsRaw, err := c.DecortAPICall(ctx, "POST", ComputeAuditsAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(computeAuditsRaw), &computeAudits) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return *computeAudits, nil | ||||
| } | ||||
| @ -0,0 +1,23 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeBootDiskCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*ItemComputeDisk, error) { | ||||
| 	compute, err := utilityComputeCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	bootDisk := &ItemComputeDisk{} | ||||
| 	for _, disk := range compute.Disks { | ||||
| 		if disk.Name == "bootdisk" { | ||||
| 			*bootDisk = disk | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| 	return bootDisk, nil | ||||
| } | ||||
| @ -0,0 +1,29 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeGetAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListShortAudits, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	computeAudits := &ListShortAudits{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computeAuditsRaw, err := c.DecortAPICall(ctx, "POST", ComputeGetAuditsAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(computeAuditsRaw), &computeAudits) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return *computeAudits, nil | ||||
| } | ||||
| @ -0,0 +1,23 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeGetConsoleUrlCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computeConsoleUrlRaw, err := c.DecortAPICall(ctx, "POST", ComputeGetConsoleUrlAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	return string(computeConsoleUrlRaw), nil | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeGetLogCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (string, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	urlValues.Add("path", d.Get("path").(string)) | ||||
| 	computeGetLogRaw, err := c.DecortAPICall(ctx, "POST", ComputeGetLogAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 
 | ||||
| 	return string(computeGetLogRaw), nil | ||||
| } | ||||
| @ -0,0 +1,39 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityDataComputeListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListComputes, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	listComputes := &ListComputes{} | ||||
| 
 | ||||
| 	if includeDeleted, ok := d.GetOk("includedeleted"); ok { | ||||
| 		urlValues.Add("includeDeleted", strconv.FormatBool(includeDeleted.(bool))) | ||||
| 	} | ||||
| 	if page, ok := d.GetOk("page"); ok { | ||||
| 		urlValues.Add("page", strconv.Itoa(page.(int))) | ||||
| 	} | ||||
| 	if size, ok := d.GetOk("size"); ok { | ||||
| 		urlValues.Add("size", strconv.Itoa(size.(int))) | ||||
| 	} | ||||
| 
 | ||||
| 	listComputesRaw, err := c.DecortAPICall(ctx, "POST", ComputeListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listComputesRaw), &listComputes) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return *listComputes, nil | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputePfwListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListPFWs, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	listPFWs := &ListPFWs{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computePfwListRaw, err := c.DecortAPICall(ctx, "POST", ComputePfwListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(computePfwListRaw), &listPFWs) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return *listPFWs, err | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,28 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityComputeUserListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (RecordACL, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	userList := &RecordACL{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computeUserListRaw, err := c.DecortAPICall(ctx, "POST", ComputeUserListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return *userList, err | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(computeUserListRaw), &userList) | ||||
| 	if err != nil { | ||||
| 		return *userList, err | ||||
| 	} | ||||
| 	return *userList, err | ||||
| } | ||||
| @ -0,0 +1,29 @@ | ||||
| package kvmvm | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityDataComputeCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (RecordCompute, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 	compute := &RecordCompute{} | ||||
| 
 | ||||
| 	urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) | ||||
| 	computeRaw, err := c.DecortAPICall(ctx, "POST", ComputeGetAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return *compute, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(computeRaw), &compute) | ||||
| 	if err != nil { | ||||
| 		return *compute, err | ||||
| 	} | ||||
| 	return *compute, nil | ||||
| } | ||||
| @ -0,0 +1,108 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupComputesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	rgComputes, err := utilityRgAffinityGroupComputesCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("items", flattenRgAffinityGroupComputes(rgComputes)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupComputesSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 		"affinity_group": { | ||||
| 			Type:        schema.TypeString, | ||||
| 			Required:    true, | ||||
| 			Description: "Affinity group label", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"compute_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"other_node": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"other_node_indirect": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"other_node_indirect_soft": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"other_node_soft": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"same_node": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"same_node_soft": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgAffinityGroupComputes() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgAffinityGroupComputesRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgAffinityGroupComputesSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,60 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupsGetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	computes, err := utilityRgAffinityGroupsGetCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("ids", computes) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupsGetSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 		"affinity_group": { | ||||
| 			Type:        schema.TypeString, | ||||
| 			Required:    true, | ||||
| 			Description: "Affinity group label", | ||||
| 		}, | ||||
| 
 | ||||
| 		"ids": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Schema{ | ||||
| 				Type: schema.TypeInt, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgAffinityGroupsGet() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgAffinityGroupsGetRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgAffinityGroupsGetSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,67 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	list, err := utilityRgAffinityGroupsListCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("affinity_groups", flattenRgListGroups(list)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgAffinityGroupsListSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 		"affinity_groups": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"label": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"ids": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgAffinityGroupsList() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgAffinityGroupsListRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgAffinityGroupsListSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,77 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgAuditsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	rgAudits, err := utilityRgAuditsCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("items", flattenRgAudits(rgAudits)) | ||||
| 
 | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgAuditsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"call": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"responsetime": { | ||||
| 						Type:     schema.TypeFloat, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"statuscode": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"timestamp": { | ||||
| 						Type:     schema.TypeFloat, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"user": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgAudits() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgAuditsRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgAuditsSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,193 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgListComputesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	listComputes, err := utilityRgListComputesCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenRgListComputes(listComputes)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func rulesSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"key": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"mode": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"policy": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"topology": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"value": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgListComputesSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 		"reason": { | ||||
| 			Type:        schema.TypeString, | ||||
| 			Optional:    true, | ||||
| 			Description: "reason for action", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"account_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"account_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"affinity_label": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"affinity_rules": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: rulesSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"affinity_weight": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"antiaffinity_rules": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: rulesSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"cpus": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"ram": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"registered": { | ||||
| 						Type:     schema.TypeBool, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"rg_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"tech_status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"total_disks_size": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"user_managed": { | ||||
| 						Type:     schema.TypeBool, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vins_connected": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgListComputes() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgListComputesRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgListComputesSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,196 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"github.com/google/uuid" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgListDeletedRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	rgList, err := utilityRgListDeletedCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	id := uuid.New() | ||||
| 	d.SetId(id.String()) | ||||
| 	d.Set("items", flattenRgList(rgList)) | ||||
| 
 | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgListDeletedSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"page": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Optional:    true, | ||||
| 			Description: "Page number", | ||||
| 		}, | ||||
| 		"size": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Optional:    true, | ||||
| 			Description: "Page size", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"account_acl": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: aclSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"account_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"account_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"acl": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: aclSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"created_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"def_net_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"def_net_type": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"desc": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"dirty": { | ||||
| 						Type:     schema.TypeBool, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"gid": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"guid": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"rg_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"lock_status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"milestones": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"register_computes": { | ||||
| 						Type:     schema.TypeBool, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"resource_limits": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: resourceLimitsSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"secret": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vins": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"vms": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeInt, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"resource_types": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeString, | ||||
| 						}, | ||||
| 					}, | ||||
| 					"uniq_pools": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeString, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgListDeleted() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgListDeletedRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgListDeletedSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,357 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgListLbRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	listLb, err := utilityRgListLbCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("items", flattenRgListLb(listLb)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func serversSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"address": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"check": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"port": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"server_settings": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: serverSettingsSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func serverSettingsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"inter": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"down_inter": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"rise": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"fall": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"slow_start": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"max_conn": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"max_queue": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"weight": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func backendsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"algorithm": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"server_default_settings": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: serverSettingsSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"servers": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: serversSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func bindingsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"address": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"port": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func frontendsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"backend": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"bindings": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: bindingsSchemaMake(), | ||||
| 			}, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"name": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func nodeSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"backend_ip": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"compute_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"frontend_ip": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"guid": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"mgmt_ip": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"network_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 	} | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgListLbSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"ha_mode": { | ||||
| 						Type:     schema.TypeBool, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"acl": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: aclSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"backends": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: backendsSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"created_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"desc": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"dp_api_user": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"extnet_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"frontends": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: frontendsSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"gid": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"guid": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"image_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"milestones": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"primary_node": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: nodeSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"rg_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"secondary_node": { | ||||
| 						Type:     schema.TypeList, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Resource{ | ||||
| 							Schema: nodeSchemaMake(), | ||||
| 						}, | ||||
| 					}, | ||||
| 					"status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"tech_status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vins_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgListLb() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgListLbRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgListLbSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,89 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgListPfwRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	listPfw, err := utilityRgListPfwCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("items", flattenRgListPfw(listPfw)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgListPfwSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"public_port_end": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"public_port_start": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vm_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vm_ip": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vm_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vm_port": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vins_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"vins_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgListPfw() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgListPfwRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgListPfwSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,126 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgListVinsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	listVins, err := utilityRgListVinsCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	d.Set("items", flattenRgListVins(listVins)) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgListVinsSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:        schema.TypeInt, | ||||
| 			Required:    true, | ||||
| 			Description: "ID of the RG", | ||||
| 		}, | ||||
| 		"reason": { | ||||
| 			Type:        schema.TypeString, | ||||
| 			Optional:    true, | ||||
| 			Description: "Reason for action", | ||||
| 		}, | ||||
| 
 | ||||
| 		"items": { | ||||
| 			Type:     schema.TypeList, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"account_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"account_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"computes": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"created_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"deleted_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"external_ip": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"network": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"pri_vnf_dev_id": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"rg_name": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"status": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_by": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"updated_time": { | ||||
| 						Type:     schema.TypeInt, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgListVins() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgListVinsRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgListVinsSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,99 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/constants" | ||||
| ) | ||||
| 
 | ||||
| func dataSourceRgUsageRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||||
| 	usage, err := utilityDataRgUsageCheckPresence(ctx, d, m) | ||||
| 	if err != nil { | ||||
| 		return diag.FromErr(err) | ||||
| 	} | ||||
| 
 | ||||
| 	d.SetId(strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	flattenRgUsageResource(d, *usage) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func dataSourceRgUsageSchemaMake() map[string]*schema.Schema { | ||||
| 	res := map[string]*schema.Schema{ | ||||
| 		"rg_id": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Required: true, | ||||
| 		}, | ||||
| 		"reason": { | ||||
| 			Type:     schema.TypeString, | ||||
| 			Optional: true, | ||||
| 		}, | ||||
| 
 | ||||
| 		"cpu": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"disk_size": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"disk_size_max": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"extips": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"exttraffic": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"gpu": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"ram": { | ||||
| 			Type:     schema.TypeInt, | ||||
| 			Computed: true, | ||||
| 		}, | ||||
| 		"seps": { | ||||
| 			Type:     schema.TypeSet, | ||||
| 			Computed: true, | ||||
| 			Elem: &schema.Resource{ | ||||
| 				Schema: map[string]*schema.Schema{ | ||||
| 					"sep_id": { | ||||
| 						Type:     schema.TypeString, | ||||
| 						Computed: true, | ||||
| 					}, | ||||
| 					"map": { | ||||
| 						Type:     schema.TypeMap, | ||||
| 						Computed: true, | ||||
| 						Elem: &schema.Schema{ | ||||
| 							Type: schema.TypeString, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| func DataSourceRgUsage() *schema.Resource { | ||||
| 	return &schema.Resource{ | ||||
| 		SchemaVersion: 1, | ||||
| 
 | ||||
| 		ReadContext: dataSourceRgUsageRead, | ||||
| 
 | ||||
| 		Timeouts: &schema.ResourceTimeout{ | ||||
| 			Read:    &constants.Timeout30s, | ||||
| 			Default: &constants.Timeout60s, | ||||
| 		}, | ||||
| 
 | ||||
| 		Schema: dataSourceRgUsageSchemaMake(), | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,111 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func existAccountID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	accountList := []struct { | ||||
| 		ID int `json:"id"` | ||||
| 	}{} | ||||
| 
 | ||||
| 	accountListAPI := "/restmachine/cloudapi/account/list" | ||||
| 
 | ||||
| 	accountListRaw, err := c.DecortAPICall(ctx, "POST", accountListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(accountListRaw), &accountList) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	haveAccount := false | ||||
| 
 | ||||
| 	myAccount := d.Get("account_id").(int) | ||||
| 	for _, account := range accountList { | ||||
| 		if account.ID == myAccount { | ||||
| 			haveAccount = true | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| 	return haveAccount, nil | ||||
| } | ||||
| func existGID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	locationList := []struct { | ||||
| 		GID int `json:"gid"` | ||||
| 	}{} | ||||
| 
 | ||||
| 	locationsListAPI := "/restmachine/cloudapi/locations/list" | ||||
| 
 | ||||
| 	locationListRaw, err := c.DecortAPICall(ctx, "POST", locationsListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(locationListRaw), &locationList) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	haveGID := false | ||||
| 
 | ||||
| 	myGID := d.Get("gid").(int) | ||||
| 	for _, location := range locationList { | ||||
| 		if location.GID == myGID { | ||||
| 			haveGID = true | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	return haveGID, nil | ||||
| } | ||||
| func existExtNetID(ctx context.Context, d *schema.ResourceData, m interface{}) (bool, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 	urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) | ||||
| 
 | ||||
| 	listExtNet := []struct { | ||||
| 		ID int `json:"id"` | ||||
| 	}{} | ||||
| 
 | ||||
| 	extNetListAPI := "/restmachine/cloudapi/extnet/list" | ||||
| 
 | ||||
| 	listExtNetRaw, err := c.DecortAPICall(ctx, "POST", extNetListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listExtNetRaw), &listExtNet) | ||||
| 	if err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 
 | ||||
| 	haveExtNet := false | ||||
| 
 | ||||
| 	myExtNetID := d.Get("ext_net_id").(int) | ||||
| 	for _, extNet := range listExtNet { | ||||
| 		if extNet.ID == myExtNetID { | ||||
| 			haveExtNet = true | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
| 	return haveExtNet, nil | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,32 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgAffinityGroupComputesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListAffinityGroupCompute, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 	listGroupComputes := ListAffinityGroupCompute{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	urlValues.Add("affinityGroup", d.Get("affinity_group").(string)) | ||||
| 
 | ||||
| 	listGroupComputesRaw, err := c.DecortAPICall(ctx, "POST", RgAffinityGroupComputesAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(listGroupComputesRaw), &listGroupComputes) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return listGroupComputes, nil | ||||
| } | ||||
| @ -0,0 +1,33 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgAffinityGroupsGetCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) ([]uint64, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 	computes := make([]uint64, 0) | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	urlValues.Add("affinityGroup", d.Get("affinity_group").(string)) | ||||
| 
 | ||||
|     computesRaw, err := c.DecortAPICall(ctx, "POST", RgAffinityGroupsGetAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(computesRaw), &computes) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return computes, nil | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgAffinityGroupsListCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (map[string][]uint64, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 	groups := make(map[string][]uint64, 0) | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 
 | ||||
| 	groupsRaw, err := c.DecortAPICall(ctx, "POST", RgAffinityGroupsListAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(groupsRaw), &groups) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return groups, nil | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgAuditsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListAudits, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 
 | ||||
| 	urlValues := &url.Values{} | ||||
| 	rgAudits := ListAudits{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	rgAuditsRow, err := c.DecortAPICall(ctx, "POST", RgAuditsAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	err = json.Unmarshal([]byte(rgAuditsRow), &rgAudits) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return rgAudits, nil | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgListComputesCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListComputes, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	listComputes := ListComputes{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 	if reason, ok := d.GetOk("reason"); ok { | ||||
| 		urlValues.Add("reason", reason.(string)) | ||||
| 	} | ||||
| 
 | ||||
| 	listComputesRaw, err := c.DecortAPICall(ctx, "POST", RgListComputesAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listComputesRaw), &listComputes) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return listComputes, nil | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgListDeletedCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListResourceGroups, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	rgList := ListResourceGroups{} | ||||
| 
 | ||||
| 	if size, ok := d.GetOk("size"); ok { | ||||
| 		urlValues.Add("size", strconv.Itoa(size.(int))) | ||||
| 	} | ||||
| 	if page, ok := d.GetOk("page"); ok { | ||||
| 		urlValues.Add("page", strconv.Itoa(page.(int))) | ||||
| 	} | ||||
| 
 | ||||
| 	rgListRaw, err := c.DecortAPICall(ctx, "POST", ResgroupListDeletedAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(rgListRaw), &rgList) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return rgList, nil | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgListLbCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListLB, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	listLb := ListLB{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 
 | ||||
| 	listLbRaw, err := c.DecortAPICall(ctx, "POST", ResgroupListLbAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listLbRaw), &listLb) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return listLb, nil | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgListPfwCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListPFW, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	listPfw := ListPFW{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 
 | ||||
| 	listPfwRaw, err := c.DecortAPICall(ctx, "POST", ResgroupListPfwAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listPfwRaw), &listPfw) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return listPfw, nil | ||||
| } | ||||
| @ -0,0 +1,36 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityRgListVinsCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (ListVINS, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := &url.Values{} | ||||
| 
 | ||||
| 	listVins := ListVINS{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 
 | ||||
| 	if val, ok := d.GetOk("reason"); ok { | ||||
| 		urlValues.Add("reason", val.(string)) | ||||
| 	} | ||||
| 
 | ||||
| 	listVinsRaw, err := c.DecortAPICall(ctx, "POST", ResgroupListVinsAPI, urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(listVinsRaw), &listVins) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return listVins, nil | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| package rg | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
| 
 | ||||
| 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||
| 	"github.com/rudecs/terraform-provider-decort/internal/controller" | ||||
| ) | ||||
| 
 | ||||
| func utilityDataRgUsageCheckPresence(ctx context.Context, d *schema.ResourceData, m interface{}) (*Resource, error) { | ||||
| 	c := m.(*controller.ControllerCfg) | ||||
| 	urlValues := url.Values{} | ||||
| 	usage := Resource{} | ||||
| 
 | ||||
| 	urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) | ||||
| 
 | ||||
| 	if reason, ok := d.GetOk("reason"); ok { | ||||
| 		urlValues.Add("reason", reason.(string)) | ||||
| 	} | ||||
| 
 | ||||
| 	usageRaw, err := c.DecortAPICall(ctx, "POST", ResgroupUsageAPI, &urlValues) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	err = json.Unmarshal([]byte(usageRaw), &usage) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	return &usage, nil | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue