Skip to content

Commit

Permalink
Vm update name issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vanarajaz committed Feb 9, 2022
1 parent 890eec2 commit c636e32
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 35 deletions.
97 changes: 90 additions & 7 deletions examples/instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ variable "coffee_name" {
# zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
# }

resource "stackbill_network" "my-server" {
description = "terraform test"
name = "terraform volume teo"
network_offering_uuid = "19c28a5d-0237-450d-b47a-dbddc67aa0df"
virtual_machine_uuid = "4d9150e6-64b5-451a-8851-0a4ea5142242"
zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
}
# resource "stackbill_network" "my-server" {
# description = "terraform test"
# name = "terraform volume teo"
# network_offering_uuid = "19c28a5d-0237-450d-b47a-dbddc67aa0df"
# virtual_machine_uuid = "4d9150e6-64b5-451a-8851-0a4ea5142242"
# zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
# }
# resource "stackbill_network_attach" "my-server" {
# network_uuid = "80934451-21e7-4bb3-be39-30a8d14db2ac"
# virutal_machine_uuid = "4d9150e6-64b5-451a-8851-0a4ea5142242"
Expand Down Expand Up @@ -124,3 +124,86 @@ resource "stackbill_network" "my-server" {
# ssh_key_name
# storage_offering_uuid
# network_uuid


# This is required for Terraform 0.13+
# terraform {
# required_providers {
# stackbill = {
# version = "~> 1.0.0"
# source = "stackbill.com/assistanz/stackbill"
# }
# }
# }

# provider "stackbill" {
# url = "http://wolfapp.assistanz24x7.com/restapi"
# api_key = "NqkTfkADuBFCNid2ypPViqq3M2vMOQddtjLyIQJ84LygYkppwfO1DZFCZX5H"
# secret_key = "H_eRcufZShygDM2ZV6g94gA9ecmgE9cKGTZ31VOkGXE72EiupuMnhuMZd0hs"
# }


#creating stackbill_instance
# resource "stackbill_instance" "my-server" {
# compute_offering_uuid = "c674ac49-32cd-4aae-96f8-25458bded6ad"
# cpu_core = "3"
# disk_size = 0
# hypervisor_name = "XenServer"
# # memory = "0"
# name = "AzTestingVmOne"
# network_uuid = "f385c6af-a900-415d-a131-44d1fc6ae4e3"

# # security_group_name = "string"
# # ssh_key_name = "string"
# storage_offering_uuid = "45ac1fe4-9e40-47d2-81a3-7dd98811bf27"
# template_uuid = "670dc0de-8958-449e-a217-262f666c2fa6"
# zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
# }

# #updating VM status
# resource "stackbill_instance_actions" "status" {
# uuid = stackbill_instance.my-server.id
# action = "Stop"
# }

# #updating display name
# resource "stackbill_instance_update_name" "update_name" {
# uuid = stackbill_instance.my-server.id
# name = "TerraformTestVM"
# }

#resizing VM
resource "stackbill_instance_resize" "resize" {
uuid = "c7e8ba23-0c79-47ab-9fd3-5158ba275c64"
compute_offering_uuid = "c674ac49-32cd-4aae-96f8-25458bded6ad"
cpu_core = "4"
memory = "512"
}

# creating network
resource "stackbill_network" "TerraformNetwork" {
description = "network created to test terraform"
name = "TerraformNetwork"
# virtual_machine_uuid = stackbill_instance.my-server.id
network_offering_uuid = "19c28a5d-0237-450d-b47a-dbddc67aa0df"
zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
is_public = "true"
}

# #creating new volume
resource "stackbill_volume" "newvolume" {
disk_size = 1024
name = "ExtraVolumeForTerrformVM"
storage_offering_uuid = "728e9c82-506d-4afb-a26f-3f74688e0740"
zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
}


# #creating snapshot
resource "stackbill_instance_snapshot" "snapshot" {
name = "terraform_VM_Snapshot"
description = "snapshot of VM created with terraform"
virtual_machine_uuid = "c7e8ba23-0c79-47ab-9fd3-5158ba275c64"
zone_uuid = "74b12720-73ce-49b6-857f-48cdac6dcd3f"
snapshot_memory = "0"
}
69 changes: 66 additions & 3 deletions examples/instance/terraform.tfstate.backup
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 4,
"terraform_version": "1.1.2",
"serial": 1,
"lineage": "5d5f0756-7a3e-5ba9-0bd5-7962d49c7bf9",
"serial": 9,
"lineage": "093cfe80-65ef-d20d-d6a8-9d1dab601e7b",
"outputs": {
"stackbill_security_group_list": {
"value": [
Expand Down Expand Up @@ -160,7 +160,7 @@
{
"schema_version": 0,
"attributes": {
"id": "1644384821",
"id": "1644405135",
"length": 2,
"securitygroups": [
{
Expand Down Expand Up @@ -247,6 +247,69 @@
"sensitive_attributes": []
}
]
},
{
"mode": "managed",
"type": "stackbill_instance_resize",
"name": "resize",
"provider": "provider[\"stackbill.com/assistanz/stackbill\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"compute_offering_uuid": "c674ac49-32cd-4aae-96f8-25458bded6ad",
"cpu_core": "4",
"id": "c7e8ba23-0c79-47ab-9fd3-5158ba275c64",
"memory": "512",
"uuid": "c7e8ba23-0c79-47ab-9fd3-5158ba275c64"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
},
{
"mode": "managed",
"type": "stackbill_network",
"name": "TerraformNetwork",
"provider": "provider[\"stackbill.com/assistanz/stackbill\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"description": "network created to test terraform",
"id": "3d33d968-3e81-4da9-953a-a0c013b0e5ac",
"is_public": true,
"name": "TerraformNetwork",
"network_offering_uuid": "19c28a5d-0237-450d-b47a-dbddc67aa0df",
"security_group_id": null,
"virtual_machine_uuid": null,
"zone_uuid": "74b12720-73ce-49b6-857f-48cdac6dcd3f"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
},
{
"mode": "managed",
"type": "stackbill_volume",
"name": "newvolume",
"provider": "provider[\"stackbill.com/assistanz/stackbill\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"disk_size": 1024,
"id": "94a9f590-ed57-4285-a03a-a0456ee135fb",
"name": "ExtraVolumeForTerrformVM",
"storage_offering_uuid": "728e9c82-506d-4afb-a26f-3f74688e0740",
"zone_uuid": "74b12720-73ce-49b6-857f-48cdac6dcd3f"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
}
]
}
13 changes: 1 addition & 12 deletions instance/instance_resize_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@ func (ir *instanceResizeResource) Create(ctx context.Context, d *schema.Resource
return diag.FromErr(err)
}
// Wait to start or stop the instance
time.Sleep(20 * time.Second)
for {
status, err := instanceApiObj.GetInstanceStatus(uuid, meta)
if err != nil {
log.Println(err.Error())
break
}
if status == "RUNNING" {
break
}
time.Sleep(10 * time.Second)
}
time.Sleep(2 * time.Second)
output := utils.FormatJsonString(response)
log.Println(output)
log.Println("Instance resize successful...!")
Expand Down
4 changes: 2 additions & 2 deletions network/network_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (nt *networkUtils) GetCreateNetworkOptionalRequest(d *schema.ResourceData)
// TODO - Documentation
func (nt *networkUtils) GetNetworkActionRequest(d *schema.ResourceData) map[string]interface{} {
request := make(map[string]interface{})
request["networkUuid"] = d.Get("network_uuid").(bool)
request["uuid"] = d.Get("virutal_machine_uuid").(bool)
request["networkUuid"] = d.Get("network_uuid").(string)
request["uuid"] = d.Get("virutal_machine_uuid").(string)
return request
}
8 changes: 4 additions & 4 deletions snapshot/vmsnapshot_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ type vmSnapshotUtils struct {
// TODO - Documentation
func (vs *vmSnapshotUtils) GetVmSnapshotRequest(d *schema.ResourceData) map[string]interface{} {
request := make(map[string]interface{})
request["description"] = d.Get("description").(bool)
request["name"] = d.Get("name").(bool)
request["description"] = d.Get("description").(string)
request["name"] = d.Get("name").(string)
request["snapshotMemory"] = d.Get("snapshot_memory").(bool)
request["virtualmachineUuid"] = d.Get("virtual_machine_uuid").(bool)
request["zoneUuid"] = d.Get("zone_uuid").(bool)
request["virtualmachineUuid"] = d.Get("virtual_machine_uuid").(string)
request["zoneUuid"] = d.Get("zone_uuid").(string)
return request
}
Binary file modified terraform-provider-stackbill
Binary file not shown.
14 changes: 7 additions & 7 deletions volume/volume_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ type volumeUtils struct {
// TODO - Documentation
func (vu *volumeUtils) GetVolumeActionRequest(d *schema.ResourceData) map[string]interface{} {
request := make(map[string]interface{})
request["action"] = d.Get("action").(bool)
request["instanceUuid"] = d.Get("instance_uuid").(bool)
request["uuid"] = d.Get("uuid").(bool)
request["action"] = d.Get("action").(string)
request["instanceUuid"] = d.Get("instance_uuid").(string)
request["uuid"] = d.Get("uuid").(string)
return request
}

// Create Instance
// TODO - Documentation
func (vu *volumeUtils) GetVolumeCreateRequest(d *schema.ResourceData) map[string]interface{} {
request := make(map[string]interface{})
request["name"] = d.Get("name").(bool)
request["diskSize"] = d.Get("disk_size").(bool)
request["storageOfferingUuid"] = d.Get("storage_offering_uuid").(bool)
request["zoneUuid"] = d.Get("zone_uuid").(bool)
request["name"] = d.Get("name").(string)
request["diskSize"] = d.Get("disk_size").(int)
request["storageOfferingUuid"] = d.Get("storage_offering_uuid").(string)
request["zoneUuid"] = d.Get("zone_uuid").(string)
return request
}

0 comments on commit c636e32

Please sign in to comment.