|
|
@ -85,8 +85,8 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
computeCreateAPI := KvmX86CreateAPI
|
|
|
|
computeCreateAPI := KvmX86CreateAPI
|
|
|
|
arch := d.Get("arch").(string)
|
|
|
|
driver := d.Get("driver").(string)
|
|
|
|
if arch == "KVM_PPC" {
|
|
|
|
if driver == "KVM_PPC" {
|
|
|
|
computeCreateAPI = KvmPPCCreateAPI
|
|
|
|
computeCreateAPI = KvmPPCCreateAPI
|
|
|
|
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM PowerPC")
|
|
|
|
log.Debugf("resourceComputeCreate: creating Compute of type KVM VM PowerPC")
|
|
|
|
} else { // note that we do not validate arch value for explicit "KVM_X86" here
|
|
|
|
} else { // note that we do not validate arch value for explicit "KVM_X86" here
|
|
|
@ -163,6 +163,7 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
|
|
|
|
|
|
|
|
// Note bene: we created compute in a STOPPED state (this is required to properly attach 1st network interface),
|
|
|
|
// Note bene: we created compute in a STOPPED state (this is required to properly attach 1st network interface),
|
|
|
|
// now we need to start it before we report the sequence complete
|
|
|
|
// now we need to start it before we report the sequence complete
|
|
|
|
|
|
|
|
if d.Get("started").(bool) {
|
|
|
|
reqValues := &url.Values{}
|
|
|
|
reqValues := &url.Values{}
|
|
|
|
reqValues.Add("computeId", fmt.Sprintf("%d", compId))
|
|
|
|
reqValues.Add("computeId", fmt.Sprintf("%d", compId))
|
|
|
|
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", compId)
|
|
|
|
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", compId)
|
|
|
@ -170,6 +171,7 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", compId, d.Get("name").(string))
|
|
|
|
log.Debugf("resourceComputeCreate: new Compute ID %d, name %s creation sequence complete", compId, d.Get("name").(string))
|
|
|
|
|
|
|
|
|
|
|
@ -214,6 +216,7 @@ func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
2. Resize (grow) boot disk
|
|
|
|
2. Resize (grow) boot disk
|
|
|
|
3. Update extra disks
|
|
|
|
3. Update extra disks
|
|
|
|
4. Update networks
|
|
|
|
4. Update networks
|
|
|
|
|
|
|
|
5. Start/stop
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// 1. Resize CPU/RAM
|
|
|
|
// 1. Resize CPU/RAM
|
|
|
@ -284,6 +287,21 @@ func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error {
|
|
|
|
d.SetPartial("network")
|
|
|
|
d.SetPartial("network")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if d.HasChange("started") {
|
|
|
|
|
|
|
|
params := &url.Values{}
|
|
|
|
|
|
|
|
params.Add("computeId", d.Id())
|
|
|
|
|
|
|
|
if d.Get("started").(bool) {
|
|
|
|
|
|
|
|
if _, err := controller.decortAPICall("POST", ComputeStartAPI, params); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if _, err := controller.decortAPICall("POST", ComputeStopAPI, params); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d.SetPartial("started")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
d.Partial(false)
|
|
|
|
d.Partial(false)
|
|
|
|
|
|
|
|
|
|
|
|
// we may reuse dataSourceComputeRead here as we maintain similarity
|
|
|
|
// we may reuse dataSourceComputeRead here as we maintain similarity
|
|
|
@ -398,7 +416,7 @@ func resourceCompute() *schema.Resource {
|
|
|
|
Description: "ID of the resource group where this compute should be deployed.",
|
|
|
|
Description: "ID of the resource group where this compute should be deployed.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
"arch": {
|
|
|
|
"driver": {
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
Required: true,
|
|
|
|
ForceNew: true,
|
|
|
|
ForceNew: true,
|
|
|
@ -473,7 +491,6 @@ func resourceCompute() *schema.Resource {
|
|
|
|
Description: "Optional text description of this compute instance.",
|
|
|
|
Description: "Optional text description of this compute instance.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"cloud_init": {
|
|
|
|
"cloud_init": {
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Optional: true,
|
|
|
|
Optional: true,
|
|
|
@ -516,6 +533,13 @@ func resourceCompute() *schema.Resource {
|
|
|
|
Description: "Guest OS users provisioned on this compute instance.",
|
|
|
|
Description: "Guest OS users provisioned on this compute instance.",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"started": {
|
|
|
|
|
|
|
|
Type: schema.TypeBool,
|
|
|
|
|
|
|
|
Optional: true,
|
|
|
|
|
|
|
|
Default: true,
|
|
|
|
|
|
|
|
Description: "Is compute started.",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
"disks": {
|
|
|
|
"disks": {
|
|
|
|
Type: schema.TypeList,
|
|
|
|
Type: schema.TypeList,
|
|
|
|