Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/testacc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:

echo "CLOUDSTACK_API_KEY=$CLOUDSTACK_API_KEY" >> $GITHUB_ENV
echo "CLOUDSTACK_SECRET_KEY=$CLOUDSTACK_SECRET_KEY" >> $GITHUB_ENV
echo "CLOUDSTACK_TEMPLATE_URL=http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2" >> $GITHUB_ENV
- name: Install CMK
run: |
curl -sfL https://github.com/apache/cloudstack-cloudmonkey/releases/download/6.3.0/cmk.linux.x86-64 -o /usr/local/bin/cmk
Expand All @@ -81,6 +82,7 @@ jobs:
ports:
- 8080:5050
strategy:
fail-fast: false
matrix:
cloudstack_version:
- 4.17.2.0
Expand Down
5 changes: 2 additions & 3 deletions cloudstack/data_source_cloudstack_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ const testAccInstanceDataSourceConfig_basic = `
resource "cloudstack_instance" "my_instance" {
name = "server-a"
service_offering = "Small Instance"
network_id = "b9c953a0-8686-4240-b8a4-43849f7079ff"
template = "CentOS 5.5(64-bit) no GUI (KVM)"
zone = "DC"
template = "CentOS 5.6 (64-bit) no GUI (Simulator)"
zone = "Sandbox-simulator"
}
data "cloudstack_instance" "my_instance_test" {
filter {
Expand Down
4 changes: 2 additions & 2 deletions cloudstack/data_source_cloudstack_ipaddress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ func TestAccIPAddressDataSource_basic(t *testing.T) {

const testIPAddressDataSourceConfig_basic = `
resource "cloudstack_ipaddress" "ipaddress-resource" {
zone = "DC"
zone = "Sandbox-simulator"
}

data "cloudstack_ipaddress" "ipaddress-data-source"{
filter{
name = "zone_name"
value= "DC"
value= "Sandbox-simulator"
}
depends_on = [
cloudstack_ipaddress.ipaddress-resource
Expand Down
28 changes: 13 additions & 15 deletions cloudstack/data_source_cloudstack_service_offering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

func TestAccServiceOfferingDataSource_basic(t *testing.T) {
resourceName := "cloudstack_service_offering.service-offering-resource"
datasourceName := "cloudstack_service_offering.service-offering-data-source"
datasourceName := "data.cloudstack_service_offering.service-offering-data-source"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -45,18 +45,16 @@ func TestAccServiceOfferingDataSource_basic(t *testing.T) {
}

const testServiceOfferingDataSourceConfig_basic = `
resource "cloudstack_service_offering" "service-offering-resource"{
name = "TestServiceUpdate"
display_text = "DisplayService"
}
resource "cloudstack_service_offering" "service-offering-resource" {
name = "TestServiceUpdate"
display_text = "DisplayService"
}

data "cloudstack_service_offering" "service-offering-data-source"{
filter{
name = "name"
value="TestServiceUpdate"
}
depends_on = [
cloudstack_service_offering.service-resource
]
}
`
data "cloudstack_service_offering" "service-offering-data-source" {
filter {
name = "name"
value = "TestServiceUpdate"
}
depends_on = [cloudstack_service_offering.service-offering-resource]
}
`
35 changes: 23 additions & 12 deletions cloudstack/data_source_cloudstack_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,30 @@ func TestAccVolumeDataSource_basic(t *testing.T) {
}

const testVolumeDataSourceConfig_basic = `
resource "cloudstack_disk_offering" "disk-offering" {
name = "TestDiskOffering"
display_text = "TestDiskOffering"
disk_size = 1
}

data "cloudstack_zone" "zone-data-source" {
filter {
name = "name"
value = "Sandbox-simulator"
}
}

resource "cloudstack_volume" "volume-resource"{
name = "TestVolume"
disk_offering_id = "0038adec-5e3e-47df-b4b4-77b5dc8e3338"
zone_id = "9a7002b2-09a2-44dc-a332-f2e4e7f01539"
name = "TestVolume"
disk_offering_id = "${cloudstack_disk_offering.disk-offering.id}"
zone_id = "${data.cloudstack_zone.zone-data-source.id}"
}

data "cloudstack_volume" "volume-data-source"{
filter{
name = "name"
value="TestVolume"
data "cloudstack_volume" "volume-data-source"{
filter {
name = "name"
value = "TestVolume"
}
depends_on = [
cloudstack_volume.volume-resource
]
}
`
depends_on = [cloudstack_volume.volume-resource]
}
`
2 changes: 1 addition & 1 deletion cloudstack/data_source_cloudstack_vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "cloudstack_vpc" "vpc-resource" {
name = "test-vpc"
cidr = "10.0.0.0/16"
vpc_offering = "Default VPC Offering"
zone = "DC"
zone = "Sandbox-simulator"
}

data "cloudstack_vpc" "vpc-data-source"{
Expand Down
4 changes: 2 additions & 2 deletions cloudstack/resource_cloudstack_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestAccCloudStackInstance_import(t *testing.T) {
ResourceName: "cloudstack_instance.foobar",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"expunge", "user_data"},
ImportStateVerifyIgnore: []string{"expunge", "user_data", "uefi"},
},
},
})
Expand All @@ -206,7 +206,7 @@ func TestAccCloudStackInstance_importProject(t *testing.T) {
ImportState: true,
ImportStateIdPrefix: "terraform/",
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"expunge", "user_data"},
ImportStateVerifyIgnore: []string{"expunge", "user_data", "uefi"},
},
},
})
Expand Down
2 changes: 1 addition & 1 deletion cloudstack/resource_cloudstack_private_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func resourceCloudStackPrivateGatewayRead(d *schema.ResourceData, meta interface
d.Set("gateway", gw.Gateway)
d.Set("ip_address", gw.Ipaddress)
d.Set("netmask", gw.Netmask)
d.Set("vlan", gw.Vlan)
d.Set("vlan", strings.Replace(gw.Vlan, "vlan://", "", -1))
d.Set("acl_id", gw.Aclid)
d.Set("vpc_id", gw.Vpcid)

Expand Down
2 changes: 2 additions & 0 deletions cloudstack/resource_cloudstack_private_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ resource "cloudstack_vpc" "foo" {
resource "cloudstack_network_acl" "foo" {
name = "terraform-acl"
vpc_id = "${cloudstack_vpc.foo.id}"
depends_on = ["cloudstack_vpc.foo"]
}

resource "cloudstack_private_gateway" "foo" {
Expand All @@ -157,4 +158,5 @@ resource "cloudstack_private_gateway" "foo" {
vlan = "1"
vpc_id = "${cloudstack_vpc.foo.id}"
acl_id = "${cloudstack_network_acl.foo.id}"
depends_on = ["cloudstack_vpc.foo","cloudstack_network_acl.foo"]
}`
28 changes: 18 additions & 10 deletions cloudstack/resource_cloudstack_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,30 @@ func resourceCloudStackTemplateRead(d *schema.ResourceData, meta interface{}) er
p := cs.Template.NewListTemplatesParams("executable")
p.SetId(d.Id())
p.SetShowunique(true)
p.SetProjectid(d.Get("project").(string))
project := d.Get("project").(string)
if project != "" {
if !cloudstack.IsID(project) {
id, _, err := cs.Project.GetProjectID(project)
if err != nil {
return err
}
project = id
}
p.SetProjectid(project)
}

r, err := cs.Template.ListTemplates(p)
count := r.Count
t := r.Templates[0]
if err != nil {
if count == 0 {
log.Printf(
"[DEBUG] Template %s no longer exists", d.Get("name").(string))
d.SetId("")
return nil
}

return err
} else if r.Count == 0 {
log.Printf(
"[DEBUG] Template %s no longer exists", d.Get("name").(string))
d.SetId("")
return nil
}

t := r.Templates[0]

d.Set("name", t.Name)
d.Set("display_text", t.Displaytext)
d.Set("format", t.Format)
Expand Down
12 changes: 6 additions & 6 deletions cloudstack/resource_cloudstack_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ func testAccCheckCloudStackTemplateBasicAttributes(
return fmt.Errorf("Bad name: %s", template.Name)
}

if template.Format != "QCOW2" {
if template.Format != "VHD" {
return fmt.Errorf("Bad format: %s", template.Format)
}

if template.Hypervisor != "Simulator" {
return fmt.Errorf("Bad hypervisor: %s", template.Hypervisor)
}

if template.Ostypename != "Centos 5.6 (64-bit)" {
if template.Ostypename != "CentOS 5.6 (64-bit)" {
return fmt.Errorf("Bad os type: %s", template.Ostypename)
}

Expand Down Expand Up @@ -189,9 +189,9 @@ func testAccCheckCloudStackTemplateDestroy(s *terraform.State) error {
var testAccCloudStackTemplate_basic = fmt.Sprintf(`
resource "cloudstack_template" "foo" {
name = "terraform-test"
format = "QCOW2"
format = "VHD"
hypervisor = "Simulator"
os_type = "Centos 5.6 (64-bit)"
os_type = "CentOS 5.6 (64-bit)"
url = "%s"
zone = "Sandbox-simulator"
tags = {
Expand All @@ -203,9 +203,9 @@ var testAccCloudStackTemplate_update = fmt.Sprintf(`
resource "cloudstack_template" "foo" {
name = "terraform-test"
display_text = "terraform-updated"
format = "QCOW2"
format = "VHD"
hypervisor = "Simulator"
os_type = "Centos 5.6 (64-bit)"
os_type = "CentOS 5.6 (64-bit)"
url = "%s"
is_dynamically_scalable = true
password_enabled = true
Expand Down