mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-10 01:00:25 -04:00
Update go-cloudstack dependency
This commit is contained in:
49
vendor/github.com/xanzy/go-cloudstack/cloudstack/VirtualMachineService.go
generated
vendored
49
vendor/github.com/xanzy/go-cloudstack/cloudstack/VirtualMachineService.go
generated
vendored
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright 2014, Sander van Harmelen
|
||||
// Copyright 2016, Sander van Harmelen
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -2592,27 +2592,23 @@ func (s *VirtualMachineService) NewListVirtualMachinesParams() *ListVirtualMachi
|
||||
}
|
||||
|
||||
// This is a courtesy helper function, which in some cases may not work as expected!
|
||||
func (s *VirtualMachineService) GetVirtualMachineID(name string) (string, error) {
|
||||
func (s *VirtualMachineService) GetVirtualMachineID(name string, opts ...OptionFunc) (string, error) {
|
||||
p := &ListVirtualMachinesParams{}
|
||||
p.p = make(map[string]interface{})
|
||||
|
||||
p.p["name"] = name
|
||||
|
||||
for _, fn := range opts {
|
||||
if err := fn(s.cs, p); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
l, err := s.ListVirtualMachines(p)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if l.Count == 0 {
|
||||
// If no matches, search all projects
|
||||
p.p["projectid"] = "-1"
|
||||
|
||||
l, err = s.ListVirtualMachines(p)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
if l.Count == 0 {
|
||||
return "", fmt.Errorf("No match found for %s: %+v", name, l)
|
||||
}
|
||||
@@ -2632,13 +2628,13 @@ func (s *VirtualMachineService) GetVirtualMachineID(name string) (string, error)
|
||||
}
|
||||
|
||||
// This is a courtesy helper function, which in some cases may not work as expected!
|
||||
func (s *VirtualMachineService) GetVirtualMachineByName(name string) (*VirtualMachine, int, error) {
|
||||
id, err := s.GetVirtualMachineID(name)
|
||||
func (s *VirtualMachineService) GetVirtualMachineByName(name string, opts ...OptionFunc) (*VirtualMachine, int, error) {
|
||||
id, err := s.GetVirtualMachineID(name, opts...)
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
|
||||
r, count, err := s.GetVirtualMachineByID(id)
|
||||
r, count, err := s.GetVirtualMachineByID(id, opts...)
|
||||
if err != nil {
|
||||
return nil, count, err
|
||||
}
|
||||
@@ -2646,12 +2642,18 @@ func (s *VirtualMachineService) GetVirtualMachineByName(name string) (*VirtualMa
|
||||
}
|
||||
|
||||
// This is a courtesy helper function, which in some cases may not work as expected!
|
||||
func (s *VirtualMachineService) GetVirtualMachineByID(id string) (*VirtualMachine, int, error) {
|
||||
func (s *VirtualMachineService) GetVirtualMachineByID(id string, opts ...OptionFunc) (*VirtualMachine, int, error) {
|
||||
p := &ListVirtualMachinesParams{}
|
||||
p.p = make(map[string]interface{})
|
||||
|
||||
p.p["id"] = id
|
||||
|
||||
for _, fn := range opts {
|
||||
if err := fn(s.cs, p); err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
}
|
||||
|
||||
l, err := s.ListVirtualMachines(p)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), fmt.Sprintf(
|
||||
@@ -2662,21 +2664,6 @@ func (s *VirtualMachineService) GetVirtualMachineByID(id string) (*VirtualMachin
|
||||
return nil, -1, err
|
||||
}
|
||||
|
||||
if l.Count == 0 {
|
||||
// If no matches, search all projects
|
||||
p.p["projectid"] = "-1"
|
||||
|
||||
l, err = s.ListVirtualMachines(p)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), fmt.Sprintf(
|
||||
"Invalid parameter id value=%s due to incorrect long value format, "+
|
||||
"or entity does not exist", id)) {
|
||||
return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
|
||||
}
|
||||
return nil, -1, err
|
||||
}
|
||||
}
|
||||
|
||||
if l.Count == 0 {
|
||||
return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user