-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from orange-cloudavenue/18-new-resource-vcd
feat: add vdc resource
- Loading branch information
Showing
7 changed files
with
765 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "cloudavenue_vdc Resource - cloudavenue" | ||
subcategory: "" | ||
description: |- | ||
Provides a Cloud Avenue Organization VDC resource. This can be used to create and delete an Organization VDC. | ||
--- | ||
|
||
# cloudavenue_vdc (Resource) | ||
|
||
Provides a Cloud Avenue Organization VDC resource. This can be used to create and delete an Organization VDC. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "cloudavenue_vdc" "example" { | ||
name = "MyVDC" | ||
vdc_group = "MyVDCGroup" | ||
description = "Example VDC created by Terraform" | ||
cpu_allocated = 6000 | ||
memory_allocated = 10 | ||
cpu_speed_in_mhz = 1200 | ||
billing_model = "PAYG" | ||
disponibility_class = "ONE-ROOM" | ||
service_class = "STD" | ||
storage_billing_model = "PAYG" | ||
storage_profile { | ||
class = "gold" | ||
default = true | ||
limit = 500 | ||
} | ||
storage_profile { | ||
class = "silver" | ||
default = false | ||
limit = 500 | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `billing_model` (String) Choose Billing model of compute resources. It can be `PAYG`, `DRAAS` or `RESERVED`. | ||
- `cpu_allocated` (Number) CPU capacity in *MHz* that is committed to be available or used as a limit in PAYG mode. | ||
It must be at least 5 * `cpu_speed_in_mhz` and at most 200 * `cpu_speed_in_mhz`. | ||
*Note:* Reserved capacity is automatically set according to the service class. | ||
- `cpu_speed_in_mhz` (Number) Specifies the clock frequency, in Mhz, for any virtual CPU that is allocated to a VM. | ||
It must be at least 1200. | ||
- `disponibility_class` (String) The disponibility class of the org VDC. It can be `ONE-ROOM`, `DUAL-ROOM` or `HA-DUAL-ROOM`. | ||
- `memory_allocated` (Number) Memory capacity in Gb that is committed to be available or used as a limit in PAYG mode. | ||
It must be between 1 and 5000. | ||
- `name` (String) The name of the org VDC. It must be unique in the organization. | ||
The length must be between 2 and 27 characters. | ||
- `service_class` (String) The service class of the org VDC. It can be `ECO`, `STD`, `HP` or `VOIP`. | ||
- `storage_billing_model` (String) Choose Billing model of storage resources. It can be `PAYG` or `RESERVED`. | ||
- `vdc_group` (String) Name of an existing VDC group or a new one. This allows you to isolate your VDC. | ||
VMs of VDCs which belong to the same VDC group can communicate together. | ||
|
||
### Optional | ||
|
||
- `description` (String) The description of the org VDC. | ||
- `storage_profile` (Block List) List of storage profiles for this VDC. (see [below for nested schema](#nestedblock--storage_profile)) | ||
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) ID is the Name of the VCD. | ||
|
||
<a id="nestedblock--storage_profile"></a> | ||
### Nested Schema for `storage_profile` | ||
|
||
Required: | ||
|
||
- `class` (String) The storage class of the storage profile. | ||
It can be `silver`, `silver_r1`, `silver_r2`, `gold`, `gold_r1`, `gold_r2`, `gold_hm`, `platinum3k`, `platinum3k_r1`, `platinum3k_r2`, `platinum3k_hm`, `platinum7k`, `platinum7k_r1`, `platinum7k_r2`, `platinum7k_hm`. | ||
- `default` (Boolean) Set this storage profile as default for this VDC. Only one storage profile can be default per VDC. | ||
- `limit` (Number) Max number of units allocated for this storage profile. In Gb. It must be between 500 and 10000. | ||
|
||
|
||
<a id="nestedatt--timeouts"></a> | ||
### Nested Schema for `timeouts` | ||
|
||
Optional: | ||
|
||
- `create` (String) | ||
- `delete` (String) | ||
- `read` (String) | ||
- `update` (String) | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# VDC can be imported using the name. | ||
|
||
terraform import cloudavenue_vdc.vdc name | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# VDC can be imported using the name. | ||
|
||
terraform import cloudavenue_vdc.vdc name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
resource "cloudavenue_vdc" "example" { | ||
name = "MyVDC" | ||
vdc_group = "MyVDCGroup" | ||
description = "Example VDC created by Terraform" | ||
cpu_allocated = 6000 | ||
memory_allocated = 10 | ||
cpu_speed_in_mhz = 1200 | ||
billing_model = "PAYG" | ||
disponibility_class = "ONE-ROOM" | ||
service_class = "STD" | ||
storage_billing_model = "PAYG" | ||
|
||
storage_profile { | ||
class = "gold" | ||
default = true | ||
limit = 500 | ||
} | ||
|
||
storage_profile { | ||
class = "silver" | ||
default = false | ||
limit = 500 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
package provider | ||
|
||
import "context" | ||
import ( | ||
"context" | ||
"strings" | ||
) | ||
|
||
type JobStatus string | ||
|
||
const ( | ||
DONE JobStatus = "DONE" | ||
FAILED JobStatus = "FAILED" | ||
CREATED JobStatus = "CREATED" | ||
PENDING JobStatus = "PENDING" | ||
INPROGRESS JobStatus = "IN_PROGRESS" | ||
ERROR JobStatus = "ERROR" | ||
) | ||
|
||
// getJobStatus is a helper function to get the status of a job. | ||
func getJobStatus(ctx context.Context, client *CloudAvenueClient, jobID string) (string, error) { | ||
func getJobStatus(ctx context.Context, client *CloudAvenueClient, jobID string) (JobStatus, error) { | ||
jobStatus, _, err := client.JobsApi.ApiCustomersV10JobsJobIdGet(ctx, jobID) | ||
if err != nil { | ||
return "", err | ||
} | ||
return jobStatus[0].Status, nil | ||
return parseJobStatus(jobStatus[0].Status), nil | ||
} | ||
|
||
// parseJobStatus return the status of a job. | ||
func parseJobStatus(str string) JobStatus { | ||
switch str { | ||
case "DONE": | ||
return DONE | ||
case "FAILED": | ||
return FAILED | ||
case "CREATED": | ||
return CREATED | ||
case "PENDING": | ||
return PENDING | ||
case "IN_PROGRESS": | ||
return INPROGRESS | ||
default: | ||
return "" | ||
} | ||
} | ||
|
||
// Stringer interface for JobStatus | ||
func (j JobStatus) String() string { | ||
return strings.ToLower(string(j)) | ||
} | ||
|
||
// IsDone is a helper function to check if a job is done. | ||
func (j JobStatus) IsDone() bool { | ||
return j == DONE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.