From 640152e310b9cab6e0e6450c9a67c2806f8eceb3 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Wed, 18 May 2016 14:37:34 +0200 Subject: [PATCH 1/2] Update `go-cloudstack` dependency --- Godeps/Godeps.json | 4 ++-- .../cloudstack/LoadBalancerService.go | 6 +++--- .../go-cloudstack/cloudstack/cloudstack.go | 20 +++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 58830d9df8..29820cd3f8 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1336,8 +1336,8 @@ }, { "ImportPath": "github.com/xanzy/go-cloudstack/cloudstack", - "Comment": "2.0.0-2-gcfbfb48", - "Rev": "cfbfb481e04c131cb89df1c6141b082f2714bc29" + "Comment": "2.0.0-6-g5686bcd", + "Rev": "5686bcde5af20565d8c7a3f66b5441430ac54186" }, { "ImportPath": "github.com/xanzy/ssh-agent", diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go index c70cf5fb52..06263a3244 100644 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go +++ b/vendor/github.com/xanzy/go-cloudstack/cloudstack/LoadBalancerService.go @@ -2008,12 +2008,12 @@ func (s *LoadBalancerService) ListLoadBalancerRuleInstances(p *ListLoadBalancerR type ListLoadBalancerRuleInstancesResponse struct { Count int `json:"count"` - LoadBalancerRuleInstances []*LoadBalancerRuleInstance `json:"loadbalancerruleinstance"` + LoadBalancerRuleInstances []*LoadBalancerRuleInstance `json:"lbrulevmidip"` } type LoadBalancerRuleInstance struct { - Lbvmipaddresses []string `json:"lbvmipaddresses,omitempty"` - Loadbalancerruleinstance string `json:"loadbalancerruleinstance,omitempty"` + Lbvmipaddresses []string `json:"lbvmipaddresses,omitempty"` + Loadbalancerruleinstance *VirtualMachine `json:"loadbalancerruleinstance,omitempty"` } type UpdateLoadBalancerRuleParams struct { diff --git a/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go b/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go index 53e38bfed2..f52cd34632 100644 --- a/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go +++ b/vendor/github.com/xanzy/go-cloudstack/cloudstack/cloudstack.go @@ -411,6 +411,26 @@ func WithProject(project string) OptionFunc { } } +// VPCIDSetter is an interface that every type that can set a vpc ID must implement +type VPCIDSetter interface { + SetVpcid(string) +} + +// WithVPCID takes a vpc ID and sets the `vpcid` parameter +func WithVPCID(id string) OptionFunc { + return func(cs *CloudStackClient, p interface{}) error { + vs, ok := p.(VPCIDSetter) + + if !ok || id == "" { + return nil + } + + vs.SetVpcid(id) + + return nil + } +} + type APIDiscoveryService struct { cs *CloudStackClient } From 6a08e893e37ee2ca1dde05d36bbee5d8edca790d Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Wed, 18 May 2016 14:43:21 +0200 Subject: [PATCH 2/2] Use the new option to list ACLs based on the ID and VPC ID --- .../resource_cloudstack_network_acl.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builtin/providers/cloudstack/resource_cloudstack_network_acl.go b/builtin/providers/cloudstack/resource_cloudstack_network_acl.go index c39c695d9b..15569d09f3 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_network_acl.go +++ b/builtin/providers/cloudstack/resource_cloudstack_network_acl.go @@ -90,8 +90,22 @@ func resourceCloudStackNetworkACLCreate(d *schema.ResourceData, meta interface{} func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) + vpc, ok := d.GetOk("vpc_id") + if !ok { + vpc, ok = d.GetOk("vpc") + } + if !ok { + return errors.New("Either `vpc_id` or [deprecated] `vpc` must be provided.") + } + + // Retrieve the vpc ID + vpcid, e := retrieveID(cs, "vpc", vpc.(string)) + if e != nil { + return e.Error() + } + // Get the network ACL list details - f, count, err := cs.NetworkACL.GetNetworkACLListByID(d.Id()) + f, count, err := cs.NetworkACL.GetNetworkACLListByID(d.Id(), cloudstack.WithVPCID(vpcid)) if err != nil { if count == 0 { log.Printf(