-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First draft of computeprofile resource Implements the resource and refactors the data source. The compute_attributes JSON is more tricky to handle, needs more testing and validation. * Extend compute_profiles with compute_attributes Implements creation and deletion of compute profiles and their own compute attributes. The most difficult part is the separate creation of compute attributes, and the combined parsing to create a single struct from both API sources. Terraform understands multiple formats: strings (jsonencode..), lists, maps etc. This implementation uses maps in the schema. See examples/compute_profiles for reference. * compute profiles: add resourceForemanComputeprofileRead; fix list init * Compute profile: add custom JSON marshaller to ForemanComputeAttribute Adds a custom marshalling func to ForemanComputeAttribute to handle the JSONified attributes (e.g. boot_order and interfaces_attributes). Also adds a more complex example, see examples/compute_profile/ * Comp Profile: remove "name" attr from compute attributes Signed-off-by: Dominik Pataky <[email protected]> * Compute profiles: fix parsing and marshalling of compute attributes The compute attributes are more difficult to handle, since they are very dynamically configurable in the Terraform manifests. This commit improves JSON marshalling and unmarshalling and type handling. Especially the correct setting of id and name of compute attributes was reworked, and tested. Signed-off-by: Dominik Pataky <[email protected]> * Implement update func for compute profiles Handles updates from Terraform for compute profiles and their respective compute attributes. Signed-off-by: Dominik Pataky <[email protected]> --------- Signed-off-by: Dominik Pataky <[email protected]>
- Loading branch information
Showing
9 changed files
with
540 additions
and
40 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
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,31 @@ | ||
|
||
# foreman_computeprofile | ||
|
||
|
||
Foreman representation of a compute profile. | ||
|
||
|
||
## Example Usage | ||
|
||
``` | ||
# Autogenerated example with required keys | ||
resource "foreman_computeprofile" "example" { | ||
} | ||
``` | ||
|
||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
- `compute_attributes` - (Required) List of compute attributes | ||
- `name` - (Required) Name of the compute profile | ||
|
||
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: | ||
|
||
- `compute_attributes` - List of compute attributes | ||
- `name` - Name of the compute profile | ||
|
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,24 @@ | ||
resource "foreman_computeprofile" "vmware_webserver" { | ||
name = "VMware Webserver" | ||
|
||
compute_attributes { | ||
name = "Webserver middle (2 CPUs and 16GB memory)" | ||
compute_resource_id = data.foreman_computeresource.vmware.id | ||
|
||
vm_attrs = { | ||
cpus = 2 | ||
corespersocket = 1 | ||
memory_mb = 16384 | ||
firmware = "bios" | ||
resource_pool = "pool1" | ||
guest_id = "ubuntu64Guest" | ||
|
||
boot_order = jsonencode([ "disk", "network" ]) | ||
|
||
interfaces_attributes = jsonencode({ | ||
0: { type: "VirtualE1000", network: "dmz-net" }, | ||
1: { type: "VirtualE1000", network: "webserver-net" } } | ||
) | ||
} | ||
} | ||
} |
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,15 @@ | ||
data "foreman_computeresource" "vmware" { | ||
name = "VMware Cluster ABC" | ||
} | ||
|
||
resource "foreman_computeprofile" "Small VM" { | ||
name = "Small VM" | ||
|
||
compute_attributes { | ||
compute_resource_id = data.foreman_computeresource.vmware.id | ||
vm_attrs = { | ||
cpus = 2 | ||
memory_mb = 4096 | ||
} | ||
} | ||
} |
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.