Add ability to manage cloudstack affinity groups (#8360)

Add documentation for cloudstack affinity group resource

Implement improvements from review by svanharmelen

Update to latest go-cloudstack v2.1.3
This commit is contained in:
Bart van der Schans 2016-09-01 10:48:49 +02:00 committed by Sander van Harmelen
parent 92a9a7c8b8
commit 0835b64456
48 changed files with 782 additions and 449 deletions

View File

@ -41,6 +41,7 @@ func Provider() terraform.ResourceProvider {
}, },
ResourcesMap: map[string]*schema.Resource{ ResourcesMap: map[string]*schema.Resource{
"cloudstack_affinity_group": resourceCloudStackAffinityGroup(),
"cloudstack_disk": resourceCloudStackDisk(), "cloudstack_disk": resourceCloudStackDisk(),
"cloudstack_egress_firewall": resourceCloudStackEgressFirewall(), "cloudstack_egress_firewall": resourceCloudStackEgressFirewall(),
"cloudstack_firewall": resourceCloudStackFirewall(), "cloudstack_firewall": resourceCloudStackFirewall(),

View File

@ -66,6 +66,9 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("CLOUDSTACK_2ND_NIC_NETWORK"); v == "" { if v := os.Getenv("CLOUDSTACK_2ND_NIC_NETWORK"); v == "" {
t.Fatal("CLOUDSTACK_2ND_NIC_NETWORK must be set for acceptance tests") t.Fatal("CLOUDSTACK_2ND_NIC_NETWORK must be set for acceptance tests")
} }
if v := os.Getenv("CLOUDSTACK_AFFINITY_GROUP_TYPE"); v == "" {
t.Fatal("CLOUDSTACK_AFFINITY_GROUP_TYPE must be set for acceptance tests")
}
if v := os.Getenv("CLOUDSTACK_DISK_OFFERING_1"); v == "" { if v := os.Getenv("CLOUDSTACK_DISK_OFFERING_1"); v == "" {
t.Fatal("CLOUDSTACK_DISK_OFFERING_1 must be set for acceptance tests") t.Fatal("CLOUDSTACK_DISK_OFFERING_1 must be set for acceptance tests")
} }
@ -146,6 +149,9 @@ func testAccPreCheck(t *testing.T) {
} }
} }
// Name of an affinity group type
var CLOUDSTACK_AFFINITY_GROUP_TYPE = os.Getenv("CLOUDSTACK_AFFINITY_GROUP_TYPE")
// Name of a valid disk offering // Name of a valid disk offering
var CLOUDSTACK_DISK_OFFERING_1 = os.Getenv("CLOUDSTACK_DISK_OFFERING_1") var CLOUDSTACK_DISK_OFFERING_1 = os.Getenv("CLOUDSTACK_DISK_OFFERING_1")

View File

@ -0,0 +1,128 @@
package cloudstack
import (
"fmt"
"log"
"strings"
"github.com/hashicorp/terraform/helper/schema"
"github.com/xanzy/go-cloudstack/cloudstack"
)
func resourceCloudStackAffinityGroup() *schema.Resource {
return &schema.Resource{
Create: resourceCloudStackAffinityGroupCreate,
Read: resourceCloudStackAffinityGroupRead,
Delete: resourceCloudStackAffinityGroupDelete,
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"type": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
},
}
}
func resourceCloudStackAffinityGroupCreate(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
name := d.Get("name").(string)
affinityGroupType := d.Get("type").(string)
log.Printf("[DEBUG] creating affinity group with name %s of type %s", name, affinityGroupType)
p := cs.AffinityGroup.NewCreateAffinityGroupParams(name, affinityGroupType)
// Set the description
if description, ok := d.GetOk("description"); ok {
p.SetDescription(description.(string))
}
// If there is a project supplied, we retrieve and set the project id
if err := setProjectid(p, cs, d); err != nil {
return err
}
r, err := cs.AffinityGroup.CreateAffinityGroup(p)
if err != nil {
return err
}
log.Printf("[DEBUG] New affinity group successfully created")
d.SetId(r.Id)
return resourceCloudStackAffinityGroupRead(d, meta)
}
func resourceCloudStackAffinityGroupRead(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
log.Printf("[DEBUG] looking for affinity group with name %s", d.Id())
// Get the affinity group details
ag, count, err := cs.AffinityGroup.GetAffinityGroupByID(d.Id(), cloudstack.WithProject(d.Get("project").(string)))
if err != nil {
if count == 0 {
log.Printf("[DEBUG] Affinity group %s does not longer exist", d.Id())
d.SetId("")
return nil
}
return err
}
//Affinity group name is unique in a cloudstack account so dont need to check for multiple
d.Set("name", ag.Name)
d.Set("description", ag.Description)
d.Set("type", ag.Type)
return nil
}
func resourceCloudStackAffinityGroupDelete(d *schema.ResourceData, meta interface{}) error {
cs := meta.(*cloudstack.CloudStackClient)
// Create a new parameter struct
p := cs.AffinityGroup.NewDeleteAffinityGroupParams()
// Set id
p.SetId(d.Id())
// If there is a project supplied, we retrieve and set the project id
if err := setProjectid(p, cs, d); err != nil {
return err
}
// Remove the affinity group
_, err := cs.AffinityGroup.DeleteAffinityGroup(p)
if err != nil {
// This is a very poor way to be told the ID does no longer exist :(
if strings.Contains(err.Error(), fmt.Sprintf(
"Invalid parameter id value=%s due to incorrect long value format, "+
"or entity does not exist", d.Id())) {
return nil
}
return fmt.Errorf("Error deleting affinity group: %s", err)
}
return nil
}

View File

@ -0,0 +1,142 @@
package cloudstack
import (
"fmt"
"strings"
"testing"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/xanzy/go-cloudstack/cloudstack"
)
func TestAccCloudStackAffinityGroup_basic(t *testing.T) {
var affinityGroup cloudstack.AffinityGroup
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackAffinityGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCloudStackAffinityGroupPair,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackAffinityGroupExists("terraform-test-affinity-group", &affinityGroup),
testAccCheckCloudStackAffinityGroupAttributes(&affinityGroup),
testAccCheckCloudStackAffinityGroupCreateAttributes("terraform-test-affinity-group"),
),
},
},
})
}
func testAccCheckCloudStackAffinityGroupExists(n string, affinityGroup *cloudstack.AffinityGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}
if rs.Primary.ID == "" {
return fmt.Errorf("No affinity group ID is set")
}
cs := testAccProvider.Meta().(*cloudstack.CloudStackClient)
p := cs.AffinityGroup.NewListAffinityGroupsParams()
p.SetName(rs.Primary.ID)
list, err := cs.AffinityGroup.ListAffinityGroups(p)
if err != nil {
return err
}
if list.Count != 1 || list.AffinityGroups[0].Name != rs.Primary.ID {
return fmt.Errorf("Affinity group not found")
}
*affinityGroup = *list.AffinityGroups[0]
return nil
}
}
func testAccCheckCloudStackAffinityGroupAttributes(
affinityGroup *cloudstack.AffinityGroup) resource.TestCheckFunc {
return func(s *terraform.State) error {
if affinityGroup.Type != CLOUDSTACK_AFFINITY_GROUP_TYPE {
return fmt.Errorf("Affinity group: Attribute type expected %s, got %s",
CLOUDSTACK_AFFINITY_GROUP_TYPE, affinityGroup.Type)
}
return nil
}
}
func testAccCheckCloudStackAffinityGroupCreateAttributes(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
found := false
for _, rs := range s.RootModule().Resources {
if rs.Type != "cloudstack_affinity_group" {
continue
}
if rs.Primary.ID != name {
continue
}
if !strings.Contains(rs.Primary.Attributes["description"], "terraform-test-description") {
return fmt.Errorf(
"Affiity group: Attribute description expected 'terraform-test-description' to be present, got %s",
rs.Primary.Attributes["description"])
}
found = true
break
}
if !found {
return fmt.Errorf("Could not find affinity group %s", name)
}
return nil
}
}
func testAccCheckCloudStackAffinityGroupDestroy(s *terraform.State) error {
cs := testAccProvider.Meta().(*cloudstack.CloudStackClient)
for _, rs := range s.RootModule().Resources {
if rs.Type != "cloudstack_affinity_group" {
continue
}
if rs.Primary.ID == "" {
return fmt.Errorf("No affinity group ID is set")
}
p := cs.AffinityGroup.NewListAffinityGroupsParams()
p.SetName(rs.Primary.ID)
r, err := cs.AffinityGroup.ListAffinityGroups(p)
if err != nil {
return err
}
for i := 0; i < r.Count; i++ {
if r.AffinityGroups[i].Id == rs.Primary.ID {
return fmt.Errorf("Affinity group %s still exists", rs.Primary.ID)
}
}
}
return nil
}
var testAccCloudStackAffinityGroupPair = fmt.Sprintf(`
resource "cloudstack_affinity_group" "foo" {
name = "terraform-test-affinty-group"
type = "%s"
description = "terraform-test-description"
}`, CLOUDSTACK_AFFINITY_GROUP_TYPE)

View File

@ -45,20 +45,21 @@ func retrieveID(cs *cloudstack.CloudStackClient, name string, value string, opts
log.Printf("[DEBUG] Retrieving ID of %s: %s", name, value) log.Printf("[DEBUG] Retrieving ID of %s: %s", name, value)
// Ignore counts, since an error is returned if there is no exact match
var err error var err error
switch name { switch name {
case "disk_offering": case "disk_offering":
id, err = cs.DiskOffering.GetDiskOfferingID(value) id, _, err = cs.DiskOffering.GetDiskOfferingID(value)
case "service_offering": case "service_offering":
id, err = cs.ServiceOffering.GetServiceOfferingID(value) id, _, err = cs.ServiceOffering.GetServiceOfferingID(value)
case "network_offering": case "network_offering":
id, err = cs.NetworkOffering.GetNetworkOfferingID(value) id, _, err = cs.NetworkOffering.GetNetworkOfferingID(value)
case "project": case "project":
id, err = cs.Project.GetProjectID(value) id, _, err = cs.Project.GetProjectID(value)
case "vpc_offering": case "vpc_offering":
id, err = cs.VPC.GetVPCOfferingID(value) id, _, err = cs.VPC.GetVPCOfferingID(value)
case "zone": case "zone":
id, err = cs.Zone.GetZoneID(value) id, _, err = cs.Zone.GetZoneID(value)
case "os_type": case "os_type":
p := cs.GuestOS.NewListOsTypesParams() p := cs.GuestOS.NewListOsTypesParams()
p.SetDescription(value) p.SetDescription(value)
@ -92,7 +93,8 @@ func retrieveTemplateID(cs *cloudstack.CloudStackClient, zoneid, value string) (
log.Printf("[DEBUG] Retrieving ID of template: %s", value) log.Printf("[DEBUG] Retrieving ID of template: %s", value)
id, err := cs.Template.GetTemplateID(value, "executable", zoneid) // Ignore count, since an error is returned if there is no exact match
id, _, err := cs.Template.GetTemplateID(value, "executable", zoneid)
if err != nil { if err != nil {
return id, &retrieveError{name: "template", value: value, err: err} return id, &retrieveError{name: "template", value: value, err: err}
} }

View File

@ -1130,7 +1130,7 @@ func (s *AccountService) NewListAccountsParams() *ListAccountsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string, error) { func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListAccountsParams{} p := &ListAccountsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1138,38 +1138,38 @@ func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListAccounts(p) l, err := s.ListAccounts(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Accounts[0].Id, nil return l.Accounts[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Accounts { for _, v := range l.Accounts {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetAccountByName(name string, opts ...OptionFunc) (*Account, int, error) { func (s *AccountService) GetAccountByName(name string, opts ...OptionFunc) (*Account, int, error) {
id, err := s.GetAccountID(name, opts...) id, count, err := s.GetAccountID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetAccountByID(id, opts...) r, count, err := s.GetAccountByID(id, opts...)
@ -1728,7 +1728,7 @@ func (s *AccountService) NewListProjectAccountsParams(projectid string) *ListPro
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AccountService) GetProjectAccountID(keyword string, projectid string, opts ...OptionFunc) (string, error) { func (s *AccountService) GetProjectAccountID(keyword string, projectid string, opts ...OptionFunc) (string, int, error) {
p := &ListProjectAccountsParams{} p := &ListProjectAccountsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1737,31 +1737,31 @@ func (s *AccountService) GetProjectAccountID(keyword string, projectid string, o
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListProjectAccounts(p) l, err := s.ListProjectAccounts(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.ProjectAccounts[0].Id, nil return l.ProjectAccounts[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.ProjectAccounts { for _, v := range l.ProjectAccounts {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// Lists project's accounts // Lists project's accounts

View File

@ -98,7 +98,7 @@ func (p *CreateAffinityGroupParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["affinityGroupType"] = v p.p["type"] = v
return return
} }
@ -108,7 +108,7 @@ func (s *AffinityGroupService) NewCreateAffinityGroupParams(name string, affinit
p := &CreateAffinityGroupParams{} p := &CreateAffinityGroupParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["name"] = name p.p["name"] = name
p.p["affinityGroupType"] = affinityGroupType p.p["type"] = affinityGroupType
return p return p
} }
@ -406,7 +406,7 @@ func (p *ListAffinityGroupsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["affinityGroupType"] = v p.p["type"] = v
return return
} }
@ -427,7 +427,7 @@ func (s *AffinityGroupService) NewListAffinityGroupsParams() *ListAffinityGroups
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFunc) (string, error) { func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListAffinityGroupsParams{} p := &ListAffinityGroupsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -435,38 +435,42 @@ func (s *AffinityGroupService) GetAffinityGroupID(name string, opts ...OptionFun
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListAffinityGroups(p) l, err := s.ListAffinityGroups(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
// This is needed because of a bug with the listAffinityGroup call. It reports the
// number of VirtualMachines in the groups as being the number of groups found.
l.Count = len(l.AffinityGroups)
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.AffinityGroups[0].Id, nil return l.AffinityGroups[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.AffinityGroups { for _, v := range l.AffinityGroups {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AffinityGroupService) GetAffinityGroupByName(name string, opts ...OptionFunc) (*AffinityGroup, int, error) { func (s *AffinityGroupService) GetAffinityGroupByName(name string, opts ...OptionFunc) (*AffinityGroup, int, error) {
id, err := s.GetAffinityGroupID(name, opts...) id, count, err := s.GetAffinityGroupID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetAffinityGroupByID(id, opts...) r, count, err := s.GetAffinityGroupByID(id, opts...)
@ -499,6 +503,10 @@ func (s *AffinityGroupService) GetAffinityGroupByID(id string, opts ...OptionFun
return nil, -1, err return nil, -1, err
} }
// This is needed because of a bug with the listAffinityGroup call. It reports the
// number of VirtualMachines in the groups as being the number of groups found.
l.Count = len(l.AffinityGroups)
if l.Count == 0 { if l.Count == 0 {
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
} }

View File

@ -100,7 +100,7 @@ func (p *ListAlertsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["alertType"] = v p.p["type"] = v
return return
} }
@ -113,7 +113,7 @@ func (s *AlertService) NewListAlertsParams() *ListAlertsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AlertService) GetAlertID(name string, opts ...OptionFunc) (string, error) { func (s *AlertService) GetAlertID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListAlertsParams{} p := &ListAlertsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -121,38 +121,38 @@ func (s *AlertService) GetAlertID(name string, opts ...OptionFunc) (string, erro
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListAlerts(p) l, err := s.ListAlerts(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Alerts[0].Id, nil return l.Alerts[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Alerts { for _, v := range l.Alerts {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AlertService) GetAlertByName(name string, opts ...OptionFunc) (*Alert, int, error) { func (s *AlertService) GetAlertByName(name string, opts ...OptionFunc) (*Alert, int, error) {
id, err := s.GetAlertID(name, opts...) id, count, err := s.GetAlertID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetAlertByID(id, opts...) r, count, err := s.GetAlertByID(id, opts...)
@ -275,7 +275,7 @@ func (p *ArchiveAlertsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["alertType"] = v p.p["type"] = v
return return
} }
@ -359,7 +359,7 @@ func (p *DeleteAlertsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["alertType"] = v p.p["type"] = v
return return
} }
@ -446,7 +446,7 @@ func (p *GenerateAlertParams) SetType(v int) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["alertType"] = v p.p["type"] = v
return return
} }
@ -465,7 +465,7 @@ func (s *AlertService) NewGenerateAlertParams(description string, name string, a
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["description"] = description p.p["description"] = description
p.p["name"] = name p.p["name"] = name
p.p["alertType"] = alertType p.p["type"] = alertType
return p return p
} }

View File

@ -1134,7 +1134,7 @@ func (s *AutoScaleService) NewListCountersParams() *ListCountersParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string, error) { func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListCountersParams{} p := &ListCountersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1142,38 +1142,38 @@ func (s *AutoScaleService) GetCounterID(name string, opts ...OptionFunc) (string
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListCounters(p) l, err := s.ListCounters(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Counters[0].Id, nil return l.Counters[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Counters { for _, v := range l.Counters {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) { func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) {
id, err := s.GetCounterID(name, opts...) id, count, err := s.GetCounterID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetCounterByID(id, opts...) r, count, err := s.GetCounterByID(id, opts...)

View File

@ -636,7 +636,7 @@ func (s *ClusterService) NewListClustersParams() *ListClustersParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ClusterService) GetClusterID(name string, opts ...OptionFunc) (string, error) { func (s *ClusterService) GetClusterID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListClustersParams{} p := &ListClustersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -644,38 +644,38 @@ func (s *ClusterService) GetClusterID(name string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListClusters(p) l, err := s.ListClusters(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Clusters[0].Id, nil return l.Clusters[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Clusters { for _, v := range l.Clusters {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ClusterService) GetClusterByName(name string, opts ...OptionFunc) (*Cluster, int, error) { func (s *ClusterService) GetClusterByName(name string, opts ...OptionFunc) (*Cluster, int, error) {
id, err := s.GetClusterID(name, opts...) id, count, err := s.GetClusterID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetClusterByID(id, opts...) r, count, err := s.GetClusterByID(id, opts...)

View File

@ -562,7 +562,7 @@ func (s *DiskOfferingService) NewListDiskOfferingsParams() *ListDiskOfferingsPar
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DiskOfferingService) GetDiskOfferingID(name string, opts ...OptionFunc) (string, error) { func (s *DiskOfferingService) GetDiskOfferingID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListDiskOfferingsParams{} p := &ListDiskOfferingsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -570,38 +570,38 @@ func (s *DiskOfferingService) GetDiskOfferingID(name string, opts ...OptionFunc)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListDiskOfferings(p) l, err := s.ListDiskOfferings(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.DiskOfferings[0].Id, nil return l.DiskOfferings[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.DiskOfferings { for _, v := range l.DiskOfferings {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DiskOfferingService) GetDiskOfferingByName(name string, opts ...OptionFunc) (*DiskOffering, int, error) { func (s *DiskOfferingService) GetDiskOfferingByName(name string, opts ...OptionFunc) (*DiskOffering, int, error) {
id, err := s.GetDiskOfferingID(name, opts...) id, count, err := s.GetDiskOfferingID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetDiskOfferingByID(id, opts...) r, count, err := s.GetDiskOfferingByID(id, opts...)

View File

@ -448,7 +448,7 @@ func (s *DomainService) NewListDomainsParams() *ListDomainsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainID(name string, opts ...OptionFunc) (string, error) { func (s *DomainService) GetDomainID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListDomainsParams{} p := &ListDomainsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -456,38 +456,38 @@ func (s *DomainService) GetDomainID(name string, opts ...OptionFunc) (string, er
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListDomains(p) l, err := s.ListDomains(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Domains[0].Id, nil return l.Domains[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Domains { for _, v := range l.Domains {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainByName(name string, opts ...OptionFunc) (*Domain, int, error) { func (s *DomainService) GetDomainByName(name string, opts ...OptionFunc) (*Domain, int, error) {
id, err := s.GetDomainID(name, opts...) id, count, err := s.GetDomainID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetDomainByID(id, opts...) r, count, err := s.GetDomainByID(id, opts...)
@ -699,7 +699,7 @@ func (s *DomainService) NewListDomainChildrenParams() *ListDomainChildrenParams
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (string, error) { func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListDomainChildrenParams{} p := &ListDomainChildrenParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -707,38 +707,38 @@ func (s *DomainService) GetDomainChildrenID(name string, opts ...OptionFunc) (st
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListDomainChildren(p) l, err := s.ListDomainChildren(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.DomainChildren[0].Id, nil return l.DomainChildren[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.DomainChildren { for _, v := range l.DomainChildren {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *DomainService) GetDomainChildrenByName(name string, opts ...OptionFunc) (*DomainChildren, int, error) { func (s *DomainService) GetDomainChildrenByName(name string, opts ...OptionFunc) (*DomainChildren, int, error) {
id, err := s.GetDomainChildrenID(name, opts...) id, count, err := s.GetDomainChildrenID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetDomainChildrenByID(id, opts...) r, count, err := s.GetDomainChildrenByID(id, opts...)
@ -912,7 +912,7 @@ func (p *LinkDomainToLdapParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["domainType"] = v p.p["type"] = v
return return
} }
@ -924,7 +924,7 @@ func (s *DomainService) NewLinkDomainToLdapParams(accounttype int, domainid stri
p.p["accounttype"] = accounttype p.p["accounttype"] = accounttype
p.p["domainid"] = domainid p.p["domainid"] = domainid
p.p["name"] = name p.p["name"] = name
p.p["domainType"] = domainType p.p["type"] = domainType
return p return p
} }

View File

@ -203,7 +203,7 @@ func (p *ListEventsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["eventType"] = v p.p["type"] = v
return return
} }
@ -379,7 +379,7 @@ func (p *ArchiveEventsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["eventType"] = v p.p["type"] = v
return return
} }
@ -463,7 +463,7 @@ func (p *DeleteEventsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["eventType"] = v p.p["type"] = v
return return
} }

View File

@ -930,7 +930,7 @@ func (p *CreateFirewallRuleParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["firewallType"] = v p.p["type"] = v
return return
} }
@ -1590,7 +1590,7 @@ func (p *CreateEgressFirewallRuleParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["firewallType"] = v p.p["type"] = v
return return
} }

View File

@ -249,7 +249,7 @@ func (s *GuestOSService) NewListOsCategoriesParams() *ListOsCategoriesParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsCategoryID(name string, opts ...OptionFunc) (string, error) { func (s *GuestOSService) GetOsCategoryID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListOsCategoriesParams{} p := &ListOsCategoriesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -257,38 +257,38 @@ func (s *GuestOSService) GetOsCategoryID(name string, opts ...OptionFunc) (strin
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListOsCategories(p) l, err := s.ListOsCategories(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.OsCategories[0].Id, nil return l.OsCategories[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.OsCategories { for _, v := range l.OsCategories {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *GuestOSService) GetOsCategoryByName(name string, opts ...OptionFunc) (*OsCategory, int, error) { func (s *GuestOSService) GetOsCategoryByName(name string, opts ...OptionFunc) (*OsCategory, int, error) {
id, err := s.GetOsCategoryID(name, opts...) id, count, err := s.GetOsCategoryID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetOsCategoryByID(id, opts...) r, count, err := s.GetOsCategoryByID(id, opts...)

View File

@ -1008,7 +1008,7 @@ func (p *ListHostsParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["hostType"] = v p.p["type"] = v
return return
} }
@ -1037,7 +1037,7 @@ func (s *HostService) NewListHostsParams() *ListHostsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostID(name string, opts ...OptionFunc) (string, error) { func (s *HostService) GetHostID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListHostsParams{} p := &ListHostsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1045,38 +1045,38 @@ func (s *HostService) GetHostID(name string, opts ...OptionFunc) (string, error)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListHosts(p) l, err := s.ListHosts(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Hosts[0].Id, nil return l.Hosts[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Hosts { for _, v := range l.Hosts {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostByName(name string, opts ...OptionFunc) (*Host, int, error) { func (s *HostService) GetHostByName(name string, opts ...OptionFunc) (*Host, int, error) {
id, err := s.GetHostID(name, opts...) id, count, err := s.GetHostID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetHostByID(id, opts...) r, count, err := s.GetHostByID(id, opts...)
@ -1255,7 +1255,7 @@ func (s *HostService) NewListHostTagsParams() *ListHostTagsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string, error) { func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListHostTagsParams{} p := &ListHostTagsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1263,31 +1263,31 @@ func (s *HostService) GetHostTagID(keyword string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListHostTags(p) l, err := s.ListHostTags(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.HostTags[0].Id, nil return l.HostTags[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.HostTags { for _, v := range l.HostTags {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// Lists host tags // Lists host tags

View File

@ -754,7 +754,7 @@ func (s *ISOService) NewListIsosParams() *ListIsosParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts ...OptionFunc) (string, error) { func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts ...OptionFunc) (string, int, error) {
p := &ListIsosParams{} p := &ListIsosParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -764,38 +764,38 @@ func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string, opts
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListIsos(p) l, err := s.ListIsos(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Isos[0].Id, nil return l.Isos[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Isos { for _, v := range l.Isos {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error) { func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid, opts...) id, count, err := s.GetIsoID(name, isofilter, zoneid, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetIsoByID(id, opts...) r, count, err := s.GetIsoByID(id, opts...)
@ -1770,7 +1770,6 @@ func (s *ISOService) GetIsoPermissionByID(id string, opts ...OptionFunc) (*IsoPe
p := &ListIsoPermissionsParams{} p := &ListIsoPermissionsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id p.p["id"] = id
for _, fn := range opts { for _, fn := range opts {

View File

@ -419,7 +419,7 @@ func (s *ImageStoreService) NewListImageStoresParams() *ListImageStoresParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetImageStoreID(name string, opts ...OptionFunc) (string, error) { func (s *ImageStoreService) GetImageStoreID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListImageStoresParams{} p := &ListImageStoresParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -427,38 +427,38 @@ func (s *ImageStoreService) GetImageStoreID(name string, opts ...OptionFunc) (st
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListImageStores(p) l, err := s.ListImageStores(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.ImageStores[0].Id, nil return l.ImageStores[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.ImageStores { for _, v := range l.ImageStores {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetImageStoreByName(name string, opts ...OptionFunc) (*ImageStore, int, error) { func (s *ImageStoreService) GetImageStoreByName(name string, opts ...OptionFunc) (*ImageStore, int, error) {
id, err := s.GetImageStoreID(name, opts...) id, count, err := s.GetImageStoreID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetImageStoreByID(id, opts...) r, count, err := s.GetImageStoreByID(id, opts...)
@ -801,7 +801,7 @@ func (s *ImageStoreService) NewListSecondaryStagingStoresParams() *ListSecondary
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetSecondaryStagingStoreID(name string, opts ...OptionFunc) (string, error) { func (s *ImageStoreService) GetSecondaryStagingStoreID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListSecondaryStagingStoresParams{} p := &ListSecondaryStagingStoresParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -809,38 +809,38 @@ func (s *ImageStoreService) GetSecondaryStagingStoreID(name string, opts ...Opti
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListSecondaryStagingStores(p) l, err := s.ListSecondaryStagingStores(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.SecondaryStagingStores[0].Id, nil return l.SecondaryStagingStores[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.SecondaryStagingStores { for _, v := range l.SecondaryStagingStores {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) { func (s *ImageStoreService) GetSecondaryStagingStoreByName(name string, opts ...OptionFunc) (*SecondaryStagingStore, int, error) {
id, err := s.GetSecondaryStagingStoreID(name, opts...) id, count, err := s.GetSecondaryStagingStoreID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetSecondaryStagingStoreByID(id, opts...) r, count, err := s.GetSecondaryStagingStoreByID(id, opts...)

View File

@ -831,7 +831,7 @@ func (s *InternalLBService) NewListInternalLoadBalancerVMsParams() *ListInternal
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerVMID(name string, opts ...OptionFunc) (string, error) { func (s *InternalLBService) GetInternalLoadBalancerVMID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListInternalLoadBalancerVMsParams{} p := &ListInternalLoadBalancerVMsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -839,38 +839,38 @@ func (s *InternalLBService) GetInternalLoadBalancerVMID(name string, opts ...Opt
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListInternalLoadBalancerVMs(p) l, err := s.ListInternalLoadBalancerVMs(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.InternalLoadBalancerVMs[0].Id, nil return l.InternalLoadBalancerVMs[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.InternalLoadBalancerVMs { for _, v := range l.InternalLoadBalancerVMs {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) { func (s *InternalLBService) GetInternalLoadBalancerVMByName(name string, opts ...OptionFunc) (*InternalLoadBalancerVM, int, error) {
id, err := s.GetInternalLoadBalancerVMID(name, opts...) id, count, err := s.GetInternalLoadBalancerVMID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetInternalLoadBalancerVMByID(id, opts...) r, count, err := s.GetInternalLoadBalancerVMByID(id, opts...)

View File

@ -1067,7 +1067,7 @@ func (s *LoadBalancerService) NewListLoadBalancerRulesParams() *ListLoadBalancer
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionFunc) (string, error) { func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListLoadBalancerRulesParams{} p := &ListLoadBalancerRulesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1075,38 +1075,38 @@ func (s *LoadBalancerService) GetLoadBalancerRuleID(name string, opts ...OptionF
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListLoadBalancerRules(p) l, err := s.ListLoadBalancerRules(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.LoadBalancerRules[0].Id, nil return l.LoadBalancerRules[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.LoadBalancerRules { for _, v := range l.LoadBalancerRules {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string, opts ...OptionFunc) (*LoadBalancerRule, int, error) { func (s *LoadBalancerService) GetLoadBalancerRuleByName(name string, opts ...OptionFunc) (*LoadBalancerRule, int, error) {
id, err := s.GetLoadBalancerRuleID(name, opts...) id, count, err := s.GetLoadBalancerRuleID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetLoadBalancerRuleByID(id, opts...) r, count, err := s.GetLoadBalancerRuleByID(id, opts...)
@ -1959,11 +1959,10 @@ func (s *LoadBalancerService) NewListLoadBalancerRuleInstancesParams(id string)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerRuleInstanceByID(id string, opts ...OptionFunc) (*LoadBalancerRuleInstance, int, error) { func (s *LoadBalancerService) GetLoadBalancerRuleInstanceByID(id string, opts ...OptionFunc) (*VirtualMachine, int, error) {
p := &ListLoadBalancerRuleInstancesParams{} p := &ListLoadBalancerRuleInstancesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id p.p["id"] = id
for _, fn := range opts { for _, fn := range opts {
@ -2008,7 +2007,8 @@ func (s *LoadBalancerService) ListLoadBalancerRuleInstances(p *ListLoadBalancerR
type ListLoadBalancerRuleInstancesResponse struct { type ListLoadBalancerRuleInstancesResponse struct {
Count int `json:"count"` Count int `json:"count"`
LoadBalancerRuleInstances []*LoadBalancerRuleInstance `json:"lbrulevmidip"` LBRuleVMIDIPs []*LoadBalancerRuleInstance `json:"lbrulevmidip,omitempty"`
LoadBalancerRuleInstances []*VirtualMachine `json:"loadbalancerruleinstance,omitempty"`
} }
type LoadBalancerRuleInstance struct { type LoadBalancerRuleInstance struct {
@ -3661,7 +3661,7 @@ func (s *LoadBalancerService) NewListGlobalLoadBalancerRulesParams() *ListGlobal
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string, opts ...OptionFunc) (string, error) { func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListGlobalLoadBalancerRulesParams{} p := &ListGlobalLoadBalancerRulesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -3669,38 +3669,38 @@ func (s *LoadBalancerService) GetGlobalLoadBalancerRuleID(keyword string, opts .
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListGlobalLoadBalancerRules(p) l, err := s.ListGlobalLoadBalancerRules(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.GlobalLoadBalancerRules[0].Id, nil return l.GlobalLoadBalancerRules[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.GlobalLoadBalancerRules { for _, v := range l.GlobalLoadBalancerRules {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) { func (s *LoadBalancerService) GetGlobalLoadBalancerRuleByName(name string, opts ...OptionFunc) (*GlobalLoadBalancerRule, int, error) {
id, err := s.GetGlobalLoadBalancerRuleID(name, opts...) id, count, err := s.GetGlobalLoadBalancerRuleID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetGlobalLoadBalancerRuleByID(id, opts...) r, count, err := s.GetGlobalLoadBalancerRuleByID(id, opts...)
@ -4408,7 +4408,7 @@ func (s *LoadBalancerService) NewListLoadBalancersParams() *ListLoadBalancersPar
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerID(name string, opts ...OptionFunc) (string, error) { func (s *LoadBalancerService) GetLoadBalancerID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListLoadBalancersParams{} p := &ListLoadBalancersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -4416,38 +4416,38 @@ func (s *LoadBalancerService) GetLoadBalancerID(name string, opts ...OptionFunc)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListLoadBalancers(p) l, err := s.ListLoadBalancers(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.LoadBalancers[0].Id, nil return l.LoadBalancers[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.LoadBalancers { for _, v := range l.LoadBalancers {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) { func (s *LoadBalancerService) GetLoadBalancerByName(name string, opts ...OptionFunc) (*LoadBalancer, int, error) {
id, err := s.GetLoadBalancerID(name, opts...) id, count, err := s.GetLoadBalancerID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetLoadBalancerByID(id, opts...) r, count, err := s.GetLoadBalancerByID(id, opts...)

View File

@ -1258,7 +1258,7 @@ func (s *NetworkACLService) NewListNetworkACLListsParams() *ListNetworkACLListsP
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc) (string, error) { func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListNetworkACLListsParams{} p := &ListNetworkACLListsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1266,38 +1266,38 @@ func (s *NetworkACLService) GetNetworkACLListID(name string, opts ...OptionFunc)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNetworkACLLists(p) l, err := s.ListNetworkACLLists(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.NetworkACLLists[0].Id, nil return l.NetworkACLLists[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.NetworkACLLists { for _, v := range l.NetworkACLLists {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkACLService) GetNetworkACLListByName(name string, opts ...OptionFunc) (*NetworkACLList, int, error) { func (s *NetworkACLService) GetNetworkACLListByName(name string, opts ...OptionFunc) (*NetworkACLList, int, error) {
id, err := s.GetNetworkACLListID(name, opts...) id, count, err := s.GetNetworkACLListID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetNetworkACLListByID(id, opts...) r, count, err := s.GetNetworkACLListByID(id, opts...)

View File

@ -808,7 +808,7 @@ func (s *NetworkOfferingService) NewListNetworkOfferingsParams() *ListNetworkOff
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkOfferingService) GetNetworkOfferingID(name string, opts ...OptionFunc) (string, error) { func (s *NetworkOfferingService) GetNetworkOfferingID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListNetworkOfferingsParams{} p := &ListNetworkOfferingsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -816,38 +816,38 @@ func (s *NetworkOfferingService) GetNetworkOfferingID(name string, opts ...Optio
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNetworkOfferings(p) l, err := s.ListNetworkOfferings(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.NetworkOfferings[0].Id, nil return l.NetworkOfferings[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.NetworkOfferings { for _, v := range l.NetworkOfferings {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkOfferingService) GetNetworkOfferingByName(name string, opts ...OptionFunc) (*NetworkOffering, int, error) { func (s *NetworkOfferingService) GetNetworkOfferingByName(name string, opts ...OptionFunc) (*NetworkOffering, int, error) {
id, err := s.GetNetworkOfferingID(name, opts...) id, count, err := s.GetNetworkOfferingID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetNetworkOfferingByID(id, opts...) r, count, err := s.GetNetworkOfferingByID(id, opts...)

View File

@ -906,7 +906,7 @@ func (p *ListNetworksParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["networkType"] = v p.p["type"] = v
return return
} }
@ -935,7 +935,7 @@ func (s *NetworkService) NewListNetworksParams() *ListNetworksParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkID(keyword string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetNetworkID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListNetworksParams{} p := &ListNetworksParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -943,38 +943,38 @@ func (s *NetworkService) GetNetworkID(keyword string, opts ...OptionFunc) (strin
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNetworks(p) l, err := s.ListNetworks(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Networks[0].Id, nil return l.Networks[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Networks { for _, v := range l.Networks {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkByName(name string, opts ...OptionFunc) (*Network, int, error) { func (s *NetworkService) GetNetworkByName(name string, opts ...OptionFunc) (*Network, int, error) {
id, err := s.GetNetworkID(name, opts...) id, count, err := s.GetNetworkID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetNetworkByID(id, opts...) r, count, err := s.GetNetworkByID(id, opts...)
@ -1788,7 +1788,7 @@ func (s *NetworkService) NewListPhysicalNetworksParams() *ListPhysicalNetworksPa
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPhysicalNetworkID(name string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetPhysicalNetworkID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListPhysicalNetworksParams{} p := &ListPhysicalNetworksParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1796,38 +1796,38 @@ func (s *NetworkService) GetPhysicalNetworkID(name string, opts ...OptionFunc) (
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListPhysicalNetworks(p) l, err := s.ListPhysicalNetworks(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.PhysicalNetworks[0].Id, nil return l.PhysicalNetworks[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.PhysicalNetworks { for _, v := range l.PhysicalNetworks {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPhysicalNetworkByName(name string, opts ...OptionFunc) (*PhysicalNetwork, int, error) { func (s *NetworkService) GetPhysicalNetworkByName(name string, opts ...OptionFunc) (*PhysicalNetwork, int, error) {
id, err := s.GetPhysicalNetworkID(name, opts...) id, count, err := s.GetPhysicalNetworkID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetPhysicalNetworkByID(id, opts...) r, count, err := s.GetPhysicalNetworkByID(id, opts...)
@ -2409,7 +2409,7 @@ func (s *NetworkService) NewListNetworkServiceProvidersParams() *ListNetworkServ
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetworkServiceProviderID(name string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetNetworkServiceProviderID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListNetworkServiceProvidersParams{} p := &ListNetworkServiceProvidersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -2417,31 +2417,31 @@ func (s *NetworkService) GetNetworkServiceProviderID(name string, opts ...Option
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNetworkServiceProviders(p) l, err := s.ListNetworkServiceProviders(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.NetworkServiceProviders[0].Id, nil return l.NetworkServiceProviders[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.NetworkServiceProviders { for _, v := range l.NetworkServiceProviders {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// Lists network serviceproviders for a given physical network. // Lists network serviceproviders for a given physical network.
@ -3122,7 +3122,7 @@ func (s *NetworkService) NewListPaloAltoFirewallNetworksParams(lbdeviceid string
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, int, error) {
p := &ListPaloAltoFirewallNetworksParams{} p := &ListPaloAltoFirewallNetworksParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -3131,31 +3131,31 @@ func (s *NetworkService) GetPaloAltoFirewallNetworkID(keyword string, lbdeviceid
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListPaloAltoFirewallNetworks(p) l, err := s.ListPaloAltoFirewallNetworks(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.PaloAltoFirewallNetworks[0].Id, nil return l.PaloAltoFirewallNetworks[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.PaloAltoFirewallNetworks { for _, v := range l.PaloAltoFirewallNetworks {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// lists network that are using Palo Alto firewall device // lists network that are using Palo Alto firewall device
@ -3323,7 +3323,7 @@ func (s *NetworkService) NewListNetscalerLoadBalancerNetworksParams(lbdeviceid s
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, int, error) {
p := &ListNetscalerLoadBalancerNetworksParams{} p := &ListNetscalerLoadBalancerNetworksParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -3332,31 +3332,31 @@ func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdev
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNetscalerLoadBalancerNetworks(p) l, err := s.ListNetscalerLoadBalancerNetworks(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.NetscalerLoadBalancerNetworks[0].Id, nil return l.NetscalerLoadBalancerNetworks[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.NetscalerLoadBalancerNetworks { for _, v := range l.NetscalerLoadBalancerNetworks {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// lists network that are using a netscaler load balancer device // lists network that are using a netscaler load balancer device
@ -3524,7 +3524,7 @@ func (s *NetworkService) NewListNiciraNvpDeviceNetworksParams(nvpdeviceid string
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid string, opts ...OptionFunc) (string, error) { func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid string, opts ...OptionFunc) (string, int, error) {
p := &ListNiciraNvpDeviceNetworksParams{} p := &ListNiciraNvpDeviceNetworksParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -3533,31 +3533,31 @@ func (s *NetworkService) GetNiciraNvpDeviceNetworkID(keyword string, nvpdeviceid
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListNiciraNvpDeviceNetworks(p) l, err := s.ListNiciraNvpDeviceNetworks(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.NiciraNvpDeviceNetworks[0].Id, nil return l.NiciraNvpDeviceNetworks[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.NiciraNvpDeviceNetworks { for _, v := range l.NiciraNvpDeviceNetworks {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// lists network that are using a nicira nvp device // lists network that are using a nicira nvp device

View File

@ -463,7 +463,7 @@ func (s *PodService) NewListPodsParams() *ListPodsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *PodService) GetPodID(name string, opts ...OptionFunc) (string, error) { func (s *PodService) GetPodID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListPodsParams{} p := &ListPodsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -471,38 +471,38 @@ func (s *PodService) GetPodID(name string, opts ...OptionFunc) (string, error) {
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListPods(p) l, err := s.ListPods(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Pods[0].Id, nil return l.Pods[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Pods { for _, v := range l.Pods {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *PodService) GetPodByName(name string, opts ...OptionFunc) (*Pod, int, error) { func (s *PodService) GetPodByName(name string, opts ...OptionFunc) (*Pod, int, error) {
id, err := s.GetPodID(name, opts...) id, count, err := s.GetPodID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetPodByID(id, opts...) r, count, err := s.GetPodByID(id, opts...)

View File

@ -168,7 +168,7 @@ func (s *PoolService) NewListStoragePoolsParams() *ListStoragePoolsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *PoolService) GetStoragePoolID(name string, opts ...OptionFunc) (string, error) { func (s *PoolService) GetStoragePoolID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListStoragePoolsParams{} p := &ListStoragePoolsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -176,38 +176,38 @@ func (s *PoolService) GetStoragePoolID(name string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListStoragePools(p) l, err := s.ListStoragePools(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.StoragePools[0].Id, nil return l.StoragePools[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.StoragePools { for _, v := range l.StoragePools {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *PoolService) GetStoragePoolByName(name string, opts ...OptionFunc) (*StoragePool, int, error) { func (s *PoolService) GetStoragePoolByName(name string, opts ...OptionFunc) (*StoragePool, int, error) {
id, err := s.GetStoragePoolID(name, opts...) id, count, err := s.GetStoragePoolID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetStoragePoolByID(id, opts...) r, count, err := s.GetStoragePoolByID(id, opts...)

View File

@ -805,7 +805,7 @@ func (s *ProjectService) NewListProjectsParams() *ListProjectsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string, error) { func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListProjectsParams{} p := &ListProjectsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -813,38 +813,38 @@ func (s *ProjectService) GetProjectID(name string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListProjects(p) l, err := s.ListProjects(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Projects[0].Id, nil return l.Projects[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Projects { for _, v := range l.Projects {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ProjectService) GetProjectByName(name string, opts ...OptionFunc) (*Project, int, error) { func (s *ProjectService) GetProjectByName(name string, opts ...OptionFunc) (*Project, int, error) {
id, err := s.GetProjectID(name, opts...) id, count, err := s.GetProjectID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetProjectByID(id, opts...) r, count, err := s.GetProjectByID(id, opts...)

View File

@ -80,7 +80,7 @@ func (s *ResourcetagsService) NewListStorageTagsParams() *ListStorageTagsParams
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ResourcetagsService) GetStorageTagID(keyword string, opts ...OptionFunc) (string, error) { func (s *ResourcetagsService) GetStorageTagID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListStorageTagsParams{} p := &ListStorageTagsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -88,31 +88,31 @@ func (s *ResourcetagsService) GetStorageTagID(keyword string, opts ...OptionFunc
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListStorageTags(p) l, err := s.ListStorageTags(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.StorageTags[0].Id, nil return l.StorageTags[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.StorageTags { for _, v := range l.StorageTags {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// Lists storage tags // Lists storage tags

View File

@ -952,7 +952,7 @@ func (s *RouterService) NewListRoutersParams() *ListRoutersParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetRouterID(name string, opts ...OptionFunc) (string, error) { func (s *RouterService) GetRouterID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListRoutersParams{} p := &ListRoutersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -960,38 +960,38 @@ func (s *RouterService) GetRouterID(name string, opts ...OptionFunc) (string, er
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListRouters(p) l, err := s.ListRouters(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Routers[0].Id, nil return l.Routers[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Routers { for _, v := range l.Routers {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *RouterService) GetRouterByName(name string, opts ...OptionFunc) (*Router, int, error) { func (s *RouterService) GetRouterByName(name string, opts ...OptionFunc) (*Router, int, error) {
id, err := s.GetRouterID(name, opts...) id, count, err := s.GetRouterID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetRouterByID(id, opts...) r, count, err := s.GetRouterByID(id, opts...)

View File

@ -1017,7 +1017,7 @@ func (s *SecurityGroupService) NewListSecurityGroupsParams() *ListSecurityGroups
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...OptionFunc) (string, error) { func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListSecurityGroupsParams{} p := &ListSecurityGroupsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1025,38 +1025,38 @@ func (s *SecurityGroupService) GetSecurityGroupID(keyword string, opts ...Option
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListSecurityGroups(p) l, err := s.ListSecurityGroups(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.SecurityGroups[0].Id, nil return l.SecurityGroups[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.SecurityGroups { for _, v := range l.SecurityGroups {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SecurityGroupService) GetSecurityGroupByName(name string, opts ...OptionFunc) (*SecurityGroup, int, error) { func (s *SecurityGroupService) GetSecurityGroupByName(name string, opts ...OptionFunc) (*SecurityGroup, int, error) {
id, err := s.GetSecurityGroupID(name, opts...) id, count, err := s.GetSecurityGroupID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetSecurityGroupByID(id, opts...) r, count, err := s.GetSecurityGroupByID(id, opts...)

View File

@ -717,7 +717,7 @@ func (s *ServiceOfferingService) NewListServiceOfferingsParams() *ListServiceOff
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...OptionFunc) (string, error) { func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListServiceOfferingsParams{} p := &ListServiceOfferingsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -725,38 +725,38 @@ func (s *ServiceOfferingService) GetServiceOfferingID(name string, opts ...Optio
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListServiceOfferings(p) l, err := s.ListServiceOfferings(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.ServiceOfferings[0].Id, nil return l.ServiceOfferings[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.ServiceOfferings { for _, v := range l.ServiceOfferings {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ServiceOfferingService) GetServiceOfferingByName(name string, opts ...OptionFunc) (*ServiceOffering, int, error) { func (s *ServiceOfferingService) GetServiceOfferingByName(name string, opts ...OptionFunc) (*ServiceOffering, int, error) {
id, err := s.GetServiceOfferingID(name, opts...) id, count, err := s.GetServiceOfferingID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetServiceOfferingByID(id, opts...) r, count, err := s.GetServiceOfferingByID(id, opts...)

View File

@ -374,7 +374,7 @@ func (s *SnapshotService) NewListSnapshotsParams() *ListSnapshotsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotID(name string, opts ...OptionFunc) (string, error) { func (s *SnapshotService) GetSnapshotID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListSnapshotsParams{} p := &ListSnapshotsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -382,38 +382,38 @@ func (s *SnapshotService) GetSnapshotID(name string, opts ...OptionFunc) (string
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListSnapshots(p) l, err := s.ListSnapshots(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Snapshots[0].Id, nil return l.Snapshots[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Snapshots { for _, v := range l.Snapshots {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetSnapshotByName(name string, opts ...OptionFunc) (*Snapshot, int, error) { func (s *SnapshotService) GetSnapshotByName(name string, opts ...OptionFunc) (*Snapshot, int, error) {
id, err := s.GetSnapshotID(name, opts...) id, count, err := s.GetSnapshotID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetSnapshotByID(id, opts...) r, count, err := s.GetSnapshotByID(id, opts...)
@ -1275,7 +1275,7 @@ func (s *SnapshotService) NewListVMSnapshotParams() *ListVMSnapshotParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (string, error) { func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListVMSnapshotParams{} p := &ListVMSnapshotParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1283,31 +1283,31 @@ func (s *SnapshotService) GetVMSnapshotID(name string, opts ...OptionFunc) (stri
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVMSnapshot(p) l, err := s.ListVMSnapshot(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.VMSnapshot[0].Id, nil return l.VMSnapshot[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.VMSnapshot { for _, v := range l.VMSnapshot {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// List virtual machine snapshot by conditions // List virtual machine snapshot by conditions

View File

@ -76,7 +76,7 @@ func (p *ListStorageProvidersParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["storagePoolType"] = v p.p["type"] = v
return return
} }
@ -85,7 +85,7 @@ func (p *ListStorageProvidersParams) SetType(v string) {
func (s *StoragePoolService) NewListStorageProvidersParams(storagePoolType string) *ListStorageProvidersParams { func (s *StoragePoolService) NewListStorageProvidersParams(storagePoolType string) *ListStorageProvidersParams {
p := &ListStorageProvidersParams{} p := &ListStorageProvidersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["storagePoolType"] = storagePoolType p.p["type"] = storagePoolType
return p return p
} }

View File

@ -182,7 +182,7 @@ func (s *SwiftService) NewListSwiftsParams() *ListSwiftsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, error) { func (s *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListSwiftsParams{} p := &ListSwiftsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -190,31 +190,31 @@ func (s *SwiftService) GetSwiftID(keyword string, opts ...OptionFunc) (string, e
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListSwifts(p) l, err := s.ListSwifts(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Swifts[0].Id, nil return l.Swifts[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Swifts { for _, v := range l.Swifts {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// List Swift. // List Swift.

View File

@ -125,7 +125,7 @@ func (p *ListCapacityParams) SetType(v int) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["systemCapacityType"] = v p.p["type"] = v
return return
} }

View File

@ -572,7 +572,7 @@ func (s *SystemVMService) NewListSystemVmsParams() *ListSystemVmsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SystemVMService) GetSystemVmID(name string, opts ...OptionFunc) (string, error) { func (s *SystemVMService) GetSystemVmID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListSystemVmsParams{} p := &ListSystemVmsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -580,38 +580,38 @@ func (s *SystemVMService) GetSystemVmID(name string, opts ...OptionFunc) (string
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListSystemVms(p) l, err := s.ListSystemVms(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.SystemVms[0].Id, nil return l.SystemVms[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.SystemVms { for _, v := range l.SystemVms {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *SystemVMService) GetSystemVmByName(name string, opts ...OptionFunc) (*SystemVm, int, error) { func (s *SystemVMService) GetSystemVmByName(name string, opts ...OptionFunc) (*SystemVm, int, error) {
id, err := s.GetSystemVmID(name, opts...) id, count, err := s.GetSystemVmID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetSystemVmByID(id, opts...) r, count, err := s.GetSystemVmByID(id, opts...)

View File

@ -1314,7 +1314,7 @@ func (s *TemplateService) NewListTemplatesParams(templatefilter string) *ListTem
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplateID(name string, templatefilter string, zoneid string, opts ...OptionFunc) (string, error) { func (s *TemplateService) GetTemplateID(name string, templatefilter string, zoneid string, opts ...OptionFunc) (string, int, error) {
p := &ListTemplatesParams{} p := &ListTemplatesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1324,38 +1324,38 @@ func (s *TemplateService) GetTemplateID(name string, templatefilter string, zone
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListTemplates(p) l, err := s.ListTemplates(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Templates[0].Id, nil return l.Templates[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Templates { for _, v := range l.Templates {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *TemplateService) GetTemplateByName(name string, templatefilter string, zoneid string, opts ...OptionFunc) (*Template, int, error) { func (s *TemplateService) GetTemplateByName(name string, templatefilter string, zoneid string, opts ...OptionFunc) (*Template, int, error) {
id, err := s.GetTemplateID(name, templatefilter, zoneid, opts...) id, count, err := s.GetTemplateID(name, templatefilter, zoneid, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetTemplateByID(id, templatefilter, opts...) r, count, err := s.GetTemplateByID(id, templatefilter, opts...)
@ -1627,7 +1627,6 @@ func (s *TemplateService) GetTemplatePermissionByID(id string, opts ...OptionFun
p := &ListTemplatePermissionsParams{} p := &ListTemplatePermissionsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
p.p["id"] = id
p.p["id"] = id p.p["id"] = id
for _, fn := range opts { for _, fn := range opts {

View File

@ -202,7 +202,7 @@ func (s *UCSService) NewListUcsManagersParams() *ListUcsManagersParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *UCSService) GetUcsManagerID(keyword string, opts ...OptionFunc) (string, error) { func (s *UCSService) GetUcsManagerID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListUcsManagersParams{} p := &ListUcsManagersParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -210,38 +210,38 @@ func (s *UCSService) GetUcsManagerID(keyword string, opts ...OptionFunc) (string
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListUcsManagers(p) l, err := s.ListUcsManagers(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.UcsManagers[0].Id, nil return l.UcsManagers[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.UcsManagers { for _, v := range l.UcsManagers {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *UCSService) GetUcsManagerByName(name string, opts ...OptionFunc) (*UcsManager, int, error) { func (s *UCSService) GetUcsManagerByName(name string, opts ...OptionFunc) (*UcsManager, int, error) {
id, err := s.GetUcsManagerID(name, opts...) id, count, err := s.GetUcsManagerID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetUcsManagerByID(id, opts...) r, count, err := s.GetUcsManagerByID(id, opts...)

View File

@ -325,7 +325,7 @@ func (s *UsageService) NewListTrafficTypesParams(physicalnetworkid string) *List
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string, opts ...OptionFunc) (string, error) { func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string, opts ...OptionFunc) (string, int, error) {
p := &ListTrafficTypesParams{} p := &ListTrafficTypesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -334,31 +334,31 @@ func (s *UsageService) GetTrafficTypeID(keyword string, physicalnetworkid string
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListTrafficTypes(p) l, err := s.ListTrafficTypes(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.TrafficTypes[0].Id, nil return l.TrafficTypes[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.TrafficTypes { for _, v := range l.TrafficTypes {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// Lists traffic types of a given physical network. // Lists traffic types of a given physical network.
@ -811,7 +811,7 @@ func (p *ListUsageRecordsParams) SetType(v int64) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["usageType"] = v p.p["type"] = v
return return
} }

View File

@ -368,7 +368,7 @@ func (s *VMGroupService) NewListInstanceGroupsParams() *ListInstanceGroupsParams
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VMGroupService) GetInstanceGroupID(name string, opts ...OptionFunc) (string, error) { func (s *VMGroupService) GetInstanceGroupID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListInstanceGroupsParams{} p := &ListInstanceGroupsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -376,38 +376,38 @@ func (s *VMGroupService) GetInstanceGroupID(name string, opts ...OptionFunc) (st
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListInstanceGroups(p) l, err := s.ListInstanceGroups(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.InstanceGroups[0].Id, nil return l.InstanceGroups[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.InstanceGroups { for _, v := range l.InstanceGroups {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VMGroupService) GetInstanceGroupByName(name string, opts ...OptionFunc) (*InstanceGroup, int, error) { func (s *VMGroupService) GetInstanceGroupByName(name string, opts ...OptionFunc) (*InstanceGroup, int, error) {
id, err := s.GetInstanceGroupID(name, opts...) id, count, err := s.GetInstanceGroupID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetInstanceGroupByID(id, opts...) r, count, err := s.GetInstanceGroupByID(id, opts...)

View File

@ -578,7 +578,7 @@ func (s *VPCService) NewListVPCsParams() *ListVPCsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCID(name string, opts ...OptionFunc) (string, error) { func (s *VPCService) GetVPCID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListVPCsParams{} p := &ListVPCsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -586,38 +586,38 @@ func (s *VPCService) GetVPCID(name string, opts ...OptionFunc) (string, error) {
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVPCs(p) l, err := s.ListVPCs(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.VPCs[0].Id, nil return l.VPCs[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.VPCs { for _, v := range l.VPCs {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCByName(name string, opts ...OptionFunc) (*VPC, int, error) { func (s *VPCService) GetVPCByName(name string, opts ...OptionFunc) (*VPC, int, error) {
id, err := s.GetVPCID(name, opts...) id, count, err := s.GetVPCID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetVPCByID(id, opts...) r, count, err := s.GetVPCByID(id, opts...)
@ -1818,7 +1818,7 @@ func (s *VPCService) NewListVPCOfferingsParams() *ListVPCOfferingsParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCOfferingID(name string, opts ...OptionFunc) (string, error) { func (s *VPCService) GetVPCOfferingID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListVPCOfferingsParams{} p := &ListVPCOfferingsParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1826,38 +1826,38 @@ func (s *VPCService) GetVPCOfferingID(name string, opts ...OptionFunc) (string,
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVPCOfferings(p) l, err := s.ListVPCOfferings(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.VPCOfferings[0].Id, nil return l.VPCOfferings[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.VPCOfferings { for _, v := range l.VPCOfferings {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPCService) GetVPCOfferingByName(name string, opts ...OptionFunc) (*VPCOffering, int, error) { func (s *VPCService) GetVPCOfferingByName(name string, opts ...OptionFunc) (*VPCOffering, int, error) {
id, err := s.GetVPCOfferingID(name, opts...) id, count, err := s.GetVPCOfferingID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetVPCOfferingByID(id, opts...) r, count, err := s.GetVPCOfferingByID(id, opts...)

View File

@ -2097,7 +2097,7 @@ func (s *VPNService) NewListVpnCustomerGatewaysParams() *ListVpnCustomerGateways
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnCustomerGatewayID(keyword string, opts ...OptionFunc) (string, error) { func (s *VPNService) GetVpnCustomerGatewayID(keyword string, opts ...OptionFunc) (string, int, error) {
p := &ListVpnCustomerGatewaysParams{} p := &ListVpnCustomerGatewaysParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -2105,38 +2105,38 @@ func (s *VPNService) GetVpnCustomerGatewayID(keyword string, opts ...OptionFunc)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVpnCustomerGateways(p) l, err := s.ListVpnCustomerGateways(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.VpnCustomerGateways[0].Id, nil return l.VpnCustomerGateways[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.VpnCustomerGateways { for _, v := range l.VpnCustomerGateways {
if v.Name == keyword { if v.Name == keyword {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VPNService) GetVpnCustomerGatewayByName(name string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) { func (s *VPNService) GetVpnCustomerGatewayByName(name string, opts ...OptionFunc) (*VpnCustomerGateway, int, error) {
id, err := s.GetVpnCustomerGatewayID(name, opts...) id, count, err := s.GetVpnCustomerGatewayID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetVpnCustomerGatewayByID(id, opts...) r, count, err := s.GetVpnCustomerGatewayByID(id, opts...)

View File

@ -2592,7 +2592,7 @@ func (s *VirtualMachineService) NewListVirtualMachinesParams() *ListVirtualMachi
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionFunc) (string, error) { func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListVirtualMachinesParams{} p := &ListVirtualMachinesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -2600,38 +2600,38 @@ func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionF
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVirtualMachines(p) l, err := s.ListVirtualMachines(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.VirtualMachines[0].Id, nil return l.VirtualMachines[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.VirtualMachines { for _, v := range l.VirtualMachines {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VirtualMachineService) GetVirtualMachineByName(name string, opts ...OptionFunc) (*VirtualMachine, int, error) { func (s *VirtualMachineService) GetVirtualMachineByName(name string, opts ...OptionFunc) (*VirtualMachine, int, error) {
id, err := s.GetVirtualMachineID(name, opts...) id, count, err := s.GetVirtualMachineID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetVirtualMachineByID(id, opts...) r, count, err := s.GetVirtualMachineByID(id, opts...)

View File

@ -1097,7 +1097,7 @@ func (p *ListVolumesParams) SetType(v string) {
if p.p == nil { if p.p == nil {
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
} }
p.p["volumeType"] = v p.p["type"] = v
return return
} }
@ -1126,7 +1126,7 @@ func (s *VolumeService) NewListVolumesParams() *ListVolumesParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, error) { func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListVolumesParams{} p := &ListVolumesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -1134,38 +1134,38 @@ func (s *VolumeService) GetVolumeID(name string, opts ...OptionFunc) (string, er
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListVolumes(p) l, err := s.ListVolumes(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Volumes[0].Id, nil return l.Volumes[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Volumes { for _, v := range l.Volumes {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *VolumeService) GetVolumeByName(name string, opts ...OptionFunc) (*Volume, int, error) { func (s *VolumeService) GetVolumeByName(name string, opts ...OptionFunc) (*Volume, int, error) {
id, err := s.GetVolumeID(name, opts...) id, count, err := s.GetVolumeID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetVolumeByID(id, opts...) r, count, err := s.GetVolumeByID(id, opts...)

View File

@ -724,7 +724,7 @@ func (s *ZoneService) NewListZonesParams() *ListZonesParams {
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ZoneService) GetZoneID(name string, opts ...OptionFunc) (string, error) { func (s *ZoneService) GetZoneID(name string, opts ...OptionFunc) (string, int, error) {
p := &ListZonesParams{} p := &ListZonesParams{}
p.p = make(map[string]interface{}) p.p = make(map[string]interface{})
@ -732,38 +732,38 @@ func (s *ZoneService) GetZoneID(name string, opts ...OptionFunc) (string, error)
for _, fn := range opts { for _, fn := range opts {
if err := fn(s.cs, p); err != nil { if err := fn(s.cs, p); err != nil {
return "", err return "", -1, err
} }
} }
l, err := s.ListZones(p) l, err := s.ListZones(p)
if err != nil { if err != nil {
return "", err return "", -1, err
} }
if l.Count == 0 { if l.Count == 0 {
return "", fmt.Errorf("No match found for %s: %+v", name, l) return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
} }
if l.Count == 1 { if l.Count == 1 {
return l.Zones[0].Id, nil return l.Zones[0].Id, l.Count, nil
} }
if l.Count > 1 { if l.Count > 1 {
for _, v := range l.Zones { for _, v := range l.Zones {
if v.Name == name { if v.Name == name {
return v.Id, nil return v.Id, l.Count, nil
} }
} }
} }
return "", fmt.Errorf("Could not find an exact match for %s: %+v", name, l) return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
} }
// This is a courtesy helper function, which in some cases may not work as expected! // This is a courtesy helper function, which in some cases may not work as expected!
func (s *ZoneService) GetZoneByName(name string, opts ...OptionFunc) (*Zone, int, error) { func (s *ZoneService) GetZoneByName(name string, opts ...OptionFunc) (*Zone, int, error) {
id, err := s.GetZoneID(name, opts...) id, count, err := s.GetZoneID(name, opts...)
if err != nil { if err != nil {
return nil, -1, err return nil, count, err
} }
r, count, err := s.GetZoneByID(id, opts...) r, count, err := s.GetZoneByID(id, opts...)

View File

@ -398,7 +398,7 @@ func WithProject(project string) OptionFunc {
} }
if !IsID(project) { if !IsID(project) {
id, err := cs.Project.GetProjectID(project) id, _, err := cs.Project.GetProjectID(project)
if err != nil { if err != nil {
return err return err
} }

6
vendor/vendor.json vendored
View File

@ -1908,9 +1908,11 @@
"revision": "9051bd6b44125d9472e0c148b5965692ab283d4a" "revision": "9051bd6b44125d9472e0c148b5965692ab283d4a"
}, },
{ {
"comment": "2.0.0-6-g5686bcd", "checksumSHA1": "CT9vuv0kaEnwEDcNywB/wD6eA54=",
"comment": "v2.1.3",
"path": "github.com/xanzy/go-cloudstack/cloudstack", "path": "github.com/xanzy/go-cloudstack/cloudstack",
"revision": "5686bcde5af20565d8c7a3f66b5441430ac54186" "revision": "b33e8849d135b99cb8236237524d10b41f597cb3",
"revisionTime": "2016-08-31T14:38:59Z"
}, },
{ {
"path": "github.com/xanzy/ssh-agent", "path": "github.com/xanzy/ssh-agent",

View File

@ -0,0 +1,42 @@
---
layout: "cloudstack"
page_title: "CloudStack: cloudstack_affinity_group"
sidebar_current: "docs-cloudstack-resource-affinity-group"
description: |-
Creates an affinity group.
---
# cloudstack\_affinity\_group
Creates an affinity group.
## Example Usage
```
resource "cloudstack_affinity_group" "default" {
name = "myGroup"
type = "anti-affinity"
project = "myProject"
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) The name of the affinity group. Changing this
forces a new resource to be created.
* `description` - (Optional) The description of the affinity group.
* `type` - (Required) The affinity group type. Changing this
forces a new resource to be created.
* `project` - (Optional) The name or ID of the project to register this
affinity group to. Changing this forces a new resource to be created.
## Attributes Reference
The following attributes are exported:
* `id` - The id of the affinity group.

View File

@ -13,6 +13,10 @@
<li<%= sidebar_current(/^docs-cloudstack-resource/) %>> <li<%= sidebar_current(/^docs-cloudstack-resource/) %>>
<a href="#">Resources</a> <a href="#">Resources</a>
<ul class="nav nav-visible"> <ul class="nav nav-visible">
<li<%= sidebar_current("docs-cloudstack-affinity-group") %>>
<a href="/docs/providers/cloudstack/r/affinity_group.html">cloudstack_disk</a>
</li>
<li<%= sidebar_current("docs-cloudstack-resource-disk") %>> <li<%= sidebar_current("docs-cloudstack-resource-disk") %>>
<a href="/docs/providers/cloudstack/r/disk.html">cloudstack_disk</a> <a href="/docs/providers/cloudstack/r/disk.html">cloudstack_disk</a>
</li> </li>