Updating some logic and tests

These fixes are needed to make the provider work with master again.
These are still some issues, but they seem not to be related to the
provider, but the changes in `helper/schema`.
This commit is contained in:
Sander van Harmelen 2015-01-15 11:29:04 +01:00
parent 3898098c78
commit 19776ba402
6 changed files with 30 additions and 17 deletions

View File

@ -397,6 +397,11 @@ func resourceCloudStackEgressFirewallDeleteRule(
uuids := rule["uuids"].(map[string]interface{})
for k, id := range uuids {
// We don't care about the count here, so just continue
if k == "#" {
continue
}
// Create the parameter struct
p := cs.Firewall.NewDeleteEgressFirewallRuleParams(id.(string))

View File

@ -111,7 +111,7 @@ func testAccCheckCloudStackEgressFirewallRulesExist(n string) resource.TestCheck
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}
@ -144,7 +144,7 @@ func testAccCheckCloudStackEgressFirewallDestroy(s *terraform.State) error {
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}
@ -165,25 +165,23 @@ resource "cloudstack_egress_firewall" "foo" {
ipaddress = "%s"
rule {
source_cidr = "10.0.0.0/24"
source_cidr = "%s/32"
protocol = "tcp"
ports = ["80", "1000-2000"]
}
}`, CLOUDSTACK_NETWORK_1)
}`,
CLOUDSTACK_NETWORK_1,
CLOUDSTACK_NETWORK_1_IPADDRESS)
var testAccCloudStackEgressFirewall_update = fmt.Sprintf(`
resource "cloudstack_egress_firewall" "foo" {
ipaddress = "%s"
rule {
source_cidr = "10.0.0.0/24"
source_cidr = "%s/32"
protocol = "tcp"
ports = ["80", "1000-2000"]
ports = ["80", "443", 1000-2000"]
}
rule {
source_cidr = "172.16.100.0/24"
protocol = "tcp"
ports = ["80", "443"]
}
}`, CLOUDSTACK_NETWORK_1)
}`,
CLOUDSTACK_NETWORK_1,
CLOUDSTACK_NETWORK_1_IPADDRESS)

View File

@ -393,6 +393,11 @@ func resourceCloudStackFirewallDeleteRule(
uuids := rule["uuids"].(map[string]interface{})
for k, id := range uuids {
// We don't care about the count here, so just continue
if k == "#" {
continue
}
// Create the parameter struct
p := cs.Firewall.NewDeleteFirewallRuleParams(id.(string))

View File

@ -111,7 +111,7 @@ func testAccCheckCloudStackFirewallRulesExist(n string) resource.TestCheckFunc {
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}
@ -144,7 +144,7 @@ func testAccCheckCloudStackFirewallDestroy(s *terraform.State) error {
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}

View File

@ -417,6 +417,11 @@ func resourceCloudStackNetworkACLRuleDeleteRule(
uuids := rule["uuids"].(map[string]interface{})
for k, id := range uuids {
// We don't care about the count here, so just continue
if k == "#" {
continue
}
// Create the parameter struct
p := cs.NetworkACL.NewDeleteNetworkACLParams(id.(string))

View File

@ -123,7 +123,7 @@ func testAccCheckCloudStackNetworkACLRulesExist(n string) resource.TestCheckFunc
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}
@ -156,7 +156,7 @@ func testAccCheckCloudStackNetworkACLRuleDestroy(s *terraform.State) error {
}
for k, uuid := range rs.Primary.Attributes {
if !strings.Contains(k, "uuids") {
if !strings.Contains(k, ".uuids.") || strings.HasSuffix(k, ".uuids.#") {
continue
}