Update Lego
This commit is contained in:
parent
36966da701
commit
253060b4f3
185 changed files with 16653 additions and 3210 deletions
213
vendor/github.com/exoscale/egoscale/accounts.go
generated
vendored
213
vendor/github.com/exoscale/egoscale/accounts.go
generated
vendored
|
@ -1,98 +1,161 @@
|
|||
package egoscale
|
||||
|
||||
const (
|
||||
// UserAccount represents a User
|
||||
UserAccount = iota
|
||||
// AdminAccount represents an Admin
|
||||
AdminAccount
|
||||
// DomainAdminAccount represents a Domain Admin
|
||||
DomainAdminAccount
|
||||
)
|
||||
import "fmt"
|
||||
|
||||
// AccountType represents the type of an Account
|
||||
//
|
||||
// http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.8/accounts.html#accounts-users-and-domains
|
||||
type AccountType int64
|
||||
type AccountType int16
|
||||
|
||||
//go:generate stringer -type AccountType
|
||||
const (
|
||||
// UserAccount represents a User
|
||||
UserAccount AccountType = 0
|
||||
// AdminAccount represents an Admin
|
||||
AdminAccount AccountType = 1
|
||||
// DomainAdminAccount represents a Domain Admin
|
||||
DomainAdminAccount AccountType = 2
|
||||
)
|
||||
|
||||
// Account provides the detailed account information
|
||||
type Account struct {
|
||||
ID string `json:"id"`
|
||||
AccountType AccountType `json:"accounttype,omitempty"`
|
||||
AccountDetails string `json:"accountdetails,omitempty"`
|
||||
CPUAvailable string `json:"cpuavailable,omitempty"`
|
||||
CPULimit string `json:"cpulimit,omitempty"`
|
||||
CPUTotal int64 `json:"cputotal,omitempty"`
|
||||
DefaultZoneID string `json:"defaultzoneid,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
EIPLimit string `json:"eiplimit,omitempty"`
|
||||
Groups []string `json:"groups,omitempty"`
|
||||
IPAvailable string `json:"ipavailable,omitempty"`
|
||||
IPLimit string `json:"iplimit,omitempty"`
|
||||
IPTotal int64 `json:"iptotal,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
MemoryAvailable string `json:"memoryavailable,omitempty"`
|
||||
MemoryLimit string `json:"memorylimit,omitempty"`
|
||||
MemoryTotal int64 `json:"memorytotal,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkAvailable string `json:"networkavailable,omitempty"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty"`
|
||||
NetworkLimit string `json:"networklimit,omitempty"`
|
||||
NetworkTotal int16 `json:"networktotal,omitempty"`
|
||||
PrimaryStorageAvailable string `json:"primarystorageavailable,omitempty"`
|
||||
PrimaryStorageLimit string `json:"primarystoragelimit,omitempty"`
|
||||
PrimaryStorageTotal int64 `json:"primarystoragetotal,omitempty"`
|
||||
ProjectAvailable string `json:"projectavailable,omitempty"`
|
||||
ProjectLimit string `json:"projectlimit,omitempty"`
|
||||
ProjectTotal int64 `json:"projecttotal,omitempty"`
|
||||
SecondaryStorageAvailable string `json:"secondarystorageavailable,omitempty"`
|
||||
SecondaryStorageLimit string `json:"secondarystoragelimit,omitempty"`
|
||||
SecondaryStorageTotal int64 `json:"secondarystoragetotal,omitempty"`
|
||||
SnapshotAvailable string `json:"snapshotavailable,omitempty"`
|
||||
SnapshotLimit string `json:"snapshotlimit,omitempty"`
|
||||
SnapshotTotal int64 `json:"snapshottotal,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
TemplateAvailable string `json:"templateavailable,omitempty"`
|
||||
TemplateLimit string `json:"templatelimit,omitempty"`
|
||||
TemplateTotal int64 `json:"templatetotal,omitempty"`
|
||||
VMAvailable string `json:"vmavailable,omitempty"`
|
||||
VMLimit string `json:"vmlimit,omitempty"`
|
||||
VMTotal int64 `json:"vmtotal,omitempty"`
|
||||
VolumeAvailable string `json:"volumeavailable,omitempty"`
|
||||
VolumeLimit string `json:"volumelimit,omitempty"`
|
||||
VolumeTotal int64 `json:"volumetotal,omitempty"`
|
||||
VPCAvailable string `json:"vpcavailable,omitempty"`
|
||||
VPCLimit string `json:"vpclimit,omitempty"`
|
||||
VPCTotal int64 `json:"vpctotal,omitempty"`
|
||||
User []User `json:"user,omitempty"`
|
||||
AccountDetails map[string]string `json:"accountdetails,omitempty" doc:"details for the account"`
|
||||
AccountType AccountType `json:"accounttype,omitempty" doc:"account type (admin, domain-admin, user)"`
|
||||
CPUAvailable string `json:"cpuavailable,omitempty" doc:"the total number of cpu cores available to be created for this account"`
|
||||
CPULimit string `json:"cpulimit,omitempty" doc:"the total number of cpu cores the account can own"`
|
||||
CPUTotal int64 `json:"cputotal,omitempty" doc:"the total number of cpu cores owned by account"`
|
||||
DefaultZoneID *UUID `json:"defaultzoneid,omitempty" doc:"the default zone of the account"`
|
||||
Domain string `json:"domain,omitempty" doc:"name of the Domain the account belongs too"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"id of the Domain the account belongs too"`
|
||||
EipLimit string `json:"eiplimit,omitempty" doc:"the total number of public elastic ip addresses this account can acquire"`
|
||||
Groups []string `json:"groups,omitempty" doc:"the list of acl groups that account belongs to"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the account"`
|
||||
IPAvailable string `json:"ipavailable,omitempty" doc:"the total number of public ip addresses available for this account to acquire"`
|
||||
IPLimit string `json:"iplimit,omitempty" doc:"the total number of public ip addresses this account can acquire"`
|
||||
IPTotal int64 `json:"iptotal,omitempty" doc:"the total number of public ip addresses allocated for this account"`
|
||||
IsCleanupRequired bool `json:"iscleanuprequired,omitempty" doc:"true if the account requires cleanup"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if account is default, false otherwise"`
|
||||
MemoryAvailable string `json:"memoryavailable,omitempty" doc:"the total memory (in MB) available to be created for this account"`
|
||||
MemoryLimit string `json:"memorylimit,omitempty" doc:"the total memory (in MB) the account can own"`
|
||||
MemoryTotal int64 `json:"memorytotal,omitempty" doc:"the total memory (in MB) owned by account"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the account"`
|
||||
NetworkAvailable string `json:"networkavailable,omitempty" doc:"the total number of networks available to be created for this account"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"the network domain"`
|
||||
NetworkLimit string `json:"networklimit,omitempty" doc:"the total number of networks the account can own"`
|
||||
NetworkTotal int64 `json:"networktotal,omitempty" doc:"the total number of networks owned by account"`
|
||||
PrimaryStorageAvailable string `json:"primarystorageavailable,omitempty" doc:"the total primary storage space (in GiB) available to be used for this account"`
|
||||
PrimaryStorageLimit string `json:"primarystoragelimit,omitempty" doc:"the total primary storage space (in GiB) the account can own"`
|
||||
PrimaryStorageTotal int64 `json:"primarystoragetotal,omitempty" doc:"the total primary storage space (in GiB) owned by account"`
|
||||
ProjectAvailable string `json:"projectavailable,omitempty" doc:"the total number of projects available for administration by this account"`
|
||||
ProjectLimit string `json:"projectlimit,omitempty" doc:"the total number of projects the account can own"`
|
||||
ProjectTotal int64 `json:"projecttotal,omitempty" doc:"the total number of projects being administrated by this account"`
|
||||
SecondaryStorageAvailable string `json:"secondarystorageavailable,omitempty" doc:"the total secondary storage space (in GiB) available to be used for this account"`
|
||||
SecondaryStorageLimit string `json:"secondarystoragelimit,omitempty" doc:"the total secondary storage space (in GiB) the account can own"`
|
||||
SecondaryStorageTotal int64 `json:"secondarystoragetotal,omitempty" doc:"the total secondary storage space (in GiB) owned by account"`
|
||||
SMTP bool `json:"smtp,omitempty" doc:"if SMTP outbound is allowed"`
|
||||
SnapshotAvailable string `json:"snapshotavailable,omitempty" doc:"the total number of snapshots available for this account"`
|
||||
SnapshotLimit string `json:"snapshotlimit,omitempty" doc:"the total number of snapshots which can be stored by this account"`
|
||||
SnapshotTotal int64 `json:"snapshottotal,omitempty" doc:"the total number of snapshots stored by this account"`
|
||||
State string `json:"state,omitempty" doc:"the state of the account"`
|
||||
TemplateAvailable string `json:"templateavailable,omitempty" doc:"the total number of templates available to be created by this account"`
|
||||
TemplateLimit string `json:"templatelimit,omitempty" doc:"the total number of templates which can be created by this account"`
|
||||
TemplateTotal int64 `json:"templatetotal,omitempty" doc:"the total number of templates which have been created by this account"`
|
||||
User []User `json:"user,omitempty" doc:"the list of users associated with account"`
|
||||
VMAvailable string `json:"vmavailable,omitempty" doc:"the total number of virtual machines available for this account to acquire"`
|
||||
VMLimit string `json:"vmlimit,omitempty" doc:"the total number of virtual machines that can be deployed by this account"`
|
||||
VMRunning int `json:"vmrunning,omitempty" doc:"the total number of virtual machines running for this account"`
|
||||
VMStopped int `json:"vmstopped,omitempty" doc:"the total number of virtual machines stopped for this account"`
|
||||
VMTotal int64 `json:"vmtotal,omitempty" doc:"the total number of virtual machines deployed by this account"`
|
||||
VolumeAvailable string `json:"volumeavailable,omitempty" doc:"the total volume available for this account"`
|
||||
VolumeLimit string `json:"volumelimit,omitempty" doc:"the total volume which can be used by this account"`
|
||||
VolumeTotal int64 `json:"volumetotal,omitempty" doc:"the total volume being used by this account"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListAccountsGroups request
|
||||
func (a Account) ListRequest() (ListCommand, error) {
|
||||
return &ListAccounts{
|
||||
ID: a.ID,
|
||||
DomainID: a.DomainID,
|
||||
AccountType: a.AccountType,
|
||||
State: a.State,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListAccounts represents a query to display the accounts
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listAccounts.html
|
||||
type ListAccounts struct {
|
||||
AccountType int64 `json:"accounttype,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsCleanUpRequired bool `json:"iscleanuprequired,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
AccountType AccountType `json:"accounttype,omitempty" doc:"list accounts by account type. Valid account types are 1 (admin), 2 (domain-admin), and 0 (user)."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list account by account ID"`
|
||||
IsCleanUpRequired *bool `json:"iscleanuprequired,omitempty" doc:"list accounts by cleanuprequired attribute (values are true or false)"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"list account by account name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"list accounts by state. Valid states are enabled, disabled, and locked."`
|
||||
_ bool `name:"listAccounts" description:"Lists accounts and provides detailed account information for listed accounts"`
|
||||
}
|
||||
|
||||
func (*ListAccounts) name() string {
|
||||
return "listAccounts"
|
||||
}
|
||||
|
||||
func (*ListAccounts) response() interface{} {
|
||||
func (ListAccounts) response() interface{} {
|
||||
return new(ListAccountsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListAccounts) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAccounts) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListAccounts) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListAccountsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListAccountsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.Account {
|
||||
if !callback(&vms.Account[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ListAccountsResponse represents a list of accounts
|
||||
type ListAccountsResponse struct {
|
||||
Count int `json:"count"`
|
||||
Account []Account `json:"account"`
|
||||
}
|
||||
|
||||
// EnableAccount represents the activation of an account
|
||||
type EnableAccount struct {
|
||||
Account string `json:"account,omitempty" doc:"Enables specified account."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Enables specified account in this domain."`
|
||||
ID *UUID `json:"id,omitempty" doc:"Account id"`
|
||||
_ bool `name:"enableAccount" description:"Enables an account"`
|
||||
}
|
||||
|
||||
func (EnableAccount) response() interface{} {
|
||||
return new(Account)
|
||||
}
|
||||
|
||||
// DisableAccount (Async) represents the deactivation of an account
|
||||
type DisableAccount struct {
|
||||
Lock *bool `json:"lock" doc:"If true, only lock the account; else disable the account"`
|
||||
Account string `json:"account,omitempty" doc:"Disables specified account."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Disables specified account in this domain."`
|
||||
ID *UUID `json:"id,omitempty" doc:"Account id"`
|
||||
_ bool `name:"disableAccount" description:"Disables an account"`
|
||||
}
|
||||
|
||||
func (DisableAccount) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DisableAccount) asyncResponse() interface{} {
|
||||
return new(Account)
|
||||
}
|
||||
|
|
16
vendor/github.com/exoscale/egoscale/accounttype_string.go
generated
vendored
Normal file
16
vendor/github.com/exoscale/egoscale/accounttype_string.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Code generated by "stringer -type AccountType"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _AccountType_name = "UserAccountAdminAccountDomainAdminAccount"
|
||||
|
||||
var _AccountType_index = [...]uint8{0, 11, 23, 41}
|
||||
|
||||
func (i AccountType) String() string {
|
||||
if i < 0 || i >= AccountType(len(_AccountType_index)-1) {
|
||||
return "AccountType(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _AccountType_name[_AccountType_index[i]:_AccountType_index[i+1]]
|
||||
}
|
259
vendor/github.com/exoscale/egoscale/addresses.go
generated
vendored
259
vendor/github.com/exoscale/egoscale/addresses.go
generated
vendored
|
@ -1,144 +1,163 @@
|
|||
package egoscale
|
||||
|
||||
import "net"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
// IPAddress represents an IP Address
|
||||
type IPAddress struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account,omitempty"`
|
||||
AllocatedAt string `json:"allocated,omitempty"`
|
||||
AssociatedNetworkID string `json:"associatednetworkid,omitempty"`
|
||||
AssociatedNetworkName string `json:"associatednetworkname,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
DomainName string `json:"domainname,omitempty"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty"`
|
||||
IPAddress net.IP `json:"ipaddress"`
|
||||
IsElastic bool `json:"iselastic,omitempty"`
|
||||
IsPortable bool `json:"isportable,omitempty"`
|
||||
IsSourceNat bool `json:"issourcenat,omitempty"`
|
||||
IsSystem bool `json:"issystem,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Purpose string `json:"purpose,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
VirtualMachineDisplayName string `json:"virtualmachinedisplayname,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
VirtualMachineName string `json:"virtualmachineName,omitempty"`
|
||||
VlanID string `json:"vlanid,omitempty"`
|
||||
VlanName string `json:"vlanname,omitempty"`
|
||||
VMIPAddress net.IP `json:"vmipaddress,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
ZoneName string `json:"zonename,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account the public IP address is associated with"`
|
||||
Allocated string `json:"allocated,omitempty" doc:"date the public IP address was acquired"`
|
||||
Associated string `json:"associated,omitempty" doc:"date the public IP address was associated"`
|
||||
AssociatedNetworkID *UUID `json:"associatednetworkid,omitempty" doc:"the ID of the Network associated with the IP address"`
|
||||
AssociatedNetworkName string `json:"associatednetworkname,omitempty" doc:"the name of the Network associated with the IP address"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain the public IP address is associated with"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID the public IP address is associated with"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"is public ip for display to the regular user"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the IP address"`
|
||||
ID *UUID `json:"id,omitempty" doc:"public IP address id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"public IP address"`
|
||||
IsElastic bool `json:"iselastic,omitempty" doc:"is an elastic ip"`
|
||||
IsPortable bool `json:"isportable,omitempty" doc:"is public IP portable across the zones"`
|
||||
IsSourceNat bool `json:"issourcenat,omitempty" doc:"true if the IP address is a source nat address, false otherwise"`
|
||||
IsStaticNat *bool `json:"isstaticnat,omitempty" doc:"true if this ip is for static nat, false otherwise"`
|
||||
IsSystem bool `json:"issystem,omitempty" doc:"true if this ip is system ip (was allocated as a part of deployVm or createLbRule)"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"the ID of the Network where ip belongs to"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"the physical network this belongs to"`
|
||||
Purpose string `json:"purpose,omitempty" doc:"purpose of the IP address. In Acton this value is not null for Ips with isSystem=true, and can have either StaticNat or LB value"`
|
||||
ReverseDNS []ReverseDNS `json:"reversedns,omitempty" doc:"the list of PTR record(s) associated with the ip address"`
|
||||
State string `json:"state,omitempty" doc:"State of the ip address. Can be: Allocatin, Allocated and Releasing"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with ip address"`
|
||||
VirtualMachineDisplayName string `json:"virtualmachinedisplayname,omitempty" doc:"virtual machine display name the ip address is assigned to (not null only for static nat Ip)"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"virtual machine id the ip address is assigned to (not null only for static nat Ip)"`
|
||||
VirtualMachineName string `json:"virtualmachinename,omitempty" doc:"virtual machine name the ip address is assigned to (not null only for static nat Ip)"`
|
||||
VlanID *UUID `json:"vlanid,omitempty" doc:"the ID of the VLAN associated with the IP address. This parameter is visible to ROOT admins only"`
|
||||
VlanName string `json:"vlanname,omitempty" doc:"the VLAN associated with the IP address"`
|
||||
VMIPAddress net.IP `json:"vmipaddress,omitempty" doc:"virtual machine (dnat) ip address (not null only for static nat Ip)"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the zone the public IP address belongs to"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the zone the public IP address belongs to"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*IPAddress) ResourceType() string {
|
||||
func (IPAddress) ResourceType() string {
|
||||
return "PublicIpAddress"
|
||||
}
|
||||
|
||||
// ListRequest builds the ListAdresses request
|
||||
func (ipaddress IPAddress) ListRequest() (ListCommand, error) {
|
||||
req := &ListPublicIPAddresses{
|
||||
Account: ipaddress.Account,
|
||||
AssociatedNetworkID: ipaddress.AssociatedNetworkID,
|
||||
DomainID: ipaddress.DomainID,
|
||||
ID: ipaddress.ID,
|
||||
IPAddress: ipaddress.IPAddress,
|
||||
PhysicalNetworkID: ipaddress.PhysicalNetworkID,
|
||||
VlanID: ipaddress.VlanID,
|
||||
ZoneID: ipaddress.ZoneID,
|
||||
}
|
||||
if ipaddress.IsElastic {
|
||||
req.IsElastic = &ipaddress.IsElastic
|
||||
}
|
||||
if ipaddress.IsSourceNat {
|
||||
req.IsSourceNat = &ipaddress.IsSourceNat
|
||||
}
|
||||
if ipaddress.ForDisplay {
|
||||
req.ForDisplay = &ipaddress.ForDisplay
|
||||
}
|
||||
if ipaddress.ForVirtualNetwork {
|
||||
req.ForVirtualNetwork = &ipaddress.ForVirtualNetwork
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// Delete removes the resource
|
||||
func (ipaddress IPAddress) Delete(ctx context.Context, client *Client) error {
|
||||
if ipaddress.ID == nil {
|
||||
return fmt.Errorf("an IPAddress may only be deleted using ID")
|
||||
}
|
||||
|
||||
return client.BooleanRequestWithContext(ctx, &DisassociateIPAddress{
|
||||
ID: ipaddress.ID,
|
||||
})
|
||||
}
|
||||
|
||||
// AssociateIPAddress (Async) represents the IP creation
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/associateIpAddress.html
|
||||
type AssociateIPAddress struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty"`
|
||||
IsPortable bool `json:"isportable,omitempty"`
|
||||
NetworkdID string `json:"networkid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
RegionID string `json:"regionid,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account to associate with this IP address"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain to associate with this IP address"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"an optional field, whether to the display the ip to the end user or not"`
|
||||
IsPortable *bool `json:"isportable,omitempty" doc:"should be set to true if public IP is required to be transferable across zones, if not specified defaults to false"`
|
||||
NetworkdID *UUID `json:"networkid,omitempty" doc:"The network this ip address should be associated to."`
|
||||
RegionID int `json:"regionid,omitempty" doc:"region ID from where portable ip is to be associated."`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availability zone you want to acquire an public IP address from"`
|
||||
_ bool `name:"associateIpAddress" description:"Acquires and associates a public IP to an account."`
|
||||
}
|
||||
|
||||
func (*AssociateIPAddress) name() string {
|
||||
return "associateIpAddress"
|
||||
func (AssociateIPAddress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*AssociateIPAddress) asyncResponse() interface{} {
|
||||
return new(AssociateIPAddressResponse)
|
||||
}
|
||||
|
||||
// AssociateIPAddressResponse represents the response to the creation of an IPAddress
|
||||
type AssociateIPAddressResponse struct {
|
||||
IPAddress IPAddress `json:"ipaddress"`
|
||||
func (AssociateIPAddress) asyncResponse() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
// DisassociateIPAddress (Async) represents the IP deletion
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/disassociateIpAddress.html
|
||||
type DisassociateIPAddress struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"the id of the public ip address to disassociate"`
|
||||
_ bool `name:"disassociateIpAddress" description:"Disassociates an ip address from the account."`
|
||||
}
|
||||
|
||||
func (*DisassociateIPAddress) name() string {
|
||||
return "disassociateIpAddress"
|
||||
func (DisassociateIPAddress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (*DisassociateIPAddress) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
|
||||
func (DisassociateIPAddress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// UpdateIPAddress (Async) represents the IP modification
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/updateIpAddress.html
|
||||
type UpdateIPAddress struct {
|
||||
ID string `json:"id"`
|
||||
CustomID string `json:"customid,omitempty"` // root only
|
||||
ForDisplay bool `json:"fordisplay,omitempty"`
|
||||
ID *UUID `json:"id" doc:"the id of the public ip address to update"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"an optional field, whether to the display the ip to the end user or not"`
|
||||
_ bool `name:"updateIpAddress" description:"Updates an ip address"`
|
||||
}
|
||||
|
||||
func (*UpdateIPAddress) name() string {
|
||||
return "updateIpAddress"
|
||||
}
|
||||
func (*UpdateIPAddress) asyncResponse() interface{} {
|
||||
return new(UpdateIPAddressResponse)
|
||||
func (UpdateIPAddress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// UpdateIPAddressResponse represents the modified IP Address
|
||||
type UpdateIPAddressResponse AssociateIPAddressResponse
|
||||
func (UpdateIPAddress) asyncResponse() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
// ListPublicIPAddresses represents a search for public IP addresses
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listPublicIpAddresses.html
|
||||
type ListPublicIPAddresses struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
AllocatedOnly bool `json:"allocatedonly,omitempty"`
|
||||
AllocatedNetworkID string `json:"allocatednetworkid,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty"`
|
||||
ForLoadBalancing bool `json:"forloadbalancing,omitempty"`
|
||||
ForVirtualNetwork string `json:"forvirtualnetwork,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty"`
|
||||
IsElastic bool `json:"iselastic,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
IsSourceNat bool `json:"issourcenat,omitempty"`
|
||||
IsStaticNat bool `json:"isstaticnat,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omiempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
VlanID string `json:"vlanid,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListPublicIPAddresses) name() string {
|
||||
return "listPublicIpAddresses"
|
||||
}
|
||||
|
||||
func (*ListPublicIPAddresses) response() interface{} {
|
||||
return new(ListPublicIPAddressesResponse)
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AllocatedOnly *bool `json:"allocatedonly,omitempty" doc:"limits search results to allocated public IP addresses"`
|
||||
AssociatedNetworkID *UUID `json:"associatednetworkid,omitempty" doc:"lists all public IP addresses associated to the network specified"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForDisplay *bool `json:"fordisplay,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
ForLoadBalancing *bool `json:"forloadbalancing,omitempty" doc:"list only ips used for load balancing"`
|
||||
ForVirtualNetwork *bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the IP address"`
|
||||
ID *UUID `json:"id,omitempty" doc:"lists ip address by id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"lists the specified IP address"`
|
||||
IsElastic *bool `json:"iselastic,omitempty" doc:"list only elastic ip addresses"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
IsSourceNat *bool `json:"issourcenat,omitempty" doc:"list only source nat ip addresses"`
|
||||
IsStaticNat *bool `json:"isstaticnat,omitempty" doc:"list only static nat ip addresses"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"lists all public IP addresses by physical network id"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
VlanID *UUID `json:"vlanid,omitempty" doc:"lists all public IP addresses by VLAN ID"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"lists all public IP addresses by Zone ID"`
|
||||
_ bool `name:"listPublicIpAddresses" description:"Lists all public ip addresses"`
|
||||
}
|
||||
|
||||
// ListPublicIPAddressesResponse represents a list of public IP addresses
|
||||
|
@ -146,3 +165,31 @@ type ListPublicIPAddressesResponse struct {
|
|||
Count int `json:"count"`
|
||||
PublicIPAddress []IPAddress `json:"publicipaddress"`
|
||||
}
|
||||
|
||||
func (ListPublicIPAddresses) response() interface{} {
|
||||
return new(ListPublicIPAddressesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListPublicIPAddresses) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListPublicIPAddresses) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListPublicIPAddresses) each(resp interface{}, callback IterateItemFunc) {
|
||||
ips, ok := resp.(*ListPublicIPAddressesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListPublicIPAddressesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range ips.PublicIPAddress {
|
||||
if !callback(&ips.PublicIPAddress[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
222
vendor/github.com/exoscale/egoscale/affinity_groups.go
generated
vendored
222
vendor/github.com/exoscale/egoscale/affinity_groups.go
generated
vendored
|
@ -1,68 +1,86 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// AffinityGroup represents an (anti-)affinity group
|
||||
//
|
||||
// Affinity and Anti-Affinity groups provide a way to influence where VMs should run.
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html#affinity-groups
|
||||
type AffinityGroup struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VirtualMachineIDs []string `json:"virtualmachineIDs,omitempty"` // *I*ds is not a typo
|
||||
Account string `json:"account,omitempty" doc:"the account owning the affinity group"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the affinity group"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the affinity group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the affinity group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the affinity group"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the affinity group"`
|
||||
VirtualMachineIDs []string `json:"virtualmachineIds,omitempty" doc:"virtual machine Ids associated with this affinity group"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListAffinityGroups request
|
||||
func (ag AffinityGroup) ListRequest() (ListCommand, error) {
|
||||
return &ListAffinityGroups{
|
||||
ID: ag.ID,
|
||||
Name: ag.Name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Delete removes the given Affinity Group
|
||||
func (ag AffinityGroup) Delete(ctx context.Context, client *Client) error {
|
||||
if ag.ID == nil && ag.Name == "" {
|
||||
return fmt.Errorf("an Affinity Group may only be deleted using ID or Name")
|
||||
}
|
||||
|
||||
req := &DeleteAffinityGroup{
|
||||
Account: ag.Account,
|
||||
DomainID: ag.DomainID,
|
||||
}
|
||||
|
||||
if ag.ID != nil {
|
||||
req.ID = ag.ID
|
||||
} else {
|
||||
req.Name = ag.Name
|
||||
}
|
||||
|
||||
return client.BooleanRequestWithContext(ctx, req)
|
||||
}
|
||||
|
||||
// AffinityGroupType represent an affinity group type
|
||||
type AffinityGroupType struct {
|
||||
Type string `json:"type"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the affinity group"`
|
||||
}
|
||||
|
||||
// CreateAffinityGroup (Async) represents a new (anti-)affinity group
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/createAffinityGroup.html
|
||||
type CreateAffinityGroup struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"an account for the affinity group. Must be used with domainId."`
|
||||
Description string `json:"description,omitempty" doc:"optional description of the affinity group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"domainId of the account owning the affinity group"`
|
||||
Name string `json:"name" doc:"name of the affinity group"`
|
||||
Type string `json:"type" doc:"Type of the affinity group from the available affinity/anti-affinity group types"`
|
||||
_ bool `name:"createAffinityGroup" description:"Creates an affinity/anti-affinity group"`
|
||||
}
|
||||
|
||||
func (*CreateAffinityGroup) name() string {
|
||||
return "createAffinityGroup"
|
||||
func (CreateAffinityGroup) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*CreateAffinityGroup) asyncResponse() interface{} {
|
||||
return new(CreateAffinityGroupResponse)
|
||||
}
|
||||
|
||||
// CreateAffinityGroupResponse represents the response of the creation of an (anti-)affinity group
|
||||
type CreateAffinityGroupResponse struct {
|
||||
AffinityGroup AffinityGroup `json:"affinitygroup"`
|
||||
func (CreateAffinityGroup) asyncResponse() interface{} {
|
||||
return new(AffinityGroup)
|
||||
}
|
||||
|
||||
// UpdateVMAffinityGroup (Async) represents a modification of a (anti-)affinity group
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/updateVMAffinityGroup.html
|
||||
type UpdateVMAffinityGroup struct {
|
||||
ID string `json:"id"`
|
||||
AffinityGroupIDs []string `json:"affinitygroupids,omitempty"` // mutually exclusive with names
|
||||
AffinityGroupNames []string `json:"affinitygroupnames,omitempty"` // mutually exclusive with ids
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
AffinityGroupIDs []UUID `json:"affinitygroupids,omitempty" doc:"comma separated list of affinity groups id that are going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupnames parameter"`
|
||||
AffinityGroupNames []string `json:"affinitygroupnames,omitempty" doc:"comma separated list of affinity groups names that are going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter"`
|
||||
_ bool `name:"updateVMAffinityGroup" description:"Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect."`
|
||||
}
|
||||
|
||||
func (*UpdateVMAffinityGroup) name() string {
|
||||
return "updateVMAffinityGroup"
|
||||
}
|
||||
|
||||
func (*UpdateVMAffinityGroup) asyncResponse() interface{} {
|
||||
return new(UpdateVMAffinityGroupResponse)
|
||||
}
|
||||
|
||||
func (req *UpdateVMAffinityGroup) onBeforeSend(params *url.Values) error {
|
||||
func (req UpdateVMAffinityGroup) onBeforeSend(params url.Values) error {
|
||||
// Either AffinityGroupIDs or AffinityGroupNames must be set
|
||||
if len(req.AffinityGroupIDs) == 0 && len(req.AffinityGroupNames) == 0 {
|
||||
params.Set("affinitygroupids", "")
|
||||
|
@ -70,69 +88,73 @@ func (req *UpdateVMAffinityGroup) onBeforeSend(params *url.Values) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// UpdateVMAffinityGroupResponse represents the new VM
|
||||
type UpdateVMAffinityGroupResponse VirtualMachineResponse
|
||||
func (UpdateVMAffinityGroup) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateVMAffinityGroup) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// DeleteAffinityGroup (Async) represents an (anti-)affinity group to be deleted
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteAffinityGroup.html
|
||||
type DeleteAffinityGroup struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account of the affinity group. Must be specified with domain ID"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the affinity group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the affinity group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The name of the affinity group. Mutually exclusive with ID parameter"`
|
||||
_ bool `name:"deleteAffinityGroup" description:"Deletes affinity group"`
|
||||
}
|
||||
|
||||
func (*DeleteAffinityGroup) name() string {
|
||||
return "deleteAffinityGroup"
|
||||
func (DeleteAffinityGroup) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*DeleteAffinityGroup) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (DeleteAffinityGroup) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListAffinityGroups represents an (anti-)affinity groups search
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listAffinityGroups.html
|
||||
type ListAffinityGroups struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list the affinity group by the ID provided"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"lists affinity groups by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
Type string `json:"type,omitempty" doc:"lists affinity groups by type"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"lists affinity groups by virtual machine ID"`
|
||||
_ bool `name:"listAffinityGroups" description:"Lists affinity groups"`
|
||||
}
|
||||
|
||||
func (*ListAffinityGroups) name() string {
|
||||
return "listAffinityGroups"
|
||||
}
|
||||
|
||||
func (*ListAffinityGroups) response() interface{} {
|
||||
func (ListAffinityGroups) response() interface{} {
|
||||
return new(ListAffinityGroupsResponse)
|
||||
}
|
||||
|
||||
// ListAffinityGroupTypes represents an (anti-)affinity groups search
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listAffinityGroupTypes.html
|
||||
type ListAffinityGroupTypes struct {
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
// SetPage sets the current page
|
||||
func (ls *ListAffinityGroups) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
func (*ListAffinityGroupTypes) name() string {
|
||||
return "listAffinityGroupTypes"
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListAffinityGroups) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (*ListAffinityGroupTypes) response() interface{} {
|
||||
return new(ListAffinityGroupTypesResponse)
|
||||
func (ListAffinityGroups) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListAffinityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListAffinityGroupsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.AffinityGroup {
|
||||
if !callback(&vms.AffinityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ListAffinityGroupsResponse represents a list of (anti-)affinity groups
|
||||
|
@ -141,36 +163,20 @@ type ListAffinityGroupsResponse struct {
|
|||
AffinityGroup []AffinityGroup `json:"affinitygroup"`
|
||||
}
|
||||
|
||||
// ListAffinityGroupTypes represents an (anti-)affinity groups search
|
||||
type ListAffinityGroupTypes struct {
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
_ bool `name:"listAffinityGroupTypes" description:"Lists affinity group types available"`
|
||||
}
|
||||
|
||||
func (ListAffinityGroupTypes) response() interface{} {
|
||||
return new(ListAffinityGroupTypesResponse)
|
||||
}
|
||||
|
||||
// ListAffinityGroupTypesResponse represents a list of (anti-)affinity group types
|
||||
type ListAffinityGroupTypesResponse struct {
|
||||
Count int `json:"count"`
|
||||
AffinityGroupType []AffinityGroupType `json:"affinitygrouptype"`
|
||||
}
|
||||
|
||||
// Legacy methods
|
||||
|
||||
// CreateAffinityGroup creates a group
|
||||
//
|
||||
// Deprecated: Use the API directly
|
||||
func (exo *Client) CreateAffinityGroup(name string, async AsyncInfo) (*AffinityGroup, error) {
|
||||
req := &CreateAffinityGroup{
|
||||
Name: name,
|
||||
}
|
||||
resp, err := exo.AsyncRequest(req, async)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ag := resp.(*CreateAffinityGroupResponse).AffinityGroup
|
||||
return &ag, nil
|
||||
}
|
||||
|
||||
// DeleteAffinityGroup deletes a group
|
||||
//
|
||||
// Deprecated: Use the API directly
|
||||
func (exo *Client) DeleteAffinityGroup(name string, async AsyncInfo) error {
|
||||
req := &DeleteAffinityGroup{
|
||||
Name: name,
|
||||
}
|
||||
return exo.BooleanAsyncRequest(req, async)
|
||||
}
|
||||
|
|
49
vendor/github.com/exoscale/egoscale/apis.go
generated
vendored
49
vendor/github.com/exoscale/egoscale/apis.go
generated
vendored
|
@ -2,14 +2,14 @@ package egoscale
|
|||
|
||||
// API represents an API service
|
||||
type API struct {
|
||||
Description string `json:"description"`
|
||||
IsAsync bool `json:"isasync"`
|
||||
Name string `json:"name"`
|
||||
Related string `json:"related"` // comma separated
|
||||
Since string `json:"since"`
|
||||
Type string `json:"type"`
|
||||
Params []APIParam `json:"params"`
|
||||
Response []APIResponse `json:"responses"`
|
||||
Description string `json:"description,omitempty" doc:"description of the api"`
|
||||
IsAsync bool `json:"isasync,omitempty" doc:"true if api is asynchronous"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the api command"`
|
||||
Related string `json:"related,omitempty" doc:"comma separated related apis"`
|
||||
Since string `json:"since,omitempty" doc:"version of CloudStack the api was introduced in"`
|
||||
Type string `json:"type,omitempty" doc:"response field type"`
|
||||
Params []APIParam `json:"params,omitempty" doc:"the list params the api accepts"`
|
||||
Response []APIField `json:"response,omitempty" doc:"api response fields"`
|
||||
}
|
||||
|
||||
// APIParam represents an API parameter field
|
||||
|
@ -17,32 +17,23 @@ type APIParam struct {
|
|||
Description string `json:"description"`
|
||||
Length int64 `json:"length"`
|
||||
Name string `json:"name"`
|
||||
Related string `json:"related"` // comma separated
|
||||
Since string `json:"since"`
|
||||
Required bool `json:"required"`
|
||||
Since string `json:"since,omitempty"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// APIResponse represents an API response field
|
||||
type APIResponse struct {
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name"`
|
||||
Response []APIResponse `json:"response"`
|
||||
Type string `json:"type"`
|
||||
// APIField represents an API response field
|
||||
type APIField struct {
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name"`
|
||||
Response []APIField `json:"response,omitempty"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// ListAPIs represents a query to list the api
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listApis.html
|
||||
type ListAPIs struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListAPIs) name() string {
|
||||
return "listApis"
|
||||
}
|
||||
|
||||
func (*ListAPIs) response() interface{} {
|
||||
return new(ListAPIsResponse)
|
||||
Name string `json:"name,omitempty" doc:"API name"`
|
||||
_ bool `name:"listApis" description:"lists all available apis on the server"`
|
||||
}
|
||||
|
||||
// ListAPIsResponse represents a list of API
|
||||
|
@ -50,3 +41,7 @@ type ListAPIsResponse struct {
|
|||
Count int `json:"count"`
|
||||
API []API `json:"api"`
|
||||
}
|
||||
|
||||
func (*ListAPIs) response() interface{} {
|
||||
return new(ListAPIsResponse)
|
||||
}
|
||||
|
|
103
vendor/github.com/exoscale/egoscale/async_jobs.go
generated
vendored
103
vendor/github.com/exoscale/egoscale/async_jobs.go
generated
vendored
|
@ -2,61 +2,54 @@ package egoscale
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// AsyncJobResult represents an asynchronous job result
|
||||
type AsyncJobResult struct {
|
||||
AccountID string `json:"accountid"`
|
||||
Cmd string `json:"cmd"`
|
||||
Created string `json:"created"`
|
||||
JobInstanceID string `json:"jobinstanceid"`
|
||||
JobInstanceType string `json:"jobinstancetype"`
|
||||
JobProcStatus int `json:"jobprocstatus"`
|
||||
JobResult *json.RawMessage `json:"jobresult"`
|
||||
JobResultCode int `json:"jobresultcode"`
|
||||
JobResultType string `json:"jobresulttype"`
|
||||
JobStatus JobStatusType `json:"jobstatus"`
|
||||
UserID string `json:"userid"`
|
||||
JobID string `json:"jobid"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account that executed the async command"`
|
||||
Cmd string `json:"cmd,omitempty" doc:"the async command executed"`
|
||||
Created string `json:"created,omitempty" doc:"the created date of the job"`
|
||||
JobID *UUID `json:"jobid,omitempty" doc:"extra field for the initial async call"`
|
||||
JobInstanceID *UUID `json:"jobinstanceid,omitempty" doc:"the unique ID of the instance/entity object related to the job"`
|
||||
JobInstanceType string `json:"jobinstancetype,omitempty" doc:"the instance/entity object related to the job"`
|
||||
JobProcStatus int `json:"jobprocstatus,omitempty" doc:"the progress information of the PENDING job"`
|
||||
JobResult *json.RawMessage `json:"jobresult,omitempty" doc:"the result reason"`
|
||||
JobResultCode int `json:"jobresultcode,omitempty" doc:"the result code for the job"`
|
||||
JobResultType string `json:"jobresulttype,omitempty" doc:"the result type"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty" doc:"the current job status-should be 0 for PENDING"`
|
||||
UserID *UUID `json:"userid,omitempty" doc:"the user that executed the async command"`
|
||||
}
|
||||
|
||||
func (a AsyncJobResult) Error() error {
|
||||
r := new(ErrorResponse)
|
||||
if e := json.Unmarshal(*a.JobResult, r); e != nil {
|
||||
return e
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// QueryAsyncJobResult represents a query to fetch the status of async job
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/queryAsyncJobResult.html
|
||||
type QueryAsyncJobResult struct {
|
||||
JobID string `json:"jobid"`
|
||||
JobID *UUID `json:"jobid" doc:"the ID of the asynchronous job"`
|
||||
_ bool `name:"queryAsyncJobResult" description:"Retrieves the current status of asynchronous job."`
|
||||
}
|
||||
|
||||
func (*QueryAsyncJobResult) name() string {
|
||||
return "queryAsyncJobResult"
|
||||
func (QueryAsyncJobResult) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*QueryAsyncJobResult) response() interface{} {
|
||||
return new(QueryAsyncJobResultResponse)
|
||||
}
|
||||
|
||||
// QueryAsyncJobResultResponse represents the current status of an asynchronous job
|
||||
type QueryAsyncJobResultResponse AsyncJobResult
|
||||
|
||||
// ListAsyncJobs list the asynchronous jobs
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listAsyncJobs.html
|
||||
type ListAsyncJobs struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListAsyncJobs) name() string {
|
||||
return "listAsyncJobs"
|
||||
}
|
||||
|
||||
func (*ListAsyncJobs) response() interface{} {
|
||||
return new(ListAsyncJobsResponse)
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date of the async job"`
|
||||
_ bool `name:"listAsyncJobs" description:"Lists all pending asynchronous jobs for the account."`
|
||||
}
|
||||
|
||||
// ListAsyncJobsResponse represents a list of job results
|
||||
|
@ -64,3 +57,35 @@ type ListAsyncJobsResponse struct {
|
|||
Count int `json:"count"`
|
||||
AsyncJobs []AsyncJobResult `json:"asyncjobs"`
|
||||
}
|
||||
|
||||
func (ListAsyncJobs) response() interface{} {
|
||||
return new(ListAsyncJobsResponse)
|
||||
}
|
||||
|
||||
// Result unmarshals the result of an AsyncJobResult into the given interface
|
||||
func (a AsyncJobResult) Result(i interface{}) error {
|
||||
if a.JobStatus == Failure {
|
||||
return a.Error()
|
||||
}
|
||||
|
||||
if a.JobStatus == Success {
|
||||
m := map[string]json.RawMessage{}
|
||||
err := json.Unmarshal(*(a.JobResult), &m)
|
||||
|
||||
if err == nil {
|
||||
if len(m) >= 1 {
|
||||
if _, ok := m["success"]; ok {
|
||||
return json.Unmarshal(*(a.JobResult), i)
|
||||
}
|
||||
|
||||
// otherwise, pick the first key
|
||||
for k := range m {
|
||||
return json.Unmarshal(m[k], i)
|
||||
}
|
||||
}
|
||||
return errors.New("empty response")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
62
vendor/github.com/exoscale/egoscale/cidr.go
generated
vendored
Normal file
62
vendor/github.com/exoscale/egoscale/cidr.go
generated
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
// CIDR represents a nicely JSON serializable net.IPNet
|
||||
type CIDR struct {
|
||||
net.IPNet
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals the raw JSON into the MAC address
|
||||
func (cidr *CIDR) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
c, err := ParseCIDR(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*cidr = CIDR{c.IPNet}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON converts the CIDR to a string representation
|
||||
func (cidr CIDR) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", cidr)), nil
|
||||
}
|
||||
|
||||
// String returns the string representation of a CIDR
|
||||
func (cidr CIDR) String() string {
|
||||
return cidr.IPNet.String()
|
||||
}
|
||||
|
||||
// ParseCIDR parses a CIDR from a string
|
||||
func ParseCIDR(s string) (*CIDR, error) {
|
||||
_, net, err := net.ParseCIDR(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &CIDR{*net}, nil
|
||||
}
|
||||
|
||||
// MustParseCIDR forces parseCIDR or panics
|
||||
func MustParseCIDR(s string) *CIDR {
|
||||
cidr, err := ParseCIDR(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return cidr
|
||||
}
|
||||
|
||||
// Equal compare two CIDR
|
||||
func (cidr CIDR) Equal(c CIDR) bool {
|
||||
return (cidr.IPNet.IP.Equal(c.IPNet.IP) && bytes.Equal(cidr.IPNet.Mask, c.IPNet.Mask))
|
||||
}
|
385
vendor/github.com/exoscale/egoscale/client.go
generated
vendored
Normal file
385
vendor/github.com/exoscale/egoscale/client.go
generated
vendored
Normal file
|
@ -0,0 +1,385 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Taggable represents a resource which can have tags attached
|
||||
//
|
||||
// This is a helper to fill the resourcetype of a CreateTags call
|
||||
type Taggable interface {
|
||||
// CloudStack resource type of the Taggable type
|
||||
ResourceType() string
|
||||
}
|
||||
|
||||
// Deletable represents an Interface that can be "Delete" by the client
|
||||
type Deletable interface {
|
||||
// Delete removes the given resource(s) or throws
|
||||
Delete(context context.Context, client *Client) error
|
||||
}
|
||||
|
||||
// Listable represents an Interface that can be "List" by the client
|
||||
type Listable interface {
|
||||
// ListRequest builds the list command
|
||||
ListRequest() (ListCommand, error)
|
||||
}
|
||||
|
||||
// Gettable represents an Interface that can be "Get" by the client
|
||||
type Gettable interface {
|
||||
Listable
|
||||
}
|
||||
|
||||
// Client represents the CloudStack API client
|
||||
type Client struct {
|
||||
// HTTPClient holds the HTTP client
|
||||
HTTPClient *http.Client
|
||||
// Endpoints is CloudStack API
|
||||
Endpoint string
|
||||
// APIKey is the API identifier
|
||||
APIKey string
|
||||
// apisecret is the API secret, hence non exposed
|
||||
apiSecret string
|
||||
// PageSize represents the default size for a paginated result
|
||||
PageSize int
|
||||
// Timeout represents the default timeout for the async requests
|
||||
Timeout time.Duration
|
||||
// RetryStrategy represents the waiting strategy for polling the async requests
|
||||
RetryStrategy RetryStrategyFunc
|
||||
// Logger contains any log, plug your own
|
||||
Logger *log.Logger
|
||||
}
|
||||
|
||||
// RetryStrategyFunc represents a how much time to wait between two calls to CloudStack
|
||||
type RetryStrategyFunc func(int64) time.Duration
|
||||
|
||||
// IterateItemFunc represents the callback to iterate a list of results, if false stops
|
||||
type IterateItemFunc func(interface{}, error) bool
|
||||
|
||||
// WaitAsyncJobResultFunc represents the callback to wait a results of an async request, if false stops
|
||||
type WaitAsyncJobResultFunc func(*AsyncJobResult, error) bool
|
||||
|
||||
// NewClient creates a CloudStack API client with default timeout (60)
|
||||
//
|
||||
// Timeout is set to both the HTTP client and the client itself.
|
||||
func NewClient(endpoint, apiKey, apiSecret string) *Client {
|
||||
timeout := 60 * time.Second
|
||||
|
||||
httpClient := &http.Client{
|
||||
Transport: http.DefaultTransport,
|
||||
}
|
||||
|
||||
client := &Client{
|
||||
HTTPClient: httpClient,
|
||||
Endpoint: endpoint,
|
||||
APIKey: apiKey,
|
||||
apiSecret: apiSecret,
|
||||
PageSize: 50,
|
||||
Timeout: timeout,
|
||||
RetryStrategy: MonotonicRetryStrategyFunc(2),
|
||||
Logger: log.New(ioutil.Discard, "", 0),
|
||||
}
|
||||
|
||||
if prefix, ok := os.LookupEnv("EXOSCALE_TRACE"); ok {
|
||||
client.Logger = log.New(os.Stderr, prefix, log.LstdFlags)
|
||||
client.TraceOn()
|
||||
}
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
// Get populates the given resource or fails
|
||||
func (client *Client) Get(g Gettable) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.GetWithContext(ctx, g)
|
||||
}
|
||||
|
||||
// GetWithContext populates the given resource or fails
|
||||
func (client *Client) GetWithContext(ctx context.Context, g Gettable) error {
|
||||
gs, err := client.ListWithContext(ctx, g)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
count := len(gs)
|
||||
if count != 1 {
|
||||
req, err := g.ListRequest()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
params, err := client.Payload(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// formatting the query string nicely
|
||||
payload := params.Encode()
|
||||
payload = strings.Replace(payload, "&", ", ", -1)
|
||||
|
||||
if count == 0 {
|
||||
return &ErrorResponse{
|
||||
ErrorCode: ParamError,
|
||||
ErrorText: fmt.Sprintf("not found, query: %s", payload),
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("more than one element found: %s", payload)
|
||||
}
|
||||
|
||||
return Copy(g, gs[0])
|
||||
}
|
||||
|
||||
// Delete removes the given resource of fails
|
||||
func (client *Client) Delete(g Deletable) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.DeleteWithContext(ctx, g)
|
||||
}
|
||||
|
||||
// DeleteWithContext removes the given resource of fails
|
||||
func (client *Client) DeleteWithContext(ctx context.Context, g Deletable) error {
|
||||
return g.Delete(ctx, client)
|
||||
}
|
||||
|
||||
// List lists the given resource (and paginate till the end)
|
||||
func (client *Client) List(g Listable) ([]interface{}, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.ListWithContext(ctx, g)
|
||||
}
|
||||
|
||||
// ListWithContext lists the given resources (and paginate till the end)
|
||||
func (client *Client) ListWithContext(ctx context.Context, g Listable) ([]interface{}, error) {
|
||||
s := make([]interface{}, 0)
|
||||
|
||||
if g == nil || reflect.ValueOf(g).IsNil() {
|
||||
return s, fmt.Errorf("g Listable shouldn't be nil, got %#v", g)
|
||||
}
|
||||
|
||||
req, err := g.ListRequest()
|
||||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
|
||||
client.PaginateWithContext(ctx, req, func(item interface{}, e error) bool {
|
||||
if item != nil {
|
||||
s = append(s, item)
|
||||
return true
|
||||
}
|
||||
err = e
|
||||
return false
|
||||
})
|
||||
|
||||
return s, err
|
||||
}
|
||||
|
||||
// AsyncListWithContext lists the given resources (and paginate till the end)
|
||||
//
|
||||
//
|
||||
// // NB: goroutine may leak if not read until the end. Create a proper context!
|
||||
// ctx, cancel := context.WithCancel(context.Background())
|
||||
// defer cancel()
|
||||
//
|
||||
// outChan, errChan := client.AsyncListWithContext(ctx, new(egoscale.VirtualMachine))
|
||||
//
|
||||
// for {
|
||||
// select {
|
||||
// case i, ok := <- outChan:
|
||||
// if ok {
|
||||
// vm := i.(egoscale.VirtualMachine)
|
||||
// // ...
|
||||
// } else {
|
||||
// outChan = nil
|
||||
// }
|
||||
// case err, ok := <- errChan:
|
||||
// if ok {
|
||||
// // do something
|
||||
// }
|
||||
// // Once an error has been received, you can expect the channels to be closed.
|
||||
// errChan = nil
|
||||
// }
|
||||
// if errChan == nil && outChan == nil {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
func (client *Client) AsyncListWithContext(ctx context.Context, g Listable) (<-chan interface{}, <-chan error) {
|
||||
outChan := make(chan interface{}, client.PageSize)
|
||||
errChan := make(chan error)
|
||||
|
||||
go func() {
|
||||
defer close(outChan)
|
||||
defer close(errChan)
|
||||
|
||||
req, err := g.ListRequest()
|
||||
if err != nil {
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
|
||||
client.PaginateWithContext(ctx, req, func(item interface{}, e error) bool {
|
||||
if item != nil {
|
||||
outChan <- item
|
||||
return true
|
||||
}
|
||||
errChan <- e
|
||||
return false
|
||||
})
|
||||
}()
|
||||
|
||||
return outChan, errChan
|
||||
}
|
||||
|
||||
// Paginate runs the ListCommand and paginates
|
||||
func (client *Client) Paginate(req ListCommand, callback IterateItemFunc) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
client.PaginateWithContext(ctx, req, callback)
|
||||
}
|
||||
|
||||
// PaginateWithContext runs the ListCommand as long as the ctx is valid
|
||||
func (client *Client) PaginateWithContext(ctx context.Context, req ListCommand, callback IterateItemFunc) {
|
||||
pageSize := client.PageSize
|
||||
|
||||
page := 1
|
||||
|
||||
for {
|
||||
req.SetPage(page)
|
||||
req.SetPageSize(pageSize)
|
||||
resp, err := client.RequestWithContext(ctx, req)
|
||||
if err != nil {
|
||||
callback(nil, err)
|
||||
break
|
||||
}
|
||||
|
||||
size := 0
|
||||
didErr := false
|
||||
req.each(resp, func(element interface{}, err error) bool {
|
||||
// If the context was cancelled, kill it in flight
|
||||
if e := ctx.Err(); e != nil {
|
||||
element = nil
|
||||
err = e
|
||||
}
|
||||
|
||||
if callback(element, err) {
|
||||
size++
|
||||
return true
|
||||
}
|
||||
|
||||
didErr = true
|
||||
return false
|
||||
})
|
||||
|
||||
if size < pageSize || didErr {
|
||||
break
|
||||
}
|
||||
|
||||
page++
|
||||
}
|
||||
}
|
||||
|
||||
// APIName returns the CloudStack name of the given command
|
||||
func (client *Client) APIName(command Command) string {
|
||||
// This is due to a limitation of Go<=1.7
|
||||
if _, ok := command.(*AuthorizeSecurityGroupEgress); ok {
|
||||
return "authorizeSecurityGroupEgress"
|
||||
}
|
||||
|
||||
info, err := info(command)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return info.Name
|
||||
}
|
||||
|
||||
// APIDescription returns the description of the given CloudStack command
|
||||
func (client *Client) APIDescription(command Command) string {
|
||||
info, err := info(command)
|
||||
if err != nil {
|
||||
return "*missing description*"
|
||||
}
|
||||
return info.Description
|
||||
}
|
||||
|
||||
// Response returns the response structure of the given command
|
||||
func (client *Client) Response(command Command) interface{} {
|
||||
switch command.(type) {
|
||||
case AsyncCommand:
|
||||
return (command.(AsyncCommand)).asyncResponse()
|
||||
default:
|
||||
return command.response()
|
||||
}
|
||||
}
|
||||
|
||||
// TraceOn activates the HTTP tracer
|
||||
func (client *Client) TraceOn() {
|
||||
if _, ok := client.HTTPClient.Transport.(*traceTransport); !ok {
|
||||
client.HTTPClient.Transport = &traceTransport{
|
||||
transport: client.HTTPClient.Transport,
|
||||
logger: client.Logger,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TraceOff deactivates the HTTP tracer
|
||||
func (client *Client) TraceOff() {
|
||||
if rt, ok := client.HTTPClient.Transport.(*traceTransport); ok {
|
||||
client.HTTPClient.Transport = rt.transport
|
||||
}
|
||||
}
|
||||
|
||||
// traceTransport contains the original HTTP transport to enable it to be reverted
|
||||
type traceTransport struct {
|
||||
transport http.RoundTripper
|
||||
logger *log.Logger
|
||||
}
|
||||
|
||||
// RoundTrip executes a single HTTP transaction
|
||||
func (t *traceTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
if dump, err := httputil.DumpRequest(req, true); err == nil {
|
||||
t.logger.Printf("%s", dump)
|
||||
}
|
||||
|
||||
resp, err := t.transport.RoundTrip(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if dump, err := httputil.DumpResponse(resp, true); err == nil {
|
||||
t.logger.Printf("%s", dump)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// MonotonicRetryStrategyFunc returns a function that waits for n seconds for each iteration
|
||||
func MonotonicRetryStrategyFunc(seconds int) RetryStrategyFunc {
|
||||
return func(iteration int64) time.Duration {
|
||||
return time.Duration(seconds) * time.Second
|
||||
}
|
||||
}
|
||||
|
||||
// FibonacciRetryStrategy waits for an increasing amount of time following the Fibonacci sequence
|
||||
func FibonacciRetryStrategy(iteration int64) time.Duration {
|
||||
var a, b, i, tmp int64
|
||||
a = 0
|
||||
b = 1
|
||||
for i = 0; i < iteration; i++ {
|
||||
tmp = a + b
|
||||
a = b
|
||||
b = tmp
|
||||
}
|
||||
return time.Duration(a) * time.Second
|
||||
}
|
37
vendor/github.com/exoscale/egoscale/copier.go
generated
vendored
Normal file
37
vendor/github.com/exoscale/egoscale/copier.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// Copy copies the value from from into to. The type of "from" must be convertible into the type of "to".
|
||||
func Copy(to, from interface{}) error {
|
||||
tt := reflect.TypeOf(to)
|
||||
tv := reflect.ValueOf(to)
|
||||
|
||||
ft := reflect.TypeOf(from)
|
||||
fv := reflect.ValueOf(from)
|
||||
|
||||
if tt.Kind() != reflect.Ptr {
|
||||
return fmt.Errorf("must copy to a pointer, got %q", tt.Name())
|
||||
}
|
||||
|
||||
tt = tt.Elem()
|
||||
tv = tv.Elem()
|
||||
|
||||
for {
|
||||
if ft.ConvertibleTo(tt) {
|
||||
break
|
||||
}
|
||||
if ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
fv = fv.Elem()
|
||||
} else {
|
||||
return fmt.Errorf("cannot convert %q into %q", tt.Name(), ft.Name())
|
||||
}
|
||||
}
|
||||
|
||||
tv.Set(fv.Convert(tt))
|
||||
return nil
|
||||
}
|
47
vendor/github.com/exoscale/egoscale/cserrorcode_string.go
generated
vendored
Normal file
47
vendor/github.com/exoscale/egoscale/cserrorcode_string.go
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Code generated by "stringer -type CSErrorCode"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _CSErrorCode_name = "CloudRuntimeExceptionExecutionExceptionHypervisorVersionChangedExceptionCloudExceptionAccountLimitExceptionAgentUnavailableExceptionCloudAuthenticationExceptionConcurrentOperationExceptionConflictingNetworkSettingsExceptionDiscoveredWithErrorExceptionHAStateExceptionInsufficientAddressCapacityExceptionInsufficientCapacityExceptionInsufficientNetworkCapacityExceptionInsufficientServerCapacityExceptionInsufficientStorageCapacityExceptionInternalErrorExceptionInvalidParameterValueExceptionManagementServerExceptionNetworkRuleConflictExceptionPermissionDeniedExceptionResourceAllocationExceptionResourceInUseExceptionResourceUnavailableExceptionStorageUnavailableExceptionUnsupportedServiceExceptionVirtualMachineMigrationExceptionAsyncCommandQueuedRequestLimitExceptionServerAPIException"
|
||||
|
||||
var _CSErrorCode_map = map[CSErrorCode]string{
|
||||
4250: _CSErrorCode_name[0:21],
|
||||
4260: _CSErrorCode_name[21:39],
|
||||
4265: _CSErrorCode_name[39:72],
|
||||
4275: _CSErrorCode_name[72:86],
|
||||
4280: _CSErrorCode_name[86:107],
|
||||
4285: _CSErrorCode_name[107:132],
|
||||
4290: _CSErrorCode_name[132:160],
|
||||
4300: _CSErrorCode_name[160:188],
|
||||
4305: _CSErrorCode_name[188:223],
|
||||
4310: _CSErrorCode_name[223:251],
|
||||
4315: _CSErrorCode_name[251:267],
|
||||
4320: _CSErrorCode_name[267:303],
|
||||
4325: _CSErrorCode_name[303:332],
|
||||
4330: _CSErrorCode_name[332:368],
|
||||
4335: _CSErrorCode_name[368:403],
|
||||
4340: _CSErrorCode_name[403:439],
|
||||
4345: _CSErrorCode_name[439:461],
|
||||
4350: _CSErrorCode_name[461:491],
|
||||
4355: _CSErrorCode_name[491:516],
|
||||
4360: _CSErrorCode_name[516:544],
|
||||
4365: _CSErrorCode_name[544:569],
|
||||
4370: _CSErrorCode_name[569:596],
|
||||
4375: _CSErrorCode_name[596:618],
|
||||
4380: _CSErrorCode_name[618:646],
|
||||
4385: _CSErrorCode_name[646:673],
|
||||
4390: _CSErrorCode_name[673:700],
|
||||
4395: _CSErrorCode_name[700:732],
|
||||
4540: _CSErrorCode_name[732:750],
|
||||
4545: _CSErrorCode_name[750:771],
|
||||
9999: _CSErrorCode_name[771:789],
|
||||
}
|
||||
|
||||
func (i CSErrorCode) String() string {
|
||||
if str, ok := _CSErrorCode_map[i]; ok {
|
||||
return str
|
||||
}
|
||||
return "CSErrorCode(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
208
vendor/github.com/exoscale/egoscale/dns.go
generated
vendored
208
vendor/github.com/exoscale/egoscale/dns.go
generated
vendored
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
@ -53,27 +54,81 @@ type DNSRecordResponse struct {
|
|||
Record DNSRecord `json:"record"`
|
||||
}
|
||||
|
||||
// UpdateDNSRecord represents a DNS record
|
||||
type UpdateDNSRecord struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
DomainID int64 `json:"domain_id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
TTL int `json:"ttl,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
UpdatedAt string `json:"updated_at,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
RecordType string `json:"record_type,omitempty"`
|
||||
Prio int `json:"prio,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateDNSRecordResponse represents the creation of a DNS record
|
||||
type UpdateDNSRecordResponse struct {
|
||||
Record UpdateDNSRecord `json:"record"`
|
||||
}
|
||||
|
||||
// DNSErrorResponse represents an error in the API
|
||||
type DNSErrorResponse struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
Errors *DNSError `json:"errors"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Errors map[string][]string `json:"errors"`
|
||||
}
|
||||
|
||||
// DNSError represents an error
|
||||
type DNSError struct {
|
||||
Name []string `json:"name"`
|
||||
}
|
||||
// Record represent record type
|
||||
type Record int
|
||||
|
||||
//go:generate stringer -type=Record
|
||||
const (
|
||||
// A record type
|
||||
A Record = iota
|
||||
// AAAA record type
|
||||
AAAA
|
||||
// ALIAS record type
|
||||
ALIAS
|
||||
// CNAME record type
|
||||
CNAME
|
||||
// HINFO record type
|
||||
HINFO
|
||||
// MX record type
|
||||
MX
|
||||
// NAPTR record type
|
||||
NAPTR
|
||||
// NS record type
|
||||
NS
|
||||
// POOL record type
|
||||
POOL
|
||||
// SPF record type
|
||||
SPF
|
||||
// SRV record type
|
||||
SRV
|
||||
// SSHFP record type
|
||||
SSHFP
|
||||
// TXT record type
|
||||
TXT
|
||||
// URL record type
|
||||
URL
|
||||
)
|
||||
|
||||
// Error formats the DNSerror into a string
|
||||
func (req *DNSErrorResponse) Error() error {
|
||||
if req.Errors != nil {
|
||||
return fmt.Errorf("DNS error: %s", strings.Join(req.Errors.Name, ", "))
|
||||
func (req *DNSErrorResponse) Error() string {
|
||||
if len(req.Errors) > 0 {
|
||||
errs := []string{}
|
||||
for name, ss := range req.Errors {
|
||||
if len(ss) > 0 {
|
||||
errs = append(errs, fmt.Sprintf("%s: %s", name, strings.Join(ss, ", ")))
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("dns error: %s (%s)", req.Message, strings.Join(errs, "; "))
|
||||
}
|
||||
return fmt.Errorf("DNS error: %s", req.Message)
|
||||
return fmt.Sprintf("dns error: %s", req.Message)
|
||||
}
|
||||
|
||||
// CreateDomain creates a DNS domain
|
||||
func (exo *Client) CreateDomain(name string) (*DNSDomain, error) {
|
||||
func (client *Client) CreateDomain(name string) (*DNSDomain, error) {
|
||||
m, err := json.Marshal(DNSDomainResponse{
|
||||
Domain: &DNSDomain{
|
||||
Name: name,
|
||||
|
@ -83,7 +138,7 @@ func (exo *Client) CreateDomain(name string) (*DNSDomain, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := exo.dnsRequest("/v1/domains", string(m), "POST")
|
||||
resp, err := client.dnsRequest("/v1/domains", nil, string(m), "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -97,8 +152,8 @@ func (exo *Client) CreateDomain(name string) (*DNSDomain, error) {
|
|||
}
|
||||
|
||||
// GetDomain gets a DNS domain
|
||||
func (exo *Client) GetDomain(name string) (*DNSDomain, error) {
|
||||
resp, err := exo.dnsRequest("/v1/domains/"+name, "", "GET")
|
||||
func (client *Client) GetDomain(name string) (*DNSDomain, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name, nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -111,20 +166,35 @@ func (exo *Client) GetDomain(name string) (*DNSDomain, error) {
|
|||
return d.Domain, nil
|
||||
}
|
||||
|
||||
// DeleteDomain delets a DNS domain
|
||||
func (exo *Client) DeleteDomain(name string) error {
|
||||
_, err := exo.dnsRequest("/v1/domains/"+name, "", "DELETE")
|
||||
// GetDomains gets DNS domains
|
||||
func (client *Client) GetDomains() ([]DNSDomain, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains", nil, "", "GET")
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil
|
||||
var d []DNSDomainResponse
|
||||
if err := json.Unmarshal(resp, &d); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
domains := make([]DNSDomain, len(d))
|
||||
for i := range d {
|
||||
domains[i] = *d[i].Domain
|
||||
}
|
||||
return domains, nil
|
||||
}
|
||||
|
||||
// DeleteDomain delets a DNS domain
|
||||
func (client *Client) DeleteDomain(name string) error {
|
||||
_, err := client.dnsRequest("/v1/domains/"+name, nil, "", "DELETE")
|
||||
return err
|
||||
}
|
||||
|
||||
// GetRecord returns a DNS record
|
||||
func (exo *Client) GetRecord(domain string, recordID int64) (*DNSRecord, error) {
|
||||
func (client *Client) GetRecord(domain string, recordID int64) (*DNSRecord, error) {
|
||||
id := strconv.FormatInt(recordID, 10)
|
||||
resp, err := exo.dnsRequest("/v1/domains/"+domain+"/records/"+id, "", "GET")
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records/"+id, nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -138,8 +208,37 @@ func (exo *Client) GetRecord(domain string, recordID int64) (*DNSRecord, error)
|
|||
}
|
||||
|
||||
// GetRecords returns the DNS records
|
||||
func (exo *Client) GetRecords(name string) ([]DNSRecord, error) {
|
||||
resp, err := exo.dnsRequest("/v1/domains/"+name+"/records", "", "GET")
|
||||
func (client *Client) GetRecords(domain string) ([]DNSRecord, error) {
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records", nil, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r []DNSRecordResponse
|
||||
if err = json.Unmarshal(resp, &r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
records := make([]DNSRecord, 0, len(r))
|
||||
for _, rec := range r {
|
||||
records = append(records, rec.Record)
|
||||
}
|
||||
|
||||
return records, nil
|
||||
}
|
||||
|
||||
// GetRecordsWithFilters returns the DNS records (filters can be empty)
|
||||
func (client *Client) GetRecordsWithFilters(domain, name, recordType string) ([]DNSRecord, error) {
|
||||
|
||||
filters := url.Values{}
|
||||
if name != "" {
|
||||
filters.Add("name", name)
|
||||
}
|
||||
if recordType != "" {
|
||||
filters.Add("record_type", recordType)
|
||||
}
|
||||
|
||||
resp, err := client.dnsRequest("/v1/domains/"+domain+"/records", filters, "", "GET")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -158,7 +257,7 @@ func (exo *Client) GetRecords(name string) ([]DNSRecord, error) {
|
|||
}
|
||||
|
||||
// CreateRecord creates a DNS record
|
||||
func (exo *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, error) {
|
||||
func (client *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, error) {
|
||||
body, err := json.Marshal(DNSRecordResponse{
|
||||
Record: rec,
|
||||
})
|
||||
|
@ -166,7 +265,7 @@ func (exo *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, error)
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := exo.dnsRequest("/v1/domains/"+name+"/records", string(body), "POST")
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name+"/records", nil, string(body), "POST")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -180,8 +279,8 @@ func (exo *Client) CreateRecord(name string, rec DNSRecord) (*DNSRecord, error)
|
|||
}
|
||||
|
||||
// UpdateRecord updates a DNS record
|
||||
func (exo *Client) UpdateRecord(name string, rec DNSRecord) (*DNSRecord, error) {
|
||||
body, err := json.Marshal(DNSRecordResponse{
|
||||
func (client *Client) UpdateRecord(name string, rec UpdateDNSRecord) (*DNSRecord, error) {
|
||||
body, err := json.Marshal(UpdateDNSRecordResponse{
|
||||
Record: rec,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -189,7 +288,7 @@ func (exo *Client) UpdateRecord(name string, rec DNSRecord) (*DNSRecord, error)
|
|||
}
|
||||
|
||||
id := strconv.FormatInt(rec.ID, 10)
|
||||
resp, err := exo.dnsRequest("/v1/domains/"+name+"/records/"+id, string(body), "PUT")
|
||||
resp, err := client.dnsRequest("/v1/domains/"+name+"/records/"+id, nil, string(body), "PUT")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -203,45 +302,64 @@ func (exo *Client) UpdateRecord(name string, rec DNSRecord) (*DNSRecord, error)
|
|||
}
|
||||
|
||||
// DeleteRecord deletes a record
|
||||
func (exo *Client) DeleteRecord(name string, recordID int64) error {
|
||||
func (client *Client) DeleteRecord(name string, recordID int64) error {
|
||||
id := strconv.FormatInt(recordID, 10)
|
||||
_, err := exo.dnsRequest("/v1/domains/"+name+"/records/"+id, "", "DELETE")
|
||||
_, err := client.dnsRequest("/v1/domains/"+name+"/records/"+id, nil, "", "DELETE")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (exo *Client) dnsRequest(uri string, params string, method string) (json.RawMessage, error) {
|
||||
url := exo.endpoint + uri
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(params))
|
||||
func (client *Client) dnsRequest(uri string, urlValues url.Values, params, method string) (json.RawMessage, error) {
|
||||
rawURL := client.Endpoint + uri
|
||||
url, err := url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
q := url.Query()
|
||||
for k, vs := range urlValues {
|
||||
for _, v := range vs {
|
||||
q.Add(k, v)
|
||||
}
|
||||
}
|
||||
url.RawQuery = q.Encode()
|
||||
|
||||
req, err := http.NewRequest(method, url.String(), strings.NewReader(params))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var hdr = make(http.Header)
|
||||
hdr.Add("X-DNS-TOKEN", exo.apiKey+":"+exo.apiSecret)
|
||||
hdr.Add("X-DNS-TOKEN", client.APIKey+":"+client.apiSecret)
|
||||
hdr.Add("User-Agent", fmt.Sprintf("exoscale/egoscale (%v)", Version))
|
||||
hdr.Add("Accept", "application/json")
|
||||
if params != "" {
|
||||
hdr.Add("Content-Type", "application/json")
|
||||
}
|
||||
req.Header = hdr
|
||||
|
||||
response, err := exo.client.Do(req)
|
||||
resp, err := client.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close() // nolint: errcheck
|
||||
|
||||
contentType := resp.Header.Get("content-type")
|
||||
if !strings.Contains(contentType, "application/json") {
|
||||
return nil, fmt.Errorf(`response content-type expected to be "application/json", got %q`, contentType)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
b, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if response.StatusCode >= 400 {
|
||||
var e DNSErrorResponse
|
||||
if err := json.Unmarshal(b, &e); err != nil {
|
||||
if resp.StatusCode >= 400 {
|
||||
e := new(DNSErrorResponse)
|
||||
if err := json.Unmarshal(b, e); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, e.Error()
|
||||
return nil, e
|
||||
}
|
||||
|
||||
return b, nil
|
||||
|
|
178
vendor/github.com/exoscale/egoscale/doc.go
generated
vendored
178
vendor/github.com/exoscale/egoscale/doc.go
generated
vendored
|
@ -1,16 +1,76 @@
|
|||
/*
|
||||
|
||||
Package egoscale is a mapping for with the CloudStack API (http://cloudstack.apache.org/api.html) from Go. It has been designed against the Exoscale (https://www.exoscale.ch/) infrastructure but should fit other CloudStack services.
|
||||
Package egoscale is a mapping for with the CloudStack API (http://cloudstack.apache.org/api.html) from Go. It has been designed against the Exoscale (https://www.exoscale.com/) infrastructure but should fit other CloudStack services.
|
||||
|
||||
Requests and Responses
|
||||
|
||||
The paradigm used in this library is that CloudStack defines two types of requests synchronous (client.Request) and asynchronous (client.AsyncRequest). And when the expected responses is a success message, you may use the boolean requests variants (client.BooleanRequest, client.BooleanAsyncRequest). To build a request, construct the adequate struct. This library expects a pointer for efficiency reasons only. The response is a struct corresponding to the request itself. E.g. DeployVirtualMachine gives DeployVirtualMachineResponse, as a pointer as well to avoid big copies.
|
||||
To build a request, construct the adequate struct. This library expects a pointer for efficiency reasons only. The response is a struct corresponding to the data at stake. E.g. DeployVirtualMachine gives a VirtualMachine, as a pointer as well to avoid big copies.
|
||||
|
||||
Then everything within the struct is not a pointer.
|
||||
Then everything within the struct is not a pointer. Find below some examples of how egoscale may be used to interact with a CloudStack endpoint, especially Exoscale itself. If anything feels odd or unclear, please let us know: https://github.com/exoscale/egoscale/issues
|
||||
|
||||
Affinity and Anti-Affinity groups
|
||||
req := &egoscale.DeployVirtualMachine{
|
||||
Size: 10,
|
||||
ServiceOfferingID: "...",
|
||||
TemplateID: "...",
|
||||
ZoneID: "...",
|
||||
}
|
||||
|
||||
fmt.Println("Deployment started")
|
||||
resp, err := cs.Request(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
vm := resp.(*egoscale.VirtualMachine)
|
||||
fmt.Printf("Virtual Machine ID: %s\n", vm.ID)
|
||||
|
||||
This example deploys a virtual machine while controlling the job status as it goes. It enables a finer control over errors, e.g. HTTP timeout, and eventually a way to kill it of (from the client side).
|
||||
|
||||
req := &egoscale.DeployVirtualMachine{
|
||||
Size: 10,
|
||||
ServiceOfferingID: "...",
|
||||
TemplateID: "...",
|
||||
ZoneID: "...",
|
||||
}
|
||||
vm := &egoscale.VirtualMachine{}
|
||||
|
||||
fmt.Println("Deployment started")
|
||||
cs.AsyncRequest(req, func(jobResult *egoscale.AsyncJobResult, err error) bool {
|
||||
if err != nil {
|
||||
// any kind of error
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Keep waiting
|
||||
if jobResult.JobStatus == egoscale.Pending {
|
||||
fmt.Println("wait...")
|
||||
return true
|
||||
}
|
||||
|
||||
// Unmarshal the response into the response struct
|
||||
if err := jobResult.Response(vm); err != nil {
|
||||
// JSON unmarshaling error
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Stop waiting
|
||||
return false
|
||||
})
|
||||
|
||||
fmt.Printf("Virtual Machine ID: %s\n", vm.ID)
|
||||
|
||||
Debugging and traces
|
||||
|
||||
As this library is mostly an HTTP client, you can reuse all the existing tools around it.
|
||||
|
||||
cs := egoscale.NewClient("https://api.exoscale.ch/compute", "EXO...", "...")
|
||||
// sets a logger on stderr
|
||||
cs.Logger = log.Newos.Stderr, "prefix", log.LstdFlags)
|
||||
// activates the HTTP traces
|
||||
cs.TraceOn()
|
||||
|
||||
Nota bene: when running the tests or the egoscale library via another tool, e.g. the exo cli (or the cs cli), the environment variable EXOSCALE_TRACE=prefix does the above configuration for you. As a developer using egoscale as a library, you'll find it more convenient to plug your favorite io.Writer as it's Logger.
|
||||
|
||||
Affinity and Anti-Affinity groups provide a way to influence where VMs should run. See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html#affinity-groups
|
||||
|
||||
APIs
|
||||
|
||||
|
@ -24,70 +84,94 @@ All the available APIs on the server and provided by the API Discovery plugin
|
|||
}
|
||||
|
||||
for _, api := range resp.(*egoscale.ListAPIsResponse).API {
|
||||
fmt.Println("%s %s", api.Name, api.Description)
|
||||
fmt.Printf("%s %s\n", api.Name, api.Description)
|
||||
}
|
||||
// Output:
|
||||
// listNetworks Lists all available networks
|
||||
// ...
|
||||
|
||||
|
||||
Elastic IPs
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html#about-elastic-ips
|
||||
|
||||
Networks
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.8/networking_and_traffic.html
|
||||
|
||||
NICs
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html#configuring-multiple-ip-addresses-on-a-single-nic
|
||||
|
||||
|
||||
Security Groups
|
||||
|
||||
Security Groups provide a way to isolate traffic to VMs.
|
||||
Security Groups provide a way to isolate traffic to VMs. Rules are added via the two Authorization commands.
|
||||
|
||||
resp, err := cs.Request(&egoscale.CreateSecurityGroup{
|
||||
Name: "Load balancer",
|
||||
Description: "Opens HTTP/HTTPS ports from the outside world",
|
||||
})
|
||||
securityGroup := resp.(*egoscale.CreateSecurityGroupResponse).SecurityGroup
|
||||
securityGroup := resp.(*egoscale.SecurityGroup)
|
||||
|
||||
resp, err = cs.Request(&egoscale.AuthorizeSecurityGroupIngress{
|
||||
Description: "SSH traffic",
|
||||
SecurityGroupID: securityGroup.ID,
|
||||
CidrList: []string{"0.0.0.0/0"},
|
||||
Protocol: "tcp",
|
||||
StartPort: 22,
|
||||
EndPort: 22,
|
||||
})
|
||||
// The modified SecurityGroup is returned
|
||||
securityGroup := resp.(*egoscale.SecurityGroup)
|
||||
|
||||
// ...
|
||||
err = client.BooleanRequest(&egoscale.DeleteSecurityGroup{
|
||||
ID: securityGroup.ID,
|
||||
})
|
||||
// ...
|
||||
|
||||
Security Group also implement the generic List, Get and Delete interfaces (Listable, Gettable and Deletable).
|
||||
|
||||
// List all Security Groups
|
||||
sgs, err := cs.List(new(egoscale.SecurityGroup))
|
||||
for _, s := range sgs {
|
||||
sg := s.(egoscale.SecurityGroup)
|
||||
// ...
|
||||
}
|
||||
|
||||
// Get a Security Group
|
||||
sg := &egoscale.SecurityGroup{Name: "Load balancer"}
|
||||
if err := cs.Get(sg); err != nil {
|
||||
...
|
||||
}
|
||||
// The SecurityGroup struct has been loaded with the SecurityGroup informations
|
||||
|
||||
if err := cs.Delete(sg); err != nil {
|
||||
...
|
||||
}
|
||||
// The SecurityGroup has been deleted
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/networking_and_traffic.html#security-groups
|
||||
|
||||
Service Offerings
|
||||
|
||||
A service offering correspond to some hardware features (CPU, RAM).
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/service_offerings.html
|
||||
|
||||
SSH Key Pairs
|
||||
|
||||
In addition to username and password (disabled on Exoscale), SSH keys are used to log into the infrastructure.
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html#creating-the-ssh-keypair
|
||||
|
||||
Virtual Machines
|
||||
|
||||
... todo ...
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html
|
||||
|
||||
Templates
|
||||
|
||||
... todo ...
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/templates.html
|
||||
|
||||
Zones
|
||||
|
||||
A Zone corresponds to a Data Center.
|
||||
A Zone corresponds to a Data Center. You may list them. Zone implements the Listable interface, which let you perform a list in two different ways. The first exposes the underlying CloudStack request while the second one hide them and you only manipulate the structs of your interest.
|
||||
|
||||
// Using ListZones request
|
||||
req := &egoscale.ListZones{}
|
||||
resp, err := client.Request(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, zone := range resp.(*egoscale.ListZonesResponse) {
|
||||
...
|
||||
}
|
||||
|
||||
// Using client.List
|
||||
zone := &egoscale.Zone{}
|
||||
zones, err := client.List(zone)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, z := range zones {
|
||||
zone := z.(egoscale.Zone)
|
||||
...
|
||||
}
|
||||
|
||||
Elastic IPs
|
||||
|
||||
An Elastic IP is a way to attach an IP address to many Virtual Machines. The API side of the story configures the external environment, like the routing. Some work is required within the machine to properly configure the interfaces.
|
||||
|
||||
See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html#about-elastic-ips
|
||||
|
||||
*/
|
||||
package egoscale
|
||||
|
|
37
vendor/github.com/exoscale/egoscale/errorcode_string.go
generated
vendored
Normal file
37
vendor/github.com/exoscale/egoscale/errorcode_string.go
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Code generated by "stringer -type ErrorCode"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const (
|
||||
_ErrorCode_name_0 = "Unauthorized"
|
||||
_ErrorCode_name_1 = "MethodNotAllowed"
|
||||
_ErrorCode_name_2 = "UnsupportedActionError"
|
||||
_ErrorCode_name_3 = "APILimitExceededMalformedParameterErrorParamError"
|
||||
_ErrorCode_name_4 = "InternalErrorAccountErrorAccountResourceLimitErrorInsufficientCapacityErrorResourceUnavailableErrorResourceAllocationErrorResourceInUseErrorNetworkRuleConflictError"
|
||||
)
|
||||
|
||||
var (
|
||||
_ErrorCode_index_3 = [...]uint8{0, 16, 39, 49}
|
||||
_ErrorCode_index_4 = [...]uint8{0, 13, 25, 50, 75, 99, 122, 140, 164}
|
||||
)
|
||||
|
||||
func (i ErrorCode) String() string {
|
||||
switch {
|
||||
case i == 401:
|
||||
return _ErrorCode_name_0
|
||||
case i == 405:
|
||||
return _ErrorCode_name_1
|
||||
case i == 422:
|
||||
return _ErrorCode_name_2
|
||||
case 429 <= i && i <= 431:
|
||||
i -= 429
|
||||
return _ErrorCode_name_3[_ErrorCode_index_3[i]:_ErrorCode_index_3[i+1]]
|
||||
case 530 <= i && i <= 537:
|
||||
i -= 530
|
||||
return _ErrorCode_name_4[_ErrorCode_index_4[i]:_ErrorCode_index_4[i+1]]
|
||||
default:
|
||||
return "ErrorCode(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
}
|
83
vendor/github.com/exoscale/egoscale/events.go
generated
vendored
83
vendor/github.com/exoscale/egoscale/events.go
generated
vendored
|
@ -2,53 +2,41 @@ package egoscale
|
|||
|
||||
// Event represents an event in the system
|
||||
type Event struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account"`
|
||||
Created string `json:"created"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Level string `json:"level"` // INFO, WARN, ERROR
|
||||
ParentID string `json:"parentid,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Type string `json:"type"`
|
||||
UserName string `json:"username,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account name for the account that owns the object being acted on in the event (e.g. the owner of the virtual machine, ip address, or security group)"`
|
||||
Created string `json:"created,omitempty" doc:"the date the event was created"`
|
||||
Description string `json:"description,omitempty" doc:"a brief description of the event"`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the account's domain"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the id of the account's domain"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the event"`
|
||||
Level string `json:"level,omitempty" doc:"the event level (INFO, WARN, ERROR)"`
|
||||
ParentID *UUID `json:"parentid,omitempty" doc:"whether the event is parented"`
|
||||
State string `json:"state,omitempty" doc:"the state of the event"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the event (see event types)"`
|
||||
UserName string `json:"username,omitempty" doc:"the name of the user who performed the action (can be different from the account if an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)"`
|
||||
}
|
||||
|
||||
// EventType represent a type of event
|
||||
type EventType struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name,omitempty" doc:"Event Type"`
|
||||
}
|
||||
|
||||
// ListEvents list the events
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listEvents.html
|
||||
type ListEvents struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Duration int `json:"duration,omitempty"`
|
||||
EndDate string `json:"enddate,omitempty"`
|
||||
EntryTime int `json:"entrytime,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Level string `json:"level,omitempty"` // INFO, WARN, ERROR
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Duration int `json:"duration,omitempty" doc:"the duration of the event"`
|
||||
EndDate string `json:"enddate,omitempty" doc:"the end date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
EntryTime int `json:"entrytime,omitempty" doc:"the time the event was entered"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the event"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves." doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Level string `json:"level,omitempty" doc:"the event level (INFO, WARN, ERROR)"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty" `
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
StartDate string `json:"startdate,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListEvents) name() string {
|
||||
return "listEvents"
|
||||
}
|
||||
|
||||
func (*ListEvents) response() interface{} {
|
||||
return new(ListEventsResponse)
|
||||
StartDate string `json:"startdate,omitempty" doc:"the start date range of the list you want to retrieve (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")"`
|
||||
Type string `json:"type,omitempty" doc:"the event type (see event types)"`
|
||||
_ bool `name:"listEvents" description:"A command to list events."`
|
||||
}
|
||||
|
||||
// ListEventsResponse represents a response of a list query
|
||||
|
@ -57,21 +45,22 @@ type ListEventsResponse struct {
|
|||
Event []Event `json:"event"`
|
||||
}
|
||||
|
||||
// ListEventTypes list the event types
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listEventTypes.html
|
||||
type ListEventTypes struct{}
|
||||
|
||||
func (*ListEventTypes) name() string {
|
||||
return "listEventTypes"
|
||||
func (ListEvents) response() interface{} {
|
||||
return new(ListEventsResponse)
|
||||
}
|
||||
|
||||
func (*ListEventTypes) response() interface{} {
|
||||
return new(ListEventTypesResponse)
|
||||
// ListEventTypes list the event types
|
||||
type ListEventTypes struct {
|
||||
_ bool `name:"listEventTypes" description:"List Event Types"`
|
||||
}
|
||||
|
||||
// ListEventTypesResponse represents a response of a list query
|
||||
type ListEventTypesResponse struct {
|
||||
Count int `json:"count"`
|
||||
EventType []EventType `json:"eventtype"`
|
||||
_ bool `name:"listEventTypes" description:"List Event Types"`
|
||||
}
|
||||
|
||||
func (ListEventTypes) response() interface{} {
|
||||
return new(ListEventTypesResponse)
|
||||
}
|
||||
|
|
99
vendor/github.com/exoscale/egoscale/hosts.go
generated
vendored
Normal file
99
vendor/github.com/exoscale/egoscale/hosts.go
generated
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// Host represents the Hypervisor
|
||||
type Host struct {
|
||||
Capabilities string `json:"capabilities,omitempty" doc:"capabilities of the host"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"the cluster ID of the host"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"the cluster name of the host"`
|
||||
ClusterType string `json:"clustertype,omitempty" doc:"the cluster type of the cluster that host belongs to"`
|
||||
CPUAllocated int64 `json:"cpuallocated,omitempty" doc:"the amount of the host's CPU currently allocated"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the CPU number of the host"`
|
||||
CPUSockets int `json:"cpusockets,omitempty" doc:"the number of CPU sockets on the host"`
|
||||
CPUSpeed int64 `json:"cpuspeed,omitempty" doc:"the CPU speed of the host"`
|
||||
CPUUsed int64 `json:"cpuused,omitempty" doc:"the amount of the host's CPU currently used"`
|
||||
CPUWithOverProvisioning int64 `json:"cpuwithoverprovisioning,omitempty" doc:"the amount of the host's CPU after applying the cpu.overprovisioning.factor"`
|
||||
Created string `json:"created,omitempty" doc:"the date and time the host was created"`
|
||||
Disconnected string `json:"disconnected,omitempty" doc:"true if the host is disconnected. False otherwise."`
|
||||
DiskSizeAllocated int64 `json:"disksizeallocated,omitempty" doc:"the host's or host storage pool's currently allocated disk size"`
|
||||
DiskSizeTotal int64 `json:"disksizetotal,omitempty" doc:"the total disk size of the host or host storage pool"`
|
||||
DiskSizeUsed int64 `json:"disksizeused,omitempty" doc:"the host's or host storage pool's currently used disk size"`
|
||||
DiskWithOverProvisioning int64 `json:"diskwithoverprovisioning,omitempty" doc:"the total disk size of the host or host storage pool with over provisioning factor"`
|
||||
Events string `json:"events,omitempty" doc:"events available for the host"`
|
||||
HAHost *bool `json:"hahost,omitempty" doc:"true if the host is Ha host (dedicated to vms started by HA process; false otherwise"`
|
||||
HostTags string `json:"hosttags,omitempty" doc:"comma-separated list of tags for the host"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the host hypervisor"`
|
||||
HypervisorVersion string `json:"hypervisorversion,omitempty" doc:"the hypervisor version"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the host"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the IP address of the host"`
|
||||
IsLocalstorageActive *bool `json:"islocalstorageactive,omitempty" doc:"true if local storage is active, false otherwise"`
|
||||
LastPinged string `json:"lastpinged,omitempty" doc:"the date and time the host was last pinged"`
|
||||
ManagementServerID *UUID `json:"managementserverid,omitempty" doc:"the management server ID of the host"`
|
||||
MemoryAllocated int64 `json:"memoryallocated,omitempty" doc:"the amount of VM's memory allocated onto the host"`
|
||||
MemoryPhysical int64 `json:"memoryphysical,omitempty" doc:"the total physical memory of the host"`
|
||||
MemoryReserved int64 `json:"memoryreserved,omitempty" doc:"the amount of the host's memory reserved"`
|
||||
MemoryTotal int64 `json:"memorytotal,omitempty" doc:"the total memory of the host available (must be physical - reserved)"`
|
||||
MemoryUsed int64 `json:"memoryused,omitempty" doc:"the amount of the host's memory used by running vm"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the host"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty" doc:"the incoming network traffic on the host"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty" doc:"the outgoing network traffic on the host"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"the OS category ID of the host"`
|
||||
OSCategoryName string `json:"oscategoryname,omitempty" doc:"the OS category name of the host"`
|
||||
PCIDevices []PCIDevice `json:"pcidevices,omitempty" doc:"PCI cards present in the host"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the Pod ID of the host"`
|
||||
PodName string `json:"podname,omitempty" doc:"the Pod name of the host"`
|
||||
Removed string `json:"removed,omitempty" doc:"the date and time the host was removed"`
|
||||
ResourceState string `json:"resourcestate,omitempty" doc:"the resource state of the host"`
|
||||
State string `json:"state,omitempty" doc:"the state of the host"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"the host's storage pool id"`
|
||||
Type string `json:"type,omitempty" doc:"the host type"`
|
||||
Version string `json:"version,omitempty" doc:"the host version"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID of the host"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the Zone name of the host"`
|
||||
}
|
||||
|
||||
// ListHosts lists hosts
|
||||
type ListHosts struct {
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"lists hosts existing in particular cluster"`
|
||||
Details []string `json:"details,omitempty" doc:"comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]"`
|
||||
HAHost *bool `json:"hahost,omitempty" doc:"if true, list only hosts dedicated to HA"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"hypervisor type of host: KVM,Simulator"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the host"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the host"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the Pod ID for the host"`
|
||||
ResourceState string `json:"resourcestate,omitempty" doc:"list hosts by resource state. Resource state represents current state determined by admin of host, value can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]"`
|
||||
State string `json:"state,omitempty" doc:"the state of the host"`
|
||||
Type string `json:"type,omitempty" doc:"the host type"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID for the host"`
|
||||
_ bool `name:"listHosts" description:"Lists hosts."`
|
||||
}
|
||||
|
||||
func (ListHosts) response() interface{} {
|
||||
return new(ListHostsResponse)
|
||||
}
|
||||
|
||||
// ListHostsResponse represents a list of hosts
|
||||
type ListHostsResponse struct {
|
||||
Count int `json:"count"`
|
||||
Host []Host `json:"host"`
|
||||
}
|
||||
|
||||
// UpdateHost changes the resources state of a host
|
||||
type UpdateHost struct {
|
||||
Allocationstate string `json:"allocationstate,omitempty" doc:"Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable"`
|
||||
HostTags []string `json:"hosttags,omitempty" doc:"list of tags to be added to the host"`
|
||||
ID *UUID `json:"id" doc:"the ID of the host to update"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"the id of Os category to update the host with"`
|
||||
URL string `json:"url,omitempty" doc:"the new uri for the secondary storage: nfs://host/path"`
|
||||
_ bool `name:"updateHost" description:"Updates a host."`
|
||||
}
|
||||
|
||||
func (UpdateHost) response() interface{} {
|
||||
return new(Host)
|
||||
}
|
22
vendor/github.com/exoscale/egoscale/init.go
generated
vendored
22
vendor/github.com/exoscale/egoscale/init.go
generated
vendored
|
@ -1,22 +0,0 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// NewClient creates a CloudStack API client
|
||||
func NewClient(endpoint string, apiKey string, apiSecret string) *Client {
|
||||
cs := &Client{
|
||||
client: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: false},
|
||||
},
|
||||
},
|
||||
endpoint: endpoint,
|
||||
apiKey: apiKey,
|
||||
apiSecret: apiSecret,
|
||||
}
|
||||
return cs
|
||||
}
|
16
vendor/github.com/exoscale/egoscale/jobstatustype_string.go
generated
vendored
Normal file
16
vendor/github.com/exoscale/egoscale/jobstatustype_string.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Code generated by "stringer -type JobStatusType"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _JobStatusType_name = "PendingSuccessFailure"
|
||||
|
||||
var _JobStatusType_index = [...]uint8{0, 7, 14, 21}
|
||||
|
||||
func (i JobStatusType) String() string {
|
||||
if i < 0 || i >= JobStatusType(len(_JobStatusType_index)-1) {
|
||||
return "JobStatusType(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _JobStatusType_name[_JobStatusType_index[i]:_JobStatusType_index[i+1]]
|
||||
}
|
171
vendor/github.com/exoscale/egoscale/keypairs.go
generated
vendored
171
vendor/github.com/exoscale/egoscale/keypairs.go
generated
vendored
|
@ -1,171 +0,0 @@
|
|||
package egoscale
|
||||
|
||||
// SSHKeyPair represents an SSH key pair
|
||||
type SSHKeyPair struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PrivateKey string `json:"privatekey,omitempty"`
|
||||
}
|
||||
|
||||
// CreateSSHKeyPair represents a new keypair to be created
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/createSSHKeyPair.html
|
||||
type CreateSSHKeyPair struct {
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*CreateSSHKeyPair) name() string {
|
||||
return "createSSHKeyPair"
|
||||
}
|
||||
|
||||
func (*CreateSSHKeyPair) response() interface{} {
|
||||
return new(CreateSSHKeyPairResponse)
|
||||
}
|
||||
|
||||
// CreateSSHKeyPairResponse represents the creation of an SSH Key Pair
|
||||
type CreateSSHKeyPairResponse struct {
|
||||
KeyPair SSHKeyPair `json:"keypair"`
|
||||
}
|
||||
|
||||
// DeleteSSHKeyPair represents a new keypair to be created
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteSSHKeyPair.html
|
||||
type DeleteSSHKeyPair struct {
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*DeleteSSHKeyPair) name() string {
|
||||
return "deleteSSHKeyPair"
|
||||
}
|
||||
|
||||
func (*DeleteSSHKeyPair) response() interface{} {
|
||||
return new(booleanSyncResponse)
|
||||
}
|
||||
|
||||
// RegisterSSHKeyPair represents a new registration of a public key in a keypair
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/registerSSHKeyPair.html
|
||||
type RegisterSSHKeyPair struct {
|
||||
Name string `json:"name"`
|
||||
PublicKey string `json:"publickey"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*RegisterSSHKeyPair) name() string {
|
||||
return "registerSSHKeyPair"
|
||||
}
|
||||
|
||||
func (*RegisterSSHKeyPair) response() interface{} {
|
||||
return new(RegisterSSHKeyPairResponse)
|
||||
}
|
||||
|
||||
// RegisterSSHKeyPairResponse represents the creation of an SSH Key Pair
|
||||
type RegisterSSHKeyPairResponse struct {
|
||||
KeyPair SSHKeyPair `json:"keypair"`
|
||||
}
|
||||
|
||||
// ListSSHKeyPairs represents a query for a list of SSH KeyPairs
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listSSHKeyPairs.html
|
||||
type ListSSHKeyPairs struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Fingerprint string `json:"fingerprint,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListSSHKeyPairs) name() string {
|
||||
return "listSSHKeyPairs"
|
||||
}
|
||||
|
||||
func (*ListSSHKeyPairs) response() interface{} {
|
||||
return new(ListSSHKeyPairsResponse)
|
||||
}
|
||||
|
||||
// ListSSHKeyPairsResponse represents a list of SSH key pairs
|
||||
type ListSSHKeyPairsResponse struct {
|
||||
Count int `json:"count"`
|
||||
SSHKeyPair []SSHKeyPair `json:"sshkeypair"`
|
||||
}
|
||||
|
||||
// ResetSSHKeyForVirtualMachine (Async) represents a change for the key pairs
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/resetSSHKeyForVirtualMachine.html
|
||||
type ResetSSHKeyForVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
KeyPair string `json:"keypair"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ResetSSHKeyForVirtualMachine) name() string {
|
||||
return "resetSSHKeyForVirtualMachine"
|
||||
}
|
||||
|
||||
func (*ResetSSHKeyForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(ResetSSHKeyForVirtualMachineResponse)
|
||||
}
|
||||
|
||||
// ResetSSHKeyForVirtualMachineResponse represents the modified VirtualMachine
|
||||
type ResetSSHKeyForVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// CreateKeypair create a new SSH Key Pair
|
||||
//
|
||||
// Deprecated: will go away, use the API directly
|
||||
func (exo *Client) CreateKeypair(name string) (*SSHKeyPair, error) {
|
||||
req := &CreateSSHKeyPair{
|
||||
Name: name,
|
||||
}
|
||||
resp, err := exo.Request(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
keypair := resp.(*CreateSSHKeyPairResponse).KeyPair
|
||||
return &keypair, nil
|
||||
}
|
||||
|
||||
// DeleteKeypair deletes an SSH key pair
|
||||
//
|
||||
// Deprecated: will go away, use the API directly
|
||||
func (exo *Client) DeleteKeypair(name string) error {
|
||||
req := &DeleteSSHKeyPair{
|
||||
Name: name,
|
||||
}
|
||||
return exo.BooleanRequest(req)
|
||||
}
|
||||
|
||||
// RegisterKeypair registers a public key in a keypair
|
||||
//
|
||||
// Deprecated: will go away, use the API directly
|
||||
func (exo *Client) RegisterKeypair(name string, publicKey string) (*SSHKeyPair, error) {
|
||||
req := &RegisterSSHKeyPair{
|
||||
Name: name,
|
||||
PublicKey: publicKey,
|
||||
}
|
||||
resp, err := exo.Request(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
keypair := resp.(*RegisterSSHKeyPairResponse).KeyPair
|
||||
return &keypair, nil
|
||||
}
|
143
vendor/github.com/exoscale/egoscale/limits.go
generated
vendored
143
vendor/github.com/exoscale/egoscale/limits.go
generated
vendored
|
@ -9,82 +9,91 @@ const (
|
|||
// VirtualMachineTypeName is the resource type name of a VM
|
||||
VirtualMachineTypeName ResourceTypeName = "user_vm"
|
||||
// IPAddressTypeName is the resource type name of an IP address
|
||||
IPAddressTypeName = "public_ip"
|
||||
IPAddressTypeName ResourceTypeName = "public_ip"
|
||||
// VolumeTypeName is the resource type name of a volume
|
||||
VolumeTypeName = "volume"
|
||||
VolumeTypeName ResourceTypeName = "volume"
|
||||
// SnapshotTypeName is the resource type name of a snapshot
|
||||
SnapshotTypeName = "snapshot"
|
||||
SnapshotTypeName ResourceTypeName = "snapshot"
|
||||
// TemplateTypeName is the resource type name of a template
|
||||
TemplateTypeName = "template"
|
||||
TemplateTypeName ResourceTypeName = "template"
|
||||
// ProjectTypeName is the resource type name of a project
|
||||
ProjectTypeName = "project"
|
||||
ProjectTypeName ResourceTypeName = "project"
|
||||
// NetworkTypeName is the resource type name of a network
|
||||
NetworkTypeName = "network"
|
||||
NetworkTypeName ResourceTypeName = "network"
|
||||
// VPCTypeName is the resource type name of a VPC
|
||||
VPCTypeName = "vpc"
|
||||
VPCTypeName ResourceTypeName = "vpc"
|
||||
// CPUTypeName is the resource type name of a CPU
|
||||
CPUTypeName = "cpu"
|
||||
CPUTypeName ResourceTypeName = "cpu"
|
||||
// MemoryTypeName is the resource type name of Memory
|
||||
MemoryTypeName = "memory"
|
||||
MemoryTypeName ResourceTypeName = "memory"
|
||||
// PrimaryStorageTypeName is the resource type name of primary storage
|
||||
PrimaryStorageTypeName = "primary_storage"
|
||||
PrimaryStorageTypeName ResourceTypeName = "primary_storage"
|
||||
// SecondaryStorageTypeName is the resource type name of secondary storage
|
||||
SecondaryStorageTypeName = "secondary_storage"
|
||||
SecondaryStorageTypeName ResourceTypeName = "secondary_storage"
|
||||
)
|
||||
|
||||
// ResourceType represents the ID of a resource type (for limits)
|
||||
type ResourceType int64
|
||||
type ResourceType string
|
||||
|
||||
const (
|
||||
// VirtualMachineType is the resource type ID of a VM
|
||||
VirtualMachineType ResourceType = iota
|
||||
VirtualMachineType ResourceType = "0"
|
||||
// IPAddressType is the resource type ID of an IP address
|
||||
IPAddressType
|
||||
IPAddressType ResourceType = "1"
|
||||
// VolumeType is the resource type ID of a volume
|
||||
VolumeType
|
||||
VolumeType ResourceType = "2"
|
||||
// SnapshotType is the resource type ID of a snapshot
|
||||
SnapshotType
|
||||
SnapshotType ResourceType = "3"
|
||||
// TemplateType is the resource type ID of a template
|
||||
TemplateType
|
||||
TemplateType ResourceType = "4"
|
||||
// ProjectType is the resource type ID of a project
|
||||
ProjectType
|
||||
ProjectType ResourceType = "5"
|
||||
// NetworkType is the resource type ID of a network
|
||||
NetworkType
|
||||
NetworkType ResourceType = "6"
|
||||
// VPCType is the resource type ID of a VPC
|
||||
VPCType
|
||||
VPCType ResourceType = "7"
|
||||
// CPUType is the resource type ID of a CPU
|
||||
CPUType
|
||||
CPUType ResourceType = "8"
|
||||
// MemoryType is the resource type ID of Memory
|
||||
MemoryType
|
||||
MemoryType ResourceType = "9"
|
||||
// PrimaryStorageType is the resource type ID of primary storage
|
||||
PrimaryStorageType
|
||||
PrimaryStorageType ResourceType = "10"
|
||||
// SecondaryStorageType is the resource type ID of secondary storage
|
||||
SecondaryStorageType
|
||||
SecondaryStorageType ResourceType = "11"
|
||||
)
|
||||
|
||||
// ResourceLimit represents the limit on a particular resource
|
||||
type ResourceLimit struct {
|
||||
Account string `json:"account,omitempty" doc:"the account of the resource limit"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the resource limit"`
|
||||
DomainID string `json:"domainid,omitempty" doc:"the domain ID of the resource limit"`
|
||||
Max int64 `json:"max,omitempty" doc:"the maximum number of the resource. A -1 means the resource currently has no limit."`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"resource type. Values include 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11. See the resourceType parameter for more information on these values."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"resource type name. Values include user_vm, public_ip, volume, snapshot, template, project, network, vpc, cpu, memory, primary_storage, secondary_storage."`
|
||||
}
|
||||
|
||||
// APILimit represents the limit count
|
||||
type APILimit struct {
|
||||
Account string `json:"account,omitempty" doc:"the account name of the api remaining count"`
|
||||
Accountid string `json:"accountid,omitempty" doc:"the account uuid of the api remaining count"`
|
||||
APIAllowed int `json:"apiAllowed,omitempty" doc:"currently allowed number of apis"`
|
||||
APIIssued int `json:"apiIssued,omitempty" doc:"number of api already issued"`
|
||||
ExpireAfter int64 `json:"expireAfter,omitempty" doc:"seconds left to reset counters"`
|
||||
}
|
||||
|
||||
// ListResourceLimits lists the resource limits
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listResourceLimits.html
|
||||
type ListResourceLimits struct {
|
||||
Account string `json:"account,omittempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty"`
|
||||
ResourceTypeName ResourceTypeName `json:"resourcetypename,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListResourceLimits) name() string {
|
||||
return "listResourceLimits"
|
||||
}
|
||||
|
||||
func (*ListResourceLimits) response() interface{} {
|
||||
return new(ListResourceLimitsResponse)
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID string `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID int64 `json:"id,omitempty" doc:"Lists resource limits by ID."`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty" doc:"Type of resource. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses an account can own. 2 - Volume. Number of disk volumes an account can own. 3 - Snapshot. Number of snapshots an account can own. 4 - Template. Number of templates an account can register/create. 5 - Project. Number of projects an account can own. 6 - Network. Number of networks an account can own. 7 - VPC. Number of VPC an account can own. 8 - CPU. Number of CPU an account can allocate for his resources. 9 - Memory. Amount of RAM an account can allocate for his resources. 10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. 11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use. 12 - Elastic IP. Number of public elastic IP addresses an account can own. 13 - SMTP. If the account is allowed SMTP outbound traffic."`
|
||||
ResourceTypeName string `json:"resourcetypename,omitempty" doc:"Type of resource (wins over resourceType if both are provided). Values are: user_vm - Instance. Number of instances a user can create. public_ip - IP. Number of public IP addresses an account can own. volume - Volume. Number of disk volumes an account can own. snapshot - Snapshot. Number of snapshots an account can own. template - Template. Number of templates an account can register/create. project - Project. Number of projects an account can own. network - Network. Number of networks an account can own. vpc - VPC. Number of VPC an account can own. cpu - CPU. Number of CPU an account can allocate for his resources. memory - Memory. Amount of RAM an account can allocate for his resources. primary_storage - PrimaryStorage. Total primary storage space (in GiB) a user can use. secondary_storage - SecondaryStorage. Total secondary storage space (in GiB) a user can use. public_elastic_ip - IP. Number of public elastic IP addresses an account can own. smtp - SG. If the account is allowed SMTP outbound traffic."`
|
||||
_ bool `name:"listResourceLimits" description:"Lists resource limits."`
|
||||
}
|
||||
|
||||
// ListResourceLimitsResponse represents a list of resource limits
|
||||
|
@ -93,14 +102,38 @@ type ListResourceLimitsResponse struct {
|
|||
ResourceLimit []ResourceLimit `json:"resourcelimit"`
|
||||
}
|
||||
|
||||
// ResourceLimit represents the limit on a particular resource
|
||||
type ResourceLimit struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Max int64 `json:"max,omitempty"` // -1 means the sky is the limit
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ResourceType ResourceType `json:"resourcetype,omitempty"`
|
||||
ResourceTypeName ResourceTypeName `json:"resourcetypename,omitempty"`
|
||||
func (ListResourceLimits) response() interface{} {
|
||||
return new(ListResourceLimitsResponse)
|
||||
}
|
||||
|
||||
// UpdateResourceLimit updates the resource limit
|
||||
type UpdateResourceLimit struct {
|
||||
Account string `json:"account,omitempty" doc:"Update resource for a specified account. Must be used with the domainId parameter."`
|
||||
DomainID string `json:"domainid,omitempty" doc:"Update resource limits for all accounts in specified domain. If used with the account parameter, updates resource limits for a specified account in specified domain."`
|
||||
Max int64 `json:"max,omitempty" doc:"Maximum resource limit."`
|
||||
ResourceType ResourceType `json:"resourcetype" doc:"Type of resource to update. Values are 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 and 11. 0 - Instance. Number of instances a user can create. 1 - IP. Number of public IP addresses a user can own. 2 - Volume. Number of disk volumes a user can create. 3 - Snapshot. Number of snapshots a user can create. 4 - Template. Number of templates that a user can register/create. 6 - Network. Number of guest network a user can create. 7 - VPC. Number of VPC a user can create. 8 - CPU. Total number of CPU cores a user can use. 9 - Memory. Total Memory (in MB) a user can use. 10 - PrimaryStorage. Total primary storage space (in GiB) a user can use. 11 - SecondaryStorage. Total secondary storage space (in GiB) a user can use."`
|
||||
_ bool `name:"updateResourceLimit" description:"Updates resource limits for an account or domain."`
|
||||
}
|
||||
|
||||
// UpdateResourceLimitResponse represents an updated resource limit
|
||||
type UpdateResourceLimitResponse struct {
|
||||
ResourceLimit ResourceLimit `json:"resourcelimit"`
|
||||
}
|
||||
|
||||
func (UpdateResourceLimit) response() interface{} {
|
||||
return new(UpdateResourceLimitResponse)
|
||||
}
|
||||
|
||||
// GetAPILimit gets API limit count for the caller
|
||||
type GetAPILimit struct {
|
||||
_ bool `name:"getApiLimit" description:"Get API limit count for the caller"`
|
||||
}
|
||||
|
||||
// GetAPILimitResponse represents the limits towards the API call
|
||||
type GetAPILimitResponse struct {
|
||||
APILimit APILimit `json:"apilimit"`
|
||||
}
|
||||
|
||||
func (GetAPILimit) response() interface{} {
|
||||
return new(GetAPILimitResponse)
|
||||
}
|
||||
|
|
63
vendor/github.com/exoscale/egoscale/macaddress.go
generated
vendored
Normal file
63
vendor/github.com/exoscale/egoscale/macaddress.go
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
// MACAddress is a nicely JSON serializable net.HardwareAddr
|
||||
type MACAddress net.HardwareAddr
|
||||
|
||||
// String returns the MAC address in standard format
|
||||
func (mac MACAddress) String() string {
|
||||
return (net.HardwareAddr)(mac).String()
|
||||
}
|
||||
|
||||
// MAC48 builds a MAC-48 MACAddress
|
||||
func MAC48(a, b, c, d, e, f byte) MACAddress {
|
||||
m := make(MACAddress, 6)
|
||||
m[0] = a
|
||||
m[1] = b
|
||||
m[2] = c
|
||||
m[3] = d
|
||||
m[4] = e
|
||||
m[5] = f
|
||||
return m
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals the raw JSON into the MAC address
|
||||
func (mac *MACAddress) UnmarshalJSON(b []byte) error {
|
||||
var addr string
|
||||
if err := json.Unmarshal(b, &addr); err != nil {
|
||||
return err
|
||||
}
|
||||
hw, err := ParseMAC(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*mac = make(MACAddress, 6)
|
||||
copy(*mac, hw)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON converts the MAC Address to a string representation
|
||||
func (mac MACAddress) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", mac.String())), nil
|
||||
}
|
||||
|
||||
// ParseMAC converts a string into a MACAddress
|
||||
func ParseMAC(s string) (MACAddress, error) {
|
||||
hw, err := net.ParseMAC(s)
|
||||
return (MACAddress)(hw), err
|
||||
}
|
||||
|
||||
// MustParseMAC acts like ParseMAC but panics if in case of an error
|
||||
func MustParseMAC(s string) MACAddress {
|
||||
mac, err := ParseMAC(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return mac
|
||||
}
|
115
vendor/github.com/exoscale/egoscale/network_offerings.go
generated
vendored
115
vendor/github.com/exoscale/egoscale/network_offerings.go
generated
vendored
|
@ -2,63 +2,51 @@ package egoscale
|
|||
|
||||
// NetworkOffering corresponds to the Compute Offerings
|
||||
type NetworkOffering struct {
|
||||
ID string `json:"id"`
|
||||
Availability string `json:"availability,omitempty"`
|
||||
ConserveMode bool `json:"conservemode,omitempty"`
|
||||
Created string `json:"created"`
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
EgressDefaultPolicy bool `json:"egressdefaultpolicy,omitempty"`
|
||||
ForVPC bool `json:"forvpc,omitempty"`
|
||||
GuestIPType string `json:"guestiptype,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
IsPersistent bool `json:"ispersistent,omitempty"`
|
||||
MaxConnections int `json:"maxconnections,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkRate int `json:"networkrate,omitempty"`
|
||||
ServiceOfferingID string `json:"serviceofferingid,omitempty"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty"`
|
||||
SpecifyVlan bool `json:"specifyvlan,omitempty"`
|
||||
State string `json:"state"` // Disabled/Enabled/Inactive
|
||||
SupportsPublicAccess bool `json:"supportspublicaccess,omitempty"`
|
||||
SupportsStrechedL2Subnet bool `json:"supportsstrechedl2subnet,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
TrafficType string `json:"traffictype,omitempty"` // Public, Management, Control, ...
|
||||
Service []Service `json:"service,omitempty"`
|
||||
Availability string `json:"availability,omitempty" doc:"availability of the network offering"`
|
||||
ConserveMode bool `json:"conservemode,omitempty" doc:"true if network offering is ip conserve mode enabled"`
|
||||
Created string `json:"created,omitempty" doc:"the date this network offering was created"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"additional key/value details tied with network offering"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"an alternate display text of the network offering."`
|
||||
EgressDefaultPolicy bool `json:"egressdefaultpolicy,omitempty" doc:"true if guest network default egress policy is allow; false if default egress policy is deny"`
|
||||
GuestIPType string `json:"guestiptype,omitempty" doc:"guest type of the network offering, can be Shared or Isolated"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the network offering"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if network offering is default, false otherwise"`
|
||||
IsPersistent bool `json:"ispersistent,omitempty" doc:"true if network offering supports persistent networks, false otherwise"`
|
||||
MaxConnections int `json:"maxconnections,omitempty" doc:"maximum number of concurrents connections to be handled by lb"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the network offering"`
|
||||
NetworkRate int `json:"networkrate,omitempty" doc:"data transfer rate in megabits per second allowed."`
|
||||
Service []Service `json:"service,omitempty" doc:"the list of supported services"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid,omitempty" doc:"the ID of the service offering used by virtual router provider"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty" doc:"true if network offering supports specifying ip ranges, false otherwise"`
|
||||
SpecifyVlan bool `json:"specifyvlan,omitempty" doc:"true if network offering supports vlans, false otherwise"`
|
||||
State string `json:"state,omitempty" doc:"state of the network offering. Can be Disabled/Enabled/Inactive"`
|
||||
SupportsStrechedL2Subnet bool `json:"supportsstrechedl2subnet,omitempty" doc:"true if network offering supports network that span multiple zones"`
|
||||
Tags string `json:"tags,omitempty" doc:"the tags for the network offering"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"the traffic type for the network offering, supported types are Public, Management, Control, Guest, Vlan or Storage."`
|
||||
}
|
||||
|
||||
// ListNetworkOfferings represents a query for network offerings
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listNetworkOfferings.html
|
||||
type ListNetworkOfferings struct {
|
||||
Availability string `json:"availability,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
ForVPC bool `json:"forvpc,omitempty"`
|
||||
GuestIPType string `json:"guestiptype,omitempty"` // shared of isolated
|
||||
ID string `json:"id,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
IsTagged bool `json:"istagged,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
SourceNATSupported bool `json:"sourcenatsupported,omitempty"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty"`
|
||||
SpecifyVlan string `json:"specifyvlan,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
SupportedServices string `json:"supportedservices,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
TrafficType string `json:"traffictype,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListNetworkOfferings) name() string {
|
||||
return "listNetworkOfferings"
|
||||
}
|
||||
|
||||
func (*ListNetworkOfferings) response() interface{} {
|
||||
return new(ListNetworkOfferingsResponse)
|
||||
Availability string `json:"availability,omitempty" doc:"the availability of network offering. Default value is Required"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"list network offerings by display text"`
|
||||
GuestIPType string `json:"guestiptype,omitempty" doc:"list network offerings by guest type: Shared or Isolated"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list network offerings by id"`
|
||||
IsDefault *bool `json:"isdefault,omitempty" doc:"true if need to list only default network offerings. Default value is false"`
|
||||
IsTagged *bool `json:"istagged,omitempty" doc:"true if offering has tags specified"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"list network offerings by name"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"the ID of the network. Pass this in if you want to see the available network offering that a network can be changed to."`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
SourceNATSupported *bool `json:"sourcenatsupported,omitempty" doc:"true if need to list only netwok offerings where source nat is supported, false otherwise"`
|
||||
SpecifyIPRanges *bool `json:"specifyipranges,omitempty" doc:"true if need to list only network offerings which support specifying ip ranges"`
|
||||
SpecifyVlan *bool `json:"specifyvlan,omitempty" doc:"the tags for the network offering."`
|
||||
State string `json:"state,omitempty" doc:"list network offerings by state"`
|
||||
SupportedServices []Service `json:"supportedservices,omitempty" doc:"list network offerings supporting certain services"`
|
||||
Tags string `json:"tags,omitempty" doc:"list network offerings by tags"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"list by traffic type"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"list network offerings available for network creation in specific zone"`
|
||||
_ bool `name:"listNetworkOfferings" description:"Lists all available network offerings."`
|
||||
}
|
||||
|
||||
// ListNetworkOfferingsResponse represents a list of service offerings
|
||||
|
@ -66,3 +54,24 @@ type ListNetworkOfferingsResponse struct {
|
|||
Count int `json:"count"`
|
||||
NetworkOffering []NetworkOffering `json:"networkoffering"`
|
||||
}
|
||||
|
||||
func (ListNetworkOfferings) response() interface{} {
|
||||
return new(ListNetworkOfferingsResponse)
|
||||
}
|
||||
|
||||
// UpdateNetworkOffering represents a modification of a network offering
|
||||
type UpdateNetworkOffering struct {
|
||||
Availability string `json:"availability,omitempty" doc:"the availability of network offering. Default value is Required for Guest Virtual network offering; Optional for Guest Direct network offering"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the network offering"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the network offering"`
|
||||
KeepAliveEnabled *bool `json:"keepaliveenabled,omitempty" doc:"if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file."`
|
||||
MaxConnections int `json:"maxconnections,omitempty" doc:"maximum number of concurrent connections supported by the network offering"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the network offering"`
|
||||
SortKey int `json:"sortkey,omitempty" doc:"sort key of the network offering, integer"`
|
||||
State string `json:"state,omitempty" doc:"update state for the network offering"`
|
||||
_ bool `name:"updateNetworkOffering" description:"Updates a network offering."`
|
||||
}
|
||||
|
||||
func (UpdateNetworkOffering) response() interface{} {
|
||||
return new(NetworkOffering)
|
||||
}
|
||||
|
|
340
vendor/github.com/exoscale/egoscale/networks.go
generated
vendored
340
vendor/github.com/exoscale/egoscale/networks.go
generated
vendored
|
@ -1,70 +1,93 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// Network represents a network
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html
|
||||
type Network struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account"`
|
||||
ACLID string `json:"aclid,omitempty"`
|
||||
ACLType string `json:"acltype,omitempty"`
|
||||
BroadcastDomainType string `json:"broadcastdomaintype,omitempty"`
|
||||
BroadcastURI string `json:"broadcasturi,omitempty"`
|
||||
CanUseForDeploy bool `json:"canusefordeploy,omitempty"`
|
||||
Cidr string `json:"cidr,omitempty"`
|
||||
DisplayNetwork bool `json:"diplaynetwork,omitempty"`
|
||||
DisplayText string `json:"displaytext"`
|
||||
DNS1 net.IP `json:"dns1,omitempty"`
|
||||
DNS2 net.IP `json:"dns2,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
IP6Cidr string `json:"ip6cidr,omitempty"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
IsPersistent bool `json:"ispersistent,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Netmask net.IP `json:"netmask,omitempty"`
|
||||
NetworkCidr string `json:"networkcidr,omitempty"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty"`
|
||||
NetworkOfferingAvailability string `json:"networkofferingavailability,omitempty"`
|
||||
NetworkOfferingConserveMode bool `json:"networkofferingconservemode,omitempty"`
|
||||
NetworkOfferingDisplayText string `json:"networkofferingdisplaytext,omitempty"`
|
||||
NetworkOfferingID string `json:"networkofferingid,omitempty"`
|
||||
NetworkOfferingName string `json:"networkofferingname,omitempty"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Related string `json:"related,omitempty"`
|
||||
ReserveIPRange string `json:"reserveiprange,omitempty"`
|
||||
RestartRequired bool `json:"restartrequired,omitempty"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty"`
|
||||
State string `json:"state"`
|
||||
StrechedL2Subnet bool `json:"strechedl2subnet,omitempty"`
|
||||
SubdomainAccess bool `json:"subdomainaccess,omitempty"`
|
||||
TrafficType string `json:"traffictype"`
|
||||
Type string `json:"type"`
|
||||
Vlan string `json:"vlan,omitemtpy"` // root only
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
ZoneName string `json:"zonename,omitempty"`
|
||||
ZonesNetworkSpans string `json:"zonesnetworkspans,omitempty"`
|
||||
Service []Service `json:"service"`
|
||||
Tags []ResourceTag `json:"tags"`
|
||||
Account string `json:"account,omitempty" doc:"the owner of the network"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the owner ID of the network"`
|
||||
BroadcastDomainType string `json:"broadcastdomaintype,omitempty" doc:"Broadcast domain type of the network"`
|
||||
BroadcastURI string `json:"broadcasturi,omitempty" doc:"broadcast uri of the network."`
|
||||
CanUseForDeploy bool `json:"canusefordeploy,omitempty" doc:"list networks available for vm deployment"`
|
||||
CIDR *CIDR `json:"cidr,omitempty" doc:"Cloudstack managed address space, all CloudStack managed VMs get IP address from CIDR"`
|
||||
DisplayNetwork bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the displaytext of the network"`
|
||||
DNS1 net.IP `json:"dns1,omitempty" doc:"the first DNS for the network"`
|
||||
DNS2 net.IP `json:"dns2,omitempty" doc:"the second DNS for the network"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the network owner"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain id of the network owner"`
|
||||
Gateway net.IP `json:"gateway,omitempty" doc:"the network's gateway"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the network"`
|
||||
IP6CIDR *CIDR `json:"ip6cidr,omitempty" doc:"the cidr of IPv6 network"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty" doc:"the gateway of IPv6 network"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if network is default, false otherwise"`
|
||||
IsPersistent bool `json:"ispersistent,omitempty" doc:"list networks that are persistent"`
|
||||
IsSystem bool `json:"issystem,omitempty" doc:"true if network is system, false otherwise"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the network"`
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the network's netmask"`
|
||||
NetworkCIDR *CIDR `json:"networkcidr,omitempty" doc:"the network CIDR of the guest network configured with IP reservation. It is the summation of CIDR and RESERVED_IP_RANGE"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"the network domain"`
|
||||
NetworkOfferingAvailability string `json:"networkofferingavailability,omitempty" doc:"availability of the network offering the network is created from"`
|
||||
NetworkOfferingConserveMode bool `json:"networkofferingconservemode,omitempty" doc:"true if network offering is ip conserve mode enabled"`
|
||||
NetworkOfferingDisplayText string `json:"networkofferingdisplaytext,omitempty" doc:"display text of the network offering the network is created from"`
|
||||
NetworkOfferingID *UUID `json:"networkofferingid,omitempty" doc:"network offering id the network is created from"`
|
||||
NetworkOfferingName string `json:"networkofferingname,omitempty" doc:"name of the network offering the network is created from"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"the physical network id"`
|
||||
Related string `json:"related,omitempty" doc:"related to what other network configuration"`
|
||||
ReservedIPRange string `json:"reservediprange,omitempty" doc:"the network's IP range not to be used by CloudStack guest VMs and can be used for non CloudStack purposes"`
|
||||
RestartRequired bool `json:"restartrequired,omitempty" doc:"true network requires restart"`
|
||||
Service []Service `json:"service,omitempty" doc:"the list of services"`
|
||||
SpecifyIPRanges bool `json:"specifyipranges,omitempty" doc:"true if network supports specifying ip ranges, false otherwise"`
|
||||
State string `json:"state,omitempty" doc:"state of the network"`
|
||||
StrechedL2Subnet bool `json:"strechedl2subnet,omitempty" doc:"true if network can span multiple zones"`
|
||||
SubdomainAccess bool `json:"subdomainaccess,omitempty" doc:"true if users from subdomains can access the domain level network"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with network"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"the traffic type of the network"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the network"`
|
||||
Vlan string `json:"vlan,omitemtpy" doc:"The vlan of the network. This parameter is visible to ROOT admins only"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"zone id of the network"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the zone the network belongs to"`
|
||||
ZonesNetworkSpans []Zone `json:"zonesnetworkspans,omitempty" doc:"If a network is enabled for 'streched l2 subnet' then represents zones on which network currently spans"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListNetworks request
|
||||
func (network Network) ListRequest() (ListCommand, error) {
|
||||
//TODO add tags support
|
||||
req := &ListNetworks{
|
||||
Account: network.Account,
|
||||
DomainID: network.DomainID,
|
||||
ID: network.ID,
|
||||
PhysicalNetworkID: network.PhysicalNetworkID,
|
||||
TrafficType: network.TrafficType,
|
||||
Type: network.Type,
|
||||
ZoneID: network.ZoneID,
|
||||
}
|
||||
|
||||
if network.CanUseForDeploy {
|
||||
req.CanUseForDeploy = &network.CanUseForDeploy
|
||||
}
|
||||
if network.RestartRequired {
|
||||
req.RestartRequired = &network.RestartRequired
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*Network) ResourceType() string {
|
||||
func (Network) ResourceType() string {
|
||||
return "Network"
|
||||
}
|
||||
|
||||
// Service is a feature of a network
|
||||
type Service struct {
|
||||
Name string `json:"name"`
|
||||
Capability []ServiceCapability `json:"capability,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Provider []ServiceProvider `json:"provider,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -77,58 +100,44 @@ type ServiceCapability struct {
|
|||
|
||||
// ServiceProvider represents the provider of the service
|
||||
type ServiceProvider struct {
|
||||
ID string `json:"id"`
|
||||
CanEnableIndividualService bool `json:"canenableindividualservice"`
|
||||
DestinationPhysicalNetworkID string `json:"destinationphysicalnetworkid"`
|
||||
DestinationPhysicalNetworkID *UUID `json:"destinationphysicalnetworkid"`
|
||||
ID *UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid"`
|
||||
ServiceList []string `json:"servicelist,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkResponse represents a network
|
||||
type NetworkResponse struct {
|
||||
Network Network `json:"network"`
|
||||
}
|
||||
|
||||
// CreateNetwork creates a network
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/createNetwork.html
|
||||
type CreateNetwork struct {
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkOfferingID string `json:"networkofferingid"`
|
||||
ZoneID string `json:"zoneid"`
|
||||
Account string `json:"account,omitempty"`
|
||||
ACLID string `json:"aclid,omitempty"`
|
||||
ACLType string `json:"acltype,omitempty"` // Account or Domain
|
||||
DisplayNetwork bool `json:"displaynetwork,omitempty"` // root only
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
EndIP net.IP `json:"endip,omitempty"`
|
||||
EndIpv6 net.IP `json:"endipv6,omitempty"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
IP6Cidr string `json:"ip6cidr,omitempty"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty"`
|
||||
IsolatedPVlan string `json:"isolatedpvlan,omitempty"`
|
||||
Netmask net.IP `json:"netmask,omitempty"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
StartIP net.IP `json:"startip,omitempty"`
|
||||
StartIpv6 net.IP `json:"startipv6,omitempty"`
|
||||
SubdomainAccess string `json:"subdomainaccess,omitempty"`
|
||||
Vlan string `json:"vlan,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"account who will own the network"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the network"` // This field is required but might be empty
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"domain ID of the account owning a network"`
|
||||
EndIP net.IP `json:"endip,omitempty" doc:"the ending IP address in the network IP range. If not specified, will be defaulted to startIP"`
|
||||
EndIpv6 net.IP `json:"endipv6,omitempty" doc:"the ending IPv6 address in the IPv6 network range"`
|
||||
Gateway net.IP `json:"gateway,omitempty" doc:"the gateway of the network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
IP6CIDR *CIDR `json:"ip6cidr,omitempty" doc:"the CIDR of IPv6 network, must be at least /64"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty" doc:"the gateway of the IPv6 network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
IsolatedPVlan string `json:"isolatedpvlan,omitempty" doc:"the isolated private vlan for this network"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the network"` // This field is required but might be empty
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the netmask of the network. Required for Shared networks and Isolated networks when it belongs to VPC"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"network domain"`
|
||||
NetworkOfferingID *UUID `json:"networkofferingid" doc:"the network offering id"`
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"the Physical Network ID the network belongs to"`
|
||||
StartIP net.IP `json:"startip,omitempty" doc:"the beginning IP address in the network IP range"`
|
||||
StartIpv6 net.IP `json:"startipv6,omitempty" doc:"the beginning IPv6 address in the IPv6 network range"`
|
||||
SubdomainAccess *bool `json:"subdomainaccess,omitempty" doc:"Defines whether to allow subdomains to use networks dedicated to their parent domain(s). Should be used with aclType=Domain, defaulted to allow.subdomain.network.access global config if not specified"`
|
||||
Vlan string `json:"vlan,omitempty" doc:"the ID or VID of the network"`
|
||||
ZoneID *UUID `json:"zoneid" doc:"the Zone ID for the network"`
|
||||
_ bool `name:"createNetwork" description:"Creates a network"`
|
||||
}
|
||||
|
||||
func (*CreateNetwork) name() string {
|
||||
return "createNetwork"
|
||||
func (CreateNetwork) response() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
func (*CreateNetwork) response() interface{} {
|
||||
return new(CreateNetworkResponse)
|
||||
}
|
||||
|
||||
func (req *CreateNetwork) onBeforeSend(params *url.Values) error {
|
||||
func (req CreateNetwork) onBeforeSend(params url.Values) error {
|
||||
// Those fields are required but might be empty
|
||||
if req.Name == "" {
|
||||
params.Set("name", "")
|
||||
|
@ -139,107 +148,80 @@ func (req *CreateNetwork) onBeforeSend(params *url.Values) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// CreateNetworkResponse represents a freshly created network
|
||||
type CreateNetworkResponse NetworkResponse
|
||||
|
||||
// UpdateNetwork updates a network
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/updateNetwork.html
|
||||
// UpdateNetwork (Async) updates a network
|
||||
type UpdateNetwork struct {
|
||||
ID string `json:"id"`
|
||||
ChangeCidr bool `json:"changecidr,omitempty"`
|
||||
CustomID string `json:"customid,omitempty"` // root only
|
||||
DisplayNetwork string `json:"displaynetwork,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Forced bool `json:"forced,omitempty"`
|
||||
GuestVMCidr string `json:"guestvmcidr,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty"`
|
||||
NetworkOfferingID string `json:"networkofferingid,omitempty"`
|
||||
UpdateInSequence bool `json:"updateinsequence,omitempty"`
|
||||
ID *UUID `json:"id" doc:"the ID of the network"`
|
||||
ChangeCIDR *bool `json:"changecidr,omitempty" doc:"Force update even if cidr type is different"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"an optional field, whether to the display the network to the end user or not."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the new display text for the network"`
|
||||
GuestVMCIDR *CIDR `json:"guestvmcidr,omitempty" doc:"CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR"`
|
||||
Name string `json:"name,omitempty" doc:"the new name for the network"`
|
||||
NetworkDomain string `json:"networkdomain,omitempty" doc:"network domain"`
|
||||
NetworkOfferingID *UUID `json:"networkofferingid,omitempty" doc:"network offering ID"`
|
||||
_ bool `name:"updateNetwork" description:"Updates a network"`
|
||||
}
|
||||
|
||||
func (*UpdateNetwork) name() string {
|
||||
return "updateNetwork"
|
||||
func (UpdateNetwork) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*UpdateNetwork) asyncResponse() interface{} {
|
||||
return new(UpdateNetworkResponse)
|
||||
func (UpdateNetwork) asyncResponse() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
// UpdateNetworkResponse represents a freshly created network
|
||||
type UpdateNetworkResponse NetworkResponse
|
||||
|
||||
// RestartNetwork updates a network
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/restartNetwork.html
|
||||
// RestartNetwork (Async) updates a network
|
||||
type RestartNetwork struct {
|
||||
ID string `json:"id"`
|
||||
Cleanup bool `json:"cleanup,omitempty"`
|
||||
ID *UUID `json:"id" doc:"The id of the network to restart."`
|
||||
Cleanup *bool `json:"cleanup,omitempty" doc:"If cleanup old network elements"`
|
||||
_ bool `name:"restartNetwork" description:"Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules"`
|
||||
}
|
||||
|
||||
func (*RestartNetwork) name() string {
|
||||
return "restartNetwork"
|
||||
func (RestartNetwork) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RestartNetwork) asyncResponse() interface{} {
|
||||
return new(RestartNetworkResponse)
|
||||
func (RestartNetwork) asyncResponse() interface{} {
|
||||
return new(Network)
|
||||
}
|
||||
|
||||
// RestartNetworkResponse represents a freshly created network
|
||||
type RestartNetworkResponse NetworkResponse
|
||||
|
||||
// DeleteNetwork deletes a network
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteNetwork.html
|
||||
type DeleteNetwork struct {
|
||||
ID string `json:"id"`
|
||||
Forced bool `json:"forced,omitempty"`
|
||||
ID *UUID `json:"id" doc:"the ID of the network"`
|
||||
Forced *bool `json:"forced,omitempty" doc:"Force delete a network. Network will be marked as 'Destroy' even when commands to shutdown and cleanup to the backend fails."`
|
||||
_ bool `name:"deleteNetwork" description:"Deletes a network"`
|
||||
}
|
||||
|
||||
func (*DeleteNetwork) name() string {
|
||||
return "deleteNetwork"
|
||||
func (DeleteNetwork) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*DeleteNetwork) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (DeleteNetwork) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListNetworks represents a query to a network
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listNetworks.html
|
||||
type ListNetworks struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
ACLType string `json:"acltype,omitempty"` // Account or Domain
|
||||
CanUseForDeploy bool `json:"canusefordeploy,omitempty"`
|
||||
DisplayNetwork bool `json:"displaynetwork,omitempty"` // root only
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ForVpc string `json:"forvpc,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
IsSystem bool `json:"issystem,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
CanUseForDeploy *bool `json:"canusefordeploy,omitempty" doc:"list networks available for vm deployment"`
|
||||
DisplayNetwork *bool `json:"displaynetwork,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list networks by id"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"true if network is system, false otherwise"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PhysicalNetworkID string `json:"physicalnetworkid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
RestartRequired bool `json:"restartrequired,omitempty"`
|
||||
SpecifyRanges bool `json:"specifyranges,omitempty"`
|
||||
SupportedServices []Service `json:"supportedservices,omitempty"`
|
||||
Tags []ResourceTag `json:"resourcetag,omitempty"`
|
||||
TrafficType string `json:"traffictype,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListNetworks) name() string {
|
||||
return "listNetworks"
|
||||
}
|
||||
|
||||
func (*ListNetworks) response() interface{} {
|
||||
return new(ListNetworksResponse)
|
||||
PhysicalNetworkID *UUID `json:"physicalnetworkid,omitempty" doc:"list networks by physical network id"`
|
||||
RestartRequired *bool `json:"restartrequired,omitempty" doc:"list networks by restartRequired"`
|
||||
SpecifyIPRanges *bool `json:"specifyipranges,omitempty" doc:"true if need to list only networks which support specifying ip ranges"`
|
||||
SupportedServices []Service `json:"supportedservices,omitempty" doc:"list networks supporting certain services"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"type of the traffic"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the network. Supported values are: Isolated and Shared"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the Zone ID of the network"`
|
||||
_ bool `name:"listNetworks" description:"Lists all available networks."`
|
||||
}
|
||||
|
||||
// ListNetworksResponse represents the list of networks
|
||||
|
@ -247,3 +229,31 @@ type ListNetworksResponse struct {
|
|||
Count int `json:"count"`
|
||||
Network []Network `json:"network"`
|
||||
}
|
||||
|
||||
func (ListNetworks) response() interface{} {
|
||||
return new(ListNetworksResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (listNetwork *ListNetworks) SetPage(page int) {
|
||||
listNetwork.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (listNetwork *ListNetworks) SetPageSize(pageSize int) {
|
||||
listNetwork.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListNetworks) each(resp interface{}, callback IterateItemFunc) {
|
||||
networks, ok := resp.(*ListNetworksResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("type error: ListNetworksResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range networks.Network {
|
||||
if !callback(&networks.Network[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
184
vendor/github.com/exoscale/egoscale/nics.go
generated
vendored
184
vendor/github.com/exoscale/egoscale/nics.go
generated
vendored
|
@ -1,57 +1,69 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
// Nic represents a Network Interface Controller (NIC)
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/networking_and_traffic.html#configuring-multiple-ip-addresses-on-a-single-nic
|
||||
type Nic struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
BroadcastURI string `json:"broadcasturi,omitempty"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty"`
|
||||
IP6Cidr string `json:"ip6cidr,omitempty"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
IsolationURI string `json:"isolationuri,omitempty"`
|
||||
MacAddress string `json:"macaddress,omitempty"`
|
||||
Netmask net.IP `json:"netmask,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
NetworkName string `json:"networkname,omitempty"`
|
||||
SecondaryIP []NicSecondaryIP `json:"secondaryip,omitempty"`
|
||||
Traffictype string `json:"traffictype,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
BroadcastURI string `json:"broadcasturi,omitempty" doc:"the broadcast uri of the nic"`
|
||||
DeviceID *UUID `json:"deviceid,omitempty" doc:"device id for the network when plugged into the virtual machine"`
|
||||
Gateway net.IP `json:"gateway,omitempty" doc:"the gateway of the nic"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the nic"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty" doc:"the IPv6 address of network"`
|
||||
IP6CIDR *CIDR `json:"ip6cidr,omitempty" doc:"the cidr of IPv6 network"`
|
||||
IP6Gateway net.IP `json:"ip6gateway,omitempty" doc:"the gateway of IPv6 network"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the ip address of the nic"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if nic is default, false otherwise"`
|
||||
IsolationURI string `json:"isolationuri,omitempty" doc:"the isolation uri of the nic"`
|
||||
MACAddress MACAddress `json:"macaddress,omitempty" doc:"true if nic is default, false otherwise"`
|
||||
Netmask net.IP `json:"netmask,omitempty" doc:"the netmask of the nic"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"the ID of the corresponding network"`
|
||||
NetworkName string `json:"networkname,omitempty" doc:"the name of the corresponding network"`
|
||||
ReverseDNS []ReverseDNS `json:"reversedns,omitempty" doc:"the list of PTR record(s) associated with the virtual machine"`
|
||||
SecondaryIP []NicSecondaryIP `json:"secondaryip,omitempty" doc:"the Secondary ipv4 addr of nic"`
|
||||
TrafficType string `json:"traffictype,omitempty" doc:"the traffic type of the nic"`
|
||||
Type string `json:"type,omitempty" doc:"the type of the nic"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"Id of the vm to which the nic belongs"`
|
||||
}
|
||||
|
||||
// ListRequest build a ListNics request from the given Nic
|
||||
func (nic Nic) ListRequest() (ListCommand, error) {
|
||||
if nic.VirtualMachineID == nil {
|
||||
return nil, errors.New("command ListNics requires the VirtualMachineID field to be set")
|
||||
}
|
||||
|
||||
req := &ListNics{
|
||||
VirtualMachineID: nic.VirtualMachineID,
|
||||
NicID: nic.ID,
|
||||
NetworkID: nic.NetworkID,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// NicSecondaryIP represents a link between NicID and IPAddress
|
||||
type NicSecondaryIP struct {
|
||||
ID string `json:"id"`
|
||||
IPAddress net.IP `json:"ipaddress"`
|
||||
NetworkID string `json:"networkid"`
|
||||
NicID string `json:"nicid"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the secondary private IP addr"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"Secondary IP address"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"the ID of the network"`
|
||||
NicID *UUID `json:"nicid,omitempty" doc:"the ID of the nic"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the vm"`
|
||||
}
|
||||
|
||||
// ListNics represents the NIC search
|
||||
type ListNics struct {
|
||||
VirtualMachineID string `json:"virtualmachineid"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
NicID string `json:"nicid,omitempty"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"list nic of the specific vm's network"`
|
||||
NicID *UUID `json:"nicid,omitempty" doc:"the ID of the nic to to list IPs"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListNics) name() string {
|
||||
return "listNics"
|
||||
}
|
||||
|
||||
func (*ListNics) response() interface{} {
|
||||
return new(ListNicsResponse)
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the vm"`
|
||||
_ bool `name:"listNics" description:"list the vm nics IP to NIC"`
|
||||
}
|
||||
|
||||
// ListNicsResponse represents a list of templates
|
||||
|
@ -60,76 +72,70 @@ type ListNicsResponse struct {
|
|||
Nic []Nic `json:"nic"`
|
||||
}
|
||||
|
||||
// AddIPToNic represents the assignation of a secondary IP
|
||||
func (ListNics) response() interface{} {
|
||||
return new(ListNicsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListNics) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListNics) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListNics) each(resp interface{}, callback IterateItemFunc) {
|
||||
nics := resp.(*ListNicsResponse)
|
||||
for i := range nics.Nic {
|
||||
if !callback(&(nics.Nic[i]), nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddIPToNic (Async) represents the assignation of a secondary IP
|
||||
type AddIPToNic struct {
|
||||
NicID string `json:"nicid"`
|
||||
IPAddress net.IP `json:"ipaddress"`
|
||||
NicID *UUID `json:"nicid" doc:"the ID of the nic to which you want to assign private IP"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"Secondary IP Address"`
|
||||
_ bool `name:"addIpToNic" description:"Assigns secondary IP to NIC"`
|
||||
}
|
||||
|
||||
func (*AddIPToNic) name() string {
|
||||
return "addIpToNic"
|
||||
}
|
||||
func (*AddIPToNic) asyncResponse() interface{} {
|
||||
return new(AddIPToNicResponse)
|
||||
func (AddIPToNic) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// AddIPToNicResponse represents the addition of an IP to a NIC
|
||||
type AddIPToNicResponse struct {
|
||||
NicSecondaryIP NicSecondaryIP `json:"nicsecondaryip"`
|
||||
func (AddIPToNic) asyncResponse() interface{} {
|
||||
return new(NicSecondaryIP)
|
||||
}
|
||||
|
||||
// RemoveIPFromNic represents a deletion request
|
||||
// RemoveIPFromNic (Async) represents a deletion request
|
||||
type RemoveIPFromNic struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"the ID of the secondary ip address to nic"`
|
||||
_ bool `name:"removeIpFromNic" description:"Removes secondary IP from the NIC."`
|
||||
}
|
||||
|
||||
func (*RemoveIPFromNic) name() string {
|
||||
return "removeIpFromNic"
|
||||
func (RemoveIPFromNic) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RemoveIPFromNic) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (RemoveIPFromNic) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListNics lists the NIC of a VM
|
||||
// ActivateIP6 (Async) activates the IP6 on the given NIC
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) ListNics(req *ListNics) ([]Nic, error) {
|
||||
resp, err := exo.Request(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp.(*ListNicsResponse).Nic, nil
|
||||
// Exoscale specific API: https://community.exoscale.ch/api/compute/#activateip6_GET
|
||||
type ActivateIP6 struct {
|
||||
NicID *UUID `json:"nicid" doc:"the ID of the nic to which you want to assign the IPv6"`
|
||||
_ bool `name:"activateIp6" description:"Activate the IPv6 on the VM's nic"`
|
||||
}
|
||||
|
||||
// AddIPToNic adds an IP to a NIC
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) AddIPToNic(nicID string, ipAddress string, async AsyncInfo) (*NicSecondaryIP, error) {
|
||||
ip := net.ParseIP(ipAddress)
|
||||
if ip == nil {
|
||||
return nil, fmt.Errorf("%s is not a valid IP address", ipAddress)
|
||||
}
|
||||
req := &AddIPToNic{
|
||||
NicID: nicID,
|
||||
IPAddress: ip,
|
||||
}
|
||||
resp, err := exo.AsyncRequest(req, async)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nic := resp.(AddIPToNicResponse).NicSecondaryIP
|
||||
return &nic, nil
|
||||
func (ActivateIP6) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// RemoveIPFromNic removes an IP from a NIC
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) RemoveIPFromNic(secondaryNicID string, async AsyncInfo) error {
|
||||
req := &RemoveIPFromNic{
|
||||
ID: secondaryNicID,
|
||||
}
|
||||
return exo.BooleanAsyncRequest(req, async)
|
||||
func (ActivateIP6) asyncResponse() interface{} {
|
||||
return new(Nic)
|
||||
}
|
||||
|
|
16
vendor/github.com/exoscale/egoscale/record_string.go
generated
vendored
Normal file
16
vendor/github.com/exoscale/egoscale/record_string.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Code generated by "stringer -type=Record"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _Record_name = "AAAAAALIASCNAMEHINFOMXNAPTRNSPOOLSPFSRVSSHFPTXTURL"
|
||||
|
||||
var _Record_index = [...]uint8{0, 1, 5, 10, 15, 20, 22, 27, 29, 33, 36, 39, 44, 47, 50}
|
||||
|
||||
func (i Record) String() string {
|
||||
if i < 0 || i >= Record(len(_Record_index)-1) {
|
||||
return "Record(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Record_name[_Record_index[i]:_Record_index[i+1]]
|
||||
}
|
781
vendor/github.com/exoscale/egoscale/request.go
generated
vendored
781
vendor/github.com/exoscale/egoscale/request.go
generated
vendored
|
@ -2,334 +2,380 @@ package egoscale
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/hmac"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Command represent a CloudStack request
|
||||
type Command interface {
|
||||
// CloudStack API command name
|
||||
name() string
|
||||
// Response interface to Unmarshal the JSON into
|
||||
response() interface{}
|
||||
}
|
||||
|
||||
// AsyncCommand represents a async CloudStack request
|
||||
type AsyncCommand interface {
|
||||
// CloudStack API command name
|
||||
name() string
|
||||
// Response interface to Unmarshal the JSON into
|
||||
asyncResponse() interface{}
|
||||
}
|
||||
|
||||
// Command represents an action to be done on the params before sending them
|
||||
//
|
||||
// This little took helps with issue of relying on JSON serialization logic only.
|
||||
// `omitempty` may make sense in some cases but not all the time.
|
||||
type onBeforeHook interface {
|
||||
onBeforeSend(params *url.Values) error
|
||||
}
|
||||
|
||||
const (
|
||||
// Pending represents a job in progress
|
||||
Pending JobStatusType = iota
|
||||
// Success represents a successfully completed job
|
||||
Success
|
||||
// Failure represents a job that has failed to complete
|
||||
Failure
|
||||
)
|
||||
|
||||
// JobStatusType represents the status of a Job
|
||||
type JobStatusType int
|
||||
|
||||
const (
|
||||
// Unauthorized represents ... (TODO)
|
||||
Unauthorized ErrorCode = 401
|
||||
// MethodNotAllowed represents ... (TODO)
|
||||
MethodNotAllowed = 405
|
||||
// UnsupportedActionError represents ... (TODO)
|
||||
UnsupportedActionError = 422
|
||||
// APILimitExceeded represents ... (TODO)
|
||||
APILimitExceeded = 429
|
||||
// MalformedParameterError represents ... (TODO)
|
||||
MalformedParameterError = 430
|
||||
// ParamError represents ... (TODO)
|
||||
ParamError = 431
|
||||
|
||||
// InternalError represents a server error
|
||||
InternalError = 530
|
||||
// AccountError represents ... (TODO)
|
||||
AccountError = 531
|
||||
// AccountResourceLimitError represents ... (TODO)
|
||||
AccountResourceLimitError = 532
|
||||
// InsufficientCapacityError represents ... (TODO)
|
||||
InsufficientCapacityError = 533
|
||||
// ResourceUnavailableError represents ... (TODO)
|
||||
ResourceUnavailableError = 534
|
||||
// ResourceAllocationError represents ... (TODO)
|
||||
ResourceAllocationError = 535
|
||||
// ResourceInUseError represents ... (TODO)
|
||||
ResourceInUseError = 536
|
||||
// NetworkRuleConflictError represents ... (TODO)
|
||||
NetworkRuleConflictError = 537
|
||||
)
|
||||
|
||||
// ErrorCode represents the CloudStack ApiErrorCode enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/org/apache/cloudstack/api/ApiErrorCode.java
|
||||
type ErrorCode int
|
||||
|
||||
// JobResultResponse represents a generic response to a job task
|
||||
type JobResultResponse struct {
|
||||
AccountID string `json:"accountid,omitempty"`
|
||||
Cmd string `json:"cmd"`
|
||||
Created string `json:"created"`
|
||||
JobID string `json:"jobid"`
|
||||
JobProcStatus int `json:"jobprocstatus"`
|
||||
JobResult *json.RawMessage `json:"jobresult"`
|
||||
JobStatus JobStatusType `json:"jobstatus"`
|
||||
JobResultType string `json:"jobresulttype"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse represents the standard error response from CloudStack
|
||||
type ErrorResponse struct {
|
||||
ErrorCode ErrorCode `json:"errorcode"`
|
||||
CsErrorCode int `json:"cserrorcode"`
|
||||
ErrorText string `json:"errortext"`
|
||||
UUIDList []string `json:"uuidList,omitempty"` // uuid*L*ist is not a typo
|
||||
}
|
||||
|
||||
// Error formats a CloudStack error into a standard error
|
||||
func (e *ErrorResponse) Error() string {
|
||||
return fmt.Sprintf("API error %d (internal code: %d): %s", e.ErrorCode, e.CsErrorCode, e.ErrorText)
|
||||
}
|
||||
|
||||
// booleanAsyncResponse represents a boolean response (usually after a deletion)
|
||||
type booleanAsyncResponse struct {
|
||||
Success bool `json:"success"`
|
||||
DisplayText string `json:"diplaytext,omitempty"`
|
||||
func (e ErrorResponse) Error() string {
|
||||
return fmt.Sprintf("API error %s %d (%s %d): %s", e.ErrorCode, e.ErrorCode, e.CSErrorCode, e.CSErrorCode, e.ErrorText)
|
||||
}
|
||||
|
||||
// Error formats a CloudStack job response into a standard error
|
||||
func (e *booleanAsyncResponse) Error() error {
|
||||
if e.Success {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("API error: %s", e.DisplayText)
|
||||
}
|
||||
|
||||
// booleanAsyncResponse represents a boolean response for sync calls
|
||||
type booleanSyncResponse struct {
|
||||
Success string `json:"success"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
}
|
||||
|
||||
func (e *booleanSyncResponse) Error() error {
|
||||
if e.Success == "true" {
|
||||
return nil
|
||||
func (e booleanResponse) Error() error {
|
||||
if !e.Success {
|
||||
return fmt.Errorf("API error: %s", e.DisplayText)
|
||||
}
|
||||
|
||||
return fmt.Errorf("API error: %s", e.DisplayText)
|
||||
return nil
|
||||
}
|
||||
|
||||
// AsyncInfo represents the details for any async call
|
||||
//
|
||||
// It retries at most Retries time and waits for Delay between each retry
|
||||
type AsyncInfo struct {
|
||||
Retries int
|
||||
Delay int
|
||||
// XXX: addIpToNic, activateIp6, restorevmresponse are kind of special
|
||||
var responseKeys = map[string]string{
|
||||
"addiptonicresponse": "addiptovmnicresponse",
|
||||
"activateip6response": "activateip6nicresponse",
|
||||
"restorevirtualmachineresponse": "restorevmresponse",
|
||||
}
|
||||
|
||||
func csQuotePlus(s string) string {
|
||||
s = strings.Replace(s, "+", "%20", -1)
|
||||
s = strings.Replace(s, "%5B", "[", -1)
|
||||
s = strings.Replace(s, "%5D", "]", -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func csEncode(s string) string {
|
||||
return csQuotePlus(url.QueryEscape(s))
|
||||
}
|
||||
|
||||
func rawValue(b json.RawMessage) (json.RawMessage, error) {
|
||||
var m map[string]json.RawMessage
|
||||
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range m {
|
||||
return v, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func rawValues(b json.RawMessage) (json.RawMessage, error) {
|
||||
var i []json.RawMessage
|
||||
|
||||
if err := json.Unmarshal(b, &i); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return i[0], nil
|
||||
}
|
||||
|
||||
func (exo *Client) parseResponse(resp *http.Response) (json.RawMessage, error) {
|
||||
func (client *Client) parseResponse(resp *http.Response, apiName string) (json.RawMessage, error) {
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
a, err := rawValues(b)
|
||||
m := map[string]json.RawMessage{}
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if a == nil {
|
||||
b, err = rawValue(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
key := fmt.Sprintf("%sresponse", strings.ToLower(apiName))
|
||||
response, ok := m[key]
|
||||
if !ok {
|
||||
if resp.StatusCode >= 400 {
|
||||
response, ok = m["errorresponse"]
|
||||
}
|
||||
|
||||
if !ok {
|
||||
// try again with the special keys
|
||||
value, ok := responseKeys[key]
|
||||
if ok {
|
||||
key = value
|
||||
}
|
||||
|
||||
response, ok = m[key]
|
||||
|
||||
if !ok {
|
||||
for k := range m {
|
||||
return nil, fmt.Errorf("malformed JSON response, %q was expected, got %q", key, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if resp.StatusCode >= 400 {
|
||||
var e ErrorResponse
|
||||
if err := json.Unmarshal(b, &e); err != nil {
|
||||
return nil, err
|
||||
errorResponse := new(ErrorResponse)
|
||||
if e := json.Unmarshal(response, errorResponse); e != nil && errorResponse.ErrorCode <= 0 {
|
||||
return nil, fmt.Errorf("%d %s", resp.StatusCode, b)
|
||||
}
|
||||
return b, &e
|
||||
return nil, errorResponse
|
||||
}
|
||||
return b, nil
|
||||
|
||||
n := map[string]json.RawMessage{}
|
||||
if err := json.Unmarshal(response, &n); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// list response may contain only one key
|
||||
if len(n) > 1 || strings.HasPrefix(key, "list") {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
if len(n) == 1 {
|
||||
for k := range n {
|
||||
// boolean response and asyncjob result may also contain
|
||||
// only one key
|
||||
if k == "success" || k == "jobid" {
|
||||
return response, nil
|
||||
}
|
||||
return n[k], nil
|
||||
}
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// AsyncRequest performs an asynchronous request and polls it for retries * day [s]
|
||||
func (exo *Client) AsyncRequest(req AsyncCommand, async AsyncInfo) (interface{}, error) {
|
||||
body, err := exo.request(req.name(), req)
|
||||
// asyncRequest perform an asynchronous job with a context
|
||||
func (client *Client) asyncRequest(ctx context.Context, asyncCommand AsyncCommand) (interface{}, error) {
|
||||
var err error
|
||||
|
||||
resp := asyncCommand.asyncResponse()
|
||||
client.AsyncRequestWithContext(
|
||||
ctx,
|
||||
asyncCommand,
|
||||
func(j *AsyncJobResult, e error) bool {
|
||||
if e != nil {
|
||||
err = e
|
||||
return false
|
||||
}
|
||||
if j.JobStatus != Pending {
|
||||
if r := j.Result(resp); r != nil {
|
||||
err = r
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// SyncRequestWithContext performs a sync request with a context
|
||||
func (client *Client) SyncRequestWithContext(ctx context.Context, command Command) (interface{}, error) {
|
||||
body, err := client.request(ctx, command)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Is it a Job?
|
||||
job := new(JobResultResponse)
|
||||
if err := json.Unmarshal(body, &job); err != nil {
|
||||
response := command.response()
|
||||
b, ok := response.(*booleanResponse)
|
||||
if ok {
|
||||
m := make(map[string]interface{})
|
||||
if errUnmarshal := json.Unmarshal(body, &m); errUnmarshal != nil {
|
||||
return nil, errUnmarshal
|
||||
}
|
||||
|
||||
b.DisplayText, _ = m["displaytext"].(string)
|
||||
|
||||
if success, okSuccess := m["success"].(string); okSuccess {
|
||||
b.Success = success == "true"
|
||||
}
|
||||
|
||||
if success, okSuccess := m["success"].(bool); okSuccess {
|
||||
b.Success = success
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(body, response); err != nil {
|
||||
errResponse := new(ErrorResponse)
|
||||
if e := json.Unmarshal(body, errResponse); e == nil && errResponse.ErrorCode > 0 {
|
||||
return errResponse, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Error response
|
||||
errorResponse := new(ErrorResponse)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// BooleanRequest performs the given boolean command
|
||||
func (client *Client) BooleanRequest(command Command) error {
|
||||
resp, err := client.Request(command)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if b, ok := resp.(*booleanResponse); ok {
|
||||
return b.Error()
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
|
||||
}
|
||||
|
||||
// BooleanRequestWithContext performs the given boolean command
|
||||
func (client *Client) BooleanRequestWithContext(ctx context.Context, command Command) error {
|
||||
resp, err := client.RequestWithContext(ctx, command)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if b, ok := resp.(*booleanResponse); ok {
|
||||
return b.Error()
|
||||
}
|
||||
|
||||
panic(fmt.Errorf("command %q is not a proper boolean response. %#v", client.APIName(command), resp))
|
||||
}
|
||||
|
||||
// Request performs the given command
|
||||
func (client *Client) Request(command Command) (interface{}, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.RequestWithContext(ctx, command)
|
||||
}
|
||||
|
||||
// RequestWithContext preforms a command with a context
|
||||
func (client *Client) RequestWithContext(ctx context.Context, command Command) (interface{}, error) {
|
||||
switch command.(type) {
|
||||
case AsyncCommand:
|
||||
return client.asyncRequest(ctx, command.(AsyncCommand))
|
||||
default:
|
||||
return client.SyncRequestWithContext(ctx, command)
|
||||
}
|
||||
}
|
||||
|
||||
// SyncRequest performs the command as is
|
||||
func (client *Client) SyncRequest(command Command) (interface{}, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
return client.SyncRequestWithContext(ctx, command)
|
||||
}
|
||||
|
||||
// AsyncRequest performs the given command
|
||||
func (client *Client) AsyncRequest(asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), client.Timeout)
|
||||
defer cancel()
|
||||
|
||||
client.AsyncRequestWithContext(ctx, asyncCommand, callback)
|
||||
}
|
||||
|
||||
// AsyncRequestWithContext preforms a request with a context
|
||||
func (client *Client) AsyncRequestWithContext(ctx context.Context, asyncCommand AsyncCommand, callback WaitAsyncJobResultFunc) {
|
||||
result, err := client.SyncRequestWithContext(ctx, asyncCommand)
|
||||
if err != nil {
|
||||
if !callback(nil, err) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
jobResult, ok := result.(*AsyncJobResult)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type, AsyncJobResult was expected instead of %T", result))
|
||||
}
|
||||
|
||||
// Successful response
|
||||
resp := req.asyncResponse()
|
||||
if job.JobID == "" || job.JobStatus != Pending {
|
||||
if err := json.Unmarshal(*job.JobResult, resp); err != nil {
|
||||
return job, err
|
||||
if jobResult.JobID == nil || jobResult.JobStatus != Pending {
|
||||
callback(jobResult, nil)
|
||||
// without a JobID, the next requests will only fail
|
||||
return
|
||||
}
|
||||
|
||||
for iteration := 0; ; iteration++ {
|
||||
time.Sleep(client.RetryStrategy(int64(iteration)))
|
||||
|
||||
req := &QueryAsyncJobResult{JobID: jobResult.JobID}
|
||||
resp, err := client.SyncRequestWithContext(ctx, req)
|
||||
if err != nil && !callback(nil, err) {
|
||||
return
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// we've got a pending job
|
||||
result := &QueryAsyncJobResultResponse{
|
||||
JobStatus: job.JobStatus,
|
||||
}
|
||||
for async.Retries > 0 && result.JobStatus == Pending {
|
||||
time.Sleep(time.Duration(async.Delay) * time.Second)
|
||||
|
||||
async.Retries--
|
||||
|
||||
req := &QueryAsyncJobResult{JobID: job.JobID}
|
||||
resp, err := exo.Request(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
result, ok := resp.(*AsyncJobResult)
|
||||
if !ok {
|
||||
if !callback(nil, fmt.Errorf("wrong type. AsyncJobResult expected, got %T", resp)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
result = resp.(*QueryAsyncJobResultResponse)
|
||||
}
|
||||
|
||||
if result.JobStatus == Failure {
|
||||
if err := json.Unmarshal(*result.JobResult, &errorResponse); err != nil {
|
||||
return nil, err
|
||||
if !callback(result, nil) {
|
||||
return
|
||||
}
|
||||
return errorResponse, errorResponse
|
||||
}
|
||||
|
||||
if result.JobStatus == Pending {
|
||||
return result, fmt.Errorf("Maximum number of retries reached")
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(*result.JobResult, resp); err != nil {
|
||||
if err := json.Unmarshal(*result.JobResult, errorResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return errorResponse, errorResponse
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// BooleanRequest performs a sync request on a boolean call
|
||||
func (exo *Client) BooleanRequest(req Command) error {
|
||||
resp, err := exo.Request(req)
|
||||
// Payload builds the HTTP request params from the given command
|
||||
func (client *Client) Payload(command Command) (url.Values, error) {
|
||||
params := url.Values{}
|
||||
err := prepareValues("", params, command)
|
||||
if err != nil {
|
||||
return err
|
||||
return params, err
|
||||
}
|
||||
|
||||
return resp.(*booleanSyncResponse).Error()
|
||||
}
|
||||
|
||||
// BooleanAsyncRequest performs a sync request on a boolean call
|
||||
func (exo *Client) BooleanAsyncRequest(req AsyncCommand, async AsyncInfo) error {
|
||||
resp, err := exo.AsyncRequest(req, async)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return resp.(*booleanAsyncResponse).Error()
|
||||
}
|
||||
|
||||
// Request performs a sync request on a generic command
|
||||
func (exo *Client) Request(req Command) (interface{}, error) {
|
||||
body, err := exo.request(req.name(), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp := req.response()
|
||||
if err := json.Unmarshal(body, resp); err != nil {
|
||||
r := new(ErrorResponse)
|
||||
if e := json.Unmarshal(body, r); e != nil {
|
||||
return nil, r
|
||||
if hookReq, ok := command.(onBeforeHook); ok {
|
||||
if err := hookReq.onBeforeSend(params); err != nil {
|
||||
return params, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
params.Set("apikey", client.APIKey)
|
||||
params.Set("command", client.APIName(command))
|
||||
params.Set("response", "json")
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// Sign signs the HTTP request and returns the signature as as base64 encoding
|
||||
func (client *Client) Sign(params url.Values) (string, error) {
|
||||
query := encodeValues(params)
|
||||
query = strings.ToLower(query)
|
||||
mac := hmac.New(sha1.New, []byte(client.apiSecret))
|
||||
_, err := mac.Write([]byte(query))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
|
||||
return signature, nil
|
||||
}
|
||||
|
||||
// request makes a Request while being close to the metal
|
||||
func (exo *Client) request(command string, req interface{}) (json.RawMessage, error) {
|
||||
params := url.Values{}
|
||||
err := prepareValues("", ¶ms, req)
|
||||
func (client *Client) request(ctx context.Context, command Command) (json.RawMessage, error) {
|
||||
params, err := client.Payload(command)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if hookReq, ok := req.(onBeforeHook); ok {
|
||||
hookReq.onBeforeSend(¶ms)
|
||||
signature, err := client.Sign(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
params.Set("apikey", exo.apiKey)
|
||||
params.Set("command", command)
|
||||
params.Set("response", "json")
|
||||
params.Add("signature", signature)
|
||||
|
||||
method := "GET"
|
||||
query := params.Encode()
|
||||
url := fmt.Sprintf("%s?%s", client.Endpoint, query)
|
||||
|
||||
var body io.Reader
|
||||
// respect Internet Explorer limit of 2048
|
||||
if len(url) > 2048 {
|
||||
url = client.Endpoint
|
||||
method = "POST"
|
||||
body = strings.NewReader(query)
|
||||
}
|
||||
|
||||
request, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
request = request.WithContext(ctx)
|
||||
request.Header.Add("User-Agent", fmt.Sprintf("exoscale/egoscale (%v)", Version))
|
||||
|
||||
if method == "POST" {
|
||||
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
request.Header.Add("Content-Length", strconv.Itoa(len(query)))
|
||||
}
|
||||
|
||||
resp, err := client.HTTPClient.Do(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close() // nolint: errcheck
|
||||
|
||||
contentType := resp.Header.Get("content-type")
|
||||
|
||||
if !strings.Contains(contentType, "application/json") {
|
||||
return nil, fmt.Errorf(`body content-type response expected "application/json", got %q`, contentType)
|
||||
}
|
||||
|
||||
text, err := client.parseResponse(resp, client.APIName(command))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return text, nil
|
||||
}
|
||||
|
||||
func encodeValues(params url.Values) string {
|
||||
// This code is borrowed from net/url/url.go
|
||||
// The way it's encoded by net/url doesn't match
|
||||
// how CloudStack works.
|
||||
// how CloudStack works to determine the signature.
|
||||
//
|
||||
// CloudStack only encodes the values of the query parameters
|
||||
// and furthermore doesn't use '+' for whitespaces. Therefore
|
||||
// after encoding the values all '+' are replaced with '%20'.
|
||||
if params == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
keys := make([]string, 0, len(params))
|
||||
for k := range params {
|
||||
|
@ -338,7 +384,7 @@ func (exo *Client) request(command string, req interface{}) (json.RawMessage, er
|
|||
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
prefix := csEncode(k) + "="
|
||||
prefix := k + "="
|
||||
for _, v := range params[k] {
|
||||
if buf.Len() > 0 {
|
||||
buf.WriteByte('&')
|
||||
|
@ -347,218 +393,5 @@ func (exo *Client) request(command string, req interface{}) (json.RawMessage, er
|
|||
buf.WriteString(csEncode(v))
|
||||
}
|
||||
}
|
||||
|
||||
query := buf.String()
|
||||
|
||||
mac := hmac.New(sha1.New, []byte(exo.apiSecret))
|
||||
mac.Write([]byte(strings.ToLower(query)))
|
||||
signature := csEncode(base64.StdEncoding.EncodeToString(mac.Sum(nil)))
|
||||
|
||||
reader := strings.NewReader(fmt.Sprintf("%s&signature=%s", csQuotePlus(query), signature))
|
||||
resp, err := exo.client.Post(exo.endpoint, "application/x-www-form-urlencoded", reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := exo.parseResponse(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return body, nil
|
||||
}
|
||||
|
||||
// prepareValues uses a command to build a POST request
|
||||
//
|
||||
// command is not a Command so it's easier to Test
|
||||
func prepareValues(prefix string, params *url.Values, command interface{}) error {
|
||||
value := reflect.ValueOf(command)
|
||||
typeof := reflect.TypeOf(command)
|
||||
// Going up the pointer chain to find the underlying struct
|
||||
for typeof.Kind() == reflect.Ptr {
|
||||
typeof = typeof.Elem()
|
||||
value = value.Elem()
|
||||
}
|
||||
|
||||
for i := 0; i < typeof.NumField(); i++ {
|
||||
field := typeof.Field(i)
|
||||
val := value.Field(i)
|
||||
tag := field.Tag
|
||||
if json, ok := tag.Lookup("json"); ok {
|
||||
n, required := extractJSONTag(field.Name, json)
|
||||
name := prefix + n
|
||||
|
||||
switch val.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
v := val.Int()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, strconv.FormatInt(v, 10))
|
||||
}
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
v := val.Uint()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, strconv.FormatUint(v, 10))
|
||||
}
|
||||
case reflect.Float32, reflect.Float64:
|
||||
v := val.Float()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, strconv.FormatFloat(v, 'f', -1, 64))
|
||||
}
|
||||
case reflect.String:
|
||||
v := val.String()
|
||||
if v == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got \"\"", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, v)
|
||||
}
|
||||
case reflect.Bool:
|
||||
v := val.Bool()
|
||||
if v == false {
|
||||
if required {
|
||||
params.Set(name, "false")
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, "true")
|
||||
}
|
||||
case reflect.Slice:
|
||||
switch field.Type.Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
switch field.Type {
|
||||
case reflect.TypeOf(net.IPv4zero):
|
||||
ip := (net.IP)(val.Bytes())
|
||||
if ip == nil || ip.Equal(net.IPv4zero) {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got zero IPv4 address", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
(*params).Set(name, ip.String())
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
v := val.Bytes()
|
||||
(*params).Set(name, base64.StdEncoding.EncodeToString(v))
|
||||
}
|
||||
}
|
||||
case reflect.String:
|
||||
{
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
elems := make([]string, 0, val.Len())
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
// XXX what if the value contains a comma? Double encode?
|
||||
s := val.Index(i).String()
|
||||
elems = append(elems, s)
|
||||
}
|
||||
(*params).Set(name, strings.Join(elems, ","))
|
||||
}
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
err := prepareList(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty map", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
err := prepareMap(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
default:
|
||||
if required {
|
||||
return fmt.Errorf("Unsupported type %s.%s (%v)", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Printf("[SKIP] %s.%s no json label found", typeof.Name(), field.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareList(prefix string, params *url.Values, slice interface{}) error {
|
||||
value := reflect.ValueOf(slice)
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
prepareValues(fmt.Sprintf("%s[%d].", prefix, i), params, value.Index(i).Interface())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareMap(prefix string, params *url.Values, m interface{}) error {
|
||||
value := reflect.ValueOf(m)
|
||||
|
||||
for i, key := range value.MapKeys() {
|
||||
var keyName string
|
||||
var keyValue string
|
||||
|
||||
switch key.Kind() {
|
||||
case reflect.String:
|
||||
keyName = key.String()
|
||||
default:
|
||||
return fmt.Errorf("Only map[string]string are supported (XXX)")
|
||||
}
|
||||
|
||||
val := value.MapIndex(key)
|
||||
switch val.Kind() {
|
||||
case reflect.String:
|
||||
keyValue = val.String()
|
||||
default:
|
||||
return fmt.Errorf("Only map[string]string are supported (XXX)")
|
||||
}
|
||||
params.Set(fmt.Sprintf("%s[%d].%s", prefix, i, keyName), keyValue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// extractJSONTag returns the variable name or defaultName as well as if the field is required (!omitempty)
|
||||
func extractJSONTag(defaultName, jsonTag string) (string, bool) {
|
||||
tags := strings.Split(jsonTag, ",")
|
||||
name := tags[0]
|
||||
required := true
|
||||
for _, tag := range tags {
|
||||
if tag == "omitempty" {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
|
||||
if name == "" || name == "omitempty" {
|
||||
name = defaultName
|
||||
}
|
||||
return name, required
|
||||
return buf.String()
|
||||
}
|
||||
|
|
184
vendor/github.com/exoscale/egoscale/request_type.go
generated
vendored
Normal file
184
vendor/github.com/exoscale/egoscale/request_type.go
generated
vendored
Normal file
|
@ -0,0 +1,184 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// Command represents a CloudStack request
|
||||
type Command interface {
|
||||
response() interface{}
|
||||
}
|
||||
|
||||
// AsyncCommand represents a async CloudStack request
|
||||
type AsyncCommand interface {
|
||||
Command
|
||||
// Response interface to Unmarshal the JSON into
|
||||
asyncResponse() interface{}
|
||||
}
|
||||
|
||||
// ListCommand represents a CloudStack list request
|
||||
type ListCommand interface {
|
||||
Command
|
||||
// SetPage defines the current pages
|
||||
SetPage(int)
|
||||
// SetPageSize defines the size of the page
|
||||
SetPageSize(int)
|
||||
// each reads the data from the response and feeds channels, and returns true if we are on the last page
|
||||
each(interface{}, IterateItemFunc)
|
||||
}
|
||||
|
||||
// onBeforeHook represents an action to be done on the params before sending them
|
||||
//
|
||||
// This little took helps with issue of relying on JSON serialization logic only.
|
||||
// `omitempty` may make sense in some cases but not all the time.
|
||||
type onBeforeHook interface {
|
||||
onBeforeSend(params url.Values) error
|
||||
}
|
||||
|
||||
// CommandInfo represents the meta data related to a Command
|
||||
type CommandInfo struct {
|
||||
Name string
|
||||
Description string
|
||||
RootOnly bool
|
||||
}
|
||||
|
||||
// JobStatusType represents the status of a Job
|
||||
type JobStatusType int
|
||||
|
||||
//go:generate stringer -type JobStatusType
|
||||
const (
|
||||
// Pending represents a job in progress
|
||||
Pending JobStatusType = iota
|
||||
// Success represents a successfully completed job
|
||||
Success
|
||||
// Failure represents a job that has failed to complete
|
||||
Failure
|
||||
)
|
||||
|
||||
// ErrorCode represents the CloudStack ApiErrorCode enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/org/apache/cloudstack/api/ApiErrorCode.java
|
||||
type ErrorCode int
|
||||
|
||||
//go:generate stringer -type ErrorCode
|
||||
const (
|
||||
// Unauthorized represents ... (TODO)
|
||||
Unauthorized ErrorCode = 401
|
||||
// MethodNotAllowed represents ... (TODO)
|
||||
MethodNotAllowed ErrorCode = 405
|
||||
// UnsupportedActionError represents ... (TODO)
|
||||
UnsupportedActionError ErrorCode = 422
|
||||
// APILimitExceeded represents ... (TODO)
|
||||
APILimitExceeded ErrorCode = 429
|
||||
// MalformedParameterError represents ... (TODO)
|
||||
MalformedParameterError ErrorCode = 430
|
||||
// ParamError represents ... (TODO)
|
||||
ParamError ErrorCode = 431
|
||||
|
||||
// InternalError represents a server error
|
||||
InternalError ErrorCode = 530
|
||||
// AccountError represents ... (TODO)
|
||||
AccountError ErrorCode = 531
|
||||
// AccountResourceLimitError represents ... (TODO)
|
||||
AccountResourceLimitError ErrorCode = 532
|
||||
// InsufficientCapacityError represents ... (TODO)
|
||||
InsufficientCapacityError ErrorCode = 533
|
||||
// ResourceUnavailableError represents ... (TODO)
|
||||
ResourceUnavailableError ErrorCode = 534
|
||||
// ResourceAllocationError represents ... (TODO)
|
||||
ResourceAllocationError ErrorCode = 535
|
||||
// ResourceInUseError represents ... (TODO)
|
||||
ResourceInUseError ErrorCode = 536
|
||||
// NetworkRuleConflictError represents ... (TODO)
|
||||
NetworkRuleConflictError ErrorCode = 537
|
||||
)
|
||||
|
||||
// CSErrorCode represents the CloudStack CSExceptionErrorCode enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/utils/src/main/java/com/cloud/utils/exception/CSExceptionErrorCode.java
|
||||
type CSErrorCode int
|
||||
|
||||
//go:generate stringer -type CSErrorCode
|
||||
const (
|
||||
// CloudRuntimeException ... (TODO)
|
||||
CloudRuntimeException CSErrorCode = 4250
|
||||
// ExecutionException ... (TODO)
|
||||
ExecutionException CSErrorCode = 4260
|
||||
// HypervisorVersionChangedException ... (TODO)
|
||||
HypervisorVersionChangedException CSErrorCode = 4265
|
||||
// CloudException ... (TODO)
|
||||
CloudException CSErrorCode = 4275
|
||||
// AccountLimitException ... (TODO)
|
||||
AccountLimitException CSErrorCode = 4280
|
||||
// AgentUnavailableException ... (TODO)
|
||||
AgentUnavailableException CSErrorCode = 4285
|
||||
// CloudAuthenticationException ... (TODO)
|
||||
CloudAuthenticationException CSErrorCode = 4290
|
||||
// ConcurrentOperationException ... (TODO)
|
||||
ConcurrentOperationException CSErrorCode = 4300
|
||||
// ConflictingNetworksException ... (TODO)
|
||||
ConflictingNetworkSettingsException CSErrorCode = 4305
|
||||
// DiscoveredWithErrorException ... (TODO)
|
||||
DiscoveredWithErrorException CSErrorCode = 4310
|
||||
// HAStateException ... (TODO)
|
||||
HAStateException CSErrorCode = 4315
|
||||
// InsufficientAddressCapacityException ... (TODO)
|
||||
InsufficientAddressCapacityException CSErrorCode = 4320
|
||||
// InsufficientCapacityException ... (TODO)
|
||||
InsufficientCapacityException CSErrorCode = 4325
|
||||
// InsufficientNetworkCapacityException ... (TODO)
|
||||
InsufficientNetworkCapacityException CSErrorCode = 4330
|
||||
// InsufficientServerCapaticyException ... (TODO)
|
||||
InsufficientServerCapacityException CSErrorCode = 4335
|
||||
// InsufficientStorageCapacityException ... (TODO)
|
||||
InsufficientStorageCapacityException CSErrorCode = 4340
|
||||
// InternalErrorException ... (TODO)
|
||||
InternalErrorException CSErrorCode = 4345
|
||||
// InvalidParameterValueException ... (TODO)
|
||||
InvalidParameterValueException CSErrorCode = 4350
|
||||
// ManagementServerException ... (TODO)
|
||||
ManagementServerException CSErrorCode = 4355
|
||||
// NetworkRuleConflictException ... (TODO)
|
||||
NetworkRuleConflictException CSErrorCode = 4360
|
||||
// PermissionDeniedException ... (TODO)
|
||||
PermissionDeniedException CSErrorCode = 4365
|
||||
// ResourceAllocationException ... (TODO)
|
||||
ResourceAllocationException CSErrorCode = 4370
|
||||
// ResourceInUseException ... (TODO)
|
||||
ResourceInUseException CSErrorCode = 4375
|
||||
// ResourceUnavailableException ... (TODO)
|
||||
ResourceUnavailableException CSErrorCode = 4380
|
||||
// StorageUnavailableException ... (TODO)
|
||||
StorageUnavailableException CSErrorCode = 4385
|
||||
// UnsupportedServiceException ... (TODO)
|
||||
UnsupportedServiceException CSErrorCode = 4390
|
||||
// VirtualMachineMigrationException ... (TODO)
|
||||
VirtualMachineMigrationException CSErrorCode = 4395
|
||||
// AsyncCommandQueued ... (TODO)
|
||||
AsyncCommandQueued CSErrorCode = 4540
|
||||
// RequestLimitException ... (TODO)
|
||||
RequestLimitException CSErrorCode = 4545
|
||||
// ServerAPIException ... (TODO)
|
||||
ServerAPIException CSErrorCode = 9999
|
||||
)
|
||||
|
||||
// ErrorResponse represents the standard error response from CloudStack
|
||||
type ErrorResponse struct {
|
||||
CSErrorCode CSErrorCode `json:"cserrorcode"`
|
||||
ErrorCode ErrorCode `json:"errorcode"`
|
||||
ErrorText string `json:"errortext"`
|
||||
UUIDList []UUIDItem `json:"uuidList,omitempty"` // uuid*L*ist is not a typo
|
||||
}
|
||||
|
||||
// UUIDItem represents an item of the UUIDList part of an ErrorResponse
|
||||
type UUIDItem struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
SerialVersionUID int64 `json:"serialVersionUID,omitempty"`
|
||||
UUID string `json:"uuid"`
|
||||
}
|
||||
|
||||
// booleanResponse represents a boolean response (usually after a deletion)
|
||||
type booleanResponse struct {
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Success bool `json:"success"`
|
||||
}
|
36
vendor/github.com/exoscale/egoscale/resource_metadata.go
generated
vendored
Normal file
36
vendor/github.com/exoscale/egoscale/resource_metadata.go
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
package egoscale
|
||||
|
||||
// ListResourceDetails lists the resource tag(s) (but different from listTags...)
|
||||
type ListResourceDetails struct {
|
||||
ResourceType string `json:"resourcetype" doc:"list by resource type"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForDisplay bool `json:"fordisplay,omitempty" doc:"if set to true, only details marked with display=true, are returned. False by default"`
|
||||
Key string `json:"key,omitempty" doc:"list by key"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"list by resource id"`
|
||||
Value string `json:"value,omitempty" doc:"list by key, value. Needs to be passed only along with key"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
_ bool `name:"listResourceDetails" description:"List resource detail(s)"`
|
||||
}
|
||||
|
||||
// ListResourceDetailsResponse represents a list of resource details
|
||||
type ListResourceDetailsResponse struct {
|
||||
Count int `json:"count"`
|
||||
ResourceDetail []ResourceTag `json:"resourcedetail"`
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) name() string {
|
||||
return "listResourceDetails"
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) description() string {
|
||||
return "List resource detail(s)"
|
||||
}
|
||||
|
||||
func (*ListResourceDetails) response() interface{} {
|
||||
return new(ListResourceDetailsResponse)
|
||||
}
|
77
vendor/github.com/exoscale/egoscale/reversedns.go
generated
vendored
Normal file
77
vendor/github.com/exoscale/egoscale/reversedns.go
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// ReverseDNS represents the PTR record linked with an IPAddress or IP6Address belonging to a Virtual Machine or a Public IP Address (Elastic IP) instance
|
||||
type ReverseDNS struct {
|
||||
DomainName string `json:"domainname,omitempty" doc:"the domain name of the PTR record"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty" doc:"the IPv6 address linked with the PTR record (mutually exclusive with ipaddress)"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the IPv4 address linked with the PTR record (mutually exclusive with ip6address)"`
|
||||
NicID *UUID `json:"nicid,omitempty" doc:"the virtual machine default NIC ID"`
|
||||
PublicIPID *UUID `json:"publicipid,omitempty" doc:"the public IP address ID"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the virtual machine ID"`
|
||||
}
|
||||
|
||||
// DeleteReverseDNSFromPublicIPAddress is a command to create/delete the PTR record of a public IP address
|
||||
type DeleteReverseDNSFromPublicIPAddress struct {
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the public IP address"`
|
||||
_ bool `name:"deleteReverseDnsFromPublicIpAddress" description:"delete the PTR DNS record from the public IP address"`
|
||||
}
|
||||
|
||||
func (*DeleteReverseDNSFromPublicIPAddress) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// DeleteReverseDNSFromVirtualMachine is a command to create/delete the PTR record(s) of a virtual machine
|
||||
type DeleteReverseDNSFromVirtualMachine struct {
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
_ bool `name:"deleteReverseDnsFromVirtualMachine" description:"Delete the PTR DNS record(s) from the virtual machine"`
|
||||
}
|
||||
|
||||
func (*DeleteReverseDNSFromVirtualMachine) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// QueryReverseDNSForPublicIPAddress is a command to create/query the PTR record of a public IP address
|
||||
type QueryReverseDNSForPublicIPAddress struct {
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the public IP address"`
|
||||
_ bool `name:"queryReverseDnsForPublicIpAddress" description:"Query the PTR DNS record for the public IP address"`
|
||||
}
|
||||
|
||||
func (*QueryReverseDNSForPublicIPAddress) response() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
// QueryReverseDNSForVirtualMachine is a command to create/query the PTR record(s) of a virtual machine
|
||||
type QueryReverseDNSForVirtualMachine struct {
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
_ bool `name:"queryReverseDnsForVirtualMachine" description:"Query the PTR DNS record(s) for the virtual machine"`
|
||||
}
|
||||
|
||||
func (*QueryReverseDNSForVirtualMachine) response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// UpdateReverseDNSForPublicIPAddress is a command to create/update the PTR record of a public IP address
|
||||
type UpdateReverseDNSForPublicIPAddress struct {
|
||||
DomainName string `json:"domainname,omitempty" doc:"the domain name for the PTR record. It must have a valid TLD"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the public IP address"`
|
||||
_ bool `name:"updateReverseDnsForPublicIpAddress" description:"Update/create the PTR DNS record for the public IP address"`
|
||||
}
|
||||
|
||||
func (*UpdateReverseDNSForPublicIPAddress) response() interface{} {
|
||||
return new(IPAddress)
|
||||
}
|
||||
|
||||
// UpdateReverseDNSForVirtualMachine is a command to create/update the PTR record(s) of a virtual machine
|
||||
type UpdateReverseDNSForVirtualMachine struct {
|
||||
DomainName string `json:"domainname,omitempty" doc:"the domain name for the PTR record(s). It must have a valid TLD"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
_ bool `name:"updateReverseDnsForVirtualMachine" description:"Update/create the PTR DNS record(s) for the virtual machine"`
|
||||
}
|
||||
|
||||
func (*UpdateReverseDNSForVirtualMachine) response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
368
vendor/github.com/exoscale/egoscale/security_groups.go
generated
vendored
368
vendor/github.com/exoscale/egoscale/security_groups.go
generated
vendored
|
@ -1,51 +1,104 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// SecurityGroup represent a firewalling set of rules
|
||||
type SecurityGroup struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
VirtualMachineCount int `json:"virtualmachinecount,omitempty"` // CloudStack 4.6+
|
||||
VirtualMachineIDs []string `json:"virtualmachineids,omitempty"` // CloudStack 4.6+
|
||||
IngressRule []IngressRule `json:"ingressrule"`
|
||||
EgressRule []EgressRule `json:"egressrule"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account owning the security group"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the security group"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the security group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the security group"`
|
||||
EgressRule []EgressRule `json:"egressrule,omitempty" doc:"the list of egress rules associated with the security group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the security group"`
|
||||
IngressRule []IngressRule `json:"ingressrule,omitempty" doc:"the list of ingress rules associated with the security group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the security group"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with the rule"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*SecurityGroup) ResourceType() string {
|
||||
func (SecurityGroup) ResourceType() string {
|
||||
return "SecurityGroup"
|
||||
}
|
||||
|
||||
// UserSecurityGroup converts a SecurityGroup to a UserSecurityGroup
|
||||
func (sg SecurityGroup) UserSecurityGroup() UserSecurityGroup {
|
||||
return UserSecurityGroup{
|
||||
Account: sg.Account,
|
||||
Group: sg.Name,
|
||||
}
|
||||
}
|
||||
|
||||
// ListRequest builds the ListSecurityGroups request
|
||||
func (sg SecurityGroup) ListRequest() (ListCommand, error) {
|
||||
//TODO add tags
|
||||
req := &ListSecurityGroups{
|
||||
Account: sg.Account,
|
||||
DomainID: sg.DomainID,
|
||||
ID: sg.ID,
|
||||
SecurityGroupName: sg.Name,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// Delete deletes the given Security Group
|
||||
func (sg SecurityGroup) Delete(ctx context.Context, client *Client) error {
|
||||
if sg.ID == nil && sg.Name == "" {
|
||||
return fmt.Errorf("a SecurityGroup may only be deleted using ID or Name")
|
||||
}
|
||||
|
||||
req := &DeleteSecurityGroup{
|
||||
Account: sg.Account,
|
||||
DomainID: sg.DomainID,
|
||||
}
|
||||
|
||||
if sg.ID != nil {
|
||||
req.ID = sg.ID
|
||||
} else {
|
||||
req.Name = sg.Name
|
||||
}
|
||||
|
||||
return client.BooleanRequestWithContext(ctx, req)
|
||||
}
|
||||
|
||||
// RuleByID returns IngressRule or EgressRule by a rule ID
|
||||
func (sg SecurityGroup) RuleByID(ruleID UUID) (*IngressRule, *EgressRule) {
|
||||
for i, in := range sg.IngressRule {
|
||||
if in.RuleID.Equal(ruleID) {
|
||||
return &sg.IngressRule[i], nil
|
||||
}
|
||||
}
|
||||
|
||||
for i, out := range sg.EgressRule {
|
||||
if out.RuleID.Equal(ruleID) {
|
||||
return nil, &sg.EgressRule[i]
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// IngressRule represents the ingress rule
|
||||
type IngressRule struct {
|
||||
RuleID string `json:"ruleid"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Cidr string `json:"cidr,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
IcmpType int `json:"icmptype,omitempty"`
|
||||
IcmpCode int `json:"icmpcode,omitempty"`
|
||||
StartPort int `json:"startport,omitempty"`
|
||||
EndPort int `json:"endport,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
SecurityGroupID string `json:"securitygroupid,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"account owning the security group rule"`
|
||||
CIDR *CIDR `json:"cidr,omitempty" doc:"the CIDR notation for the base IP address of the security group rule"`
|
||||
Description string `json:"description,omitempty" doc:"description of the security group rule"`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"the ending port of the security group rule "`
|
||||
IcmpCode uint8 `json:"icmpcode,omitempty" doc:"the code for the ICMP message response"`
|
||||
IcmpType uint8 `json:"icmptype,omitempty" doc:"the type of the ICMP message response"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"the protocol of the security group rule"`
|
||||
RuleID *UUID `json:"ruleid,omitempty" doc:"the id of the security group rule"`
|
||||
SecurityGroupID *UUID `json:"securitygroupid,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"security group name"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"the starting port of the security group rule"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with the rule"`
|
||||
UserSecurityGroupList []UserSecurityGroup `json:"usersecuritygrouplist,omitempty"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
}
|
||||
|
||||
// EgressRule represents the ingress rule
|
||||
|
@ -57,165 +110,131 @@ type UserSecurityGroup struct {
|
|||
Account string `json:"account,omitempty"`
|
||||
}
|
||||
|
||||
// SecurityGroupResponse represents a generic security group response
|
||||
type SecurityGroupResponse struct {
|
||||
SecurityGroup SecurityGroup `json:"securitygroup"`
|
||||
// String gives the UserSecurityGroup name
|
||||
func (usg UserSecurityGroup) String() string {
|
||||
return usg.Group
|
||||
}
|
||||
|
||||
// CreateSecurityGroup represents a security group creation
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/createSecurityGroup.html
|
||||
type CreateSecurityGroup struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Name string `json:"name" doc:"name of the security group"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the security group. Must be used with domainId."`
|
||||
Description string `json:"description,omitempty" doc:"the description of the security group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the security group. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"createSecurityGroup" description:"Creates a security group"`
|
||||
}
|
||||
|
||||
func (*CreateSecurityGroup) name() string {
|
||||
return "createSecurityGroup"
|
||||
func (CreateSecurityGroup) response() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
func (*CreateSecurityGroup) response() interface{} {
|
||||
return new(CreateSecurityGroupResponse)
|
||||
}
|
||||
|
||||
// CreateSecurityGroupResponse represents a new security group
|
||||
type CreateSecurityGroupResponse SecurityGroupResponse
|
||||
|
||||
// DeleteSecurityGroup represents a security group deletion
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/deleteSecurityGroup.html
|
||||
type DeleteSecurityGroup struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"` // Mutually exclusive with name
|
||||
Name string `json:"name,omitempty"` // Mutually exclusive with id
|
||||
ProjectID string `json:"project,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account of the security group. Must be specified with domain ID"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the security group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"The ID of the security group. Mutually exclusive with name parameter"`
|
||||
Name string `json:"name,omitempty" doc:"The ID of the security group. Mutually exclusive with id parameter"`
|
||||
_ bool `name:"deleteSecurityGroup" description:"Deletes security group"`
|
||||
}
|
||||
|
||||
func (*DeleteSecurityGroup) name() string {
|
||||
return "deleteSecurityGroup"
|
||||
}
|
||||
|
||||
func (*DeleteSecurityGroup) response() interface{} {
|
||||
return new(booleanSyncResponse)
|
||||
func (DeleteSecurityGroup) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// AuthorizeSecurityGroupIngress (Async) represents the ingress rule creation
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/authorizeSecurityGroupIngress.html
|
||||
type AuthorizeSecurityGroupIngress struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
CidrList []string `json:"cidrlist,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
IcmpType int `json:"icmptype,omitempty"`
|
||||
IcmpCode int `json:"icmpcode,omitempty"`
|
||||
StartPort int `json:"startport,omitempty"`
|
||||
EndPort int `json:"endport,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
SecurityGroupID string `json:"securitygroupid,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty"`
|
||||
UserSecurityGroupList []UserSecurityGroup `json:"usersecuritygrouplist,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the security group. Must be used with domainId."`
|
||||
CIDRList []CIDR `json:"cidrlist,omitempty" doc:"the cidr list associated"`
|
||||
Description string `json:"description,omitempty" doc:"the description of the ingress/egress rule"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainid for the security group. If the account parameter is used, domainid must also be used."`
|
||||
EndPort uint16 `json:"endport,omitempty" doc:"end port for this ingress rule"`
|
||||
IcmpCode uint8 `json:"icmpcode,omitempty" doc:"error code for this icmp message"`
|
||||
IcmpType uint8 `json:"icmptype,omitempty" doc:"type of the icmp message being sent"`
|
||||
Protocol string `json:"protocol,omitempty" doc:"TCP is default. UDP, ICMP, ICMPv6, AH, ESP, GRE are the other supported protocols"`
|
||||
SecurityGroupID *UUID `json:"securitygroupid,omitempty" doc:"The ID of the security group. Mutually exclusive with securitygroupname parameter"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"The name of the security group. Mutually exclusive with securitygroupid parameter"`
|
||||
StartPort uint16 `json:"startport,omitempty" doc:"start port for this ingress rule"`
|
||||
UserSecurityGroupList []UserSecurityGroup `json:"usersecuritygrouplist,omitempty" doc:"user to security group mapping"`
|
||||
_ bool `name:"authorizeSecurityGroupIngress" description:"Authorizes a particular ingress/egress rule for this security group"`
|
||||
}
|
||||
|
||||
func (*AuthorizeSecurityGroupIngress) name() string {
|
||||
return "authorizeSecurityGroupIngress"
|
||||
func (AuthorizeSecurityGroupIngress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*AuthorizeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
return new(AuthorizeSecurityGroupIngressResponse)
|
||||
func (AuthorizeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
func (req *AuthorizeSecurityGroupIngress) onBeforeSend(params *url.Values) error {
|
||||
func (req AuthorizeSecurityGroupIngress) onBeforeSend(params url.Values) error {
|
||||
// ICMP code and type may be zero but can also be omitted...
|
||||
if req.Protocol == "ICMP" {
|
||||
if strings.HasPrefix(strings.ToLower(req.Protocol), "icmp") {
|
||||
params.Set("icmpcode", strconv.FormatInt(int64(req.IcmpCode), 10))
|
||||
params.Set("icmptype", strconv.FormatInt(int64(req.IcmpType), 10))
|
||||
}
|
||||
// StartPort may be zero but can also be omitted...
|
||||
if req.EndPort != 0 && req.StartPort == 0 {
|
||||
params.Set("startport", "0")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AuthorizeSecurityGroupIngressResponse represents the new egress rule
|
||||
// /!\ the Cloud Stack API document is not fully accurate. /!\
|
||||
type AuthorizeSecurityGroupIngressResponse SecurityGroupResponse
|
||||
|
||||
// AuthorizeSecurityGroupEgress (Async) represents the egress rule creation
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/authorizeSecurityGroupEgress.html
|
||||
type AuthorizeSecurityGroupEgress AuthorizeSecurityGroupIngress
|
||||
|
||||
func (*AuthorizeSecurityGroupEgress) name() string {
|
||||
return "authorizeSecurityGroupEgress"
|
||||
func (AuthorizeSecurityGroupEgress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*AuthorizeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
return new(AuthorizeSecurityGroupEgressResponse)
|
||||
func (AuthorizeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
return new(SecurityGroup)
|
||||
}
|
||||
|
||||
func (req *AuthorizeSecurityGroupEgress) onBeforeSend(params *url.Values) error {
|
||||
return (*AuthorizeSecurityGroupIngress)(req).onBeforeSend(params)
|
||||
func (req AuthorizeSecurityGroupEgress) onBeforeSend(params url.Values) error {
|
||||
return (AuthorizeSecurityGroupIngress)(req).onBeforeSend(params)
|
||||
}
|
||||
|
||||
// AuthorizeSecurityGroupEgressResponse represents the new egress rule
|
||||
// /!\ the Cloud Stack API document is not fully accurate. /!\
|
||||
type AuthorizeSecurityGroupEgressResponse CreateSecurityGroupResponse
|
||||
|
||||
// RevokeSecurityGroupIngress (Async) represents the ingress/egress rule deletion
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/revokeSecurityGroupIngress.html
|
||||
type RevokeSecurityGroupIngress struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the ingress rule"`
|
||||
_ bool `name:"revokeSecurityGroupIngress" description:"Deletes a particular ingress rule from this security group"`
|
||||
}
|
||||
|
||||
func (*RevokeSecurityGroupIngress) name() string {
|
||||
return "revokeSecurityGroupIngress"
|
||||
func (RevokeSecurityGroupIngress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RevokeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (RevokeSecurityGroupIngress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// RevokeSecurityGroupEgress (Async) represents the ingress/egress rule deletion
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/revokeSecurityGroupEgress.html
|
||||
type RevokeSecurityGroupEgress struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the egress rule"`
|
||||
_ bool `name:"revokeSecurityGroupEgress" description:"Deletes a particular egress rule from this security group"`
|
||||
}
|
||||
|
||||
func (*RevokeSecurityGroupEgress) name() string {
|
||||
return "revokeSecurityGroupEgress"
|
||||
func (RevokeSecurityGroupEgress) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RevokeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (RevokeSecurityGroupEgress) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListSecurityGroups represents a search for security groups
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listSecurityGroups.html
|
||||
type ListSecurityGroups struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list the security group by the id provided"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListSecurityGroups) name() string {
|
||||
return "listSecurityGroups"
|
||||
}
|
||||
|
||||
func (*ListSecurityGroups) response() interface{} {
|
||||
return new(ListSecurityGroupsResponse)
|
||||
SecurityGroupName string `json:"securitygroupname,omitempty" doc:"lists security groups by name"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"lists security groups by virtual machine id"`
|
||||
_ bool `name:"listSecurityGroups" description:"Lists security groups"`
|
||||
}
|
||||
|
||||
// ListSecurityGroupsResponse represents a list of security groups
|
||||
|
@ -224,79 +243,30 @@ type ListSecurityGroupsResponse struct {
|
|||
SecurityGroup []SecurityGroup `json:"securitygroup"`
|
||||
}
|
||||
|
||||
// CreateIngressRule creates a set of ingress rules
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) CreateIngressRule(req *AuthorizeSecurityGroupIngress, async AsyncInfo) ([]IngressRule, error) {
|
||||
resp, err := exo.AsyncRequest(req, async)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*AuthorizeSecurityGroupIngressResponse).SecurityGroup.IngressRule, nil
|
||||
func (ListSecurityGroups) response() interface{} {
|
||||
return new(ListSecurityGroupsResponse)
|
||||
}
|
||||
|
||||
// CreateEgressRule creates a set of egress rules
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) CreateEgressRule(req *AuthorizeSecurityGroupEgress, async AsyncInfo) ([]EgressRule, error) {
|
||||
resp, err := exo.AsyncRequest(req, async)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.(*AuthorizeSecurityGroupEgressResponse).SecurityGroup.EgressRule, nil
|
||||
// SetPage sets the current page
|
||||
func (lsg *ListSecurityGroups) SetPage(page int) {
|
||||
lsg.Page = page
|
||||
}
|
||||
|
||||
// CreateSecurityGroupWithRules create a security group with its rules
|
||||
// Warning: it doesn't rollback in case of a failure!
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) CreateSecurityGroupWithRules(name string, ingress []AuthorizeSecurityGroupIngress, egress []AuthorizeSecurityGroupEgress, async AsyncInfo) (*SecurityGroup, error) {
|
||||
req := &CreateSecurityGroup{
|
||||
Name: name,
|
||||
}
|
||||
resp, err := exo.Request(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// SetPageSize sets the page size
|
||||
func (lsg *ListSecurityGroups) SetPageSize(pageSize int) {
|
||||
lsg.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListSecurityGroups) each(resp interface{}, callback IterateItemFunc) {
|
||||
sgs, ok := resp.(*ListSecurityGroupsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListSecurityGroupsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
sg := resp.(*SecurityGroupResponse).SecurityGroup
|
||||
reqs := make([]AsyncCommand, 0, len(ingress)+len(egress))
|
||||
// Egress rules
|
||||
for _, ereq := range egress {
|
||||
ereq.SecurityGroupID = sg.ID
|
||||
reqs = append(reqs, &ereq)
|
||||
|
||||
}
|
||||
// Ingress rules
|
||||
for _, ireq := range ingress {
|
||||
ireq.SecurityGroupID = sg.ID
|
||||
reqs = append(reqs, &ireq)
|
||||
}
|
||||
|
||||
for _, r := range reqs {
|
||||
_, err := exo.AsyncRequest(r, async)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
for i := range sgs.SecurityGroup {
|
||||
if !callback(&sgs.SecurityGroup[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
r, err := exo.Request(&ListSecurityGroups{
|
||||
ID: sg.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sg = r.(*ListSecurityGroupsResponse).SecurityGroup[0]
|
||||
return &sg, nil
|
||||
}
|
||||
|
||||
// DeleteSecurityGroup deletes a security group
|
||||
//
|
||||
// Deprecated: use the API directly
|
||||
func (exo *Client) DeleteSecurityGroup(name string) error {
|
||||
req := &DeleteSecurityGroup{
|
||||
Name: name,
|
||||
}
|
||||
return exo.BooleanRequest(req)
|
||||
}
|
||||
|
|
328
vendor/github.com/exoscale/egoscale/serialization.go
generated
vendored
Normal file
328
vendor/github.com/exoscale/egoscale/serialization.go
generated
vendored
Normal file
|
@ -0,0 +1,328 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func csQuotePlus(s string) string {
|
||||
s = strings.Replace(s, "+", "%20", -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func csEncode(s string) string {
|
||||
return csQuotePlus(url.QueryEscape(s))
|
||||
}
|
||||
|
||||
// info returns the meta info of a command
|
||||
//
|
||||
// command is not a Command so it's easier to Test
|
||||
func info(command interface{}) (*CommandInfo, error) {
|
||||
typeof := reflect.TypeOf(command)
|
||||
|
||||
// Going up the pointer chain to find the underlying struct
|
||||
for typeof.Kind() == reflect.Ptr {
|
||||
typeof = typeof.Elem()
|
||||
}
|
||||
|
||||
field, ok := typeof.FieldByName("_")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf(`missing meta ("_") field in %#v`, command)
|
||||
}
|
||||
|
||||
name, nameOk := field.Tag.Lookup("name")
|
||||
description, _ := field.Tag.Lookup("description")
|
||||
|
||||
if !nameOk {
|
||||
return nil, fmt.Errorf(`missing "name" key in the tag string of %#v`, command)
|
||||
}
|
||||
|
||||
info := &CommandInfo{
|
||||
Name: name,
|
||||
Description: description,
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// prepareValues uses a command to build a POST request
|
||||
//
|
||||
// command is not a Command so it's easier to Test
|
||||
func prepareValues(prefix string, params url.Values, command interface{}) error {
|
||||
value := reflect.ValueOf(command)
|
||||
typeof := reflect.TypeOf(command)
|
||||
|
||||
// Going up the pointer chain to find the underlying struct
|
||||
for typeof.Kind() == reflect.Ptr {
|
||||
typeof = typeof.Elem()
|
||||
value = value.Elem()
|
||||
}
|
||||
|
||||
// Checking for nil commands
|
||||
if !value.IsValid() {
|
||||
return fmt.Errorf("cannot serialize the invalid value %#v", command)
|
||||
}
|
||||
|
||||
for i := 0; i < typeof.NumField(); i++ {
|
||||
field := typeof.Field(i)
|
||||
if field.Name == "_" {
|
||||
continue
|
||||
}
|
||||
|
||||
val := value.Field(i)
|
||||
tag := field.Tag
|
||||
if json, ok := tag.Lookup("json"); ok {
|
||||
n, required := ExtractJSONTag(field.Name, json)
|
||||
name := prefix + n
|
||||
|
||||
switch val.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
v := val.Int()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatInt(v, 10))
|
||||
}
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
v := val.Uint()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatUint(v, 10))
|
||||
}
|
||||
case reflect.Float32, reflect.Float64:
|
||||
v := val.Float()
|
||||
if v == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got 0", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, strconv.FormatFloat(v, 'f', -1, 64))
|
||||
}
|
||||
case reflect.String:
|
||||
v := val.String()
|
||||
if v == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got \"\"", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, v)
|
||||
}
|
||||
case reflect.Bool:
|
||||
v := val.Bool()
|
||||
if !v {
|
||||
if required {
|
||||
params.Set(name, "false")
|
||||
}
|
||||
} else {
|
||||
params.Set(name, "true")
|
||||
}
|
||||
case reflect.Ptr:
|
||||
if val.IsNil() {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty ptr", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
switch field.Type.Elem().Kind() {
|
||||
case reflect.Bool:
|
||||
params.Set(name, strconv.FormatBool(val.Elem().Bool()))
|
||||
case reflect.Struct:
|
||||
i := val.Interface()
|
||||
s, ok := i.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s.%s (%v) is not a Stringer", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
if s != nil && s.String() == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty value", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(n, s.String())
|
||||
}
|
||||
default:
|
||||
log.Printf("[SKIP] %s.%s (%v) not supported", typeof.Name(), n, field.Type.Elem().Kind())
|
||||
}
|
||||
}
|
||||
case reflect.Slice:
|
||||
switch field.Type.Elem().Kind() {
|
||||
case reflect.Uint8:
|
||||
switch field.Type {
|
||||
case reflect.TypeOf(net.IPv4zero):
|
||||
ip := (net.IP)(val.Bytes())
|
||||
if ip == nil || ip.Equal(net.IPv4zero) {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got zero IPv4 address", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, ip.String())
|
||||
}
|
||||
case reflect.TypeOf(MAC48(0, 0, 0, 0, 0, 0)):
|
||||
mac := val.Interface().(MACAddress)
|
||||
s := mac.String()
|
||||
if s == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty MAC address", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(name, s)
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
v := val.Bytes()
|
||||
params.Set(name, base64.StdEncoding.EncodeToString(v))
|
||||
}
|
||||
}
|
||||
case reflect.String:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
elems := make([]string, 0, val.Len())
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
// XXX what if the value contains a comma? Double encode?
|
||||
s := val.Index(i).String()
|
||||
elems = append(elems, s)
|
||||
}
|
||||
params.Set(name, strings.Join(elems, ","))
|
||||
}
|
||||
default:
|
||||
switch field.Type.Elem() {
|
||||
case reflect.TypeOf(CIDR{}), reflect.TypeOf(UUID{}):
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
value := reflect.ValueOf(val.Interface())
|
||||
ss := make([]string, val.Len())
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
v := value.Index(i).Interface()
|
||||
s, ok := v.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("not a String, %T", v)
|
||||
}
|
||||
ss[i] = s.String()
|
||||
}
|
||||
params.Set(name, strings.Join(ss, ","))
|
||||
}
|
||||
default:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty slice", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
} else {
|
||||
err := prepareList(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
if val.Len() == 0 {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty map", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
err := prepareMap(name, params, val.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
case reflect.Struct:
|
||||
i := val.Interface()
|
||||
s, ok := i.(fmt.Stringer)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s.%s (%v) is not a Stringer", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
if s != nil && s.String() == "" {
|
||||
if required {
|
||||
return fmt.Errorf("%s.%s (%v) is required, got empty value", typeof.Name(), field.Name, val.Kind())
|
||||
}
|
||||
} else {
|
||||
params.Set(n, s.String())
|
||||
}
|
||||
default:
|
||||
if required {
|
||||
return fmt.Errorf("unsupported type %s.%s (%v)", typeof.Name(), n, val.Kind())
|
||||
}
|
||||
fmt.Printf("%s\n", val.Kind())
|
||||
}
|
||||
} else {
|
||||
log.Printf("[SKIP] %s.%s no json label found", typeof.Name(), field.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareList(prefix string, params url.Values, slice interface{}) error {
|
||||
value := reflect.ValueOf(slice)
|
||||
|
||||
for i := 0; i < value.Len(); i++ {
|
||||
err := prepareValues(fmt.Sprintf("%s[%d].", prefix, i), params, value.Index(i).Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func prepareMap(prefix string, params url.Values, m interface{}) error {
|
||||
value := reflect.ValueOf(m)
|
||||
|
||||
for i, key := range value.MapKeys() {
|
||||
var keyName string
|
||||
var keyValue string
|
||||
|
||||
switch key.Kind() {
|
||||
case reflect.String:
|
||||
keyName = key.String()
|
||||
default:
|
||||
return fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
}
|
||||
|
||||
val := value.MapIndex(key)
|
||||
switch val.Kind() {
|
||||
case reflect.String:
|
||||
keyValue = val.String()
|
||||
default:
|
||||
return fmt.Errorf("only map[string]string are supported (XXX)")
|
||||
}
|
||||
params.Set(fmt.Sprintf("%s[%d].%s", prefix, i, keyName), keyValue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExtractJSONTag returns the variable name or defaultName as well as if the field is required (!omitempty)
|
||||
func ExtractJSONTag(defaultName, jsonTag string) (string, bool) {
|
||||
tags := strings.Split(jsonTag, ",")
|
||||
name := tags[0]
|
||||
required := true
|
||||
for _, tag := range tags {
|
||||
if tag == "omitempty" {
|
||||
required = false
|
||||
}
|
||||
}
|
||||
|
||||
if name == "" || name == "omitempty" {
|
||||
name = defaultName
|
||||
}
|
||||
return name, required
|
||||
}
|
142
vendor/github.com/exoscale/egoscale/service_offerings.go
generated
vendored
142
vendor/github.com/exoscale/egoscale/service_offerings.go
generated
vendored
|
@ -1,61 +1,79 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ServiceOffering corresponds to the Compute Offerings
|
||||
//
|
||||
// A service offering correspond to some hardware features (CPU, RAM).
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/service_offerings.html
|
||||
type ServiceOffering struct {
|
||||
ID string `json:"id"`
|
||||
CPUNumber int `json:"cpunumber"`
|
||||
CPUSpeed int `json:"cpuspeed"`
|
||||
Created string `json:"created"`
|
||||
DefaultUse bool `json:"defaultuse,omitempty"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty"`
|
||||
DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty"`
|
||||
DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty"`
|
||||
DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty"`
|
||||
DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Domain string `json:"domain"`
|
||||
DomainID string `json:"domainid"`
|
||||
HostTags string `json:"hosttags,omitempty"`
|
||||
HypervisorSnapshotReserve int `json:"hypervisorsnapshotreserve,omitempty"`
|
||||
IsCustomized bool `json:"iscustomized,omitempty"`
|
||||
IsCustomizedIops bool `json:"iscustomizediops,omitempty"`
|
||||
IsSystem bool `json:"issystem,omitempty"`
|
||||
IsVolatile bool `json:"isvolatile,omitempty"`
|
||||
LimitCPUUse bool `json:"limitcpuuse,omitempty"`
|
||||
MaxIops int64 `json:"maxiops,omitempty"`
|
||||
Memory int `json:"memory,omitempty"`
|
||||
MinIops int64 `json:"miniops,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkRate int `json:"networkrate,omitempty"`
|
||||
OfferHA bool `json:"offerha,omitempty"`
|
||||
ServiceOfferingDetails map[string]string `json:"serviceofferingdetails,omitempty"`
|
||||
StorageType string `json:"storagetype,omitempty"`
|
||||
SystemVMType string `json:"systemvmtype,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
Authorized bool `json:"authorized,omitempty" doc:"is the account/domain authorized to use this service offering"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the number of CPU"`
|
||||
CPUSpeed int `json:"cpuspeed,omitempty" doc:"the clock rate CPU speed in Mhz"`
|
||||
Created string `json:"created,omitempty" doc:"the date this service offering was created"`
|
||||
DefaultUse bool `json:"defaultuse,omitempty" doc:"is this a default system vm offering"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty" doc:"deployment strategy used to deploy VM."`
|
||||
DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty" doc:"bytes read rate of the service offering"`
|
||||
DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty" doc:"bytes write rate of the service offering"`
|
||||
DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty" doc:"io requests read rate of the service offering"`
|
||||
DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty" doc:"io requests write rate of the service offering"`
|
||||
Displaytext string `json:"displaytext,omitempty" doc:"an alternate display text of the service offering."`
|
||||
Domain string `json:"domain,omitempty" doc:"Domain name for the offering"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain id of the service offering"`
|
||||
HostTags string `json:"hosttags,omitempty" doc:"the host tag for the service offering"`
|
||||
HypervisorSnapshotReserve int `json:"hypervisorsnapshotreserve,omitempty" doc:"Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the service offering"`
|
||||
IsCustomized bool `json:"iscustomized,omitempty" doc:"is true if the offering is customized"`
|
||||
IsCustomizedIops bool `json:"iscustomizediops,omitempty" doc:"true if disk offering uses custom iops, false otherwise"`
|
||||
IsSystem bool `json:"issystem,omitempty" doc:"is this a system vm offering"`
|
||||
IsVolatile bool `json:"isvolatile,omitempty" doc:"true if the vm needs to be volatile, i.e., on every reboot of vm from API root disk is discarded and creates a new root disk"`
|
||||
LimitCPUUse bool `json:"limitcpuuse,omitempty" doc:"restrict the CPU usage to committed service offering"`
|
||||
MaxIops int64 `json:"maxiops,omitempty" doc:"the max iops of the disk offering"`
|
||||
Memory int `json:"memory,omitempty" doc:"the memory in MB"`
|
||||
MinIops int64 `json:"miniops,omitempty" doc:"the min iops of the disk offering"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the service offering"`
|
||||
NetworkRate int `json:"networkrate,omitempty" doc:"data transfer rate in megabits per second allowed."`
|
||||
OfferHA bool `json:"offerha,omitempty" doc:"the ha support in the service offering"`
|
||||
Restricted bool `json:"restricted,omitempty" doc:"is this offering restricted"`
|
||||
ServiceOfferingDetails map[string]string `json:"serviceofferingdetails,omitempty" doc:"additional key/value details tied with this service offering"`
|
||||
StorageType string `json:"storagetype,omitempty" doc:"the storage type for this service offering"`
|
||||
SystemVMType string `json:"systemvmtype,omitempty" doc:"is this a the systemvm type for system vm offering"`
|
||||
Tags string `json:"tags,omitempty" doc:"the tags for the service offering"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListSecurityGroups request
|
||||
func (so ServiceOffering) ListRequest() (ListCommand, error) {
|
||||
// Restricted cannot be applied here because it really has three states
|
||||
req := &ListServiceOfferings{
|
||||
ID: so.ID,
|
||||
DomainID: so.DomainID,
|
||||
Name: so.Name,
|
||||
SystemVMType: so.SystemVMType,
|
||||
}
|
||||
|
||||
if so.IsSystem {
|
||||
req.IsSystem = &so.IsSystem
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// ListServiceOfferings represents a query for service offerings
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listServiceOfferings.html
|
||||
type ListServiceOfferings struct {
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
IsSystem bool `json:"issystem,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the service offering"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the service offering"`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"is this a system vm offering"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"name of the service offering"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
SystemVMType string `json:"systemvmtype,omitempty"` // consoleproxy, secondarystoragevm, or domainrouter
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListServiceOfferings) name() string {
|
||||
return "listServiceOfferings"
|
||||
}
|
||||
|
||||
func (*ListServiceOfferings) response() interface{} {
|
||||
return new(ListServiceOfferingsResponse)
|
||||
Restricted *bool `json:"restricted,omitempty" doc:"filter by the restriction flag: true to list only the restricted service offerings, false to list non-restricted service offerings, or nothing for all."`
|
||||
SystemVMType string `json:"systemvmtype,omitempty" doc:"the system VM type. Possible types are \"consoleproxy\", \"secondarystoragevm\" or \"domainrouter\"."`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the virtual machine. Pass this in if you want to see the available service offering that a virtual machine can be changed to."`
|
||||
_ bool `name:"listServiceOfferings" description:"Lists all available service offerings."`
|
||||
}
|
||||
|
||||
// ListServiceOfferingsResponse represents a list of service offerings
|
||||
|
@ -63,3 +81,31 @@ type ListServiceOfferingsResponse struct {
|
|||
Count int `json:"count"`
|
||||
ServiceOffering []ServiceOffering `json:"serviceoffering"`
|
||||
}
|
||||
|
||||
func (ListServiceOfferings) response() interface{} {
|
||||
return new(ListServiceOfferingsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (lso *ListServiceOfferings) SetPage(page int) {
|
||||
lso.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (lso *ListServiceOfferings) SetPageSize(pageSize int) {
|
||||
lso.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListServiceOfferings) each(resp interface{}, callback IterateItemFunc) {
|
||||
sos, ok := resp.(*ListServiceOfferingsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListServiceOfferingsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range sos.ServiceOffering {
|
||||
if !callback(&sos.ServiceOffering[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
165
vendor/github.com/exoscale/egoscale/snapshots.go
generated
vendored
165
vendor/github.com/exoscale/egoscale/snapshots.go
generated
vendored
|
@ -1,86 +1,93 @@
|
|||
package egoscale
|
||||
|
||||
// SnapshotState represents the Snapshot.State enum
|
||||
//
|
||||
// See: https://github.com/apache/cloudstack/blob/master/api/src/main/java/com/cloud/storage/Snapshot.java
|
||||
type SnapshotState int
|
||||
|
||||
//go:generate stringer -type SnapshotState
|
||||
const (
|
||||
// Allocated ... (TODO)
|
||||
Allocated SnapshotState = iota
|
||||
// Creating ... (TODO)
|
||||
Creating
|
||||
// CreatedOnPrimary ... (TODO)
|
||||
CreatedOnPrimary
|
||||
// BackingUp ... (TODO)
|
||||
BackingUp
|
||||
// BackedUp ... (TODO)
|
||||
BackedUp
|
||||
// Copying ... (TODO)
|
||||
Copying
|
||||
// Destroying ... (TODO)
|
||||
Destroying
|
||||
// Destroyed ... (TODO)
|
||||
Destroyed
|
||||
// Error is a state where the user can't see the snapshot while the snapshot may still exist on the storage
|
||||
Error
|
||||
)
|
||||
|
||||
// Snapshot represents a volume snapshot
|
||||
type Snapshot struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Domain string `json:"domain"`
|
||||
DomainID string `json:"domainid"`
|
||||
IntervalType string `json:"intervaltype,omitempty"` // hourly, daily, weekly, monthly, ..., none
|
||||
Name string `json:"name,omitempty"`
|
||||
PhysicalSize int64 `json:"physicalsize"`
|
||||
Project string `json:"project"`
|
||||
ProjectID string `json:"projectid"`
|
||||
Revertable bool `json:"revertable,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
SnapshotType string `json:"snapshottype,omitempty"`
|
||||
State string `json:"state"` // BackedUp, Creating, BackingUp, ...
|
||||
VolumeID string `json:"volumeid"`
|
||||
VolumeName string `json:"volumename,omitempty"`
|
||||
VolumeType string `json:"volumetype,omitempty"`
|
||||
ZoneID string `json:"zoneid"`
|
||||
Tags []ResourceTag `json:"tags"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the snapshot"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID associated with the snapshot"`
|
||||
Created string `json:"created,omitempty" doc:"the date the snapshot was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the snapshot's account"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the snapshot's account"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the snapshot"`
|
||||
IntervalType string `json:"intervaltype,omitempty" doc:"valid types are hourly, daily, weekly, monthy, template, and none."`
|
||||
Name string `json:"name,omitempty" doc:"name of the snapshot"`
|
||||
PhysicalSize int64 `json:"physicalsize,omitempty" doc:"physical size of the snapshot on image store"`
|
||||
Revertable *bool `json:"revertable,omitempty" doc:"indicates whether the underlying storage supports reverting the volume to this snapshot"`
|
||||
Size int64 `json:"size,omitempty" doc:"the size of original volume"`
|
||||
SnapshotType string `json:"snapshottype,omitempty" doc:"the type of the snapshot"`
|
||||
State SnapshotState `json:"state,omitempty" doc:"the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with snapshot"`
|
||||
VolumeID *UUID `json:"volumeid,omitempty" doc:"ID of the disk volume"`
|
||||
VolumeName string `json:"volumename,omitempty" doc:"name of the disk volume"`
|
||||
VolumeType string `json:"volumetype,omitempty" doc:"type of the disk volume"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"id of the availability zone"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*Snapshot) ResourceType() string {
|
||||
func (Snapshot) ResourceType() string {
|
||||
return "Snapshot"
|
||||
}
|
||||
|
||||
// CreateSnapshot represents a request to create a volume snapshot
|
||||
//
|
||||
// CloudStackAPI: http://cloudstack.apache.org/api/apidocs-4.10/apis/createSnapshot.html
|
||||
// CreateSnapshot (Async) creates an instant snapshot of a volume
|
||||
type CreateSnapshot struct {
|
||||
VolumeID string `json:"volumeid"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
PolicyID string `json:"policyid,omitempty"`
|
||||
QuiesceVM bool `json:"quiescevm,omitempty"`
|
||||
VolumeID *UUID `json:"volumeid" doc:"The ID of the disk volume"`
|
||||
Account string `json:"account,omitempty" doc:"The account of the snapshot. The account parameter must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume."`
|
||||
QuiesceVM *bool `json:"quiescevm,omitempty" doc:"quiesce vm if true"`
|
||||
_ bool `name:"createSnapshot" description:"Creates an instant snapshot of a volume."`
|
||||
}
|
||||
|
||||
func (*CreateSnapshot) name() string {
|
||||
return "createSnapshot"
|
||||
func (CreateSnapshot) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*CreateSnapshot) asyncResponse() interface{} {
|
||||
return new(CreateSnapshotResponse)
|
||||
}
|
||||
|
||||
// CreateSnapshotResponse represents a freshly created snapshot
|
||||
type CreateSnapshotResponse struct {
|
||||
Snapshot Snapshot `json:"snapshot"`
|
||||
func (CreateSnapshot) asyncResponse() interface{} {
|
||||
return new(Snapshot)
|
||||
}
|
||||
|
||||
// ListSnapshots lists the volume snapshots
|
||||
//
|
||||
// CloudStackAPI: http://cloudstack.apache.org/api/apidocs-4.10/apis/listSnapshots.html
|
||||
type ListSnapshots struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IntervalType string `json:"intervaltype,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"lists snapshot by snapshot ID"`
|
||||
IntervalType string `json:"intervaltype,omitempty" doc:"valid values are HOURLY, DAILY, WEEKLY, and MONTHLY."`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"lists snapshot by snapshot name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
SnapshotType string `json:"snapshottype,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
VolumeID string `json:"volumeid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListSnapshots) name() string {
|
||||
return "listSnapshots"
|
||||
}
|
||||
|
||||
func (*ListSnapshots) response() interface{} {
|
||||
return new(ListSnapshotsResponse)
|
||||
SnapshotType string `json:"snapshottype,omitempty" doc:"valid values are MANUAL or RECURRING."`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
VolumeID *UUID `json:"volumeid,omitempty" doc:"the ID of the disk volume"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"list snapshots by zone id"`
|
||||
_ bool `name:"listSnapshots" description:"Lists all available snapshots for the account."`
|
||||
}
|
||||
|
||||
// ListSnapshotsResponse represents a list of volume snapshots
|
||||
|
@ -89,32 +96,34 @@ type ListSnapshotsResponse struct {
|
|||
Snapshot []Snapshot `json:"snapshot"`
|
||||
}
|
||||
|
||||
// DeleteSnapshot represents the deletion of a volume snapshot
|
||||
//
|
||||
// CloudStackAPI: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteSnapshot.html
|
||||
func (ListSnapshots) response() interface{} {
|
||||
return new(ListSnapshotsResponse)
|
||||
}
|
||||
|
||||
// DeleteSnapshot (Async) deletes a snapshot of a disk volume
|
||||
type DeleteSnapshot struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the snapshot"`
|
||||
_ bool `name:"deleteSnapshot" description:"Deletes a snapshot of a disk volume."`
|
||||
}
|
||||
|
||||
func (*DeleteSnapshot) name() string {
|
||||
return "deleteSnapshot"
|
||||
func (DeleteSnapshot) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*DeleteSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (DeleteSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// RevertSnapshot revert a volume snapshot
|
||||
//
|
||||
// CloudStackAPI: http://cloudstack.apache.org/api/apidocs-4.10/apis/revertSnapshot.html
|
||||
// RevertSnapshot (Async) reverts a volume snapshot
|
||||
type RevertSnapshot struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the snapshot"`
|
||||
_ bool `name:"revertSnapshot" description:"revert a volume snapshot."`
|
||||
}
|
||||
|
||||
func (*RevertSnapshot) name() string {
|
||||
return "revertSnapshot"
|
||||
func (RevertSnapshot) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RevertSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (RevertSnapshot) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
|
16
vendor/github.com/exoscale/egoscale/snapshotstate_string.go
generated
vendored
Normal file
16
vendor/github.com/exoscale/egoscale/snapshotstate_string.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Code generated by "stringer -type SnapshotState"; DO NOT EDIT.
|
||||
|
||||
package egoscale
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _SnapshotState_name = "AllocatedCreatingCreatedOnPrimaryBackingUpBackedUpCopyingDestroyingDestroyedError"
|
||||
|
||||
var _SnapshotState_index = [...]uint8{0, 9, 17, 33, 42, 50, 57, 67, 76, 81}
|
||||
|
||||
func (i SnapshotState) String() string {
|
||||
if i < 0 || i >= SnapshotState(len(_SnapshotState_index)-1) {
|
||||
return "SnapshotState(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _SnapshotState_name[_SnapshotState_index[i]:_SnapshotState_index[i+1]]
|
||||
}
|
138
vendor/github.com/exoscale/egoscale/ssh_keypairs.go
generated
vendored
Normal file
138
vendor/github.com/exoscale/egoscale/ssh_keypairs.go
generated
vendored
Normal file
|
@ -0,0 +1,138 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// SSHKeyPair represents an SSH key pair
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html#creating-the-ssh-keypair
|
||||
type SSHKeyPair struct {
|
||||
Fingerprint string `json:"fingerprint,omitempty" doc:"Fingerprint of the public key"`
|
||||
Name string `json:"name,omitempty" doc:"Name of the keypair"`
|
||||
PrivateKey string `json:"privatekey,omitempty" doc:"Private key"`
|
||||
}
|
||||
|
||||
// Delete removes the given SSH key, by Name
|
||||
func (ssh SSHKeyPair) Delete(ctx context.Context, client *Client) error {
|
||||
if ssh.Name == "" {
|
||||
return fmt.Errorf("an SSH Key Pair may only be deleted using Name")
|
||||
}
|
||||
|
||||
return client.BooleanRequestWithContext(ctx, &DeleteSSHKeyPair{
|
||||
Name: ssh.Name,
|
||||
})
|
||||
}
|
||||
|
||||
// ListRequest builds the ListSSHKeyPairs request
|
||||
func (ssh SSHKeyPair) ListRequest() (ListCommand, error) {
|
||||
req := &ListSSHKeyPairs{
|
||||
Fingerprint: ssh.Fingerprint,
|
||||
Name: ssh.Name,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// CreateSSHKeyPair represents a new keypair to be created
|
||||
type CreateSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the ssh key. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"createSSHKeyPair" description:"Create a new keypair and returns the private key"`
|
||||
}
|
||||
|
||||
func (CreateSSHKeyPair) response() interface{} {
|
||||
return new(SSHKeyPair)
|
||||
}
|
||||
|
||||
// DeleteSSHKeyPair represents a new keypair to be created
|
||||
type DeleteSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the keypair. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID associated with the keypair"`
|
||||
_ bool `name:"deleteSSHKeyPair" description:"Deletes a keypair by name"`
|
||||
}
|
||||
|
||||
func (DeleteSSHKeyPair) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// RegisterSSHKeyPair represents a new registration of a public key in a keypair
|
||||
type RegisterSSHKeyPair struct {
|
||||
Name string `json:"name" doc:"Name of the keypair"`
|
||||
PublicKey string `json:"publickey" doc:"Public key material of the keypair"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the ssh key. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"registerSSHKeyPair" description:"Register a public key in a keypair under a certain name"`
|
||||
}
|
||||
|
||||
func (RegisterSSHKeyPair) response() interface{} {
|
||||
return new(SSHKeyPair)
|
||||
}
|
||||
|
||||
// ListSSHKeyPairs represents a query for a list of SSH KeyPairs
|
||||
type ListSSHKeyPairs struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Fingerprint string `json:"fingerprint,omitempty" doc:"A public key fingerprint to look for"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"A key pair name to look for"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
_ bool `name:"listSSHKeyPairs" description:"List registered keypairs"`
|
||||
}
|
||||
|
||||
// ListSSHKeyPairsResponse represents a list of SSH key pairs
|
||||
type ListSSHKeyPairsResponse struct {
|
||||
Count int `json:"count"`
|
||||
SSHKeyPair []SSHKeyPair `json:"sshkeypair"`
|
||||
}
|
||||
|
||||
func (ListSSHKeyPairs) response() interface{} {
|
||||
return new(ListSSHKeyPairsResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListSSHKeyPairs) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListSSHKeyPairs) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListSSHKeyPairs) each(resp interface{}, callback IterateItemFunc) {
|
||||
sshs, ok := resp.(*ListSSHKeyPairsResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListSSHKeyPairsResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range sshs.SSHKeyPair {
|
||||
if !callback(&sshs.SSHKeyPair[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ResetSSHKeyForVirtualMachine (Async) represents a change for the key pairs
|
||||
type ResetSSHKeyForVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
KeyPair string `json:"keypair" doc:"name of the ssh key pair used to login to the virtual machine"`
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the ssh key. Must be used with domainId."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used."`
|
||||
_ bool `name:"resetSSHKeyForVirtualMachine" description:"Resets the SSH Key for virtual machine. The virtual machine must be in a \"Stopped\" state."`
|
||||
}
|
||||
|
||||
func (ResetSSHKeyForVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (ResetSSHKeyForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
98
vendor/github.com/exoscale/egoscale/tags.go
generated
vendored
98
vendor/github.com/exoscale/egoscale/tags.go
generated
vendored
|
@ -1,89 +1,67 @@
|
|||
package egoscale
|
||||
|
||||
// Taggable represents a resource which can have tags attached
|
||||
//
|
||||
// This is a helper to fill the resourcetype of a CreateTags call
|
||||
type Taggable interface {
|
||||
// CloudStack resource type of the Taggable type
|
||||
ResourceType() string
|
||||
}
|
||||
|
||||
// ResourceTag is a tag associated with a resource
|
||||
//
|
||||
// http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.9/management.html
|
||||
type ResourceTag struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
Customer string `json:"customer,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Key string `json:"key"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ResourceID string `json:"resourceid,omitempty"`
|
||||
ResourceType string `json:"resourcetype,omitempty"`
|
||||
Value string `json:"value"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the tag"`
|
||||
Customer string `json:"customer,omitempty" doc:"customer associated with the tag"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain associated with the tag"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the tag"`
|
||||
Key string `json:"key,omitempty" doc:"tag key name"`
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"id of the resource"`
|
||||
ResourceType string `json:"resourcetype,omitempty" doc:"resource type"`
|
||||
Value string `json:"value,omitempty" doc:"tag value"`
|
||||
}
|
||||
|
||||
// CreateTags (Async) creates resource tag(s)
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/createTags.html
|
||||
type CreateTags struct {
|
||||
ResourceIDs []string `json:"resourceids"`
|
||||
ResourceType string `json:"resourcetype"`
|
||||
Tags []ResourceTag `json:"tags"`
|
||||
Customer string `json:"customer,omitempty"`
|
||||
ResourceIDs []UUID `json:"resourceids" doc:"list of resources to create the tags for"`
|
||||
ResourceType string `json:"resourcetype" doc:"type of the resource"`
|
||||
Tags []ResourceTag `json:"tags" doc:"Map of tags (key/value pairs)"`
|
||||
Customer string `json:"customer,omitempty" doc:"identifies client specific tag. When the value is not null, the tag can't be used by cloudStack code internally"`
|
||||
_ bool `name:"createTags" description:"Creates resource tag(s)"`
|
||||
}
|
||||
|
||||
func (*CreateTags) name() string {
|
||||
return "createTags"
|
||||
func (CreateTags) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*CreateTags) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (CreateTags) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// DeleteTags (Async) deletes the resource tag(s)
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteTags.html
|
||||
type DeleteTags struct {
|
||||
ResourceIDs []string `json:"resourceids"`
|
||||
ResourceType string `json:"resourcetype"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
ResourceIDs []UUID `json:"resourceids" doc:"Delete tags for resource id(s)"`
|
||||
ResourceType string `json:"resourcetype" doc:"Delete tag by resource type"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"Delete tags matching key/value pairs"`
|
||||
_ bool `name:"deleteTags" description:"Deleting resource tag(s)"`
|
||||
}
|
||||
|
||||
func (*DeleteTags) name() string {
|
||||
return "deleteTags"
|
||||
func (DeleteTags) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*DeleteTags) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (DeleteTags) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListTags list resource tag(s)
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listTags.html
|
||||
type ListTags struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
Customer string `json:"customer,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Key string `json:"key,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
Customer string `json:"customer,omitempty" doc:"list by customer name"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Key string `json:"key,omitempty" doc:"list by key"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ResourceID string `json:"resourceid,omitempty"`
|
||||
ResourceType string `json:"resourcetype,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListTags) name() string {
|
||||
return "listTags"
|
||||
}
|
||||
|
||||
func (*ListTags) response() interface{} {
|
||||
return new(ListTagsResponse)
|
||||
ResourceID *UUID `json:"resourceid,omitempty" doc:"list by resource id"`
|
||||
ResourceType string `json:"resourcetype,omitempty" doc:"list by resource type"`
|
||||
Value string `json:"value,omitempty" doc:"list by value"`
|
||||
_ bool `name:"listTags" description:"List resource tag(s)"`
|
||||
}
|
||||
|
||||
// ListTagsResponse represents a list of resource tags
|
||||
|
@ -91,3 +69,7 @@ type ListTagsResponse struct {
|
|||
Count int `json:"count"`
|
||||
Tag []ResourceTag `json:"tag"`
|
||||
}
|
||||
|
||||
func (ListTags) response() interface{} {
|
||||
return new(ListTagsResponse)
|
||||
}
|
||||
|
|
315
vendor/github.com/exoscale/egoscale/templates.go
generated
vendored
315
vendor/github.com/exoscale/egoscale/templates.go
generated
vendored
|
@ -1,72 +1,94 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Template represents a machine to be deployed
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/latest/templates.html
|
||||
type Template struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
AccountID string `json:"accountid,omitempty"`
|
||||
Bootable bool `json:"bootable,omitempty"`
|
||||
Checksum string `json:"checksum,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
CrossZones bool `json:"crossZones,omitempty"`
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Format string `json:"format,omitempty"`
|
||||
HostID string `json:"hostid,omitempty"`
|
||||
HostName string `json:"hostname,omitempty"`
|
||||
Hypervisor string `json:"hypervisor,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty"`
|
||||
IsExtractable bool `json:"isextractable,omitempty"`
|
||||
IsFeatured bool `json:"isfeatured,omitempty"`
|
||||
IsPublic bool `json:"ispublic,omitempty"`
|
||||
IsReady bool `json:"isready,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
OsTypeID string `json:"ostypeid,omitempty"`
|
||||
OsTypeName string `json:"ostypename,omitempty"`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Removed string `json:"removed,omitempty"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
SourceTemplateID string `json:"sourcetemplateid,omitempty"`
|
||||
SSHKeyEnabled bool `json:"sshkeyenabled,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Zoneid string `json:"zoneid,omitempty"`
|
||||
Zonename string `json:"zonename,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account name to which the template belongs"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account id to which the template belongs"`
|
||||
Bootable bool `json:"bootable,omitempty" doc:"true if the ISO is bootable, false otherwise"`
|
||||
Checksum string `json:"checksum,omitempty" doc:"checksum of the template"`
|
||||
Created string `json:"created,omitempty" doc:"the date this template was created"`
|
||||
CrossZones bool `json:"crossZones,omitempty" doc:"true if the template is managed across all Zones, false otherwise"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"additional key/value details tied with template"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the template display text"`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the domain to which the template belongs"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain to which the template belongs"`
|
||||
Format string `json:"format,omitempty" doc:"the format of the template."`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the ID of the secondary storage host for the template"`
|
||||
HostName string `json:"hostname,omitempty" doc:"the name of the secondary storage host for the template"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which the template runs"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the template ID"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsExtractable bool `json:"isextractable,omitempty" doc:"true if the template is extractable, false otherwise"`
|
||||
IsFeatured bool `json:"isfeatured,omitempty" doc:"true if this template is a featured template, false otherwise"`
|
||||
IsPublic bool `json:"ispublic,omitempty" doc:"true if this template is a public template, false otherwise"`
|
||||
IsReady bool `json:"isready,omitempty" doc:"true if the template is ready to be deployed from, false otherwise."`
|
||||
Name string `json:"name,omitempty" doc:"the template name"`
|
||||
OsTypeID *UUID `json:"ostypeid,omitempty" doc:"the ID of the OS type for this template."`
|
||||
OsTypeName string `json:"ostypename,omitempty" doc:"the name of the OS type for this template."`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty" doc:"true if the reset password feature is enabled, false otherwise"`
|
||||
Removed string `json:"removed,omitempty" doc:"the date this template was removed"`
|
||||
Size int64 `json:"size,omitempty" doc:"the size of the template"`
|
||||
SourceTemplateID *UUID `json:"sourcetemplateid,omitempty" doc:"the template ID of the parent template if present"`
|
||||
SSHKeyEnabled bool `json:"sshkeyenabled,omitempty" doc:"true if template is sshkey enabled, false otherwise"`
|
||||
Status string `json:"status,omitempty" doc:"the status of the template"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with tempate"`
|
||||
TemplateDirectory string `json:"templatedirectory,omitempty" doc:"Template directory"`
|
||||
TemplateTag string `json:"templatetag,omitempty" doc:"the tag of this template"`
|
||||
TemplateType string `json:"templatetype,omitempty" doc:"the type of the template"`
|
||||
URL string `json:"url,omitempty" doc:"Original URL of the template where it was downloaded"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the zone for this template"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the zone for this template"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*Template) ResourceType() string {
|
||||
func (Template) ResourceType() string {
|
||||
return "Template"
|
||||
}
|
||||
|
||||
// ListRequest builds the ListTemplates request
|
||||
func (temp Template) ListRequest() (ListCommand, error) {
|
||||
req := &ListTemplates{
|
||||
Name: temp.Name,
|
||||
Account: temp.Account,
|
||||
DomainID: temp.DomainID,
|
||||
ID: temp.ID,
|
||||
ZoneID: temp.ZoneID,
|
||||
Hypervisor: temp.Hypervisor,
|
||||
//TODO Tags
|
||||
}
|
||||
if temp.IsFeatured {
|
||||
req.TemplateFilter = "featured"
|
||||
}
|
||||
if temp.Removed != "" {
|
||||
*req.ShowRemoved = true
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// ListTemplates represents a template query filter
|
||||
type ListTemplates struct {
|
||||
TemplateFilter string `json:"templatefilter"` // featured, etc.
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Hypervisor string `json:"hypervisor,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
TemplateFilter string `json:"templatefilter" doc:"possible values are \"featured\", \"self\", \"selfexecutable\",\"sharedexecutable\",\"executable\", and \"community\". * featured : templates that have been marked as featured and public. * self : templates that have been registered or created by the calling user. * selfexecutable : same as self, but only returns templates that can be used to deploy a new VM. * sharedexecutable : templates ready to be deployed that have been granted to the calling user by another user. * executable : templates that are owned by the calling user, or public templates, that can be used to deploy a VM. * community : templates that have been marked as public but not featured. * all : all templates (only usable by admins)."`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor for which to restrict the search"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the template ID"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"the template name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ShowRemoved bool `json:"showremoved,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListTemplates) name() string {
|
||||
return "listTemplates"
|
||||
}
|
||||
|
||||
func (*ListTemplates) response() interface{} {
|
||||
return new(ListTemplatesResponse)
|
||||
ShowRemoved *bool `json:"showremoved,omitempty" doc:"show removed templates as well"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"list templates by zoneId"`
|
||||
_ bool `name:"listTemplates" description:"List all public, private, and privileged templates."`
|
||||
}
|
||||
|
||||
// ListTemplatesResponse represents a list of templates
|
||||
|
@ -74,3 +96,186 @@ type ListTemplatesResponse struct {
|
|||
Count int `json:"count"`
|
||||
Template []Template `json:"template"`
|
||||
}
|
||||
|
||||
func (ListTemplates) response() interface{} {
|
||||
return new(ListTemplatesResponse)
|
||||
}
|
||||
|
||||
func (ListTemplates) each(resp interface{}, callback IterateItemFunc) {
|
||||
temps, ok := resp.(*ListTemplatesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListTemplatesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range temps.Template {
|
||||
if !callback(&temps.Template[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListTemplates) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListTemplates) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
// CreateTemplate (Async) represents a template creation
|
||||
type CreateTemplate struct {
|
||||
Bits int `json:"bits,omitempty" doc:"32 or 64 bit"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Template details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext" doc:"the display text of the template. This is usually used for display purposes."`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsFeatured *bool `json:"isfeatured,omitempty" doc:"true if this template is a featured template, false otherwise"`
|
||||
IsPublic *bool `json:"ispublic,omitempty" doc:"true if this template is a public template, false otherwise"`
|
||||
Name string `json:"name" doc:"the name of the template"`
|
||||
OsTypeID *UUID `json:"ostypeid" doc:"the ID of the OS Type that best represents the OS of this template."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the template supports the password reset feature; default is false"`
|
||||
RequiresHVM *bool `json:"requireshvm,omitempty" doc:"true if the template requres HVM, false otherwise"`
|
||||
SnapshotID *UUID `json:"snapshotid,omitempty" doc:"the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in"`
|
||||
TemplateTag string `json:"templatetag,omitempty" doc:"the tag for this template."`
|
||||
URL string `json:"url,omitempty" doc:"Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal"`
|
||||
VolumeID *UUID `json:"volumeid,omitempty" doc:"the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in"`
|
||||
_ bool `name:"createTemplate" description:"Creates a template of a virtual machine. The virtual machine must be in a STOPPED state. A template created from this command is automatically designated as a private template visible to the account that created it."`
|
||||
}
|
||||
|
||||
func (CreateTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CreateTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// CopyTemplate (Async) represents a template copy
|
||||
type CopyTemplate struct {
|
||||
DestZoneID *UUID `json:"destzoneid" doc:"ID of the zone the template is being copied to."`
|
||||
ID *UUID `json:"id" doc:"Template ID."`
|
||||
SourceZoneID *UUID `json:"sourcezoneid,omitempty" doc:"ID of the zone the template is currently hosted on. If not specified and template is cross-zone, then we will sync this template to region wide image store."`
|
||||
_ bool `name:"copyTemplate" description:"Copies a template from one zone to another."`
|
||||
}
|
||||
|
||||
func (CopyTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (CopyTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// UpdateTemplate represents a template change
|
||||
type UpdateTemplate struct {
|
||||
Bootable *bool `json:"bootable,omitempty" doc:"true if image is bootable, false otherwise"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the image"`
|
||||
Format string `json:"format,omitempty" doc:"the format for the image"`
|
||||
ID *UUID `json:"id" doc:"the ID of the image file"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template/ISO contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsRouting *bool `json:"isrouting,omitempty" doc:"true if the template type is routing i.e., if template is used to deploy router"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the image file"`
|
||||
OsTypeID *UUID `json:"ostypeid,omitempty" doc:"the ID of the OS type that best represents the OS of this image."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the image supports the password reset feature; default is false"`
|
||||
SortKey int `json:"sortkey,omitempty" doc:"sort key of the template, integer"`
|
||||
_ bool `name:"updateTemplate" description:"Updates attributes of a template."`
|
||||
}
|
||||
|
||||
func (UpdateTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (UpdateTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// DeleteTemplate (Async) represents the deletion of a template
|
||||
type DeleteTemplate struct {
|
||||
ID *UUID `json:"id" doc:"the ID of the template"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of zone of the template"`
|
||||
_ bool `name:"deleteTemplate" description:"Deletes a template from the system. All virtual machines using the deleted template will not be affected."`
|
||||
}
|
||||
|
||||
func (DeleteTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (DeleteTemplate) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// PrepareTemplate represents a template preparation
|
||||
type PrepareTemplate struct {
|
||||
TemplateID *UUID `json:"templateid" doc:"template ID of the template to be prepared in primary storage(s)."`
|
||||
ZoneID *UUID `json:"zoneid" doc:"zone ID of the template to be prepared in primary storage(s)."`
|
||||
_ bool `name:"prepareTemplate" description:"load template into primary storage"`
|
||||
}
|
||||
|
||||
func (PrepareTemplate) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (PrepareTemplate) asyncResponse() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// RegisterTemplate represents a template registration
|
||||
type RegisterTemplate struct {
|
||||
Account string `json:"account,omitempty" doc:"an optional accountName. Must be used with domainId."`
|
||||
Bits int `json:"bits,omitempty" doc:"32 or 64 bits support. 64 by default"`
|
||||
Checksum string `json:"checksum,omitempty" doc:"the MD5 checksum value of this template"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Template details in key/value pairs."`
|
||||
DisplayText string `json:"displaytext" doc:"the display text of the template. This is usually used for display purposes."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId. If the account parameter is used, domainId must also be used."`
|
||||
Format string `json:"format" doc:"the format for the template. Possible values include QCOW2, RAW, and VHD."`
|
||||
Hypervisor string `json:"hypervisor" doc:"the target hypervisor for the template"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if template contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
IsExtractable *bool `json:"isextractable,omitempty" doc:"true if the template or its derivatives are extractable; default is false"`
|
||||
IsFeatured *bool `json:"isfeatured,omitempty" doc:"true if this template is a featured template, false otherwise"`
|
||||
IsPublic *bool `json:"ispublic,omitempty" doc:"true if the template is available to all accounts; default is true"`
|
||||
IsRouting *bool `json:"isrouting,omitempty" doc:"true if the template type is routing i.e., if template is used to deploy router"`
|
||||
IsSystem *bool `json:"issystem,omitempty" doc:"true if the template type is system i.e., if template is used to deploy system VM"`
|
||||
Name string `json:"name" doc:"the name of the template"`
|
||||
OsTypeID *UUID `json:"ostypeid" doc:"the ID of the OS Type that best represents the OS of this template."`
|
||||
PasswordEnabled *bool `json:"passwordenabled,omitempty" doc:"true if the template supports the password reset feature; default is false"`
|
||||
RequiresHVM *bool `json:"requireshvm,omitempty" doc:"true if this template requires HVM"`
|
||||
SSHKeyEnabled *bool `json:"sshkeyenabled,omitempty" doc:"true if the template supports the sshkey upload feature; default is false"`
|
||||
TemplateTag string `json:"templatetag,omitempty" doc:"the tag for this template."`
|
||||
URL string `json:"url" doc:"the URL of where the template is hosted. Possible URL include http:// and https://"`
|
||||
ZoneID *UUID `json:"zoneid" doc:"the ID of the zone the template is to be hosted on"`
|
||||
_ bool `name:"registerTemplate" description:"Registers an existing template into the CloudStack cloud."`
|
||||
}
|
||||
|
||||
func (RegisterTemplate) response() interface{} {
|
||||
return new(Template)
|
||||
}
|
||||
|
||||
// OSCategory represents an OS category
|
||||
type OSCategory struct {
|
||||
ID string `json:"id,omitempty" doc:"the ID of the OS category"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the OS category"`
|
||||
}
|
||||
|
||||
// ListOSCategories lists the OS categories
|
||||
type ListOSCategories struct {
|
||||
ID string `json:"id,omitempty" doc:"list Os category by id"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"list os category by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
_ bool `name:"listOsCategories" description:"Lists all supported OS categories for this cloud."`
|
||||
}
|
||||
|
||||
// ListOSCategoriesResponse represents a list of OS categories
|
||||
type ListOSCategoriesResponse struct {
|
||||
Count int `json:"count"`
|
||||
OSCategory []OSCategory `json:"oscategory"`
|
||||
}
|
||||
|
||||
func (ListOSCategories) response() interface{} {
|
||||
return new(ListOSCategoriesResponse)
|
||||
}
|
||||
|
|
208
vendor/github.com/exoscale/egoscale/topology.go
generated
vendored
208
vendor/github.com/exoscale/egoscale/topology.go
generated
vendored
|
@ -1,208 +0,0 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetSecurityGroups returns all security groups
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetSecurityGroups() (map[string]SecurityGroup, error) {
|
||||
var sgs map[string]SecurityGroup
|
||||
resp, err := exo.Request(&ListSecurityGroups{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sgs = make(map[string]SecurityGroup)
|
||||
for _, sg := range resp.(*ListSecurityGroupsResponse).SecurityGroup {
|
||||
sgs[sg.Name] = sg
|
||||
}
|
||||
return sgs, nil
|
||||
}
|
||||
|
||||
// GetSecurityGroupID returns security group by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetSecurityGroupID(name string) (string, error) {
|
||||
resp, err := exo.Request(&ListSecurityGroups{SecurityGroupName: name})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, sg := range resp.(*ListSecurityGroupsResponse).SecurityGroup {
|
||||
if sg.Name == name {
|
||||
return sg.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// GetAllZones returns all the zone id by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetAllZones() (map[string]string, error) {
|
||||
var zones map[string]string
|
||||
resp, err := exo.Request(&ListZones{})
|
||||
if err != nil {
|
||||
return zones, err
|
||||
}
|
||||
|
||||
zones = make(map[string]string)
|
||||
for _, zone := range resp.(*ListZonesResponse).Zone {
|
||||
zones[strings.ToLower(zone.Name)] = zone.ID
|
||||
}
|
||||
return zones, nil
|
||||
}
|
||||
|
||||
// GetProfiles returns a mapping of the service offerings by name
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetProfiles() (map[string]string, error) {
|
||||
profiles := make(map[string]string)
|
||||
resp, err := exo.Request(&ListServiceOfferings{})
|
||||
if err != nil {
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
for _, offering := range resp.(*ListServiceOfferingsResponse).ServiceOffering {
|
||||
profiles[strings.ToLower(offering.Name)] = offering.ID
|
||||
}
|
||||
|
||||
return profiles, nil
|
||||
}
|
||||
|
||||
// GetKeypairs returns the list of SSH keyPairs
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetKeypairs() ([]SSHKeyPair, error) {
|
||||
var keypairs []SSHKeyPair
|
||||
|
||||
resp, err := exo.Request(&ListSSHKeyPairs{})
|
||||
if err != nil {
|
||||
return keypairs, err
|
||||
}
|
||||
|
||||
r := resp.(*ListSSHKeyPairsResponse)
|
||||
keypairs = make([]SSHKeyPair, r.Count)
|
||||
for i, keypair := range r.SSHKeyPair {
|
||||
keypairs[i] = keypair
|
||||
}
|
||||
return keypairs, nil
|
||||
}
|
||||
|
||||
// GetAffinityGroups returns a mapping of the (anti-)affinity groups
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetAffinityGroups() (map[string]string, error) {
|
||||
var affinitygroups map[string]string
|
||||
|
||||
resp, err := exo.Request(&ListAffinityGroups{})
|
||||
if err != nil {
|
||||
return affinitygroups, err
|
||||
}
|
||||
|
||||
affinitygroups = make(map[string]string)
|
||||
for _, affinitygroup := range resp.(*ListAffinityGroupsResponse).AffinityGroup {
|
||||
affinitygroups[affinitygroup.Name] = affinitygroup.ID
|
||||
}
|
||||
return affinitygroups, nil
|
||||
}
|
||||
|
||||
// GetImages list the available featured images and group them by name, then size.
|
||||
//
|
||||
// Deprecated: do it yourself
|
||||
func (exo *Client) GetImages() (map[string]map[int64]string, error) {
|
||||
var images map[string]map[int64]string
|
||||
images = make(map[string]map[int64]string)
|
||||
re := regexp.MustCompile(`^Linux (?P<name>.+?) (?P<version>[0-9.]+)\b`)
|
||||
|
||||
resp, err := exo.Request(&ListTemplates{
|
||||
TemplateFilter: "featured",
|
||||
ZoneID: "1", // XXX: Hack to list only CH-GVA
|
||||
})
|
||||
if err != nil {
|
||||
return images, err
|
||||
}
|
||||
|
||||
for _, template := range resp.(*ListTemplatesResponse).Template {
|
||||
size := int64(template.Size >> 30) // B to GiB
|
||||
|
||||
fullname := strings.ToLower(template.Name)
|
||||
|
||||
if _, present := images[fullname]; !present {
|
||||
images[fullname] = make(map[int64]string)
|
||||
}
|
||||
images[fullname][size] = template.ID
|
||||
|
||||
submatch := re.FindStringSubmatch(template.Name)
|
||||
if len(submatch) > 0 {
|
||||
name := strings.Replace(strings.ToLower(submatch[1]), " ", "-", -1)
|
||||
version := submatch[2]
|
||||
image := fmt.Sprintf("%s-%s", name, version)
|
||||
|
||||
if _, present := images[image]; !present {
|
||||
images[image] = make(map[int64]string)
|
||||
}
|
||||
images[image][size] = template.ID
|
||||
}
|
||||
}
|
||||
return images, nil
|
||||
}
|
||||
|
||||
// GetTopology returns an big, yet incomplete view of the world
|
||||
//
|
||||
// Deprecated: will go away in the future
|
||||
func (exo *Client) GetTopology() (*Topology, error) {
|
||||
zones, err := exo.GetAllZones()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
images, err := exo.GetImages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
securityGroups, err := exo.GetSecurityGroups()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groups := make(map[string]string)
|
||||
for k, v := range securityGroups {
|
||||
groups[k] = v.ID
|
||||
}
|
||||
|
||||
keypairs, err := exo.GetKeypairs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
/* Convert the ssh keypair to contain just the name */
|
||||
keynames := make([]string, len(keypairs))
|
||||
for i, k := range keypairs {
|
||||
keynames[i] = k.Name
|
||||
}
|
||||
|
||||
affinitygroups, err := exo.GetAffinityGroups()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
profiles, err := exo.GetProfiles()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
topo := &Topology{
|
||||
Zones: zones,
|
||||
Images: images,
|
||||
Keypairs: keynames,
|
||||
Profiles: profiles,
|
||||
AffinityGroups: affinitygroups,
|
||||
SecurityGroups: groups,
|
||||
}
|
||||
|
||||
return topo, nil
|
||||
}
|
23
vendor/github.com/exoscale/egoscale/types.go
generated
vendored
23
vendor/github.com/exoscale/egoscale/types.go
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Client represents the CloudStack API client
|
||||
type Client struct {
|
||||
client *http.Client
|
||||
endpoint string
|
||||
apiKey string
|
||||
apiSecret string
|
||||
}
|
||||
|
||||
// Topology represents a view of the servers
|
||||
type Topology struct {
|
||||
Zones map[string]string
|
||||
Images map[string]map[int64]string
|
||||
Profiles map[string]string
|
||||
Keypairs []string
|
||||
SecurityGroups map[string]string
|
||||
AffinityGroups map[string]string
|
||||
}
|
132
vendor/github.com/exoscale/egoscale/users.go
generated
vendored
132
vendor/github.com/exoscale/egoscale/users.go
generated
vendored
|
@ -2,42 +2,108 @@ package egoscale
|
|||
|
||||
// User represents a User
|
||||
type User struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
AccountID string `json:"accountid,omitempty"`
|
||||
AccountType string `json:"accounttype,omitempty"`
|
||||
APIKey string `json:"apikey,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
FirstName string `json:"firstname,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsCallerChildDomain bool `json:"iscallerchilddomain,omitempty"`
|
||||
IsDefault bool `json:"isdefault,omitempty"`
|
||||
LastName string `json:"lastname,omitempty"`
|
||||
SecretKey string `json:"secretkey,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
UserName string `json:"username,omitempty"`
|
||||
APIKey string `json:"apikey,omitempty" doc:"the api key of the user"`
|
||||
Account string `json:"account,omitempty" doc:"the account name of the user"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID of the user"`
|
||||
AccountType int16 `json:"accounttype,omitempty" doc:"the account type of the user"`
|
||||
Created string `json:"created,omitempty" doc:"the date and time the user account was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the user"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the user"`
|
||||
Email string `json:"email,omitempty" doc:"the user email address"`
|
||||
FirstName string `json:"firstname,omitempty" doc:"the user firstname"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the user ID"`
|
||||
IsCallerChildDomain bool `json:"iscallerchilddomain,omitempty" doc:"the boolean value representing if the updating target is in caller's child domain"`
|
||||
IsDefault bool `json:"isdefault,omitempty" doc:"true if user is default, false otherwise"`
|
||||
LastName string `json:"lastname,omitempty" doc:"the user lastname"`
|
||||
RoleID *UUID `json:"roleid,omitempty" doc:"the ID of the role"`
|
||||
RoleName string `json:"rolename,omitempty" doc:"the name of the role"`
|
||||
RoleType string `json:"roletype,omitempty" doc:"the type of the role"`
|
||||
SecretKey string `json:"secretkey,omitempty" doc:"the secret key of the user"`
|
||||
State string `json:"state,omitempty" doc:"the user state"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"the timezone user was created in"`
|
||||
UserName string `json:"username,omitempty" doc:"the user name"`
|
||||
}
|
||||
|
||||
// RegisterUserKeys registers a new set of key of the given user
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/registerUserKeys.html
|
||||
type RegisterUserKeys struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func (*RegisterUserKeys) name() string {
|
||||
return "registerUserKeys"
|
||||
}
|
||||
|
||||
func (*RegisterUserKeys) response() interface{} {
|
||||
return new(RegisterUserKeysResponse)
|
||||
}
|
||||
|
||||
// RegisterUserKeysResponse represents a new set of UserKeys
|
||||
//
|
||||
// NB: only the APIKey and SecretKey will be filled
|
||||
type RegisterUserKeysResponse struct {
|
||||
UserKeys User `json:"userkeys"`
|
||||
type RegisterUserKeys struct {
|
||||
ID *UUID `json:"id" doc:"User id"`
|
||||
_ bool `name:"registerUserKeys" description:"This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user"`
|
||||
}
|
||||
|
||||
func (RegisterUserKeys) response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
|
||||
// CreateUser represents the creation of a User
|
||||
type CreateUser struct {
|
||||
Account string `json:"account" doc:"Creates the user under the specified account. If no account is specified, the username will be used as the account name."`
|
||||
Email string `json:"email" doc:"email"`
|
||||
FirstName string `json:"firstname" doc:"firstname"`
|
||||
LastName string `json:"lastname" doc:"lastname"`
|
||||
Password string `json:"password" doc:"Clear text password (Default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter See Docs section."`
|
||||
UserName string `json:"username" doc:"Unique username."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"Creates the user under the specified domain. Has to be accompanied with the account parameter"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format."`
|
||||
UserID *UUID `json:"userid,omitempty" doc:"User UUID, required for adding account from external provisioning system"`
|
||||
_ bool `name:"createUser" description:"Creates a user for an account that already exists"`
|
||||
}
|
||||
|
||||
func (CreateUser) response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
|
||||
// UpdateUser represents the modification of a User
|
||||
type UpdateUser struct {
|
||||
ID *UUID `json:"id" doc:"User uuid"`
|
||||
Email string `json:"email,omitempty" doc:"email"`
|
||||
FirstName string `json:"firstname,omitempty" doc:"first name"`
|
||||
LastName string `json:"lastname,omitempty" doc:"last name"`
|
||||
Password string `json:"password,omitempty" doc:"Clear text password (default hashed to SHA256SALT). If you wish to use any other hashing algorithm, you would need to write a custom authentication adapter"`
|
||||
Timezone string `json:"timezone,omitempty" doc:"Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format."`
|
||||
UserAPIKey string `json:"userapikey,omitempty" doc:"The API key for the user. Must be specified with userSecretKey"`
|
||||
UserName string `json:"username,omitempty" doc:"Unique username"`
|
||||
UserSecretKey string `json:"usersecretkey,omitempty" doc:"The secret key for the user. Must be specified with userApiKey"`
|
||||
_ bool `name:"updateUser" description:"Updates a user account"`
|
||||
}
|
||||
|
||||
func (UpdateUser) response() interface{} {
|
||||
return new(User)
|
||||
}
|
||||
|
||||
// ListUsers represents the search for Users
|
||||
type ListUsers struct {
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AccountType int64 `json:"accounttype,omitempty" doc:"List users by account type. Valid types include admin, domain-admin, read-only-admin, or user."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"List user by ID."`
|
||||
IsRecursive bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty" doc:"List users by state of the user account."`
|
||||
Username string `json:"username,omitempty" doc:"List user by the username"`
|
||||
_ bool `name:"listUsers" description:"Lists user accounts"`
|
||||
}
|
||||
|
||||
// ListUsersResponse represents a list of users
|
||||
type ListUsersResponse struct {
|
||||
Count int `json:"count"`
|
||||
User []User `json:"user"`
|
||||
}
|
||||
|
||||
func (ListUsers) response() interface{} {
|
||||
return new(ListUsersResponse)
|
||||
}
|
||||
|
||||
// DeleteUser deletes a user for an account
|
||||
type DeleteUser struct {
|
||||
ID *UUID `json:"id" doc:"id of the user to be deleted"`
|
||||
_ bool `name:"deleteUser" description:"Deletes a user for an account"`
|
||||
}
|
||||
|
||||
func (DeleteUser) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
|
55
vendor/github.com/exoscale/egoscale/uuid.go
generated
vendored
Normal file
55
vendor/github.com/exoscale/egoscale/uuid.go
generated
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
package egoscale
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/satori/go.uuid"
|
||||
)
|
||||
|
||||
// UUID holds a UUID v4
|
||||
type UUID struct {
|
||||
uuid.UUID
|
||||
}
|
||||
|
||||
// Equal returns true if itself is equal to other
|
||||
func (u UUID) Equal(other UUID) bool {
|
||||
return uuid.Equal(u.UUID, other.UUID)
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals the raw JSON into the MAC address
|
||||
func (u *UUID) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
new, err := ParseUUID(s)
|
||||
if err == nil {
|
||||
u.UUID = new.UUID
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// MarshalJSON converts the UUID to a string representation
|
||||
func (u UUID) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("%q", u.String())), nil
|
||||
}
|
||||
|
||||
// ParseUUID parses a string into a UUID
|
||||
func ParseUUID(s string) (*UUID, error) {
|
||||
u, err := uuid.FromString(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &UUID{u}, nil
|
||||
}
|
||||
|
||||
// MustParseUUID acts like ParseUUID but panic in case of a failure
|
||||
func MustParseUUID(s string) *UUID {
|
||||
u, e := ParseUUID(s)
|
||||
if e != nil {
|
||||
panic(e)
|
||||
}
|
||||
return u
|
||||
}
|
4
vendor/github.com/exoscale/egoscale/version.go
generated
vendored
Normal file
4
vendor/github.com/exoscale/egoscale/version.go
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
package egoscale
|
||||
|
||||
// Version of the library
|
||||
const Version = "0.11.3"
|
796
vendor/github.com/exoscale/egoscale/virtual_machines.go
generated
vendored
796
vendor/github.com/exoscale/egoscale/virtual_machines.go
generated
vendored
|
@ -1,93 +1,176 @@
|
|||
package egoscale
|
||||
|
||||
import "net"
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// VirtualMachine reprents a virtual machine
|
||||
// VirtualMachineState holds the state of the instance
|
||||
//
|
||||
// https://github.com/apache/cloudstack/blob/master/api/src/main/java/com/cloud/vm/VirtualMachine.java
|
||||
type VirtualMachineState string
|
||||
|
||||
const (
|
||||
// VirtualMachineStarting VM is being started. At this state, you should find host id filled which means it's being started on that host
|
||||
VirtualMachineStarting VirtualMachineState = "Starting"
|
||||
// VirtualMachineRunning VM is running. host id has the host that it is running on
|
||||
VirtualMachineRunning VirtualMachineState = "Running"
|
||||
// VirtualMachineStopping VM is being stopped. host id has the host that it is being stopped on
|
||||
VirtualMachineStopping VirtualMachineState = "Stopping"
|
||||
// VirtualMachineStopped VM is stopped. host id should be null
|
||||
VirtualMachineStopped VirtualMachineState = "Stopped"
|
||||
// VirtualMachineDestroyed VM is marked for destroy
|
||||
VirtualMachineDestroyed VirtualMachineState = "Destroyed"
|
||||
// VirtualMachineExpunging "VM is being expunged
|
||||
VirtualMachineExpunging VirtualMachineState = "Expunging"
|
||||
// VirtualMachineMigrating VM is being migrated. host id holds to from host
|
||||
VirtualMachineMigrating VirtualMachineState = "Migrating"
|
||||
// VirtualMachineError VM is in error
|
||||
VirtualMachineError VirtualMachineState = "Error"
|
||||
// VirtualMachineUnknown VM state is unknown
|
||||
VirtualMachineUnknown VirtualMachineState = "Unknown"
|
||||
// VirtualMachineShutdowned VM is shutdowned from inside
|
||||
VirtualMachineShutdowned VirtualMachineState = "Shutdowned"
|
||||
)
|
||||
|
||||
// VirtualMachine represents a virtual machine
|
||||
//
|
||||
// See: http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/stable/virtual_machines.html
|
||||
type VirtualMachine struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
Account string `json:"account,omitempty"`
|
||||
ClusterID string `json:"clusterid,omitempty"`
|
||||
ClusterName string `json:"clustername,omitempty"`
|
||||
CPUNumber int64 `json:"cpunumber,omitempty"`
|
||||
CPUSpeed int64 `json:"cpuspeed,omitempty"`
|
||||
CPUUsed string `json:"cpuused,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DiskIoRead int64 `json:"diskioread,omitempty"`
|
||||
DiskIoWrite int64 `json:"diskiowrite,omitempty"`
|
||||
DiskKbsRead int64 `json:"diskkbsread,omitempty"`
|
||||
DiskKbsWrite int64 `json:"diskkbswrite,omitempty"`
|
||||
DiskOfferingID string `json:"diskofferingid,omitempty"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty"`
|
||||
DisplayName string `json:"displayname,omitempty"`
|
||||
DisplayVM bool `json:"displayvm,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
GroupID string `json:"groupid,omitempty"`
|
||||
GuestOsID string `json:"guestosid,omitempty"`
|
||||
HaEnable bool `json:"haenable,omitempty"`
|
||||
HostID string `json:"hostid,omitempty"`
|
||||
HostName string `json:"hostname,omitempty"`
|
||||
Hypervisor string `json:"hypervisor,omitempty"`
|
||||
InstanceName string `json:"instancename,omitempty"` // root only
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty"`
|
||||
IsoDisplayText string `json:"isodisplaytext,omitempty"`
|
||||
IsoID string `json:"isoid,omitempty"`
|
||||
IsoName string `json:"isoname,omitempty"`
|
||||
KeyPair string `json:"keypair,omitempty"`
|
||||
Memory int64 `json:"memory,omitempty"`
|
||||
MemoryIntFreeKbs int64 `json:"memoryintfreekbs,omitempty"`
|
||||
MemoryKbs int64 `json:"memorykbs,omitempty"`
|
||||
MemoryTargetKbs int64 `json:"memorytargetkbs,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty"`
|
||||
OsCategoryID string `json:"oscategoryid,omitempty"`
|
||||
OsTypeID int64 `json:"ostypeid,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty"`
|
||||
PCIDevices string `json:"pcidevices,omitempty"` // not in the doc
|
||||
PodID string `json:"podid,omitempty"`
|
||||
PodName string `json:"podname,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
PublicIP string `json:"publicip,omitempty"`
|
||||
PublicIPID string `json:"publicipid,omitempty"`
|
||||
RootDeviceID int64 `json:"rootdeviceid,omitempty"`
|
||||
RootDeviceType string `json:"rootdevicetype,omitempty"`
|
||||
ServiceOfferingID string `json:"serviceofferingid,omitempty"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty"`
|
||||
ServiceState string `json:"servicestate,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty"`
|
||||
TemplateID string `json:"templateid,omitempty"`
|
||||
TemplateName string `json:"templatename,omitempty"`
|
||||
UserID string `json:"userid,omitempty"` // not in the doc
|
||||
UserName string `json:"username,omitempty"` // not in the doc
|
||||
Vgpu string `json:"vgpu,omitempty"` // not in the doc
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
ZoneName string `json:"zonename,omitempty"`
|
||||
AffinityGroup []AffinityGroup `json:"affinitygroup,omitempty"`
|
||||
Nic []Nic `json:"nic,omitempty"`
|
||||
SecurityGroup []SecurityGroup `json:"securitygroup,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the virtual machine"`
|
||||
AccountID *UUID `json:"accountid,omitempty" doc:"the account ID associated with the virtual machine"`
|
||||
AffinityGroup []AffinityGroup `json:"affinitygroup,omitempty" doc:"list of affinity groups associated with the virtual machine"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"the ID of the vm's cluster"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"the name of the vm's cluster"`
|
||||
CPUNumber int `json:"cpunumber,omitempty" doc:"the number of cpu this virtual machine is running with"`
|
||||
CPUSpeed int `json:"cpuspeed,omitempty" doc:"the speed of each cpu"`
|
||||
CPUUsed string `json:"cpuused,omitempty" doc:"the amount of the vm's CPU currently used"`
|
||||
Created string `json:"created,omitempty" doc:"the date when this virtual machine was created"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Vm details in key/value pairs."`
|
||||
DiskIoRead int64 `json:"diskioread,omitempty" doc:"the read (io) of disk on the vm"`
|
||||
DiskIoWrite int64 `json:"diskiowrite,omitempty" doc:"the write (io) of disk on the vm"`
|
||||
DiskKbsRead int64 `json:"diskkbsread,omitempty" doc:"the read (bytes) of disk on the vm"`
|
||||
DiskKbsWrite int64 `json:"diskkbswrite,omitempty" doc:"the write (bytes) of disk on the vm"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering of the virtual machine"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty" doc:"the name of the disk offering of the virtual machine"`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name. The name of the virtual machine is returned if no displayname exists."`
|
||||
DisplayVM bool `json:"displayvm,omitempty" doc:"an optional field whether to the display the vm to the end user or not."`
|
||||
Domain string `json:"domain,omitempty" doc:"the name of the domain in which the virtual machine exists"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain in which the virtual machine exists"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty" doc:"the virtual network for the service offering"`
|
||||
Group string `json:"group,omitempty" doc:"the group name of the virtual machine"`
|
||||
GroupID *UUID `json:"groupid,omitempty" doc:"the group ID of the virtual machine"`
|
||||
HAEnable bool `json:"haenable,omitempty" doc:"true if high-availability is enabled, false otherwise"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the ID of the host for the virtual machine"`
|
||||
HostName string `json:"hostname,omitempty" doc:"the name of the host for the virtual machine"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which the template runs"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
InstanceName string `json:"instancename,omitempty" doc:"instance name of the user vm; this parameter is returned to the ROOT admin only"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty" doc:"true if vm contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory."`
|
||||
IsoDisplayText string `json:"isodisplaytext,omitempty" doc:"an alternate display text of the ISO attached to the virtual machine"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"the ID of the ISO attached to the virtual machine"`
|
||||
IsoName string `json:"isoname,omitempty" doc:"the name of the ISO attached to the virtual machine"`
|
||||
KeyPair string `json:"keypair,omitempty" doc:"ssh key-pair"`
|
||||
Memory int `json:"memory,omitempty" doc:"the memory allocated for the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the virtual machine"`
|
||||
NetworkKbsRead int64 `json:"networkkbsread,omitempty" doc:"the incoming network traffic on the vm"`
|
||||
NetworkKbsWrite int64 `json:"networkkbswrite,omitempty" doc:"the outgoing network traffic on the host"`
|
||||
Nic []Nic `json:"nic,omitempty" doc:"the list of nics associated with vm"`
|
||||
OSCategoryID *UUID `json:"oscategoryid,omitempty" doc:"Os category ID of the virtual machine"`
|
||||
OSCategoryName string `json:"oscategoryname,omitempty" doc:"Os category name of the virtual machine"`
|
||||
Password string `json:"password,omitempty" doc:"the password (if exists) of the virtual machine"`
|
||||
PasswordEnabled bool `json:"passwordenabled,omitempty" doc:"true if the password rest feature is enabled, false otherwise"`
|
||||
PCIDevices []PCIDevice `json:"pcidevices,omitempty" doc:"list of PCI devices"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the ID of the vm's pod"`
|
||||
PodName string `json:"podname,omitempty" doc:"the name of the vm's pod"`
|
||||
PublicIP string `json:"publicip,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
PublicIPID *UUID `json:"publicipid,omitempty" doc:"public IP address id associated with vm via Static nat rule"`
|
||||
RootDeviceID int64 `json:"rootdeviceid,omitempty" doc:"device ID of the root volume"`
|
||||
RootDeviceType string `json:"rootdevicetype,omitempty" doc:"device type of the root volume"`
|
||||
SecurityGroup []SecurityGroup `json:"securitygroup,omitempty" doc:"list of security groups associated with the virtual machine"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid,omitempty" doc:"the ID of the service offering of the virtual machine"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty" doc:"the name of the service offering of the virtual machine"`
|
||||
ServiceState string `json:"servicestate,omitempty" doc:"State of the Service from LB rule"`
|
||||
State string `json:"state,omitempty" doc:"the state of the virtual machine"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with vm"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty" doc:"an alternate display text of the template for the virtual machine"`
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."`
|
||||
TemplateName string `json:"templatename,omitempty" doc:"the name of the template for the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availablility zone for the virtual machine"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"the name of the availability zone for the virtual machine"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*VirtualMachine) ResourceType() string {
|
||||
func (VirtualMachine) ResourceType() string {
|
||||
return "UserVM"
|
||||
}
|
||||
|
||||
// Delete destroys the VM
|
||||
func (vm VirtualMachine) Delete(ctx context.Context, client *Client) error {
|
||||
_, err := client.RequestWithContext(ctx, &DestroyVirtualMachine{
|
||||
ID: vm.ID,
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// ListRequest builds the ListVirtualMachines request
|
||||
func (vm VirtualMachine) ListRequest() (ListCommand, error) {
|
||||
// XXX: AffinityGroupID, SecurityGroupID, Tags
|
||||
|
||||
req := &ListVirtualMachines{
|
||||
Account: vm.Account,
|
||||
DomainID: vm.DomainID,
|
||||
GroupID: vm.GroupID,
|
||||
ID: vm.ID,
|
||||
Name: vm.Name,
|
||||
State: vm.State,
|
||||
TemplateID: vm.TemplateID,
|
||||
ZoneID: vm.ZoneID,
|
||||
}
|
||||
|
||||
nic := vm.DefaultNic()
|
||||
if nic != nil {
|
||||
req.IPAddress = nic.IPAddress
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// DefaultNic returns the default nic
|
||||
func (vm VirtualMachine) DefaultNic() *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.IsDefault {
|
||||
return &nic
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// IP returns the default nic IP address
|
||||
func (vm VirtualMachine) IP() *net.IP {
|
||||
nic := vm.DefaultNic()
|
||||
if nic != nil {
|
||||
ip := nic.IPAddress
|
||||
return &ip
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NicsByType returns the corresponding interfaces base on the given type
|
||||
func (vm *VirtualMachine) NicsByType(nicType string) []Nic {
|
||||
func (vm VirtualMachine) NicsByType(nicType string) []Nic {
|
||||
nics := make([]Nic, 0)
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.Type == nicType {
|
||||
// XXX The CloudStack API forgets to specify it
|
||||
// XXX The API forgets to specify it
|
||||
nic.VirtualMachineID = vm.ID
|
||||
nics = append(nics, nic)
|
||||
}
|
||||
|
@ -96,9 +179,11 @@ func (vm *VirtualMachine) NicsByType(nicType string) []Nic {
|
|||
}
|
||||
|
||||
// NicByNetworkID returns the corresponding interface based on the given NetworkID
|
||||
func (vm *VirtualMachine) NicByNetworkID(networkID string) *Nic {
|
||||
//
|
||||
// A VM cannot be connected twice to a same network.
|
||||
func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.NetworkID == networkID {
|
||||
if nic.NetworkID.Equal(networkID) {
|
||||
nic.VirtualMachineID = vm.ID
|
||||
return &nic
|
||||
}
|
||||
|
@ -107,9 +192,9 @@ func (vm *VirtualMachine) NicByNetworkID(networkID string) *Nic {
|
|||
}
|
||||
|
||||
// NicByID returns the corresponding interface base on its ID
|
||||
func (vm *VirtualMachine) NicByID(nicID string) *Nic {
|
||||
func (vm VirtualMachine) NicByID(nicID UUID) *Nic {
|
||||
for _, nic := range vm.Nic {
|
||||
if nic.ID == nicID {
|
||||
if nic.ID.Equal(nicID) {
|
||||
nic.VirtualMachineID = vm.ID
|
||||
return &nic
|
||||
}
|
||||
|
@ -120,332 +205,319 @@ func (vm *VirtualMachine) NicByID(nicID string) *Nic {
|
|||
|
||||
// IPToNetwork represents a mapping between ip and networks
|
||||
type IPToNetwork struct {
|
||||
IP string `json:"ip,omitempty"`
|
||||
IPV6 string `json:"ipv6,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
IP net.IP `json:"ip,omitempty"`
|
||||
Ipv6 net.IP `json:"ipv6,omitempty"`
|
||||
NetworkID *UUID `json:"networkid,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualMachineResponse represents a generic Virtual Machine response
|
||||
type VirtualMachineResponse struct {
|
||||
VirtualMachine VirtualMachine `json:"virtualmachine"`
|
||||
// PCIDevice represents a PCI card present in the host
|
||||
type PCIDevice struct {
|
||||
PCIVendorName string `json:"pcivendorname,omitempty" doc:"Device vendor name of pci card"`
|
||||
DeviceID *UUID `json:"deviceid,omitempty" doc:"Device model ID of pci card"`
|
||||
RemainingCapacity int `json:"remainingcapacity,omitempty" doc:"Remaining capacity in terms of no. of more VMs that can be deployped with this vGPU type"`
|
||||
MaxCapacity int `json:"maxcapacity,omitempty" doc:"Maximum vgpu can be created with this vgpu type on the given pci group"`
|
||||
PCIVendorID *UUID `json:"pcivendorid,omitempty" doc:"Device vendor ID of pci card"`
|
||||
PCIDeviceName string `json:"pcidevicename,omitempty" doc:"Device model name of pci card"`
|
||||
}
|
||||
|
||||
// Password represents an encrypted password
|
||||
//
|
||||
// TODO: method to decrypt it, https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=34014652
|
||||
type Password struct {
|
||||
EncryptedPassword string `json:"encryptedpassword"`
|
||||
}
|
||||
|
||||
// VirtualMachineUserData represents the base64 encoded user-data
|
||||
type VirtualMachineUserData struct {
|
||||
UserData string `json:"userdata,omitempty" doc:"Base 64 encoded VM user data"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the virtual machine"`
|
||||
}
|
||||
|
||||
// Decode decodes as a readable string the content of the user-data (base64 · gzip)
|
||||
func (userdata VirtualMachineUserData) Decode() (string, error) {
|
||||
data, err := base64.StdEncoding.DecodeString(userdata.UserData)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// 0x1f8b is the magic number for gzip
|
||||
if len(data) < 2 || data[0] != 0x1f || data[1] != 0x8b {
|
||||
return string(data), nil
|
||||
}
|
||||
gr, err := gzip.NewReader(bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer gr.Close() // nolint: errcheck
|
||||
|
||||
str, err := ioutil.ReadAll(gr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(str), nil
|
||||
}
|
||||
|
||||
// DeployVirtualMachine (Async) represents the machine creation
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/deployVirtualMachine.html
|
||||
// Regarding the UserData field, the client is responsible to base64 (and probably gzip) it. Doing it within this library would make the integration with other tools, e.g. Terraform harder.
|
||||
type DeployVirtualMachine struct {
|
||||
ServiceOfferingID string `json:"serviceofferingid"`
|
||||
TemplateID string `json:"templateid"`
|
||||
ZoneID string `json:"zoneid"`
|
||||
Account string `json:"account,omitempty"`
|
||||
AffinityGroupIDs []string `json:"affinitygroupids,omitempty"`
|
||||
AffinityGroupNames []string `json:"affinitygroupnames,omitempty"`
|
||||
CustomID string `json:"customid,omitempty"` // root only
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty"` // root only
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DiskOfferingID string `json:"diskofferingid,omitempty"`
|
||||
DisplayName string `json:"displayname,omitempty"`
|
||||
DisplayVM bool `json:"displayvm,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
HostID string `json:"hostid,omitempty"`
|
||||
Hypervisor string `json:"hypervisor,omitempty"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty"`
|
||||
IPToNetworkList []IPToNetwork `json:"iptonetworklist,omitempty"`
|
||||
Keyboard string `json:"keyboard,omitempty"`
|
||||
KeyPair string `json:"keypair,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkIDs []string `json:"networkids,omitempty"` // mutually exclusive with IPToNetworkList
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
RootDiskSize int64 `json:"rootdisksize,omitempty"` // in GiB
|
||||
SecurityGroupIDs []string `json:"securitygroupids,omitempty"`
|
||||
SecurityGroupNames []string `json:"securitygroupnames,omitempty"` // does nothing, mutually exclusive
|
||||
Size string `json:"size,omitempty"` // mutually exclusive with DiskOfferingID
|
||||
StartVM bool `json:"startvm,omitempty"`
|
||||
UserData string `json:"userdata,omitempty"` // the client is responsible to base64/gzip it
|
||||
Account string `json:"account,omitempty" doc:"an optional account for the virtual machine. Must be used with domainId."`
|
||||
AffinityGroupIDs []UUID `json:"affinitygroupids,omitempty" doc:"comma separated list of affinity groups id that are going to be applied to the virtual machine. Mutually exclusive with affinitygroupnames parameter"`
|
||||
AffinityGroupNames []string `json:"affinitygroupnames,omitempty" doc:"comma separated list of affinity groups names that are going to be applied to the virtual machine.Mutually exclusive with affinitygroupids parameter"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty" doc:"Deployment planner to use for vm allocation. Available to ROOT admin only"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"used to specify the custom parameters."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"the ID of the disk offering for the virtual machine. If the template is of ISO format, the diskOfferingId is for the root disk volume. Otherwise this parameter is used to indicate the offering for the data disk volume. If the templateId parameter passed is from a Template object, the diskOfferingId refers to a DATA Disk Volume created. If the templateId parameter passed is from an ISO object, the diskOfferingId refers to a ROOT Disk Volume created."`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"an optional user generated name for the virtual machine"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"an optional field, whether to the display the vm to the end user or not."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"an optional domainId for the virtual machine. If the account parameter is used, domainId must also be used."`
|
||||
Group string `json:"group,omitempty" doc:"an optional group for the virtual machine"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"destination Host ID to deploy the VM to - parameter available for root admin only"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the hypervisor on which to deploy the virtual machine"`
|
||||
IP4 *bool `json:"ip4,omitempty" doc:"True to set an IPv4 to the default interface"`
|
||||
IP6 *bool `json:"ip6,omitempty" doc:"True to set an IPv6 to the default interface"`
|
||||
IP6Address net.IP `json:"ip6address,omitempty" doc:"the ipv6 address for default vm's network"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"the ip address for default vm's network"`
|
||||
IPToNetworkList []IPToNetwork `json:"iptonetworklist,omitempty" doc:"ip to network mapping. Can't be specified with networkIds parameter. Example: iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].ipv6=fc00:1234:5678::abcd&iptonetworklist[0].networkid=uuid - requests to use ip 10.10.10.11 in network id=uuid"`
|
||||
Keyboard string `json:"keyboard,omitempty" doc:"an optional keyboard device type for the virtual machine. valid value can be one of de,de-ch,es,fi,fr,fr-be,fr-ch,is,it,jp,nl-be,no,pt,uk,us"`
|
||||
KeyPair string `json:"keypair,omitempty" doc:"name of the ssh key pair used to login to the virtual machine"`
|
||||
Name string `json:"name,omitempty" doc:"host name for the virtual machine"`
|
||||
NetworkIDs []UUID `json:"networkids,omitempty" doc:"list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter"`
|
||||
RootDiskSize int64 `json:"rootdisksize,omitempty" doc:"Optional field to resize root disk on deploy. Value is in GB. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided"`
|
||||
SecurityGroupIDs []UUID `json:"securitygroupids,omitempty" doc:"comma separated list of security groups id that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupnames parameter"`
|
||||
SecurityGroupNames []string `json:"securitygroupnames,omitempty" doc:"comma separated list of security groups names that going to be applied to the virtual machine. Should be passed only when vm is created from a zone with Basic Network support. Mutually exclusive with securitygroupids parameter"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid" doc:"the ID of the service offering for the virtual machine"`
|
||||
Size int64 `json:"size,omitempty" doc:"the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId"`
|
||||
StartVM *bool `json:"startvm,omitempty" doc:"true if start vm after creating. Default value is true"`
|
||||
TemplateID *UUID `json:"templateid" doc:"the ID of the template for the virtual machine"`
|
||||
UserData string `json:"userdata,omitempty" doc:"an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding."`
|
||||
ZoneID *UUID `json:"zoneid" doc:"availability zone for the virtual machine"`
|
||||
_ bool `name:"deployVirtualMachine" description:"Creates and automatically starts a virtual machine based on a service offering, disk offering, and template."`
|
||||
}
|
||||
|
||||
func (*DeployVirtualMachine) name() string {
|
||||
return "deployVirtualMachine"
|
||||
func (req DeployVirtualMachine) onBeforeSend(params url.Values) error {
|
||||
// Either AffinityGroupIDs or AffinityGroupNames must be set
|
||||
if len(req.AffinityGroupIDs) > 0 && len(req.AffinityGroupNames) > 0 {
|
||||
return fmt.Errorf("either AffinityGroupIDs or AffinityGroupNames must be set")
|
||||
}
|
||||
|
||||
// Either SecurityGroupIDs or SecurityGroupNames must be set
|
||||
if len(req.SecurityGroupIDs) > 0 && len(req.SecurityGroupNames) > 0 {
|
||||
return fmt.Errorf("either SecurityGroupIDs or SecurityGroupNames must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*DeployVirtualMachine) asyncResponse() interface{} {
|
||||
return new(DeployVirtualMachineResponse)
|
||||
func (DeployVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// DeployVirtualMachineResponse represents a deployed VM instance
|
||||
type DeployVirtualMachineResponse VirtualMachineResponse
|
||||
func (DeployVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// StartVirtualMachine (Async) represents the creation of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/startVirtualMachine.html
|
||||
type StartVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty"` // root only
|
||||
HostID string `json:"hostid,omitempty"` // root only
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
DeploymentPlanner string `json:"deploymentplanner,omitempty" doc:"Deployment planner to use for vm allocation. Available to ROOT admin only"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"destination Host ID to deploy the VM to - parameter available for root admin only"`
|
||||
_ bool `name:"startVirtualMachine" description:"Starts a virtual machine."`
|
||||
}
|
||||
|
||||
func (*StartVirtualMachine) name() string {
|
||||
return "startVirtualMachine"
|
||||
}
|
||||
func (*StartVirtualMachine) asyncResponse() interface{} {
|
||||
return new(StartVirtualMachineResponse)
|
||||
func (StartVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
// StartVirtualMachineResponse represents a started VM instance
|
||||
type StartVirtualMachineResponse VirtualMachineResponse
|
||||
func (StartVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// StopVirtualMachine (Async) represents the stopping of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/stopVirtualMachine.html
|
||||
type StopVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
Forced bool `json:"forced,omitempty"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
Forced *bool `json:"forced,omitempty" doc:"Force stop the VM (vm is marked as Stopped even when command fails to be send to the backend). The caller knows the VM is stopped."`
|
||||
_ bool `name:"stopVirtualMachine" description:"Stops a virtual machine."`
|
||||
}
|
||||
|
||||
func (*StopVirtualMachine) name() string {
|
||||
return "stopVirtualMachine"
|
||||
func (StopVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*StopVirtualMachine) asyncResponse() interface{} {
|
||||
return new(StopVirtualMachineResponse)
|
||||
func (StopVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// StopVirtualMachineResponse represents a stopped VM instance
|
||||
type StopVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// RebootVirtualMachine (Async) represents the rebooting of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/rebootVirtualMachine.html
|
||||
type RebootVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"rebootVirtualMachine" description:"Reboots a virtual machine."`
|
||||
}
|
||||
|
||||
func (*RebootVirtualMachine) name() string {
|
||||
return "rebootVirtualMachine"
|
||||
func (RebootVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RebootVirtualMachine) asyncResponse() interface{} {
|
||||
return new(RebootVirtualMachineResponse)
|
||||
func (RebootVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// RebootVirtualMachineResponse represents a rebooted VM instance
|
||||
type RebootVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// RestoreVirtualMachine (Async) represents the restoration of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/restoreVirtualMachine.html
|
||||
type RestoreVirtualMachine struct {
|
||||
VirtualMachineID string `json:"virtualmachineid"`
|
||||
TemplateID string `json:"templateid,omitempty"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"Virtual Machine ID"`
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"an optional template Id to restore vm from the new template. This can be an ISO id in case of restore vm deployed using ISO"`
|
||||
RootDiskSize int64 `json:"rootdisksize,omitempty" doc:"Optional field to resize root disk on restore. Value is in GB. Only applies to template-based deployments."`
|
||||
_ bool `name:"restoreVirtualMachine" description:"Restore a VM to original template/ISO or new template/ISO"`
|
||||
}
|
||||
|
||||
func (*RestoreVirtualMachine) name() string {
|
||||
return "restoreVirtualMachine"
|
||||
func (RestoreVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RestoreVirtualMachine) asyncResponse() interface{} {
|
||||
return new(RestoreVirtualMachineResponse)
|
||||
func (RestoreVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// RestoreVirtualMachineResponse represents a restored VM instance
|
||||
type RestoreVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// RecoverVirtualMachine represents the restoration of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/recoverVirtualMachine.html
|
||||
type RecoverVirtualMachine struct {
|
||||
ID string `json:"virtualmachineid"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"recoverVirtualMachine" description:"Recovers a virtual machine."`
|
||||
}
|
||||
|
||||
func (*RecoverVirtualMachine) name() string {
|
||||
return "recoverVirtualMachine"
|
||||
func (RecoverVirtualMachine) response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
func (*RecoverVirtualMachine) response() interface{} {
|
||||
return new(RecoverVirtualMachineResponse)
|
||||
}
|
||||
|
||||
// RecoverVirtualMachineResponse represents a recovered VM instance
|
||||
type RecoverVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// DestroyVirtualMachine (Async) represents the destruction of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/destroyVirtualMachine.html
|
||||
type DestroyVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
Expunge bool `json:"expunge,omitempty"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
Expunge *bool `json:"expunge,omitempty" doc:"If true is passed, the vm is expunged immediately. False by default."`
|
||||
_ bool `name:"destroyVirtualMachine" description:"Destroys a virtual machine."`
|
||||
}
|
||||
|
||||
func (*DestroyVirtualMachine) name() string {
|
||||
return "destroyVirtualMachine"
|
||||
func (DestroyVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*DestroyVirtualMachine) asyncResponse() interface{} {
|
||||
return new(DestroyVirtualMachineResponse)
|
||||
func (DestroyVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// DestroyVirtualMachineResponse represents a destroyed VM instance
|
||||
type DestroyVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// UpdateVirtualMachine represents the update of the virtual machine
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/updateVirtualMachine.html
|
||||
type UpdateVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
CustomID string `json:"customid,omitempty"` // root only
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DisplayName string `json:"displayname,omitempty"`
|
||||
DisplayVM bool `json:"displayvm,omitempty"`
|
||||
Group string `json:"group,omitempty"`
|
||||
HAEnable bool `json:"haenable,omitempty"`
|
||||
IsDynamicallyScalable bool `json:"isdynamicallyscalable,omitempty"`
|
||||
Name string `json:"name,omitempty"` // must reboot
|
||||
OsTypeID int64 `json:"ostypeid,omitempty"`
|
||||
SecurityGroupIDs []string `json:"securitygroupids,omitempty"`
|
||||
UserData string `json:"userdata,omitempty"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
CustomID *UUID `json:"customid,omitempty" doc:"an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"Details in key/value pairs."`
|
||||
DisplayName string `json:"displayname,omitempty" doc:"user generated name"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"an optional field, whether to the display the vm to the end user or not."`
|
||||
Group string `json:"group,omitempty" doc:"group of the virtual machine"`
|
||||
HAEnable *bool `json:"haenable,omitempty" doc:"true if high-availability is enabled for the virtual machine, false otherwise"`
|
||||
IsDynamicallyScalable *bool `json:"isdynamicallyscalable,omitempty" doc:"true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory"`
|
||||
Name string `json:"name,omitempty" doc:"new host name of the vm. The VM has to be stopped/started for this update to take affect"`
|
||||
SecurityGroupIDs []UUID `json:"securitygroupids,omitempty" doc:"list of security group ids to be applied on the virtual machine."`
|
||||
UserData string `json:"userdata,omitempty" doc:"an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding. Using HTTP POST(via POST body), you can send up to 32K of data after base64 encoding."`
|
||||
_ bool `name:"updateVirtualMachine" description:"Updates properties of a virtual machine. The VM has to be stopped and restarted for the new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. Therefore, stop the VM manually before issuing this call."`
|
||||
}
|
||||
|
||||
func (*UpdateVirtualMachine) name() string {
|
||||
return "updateVirtualMachine"
|
||||
func (UpdateVirtualMachine) response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
func (*UpdateVirtualMachine) response() interface{} {
|
||||
return new(UpdateVirtualMachineResponse)
|
||||
}
|
||||
|
||||
// UpdateVirtualMachineResponse represents an updated VM instance
|
||||
type UpdateVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// ExpungeVirtualMachine represents the annihilation of a VM
|
||||
type ExpungeVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"expungeVirtualMachine" description:"Expunge a virtual machine. Once expunged, it cannot be recoverd."`
|
||||
}
|
||||
|
||||
func (*ExpungeVirtualMachine) name() string {
|
||||
return "expungeVirtualMachine"
|
||||
func (ExpungeVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*ExpungeVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (ExpungeVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ScaleVirtualMachine (Async) represents the scaling of a VM
|
||||
// ScaleVirtualMachine (Async) scales the virtual machine to a new service offering.
|
||||
//
|
||||
// ChangeServiceForVirtualMachine does the same thing but returns the
|
||||
// new Virtual Machine which is more consistent with the rest of the API.
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/scaleVirtualMachine.html
|
||||
type ScaleVirtualMachine struct {
|
||||
ID string `json:"id"`
|
||||
ServiceOfferingID string `json:"serviceofferingid"`
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid" doc:"the ID of the service offering for the virtual machine"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"name value pairs of custom parameters for cpu,memory and cpunumber. example details[i].name=value"`
|
||||
_ bool `name:"scaleVirtualMachine" description:"Scales the virtual machine to a new service offering."`
|
||||
}
|
||||
|
||||
func (*ScaleVirtualMachine) name() string {
|
||||
return "scaleVirtualMachine"
|
||||
func (ScaleVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*ScaleVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanAsyncResponse)
|
||||
func (ScaleVirtualMachine) asyncResponse() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ChangeServiceForVirtualMachine represents the scaling of a VM
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/changeServiceForVirtualMachine.html
|
||||
type ChangeServiceForVirtualMachine ScaleVirtualMachine
|
||||
|
||||
func (*ChangeServiceForVirtualMachine) name() string {
|
||||
return "changeServiceForVirtualMachine"
|
||||
// ChangeServiceForVirtualMachine changes the service offering for a virtual machine. The virtual machine must be in a "Stopped" state for this command to take effect.
|
||||
type ChangeServiceForVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid" doc:"the service offering ID to apply to the virtual machine"`
|
||||
Details map[string]string `json:"details,omitempty" doc:"name value pairs of custom parameters for cpu, memory and cpunumber. example details[i].name=value"`
|
||||
_ bool `name:"changeServiceForVirtualMachine" description:"Changes the service offering for a virtual machine. The virtual machine must be in a \"Stopped\" state for this command to take effect."`
|
||||
}
|
||||
|
||||
func (*ChangeServiceForVirtualMachine) response() interface{} {
|
||||
return new(ChangeServiceForVirtualMachineResponse)
|
||||
func (ChangeServiceForVirtualMachine) response() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// ChangeServiceForVirtualMachineResponse represents an changed VM instance
|
||||
type ChangeServiceForVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// ResetPasswordForVirtualMachine (Async) represents the scaling of a VM
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/resetPasswordForVirtualMachine.html
|
||||
type ResetPasswordForVirtualMachine ScaleVirtualMachine
|
||||
|
||||
func (*ResetPasswordForVirtualMachine) name() string {
|
||||
return "resetPasswordForVirtualMachine"
|
||||
// ResetPasswordForVirtualMachine resets the password for virtual machine. The virtual machine must be in a "Stopped" state...
|
||||
type ResetPasswordForVirtualMachine struct {
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"resetPasswordForVirtualMachine" description:"Resets the password for virtual machine. The virtual machine must be in a \"Stopped\" state and the template must already support this feature for this command to take effect."`
|
||||
}
|
||||
|
||||
func (*ResetPasswordForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(ResetPasswordForVirtualMachineResponse)
|
||||
func (ResetPasswordForVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (ResetPasswordForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// ResetPasswordForVirtualMachineResponse represents the updated vm
|
||||
type ResetPasswordForVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// GetVMPassword asks for an encrypted password
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/getVMPassword.html
|
||||
type GetVMPassword struct {
|
||||
ID string `json:"id"`
|
||||
ID *UUID `json:"id" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"getVMPassword" description:"Returns an encrypted password for the VM"`
|
||||
}
|
||||
|
||||
func (*GetVMPassword) name() string {
|
||||
return "getVMPassword"
|
||||
}
|
||||
|
||||
func (*GetVMPassword) response() interface{} {
|
||||
return new(GetVMPasswordResponse)
|
||||
}
|
||||
|
||||
// GetVMPasswordResponse represents the encrypted password
|
||||
type GetVMPasswordResponse struct {
|
||||
// Base64 encrypted password for the VM
|
||||
EncryptedPassword string `json:"encryptedpassword"`
|
||||
func (GetVMPassword) response() interface{} {
|
||||
return new(Password)
|
||||
}
|
||||
|
||||
// ListVirtualMachines represents a search for a VM
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listVirtualMachine.html
|
||||
type ListVirtualMachines struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
AffinityGroupID string `json:"affinitygroupid,omitempty"`
|
||||
Details map[string]string `json:"details,omitempty"`
|
||||
DisplayVM bool `json:"displayvm,omitempty"` // root only
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ForVirtualNetwork bool `json:"forvirtualnetwork,omitempty"`
|
||||
GroupID string `json:"groupid,omitempty"`
|
||||
HostID string `json:"hostid,omitempty"`
|
||||
Hypervisor string `json:"hypervisor,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IDs []string `json:"ids,omitempty"` // mutually exclusive with id
|
||||
IsoID string `json:"isoid,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
KeyPair string `json:"keypair,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkID string `json:"networkid,omitempty"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PodID string `json:"podid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ServiceOfferindID string `json:"serviceofferingid,omitempty"`
|
||||
State string `json:"state,omitempty"` // Running, Stopped, Present, ...
|
||||
StorageID string `json:"storageid,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
TemplateID string `json:"templateid,omitempty"`
|
||||
UserID string `json:"userid,omitempty"`
|
||||
VpcID string `json:"vpcid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListVirtualMachines) name() string {
|
||||
return "listVirtualMachines"
|
||||
}
|
||||
|
||||
func (*ListVirtualMachines) response() interface{} {
|
||||
return new(ListVirtualMachinesResponse)
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
AffinityGroupID *UUID `json:"affinitygroupid,omitempty" doc:"list vms by affinity group"`
|
||||
Details []string `json:"details,omitempty" doc:"comma separated list of host details requested, value can be a list of [all, group, nics, stats, secgrp, tmpl, servoff, diskoff, iso, volume, min, affgrp]. If no parameter is passed in, the details will be defaulted to all"`
|
||||
DisplayVM *bool `json:"displayvm,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ForVirtualNetwork *bool `json:"forvirtualnetwork,omitempty" doc:"list by network type; true if need to list vms using Virtual Network, false otherwise"`
|
||||
GroupID *UUID `json:"groupid,omitempty" doc:"the group ID"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"the host ID"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"the target hypervisor for the template"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the virtual machine"`
|
||||
IDs []string `json:"ids,omitempty" doc:"the IDs of the virtual machines, mutually exclusive with id"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"an IP address to filter the result"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"list vms by iso"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"name of the virtual machine"`
|
||||
NetworkID *UUID `json:"networkid,omitempty" doc:"list by network id"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ServiceOfferindID *UUID `json:"serviceofferingid,omitempty" doc:"list by the service offering"`
|
||||
State string `json:"state,omitempty" doc:"state of the virtual machine"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
TemplateID *UUID `json:"templateid,omitempty" doc:"list vms by template"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the availability zone ID"`
|
||||
_ bool `name:"listVirtualMachines" description:"List the virtual machines owned by the account."`
|
||||
}
|
||||
|
||||
// ListVirtualMachinesResponse represents a list of virtual machines
|
||||
|
@ -454,61 +526,103 @@ type ListVirtualMachinesResponse struct {
|
|||
VirtualMachine []VirtualMachine `json:"virtualmachine"`
|
||||
}
|
||||
|
||||
func (ListVirtualMachines) response() interface{} {
|
||||
return new(ListVirtualMachinesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListVirtualMachines) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVirtualMachines) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListVirtualMachines) each(resp interface{}, callback IterateItemFunc) {
|
||||
vms, ok := resp.(*ListVirtualMachinesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListVirtualMachinesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range vms.VirtualMachine {
|
||||
if !callback(&vms.VirtualMachine[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AddNicToVirtualMachine (Async) adds a NIC to a VM
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/addNicToVirtualMachine.html
|
||||
type AddNicToVirtualMachine struct {
|
||||
NetworkID string `json:"networkid"`
|
||||
VirtualMachineID string `json:"virtualmachineid"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty"`
|
||||
NetworkID *UUID `json:"networkid" doc:"Network ID"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"Virtual Machine ID"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty" doc:"IP Address for the new network"`
|
||||
_ bool `name:"addNicToVirtualMachine" description:"Adds VM to specified network by creating a NIC"`
|
||||
}
|
||||
|
||||
func (*AddNicToVirtualMachine) name() string {
|
||||
return "addNicToVirtualMachine"
|
||||
func (AddNicToVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*AddNicToVirtualMachine) asyncResponse() interface{} {
|
||||
return new(AddNicToVirtualMachineResponse)
|
||||
func (AddNicToVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// AddNicToVirtualMachineResponse represents the modified VM
|
||||
type AddNicToVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// RemoveNicFromVirtualMachine (Async) removes a NIC from a VM
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/removeNicFromVirtualMachine.html
|
||||
type RemoveNicFromVirtualMachine struct {
|
||||
NicID string `json:"nicid"`
|
||||
VirtualMachineID string `json:"virtualmachineid"`
|
||||
NicID *UUID `json:"nicid" doc:"NIC ID"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"Virtual Machine ID"`
|
||||
_ bool `name:"removeNicFromVirtualMachine" description:"Removes VM from specified network by deleting a NIC"`
|
||||
}
|
||||
|
||||
func (*RemoveNicFromVirtualMachine) name() string {
|
||||
return "removeNicFromVirtualMachine"
|
||||
func (RemoveNicFromVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*RemoveNicFromVirtualMachine) asyncResponse() interface{} {
|
||||
return new(RemoveNicFromVirtualMachineResponse)
|
||||
func (RemoveNicFromVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
// RemoveNicFromVirtualMachineResponse represents the modified VM
|
||||
type RemoveNicFromVirtualMachineResponse VirtualMachineResponse
|
||||
|
||||
// UpdateDefaultNicForVirtualMachine (Async) adds a NIC to a VM
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/updateDefaultNicForVirtualMachine.html
|
||||
type UpdateDefaultNicForVirtualMachine struct {
|
||||
NetworkID string `json:"networkid"`
|
||||
VirtualMachineID string `json:"virtualmachineid"`
|
||||
IPAddress net.IP `json:"ipaddress,omitempty"`
|
||||
NicID *UUID `json:"nicid" doc:"NIC ID"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"Virtual Machine ID"`
|
||||
_ bool `name:"updateDefaultNicForVirtualMachine" description:"Changes the default NIC on a VM"`
|
||||
}
|
||||
|
||||
func (*UpdateDefaultNicForVirtualMachine) name() string {
|
||||
return "updateDefaultNicForVirtualMachine"
|
||||
func (UpdateDefaultNicForVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
func (UpdateDefaultNicForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
||||
func (*UpdateDefaultNicForVirtualMachine) asyncResponse() interface{} {
|
||||
return new(UpdateDefaultNicForVirtualMachineResponse)
|
||||
// GetVirtualMachineUserData returns the user-data of the given VM
|
||||
type GetVirtualMachineUserData struct {
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"The ID of the virtual machine"`
|
||||
_ bool `name:"getVirtualMachineUserData" description:"Returns user data associated with the VM"`
|
||||
}
|
||||
|
||||
// UpdateDefaultNicForVirtualMachineResponse represents the modified VM
|
||||
type UpdateDefaultNicForVirtualMachineResponse VirtualMachineResponse
|
||||
func (GetVirtualMachineUserData) response() interface{} {
|
||||
return new(VirtualMachineUserData)
|
||||
}
|
||||
|
||||
// Decode decodes the base64 / gzipped encoded user data
|
||||
|
||||
// MigrateVirtualMachine (Async) attempts migration of a VM to a different host or Root volume of the vm to a different storage pool
|
||||
type MigrateVirtualMachine struct {
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"Destination Host ID to migrate VM to. Required for live migrating a VM from host to host"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"Destination storage pool ID to migrate VM volumes to. Required for migrating the root disk volume"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid" doc:"the ID of the virtual machine"`
|
||||
_ bool `name:"migrateVirtualMachine" description:"Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool"`
|
||||
}
|
||||
|
||||
func (MigrateVirtualMachine) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (MigrateVirtualMachine) asyncResponse() interface{} {
|
||||
return new(VirtualMachine)
|
||||
}
|
||||
|
|
108
vendor/github.com/exoscale/egoscale/vm_groups.go
generated
vendored
108
vendor/github.com/exoscale/egoscale/vm_groups.go
generated
vendored
|
@ -2,101 +2,59 @@ package egoscale
|
|||
|
||||
// InstanceGroup represents a group of VM
|
||||
type InstanceGroup struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Project string `json:"project,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
// InstanceGroupResponse represents a VM group
|
||||
type InstanceGroupResponse struct {
|
||||
InstanceGroup InstanceGroup `json:"instancegroup"`
|
||||
Account string `json:"account,omitempty" doc:"the account owning the instance group"`
|
||||
Created string `json:"created,omitempty" doc:"time and date the instance group was created"`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain name of the instance group"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of the instance group"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the id of the instance group"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the instance group"`
|
||||
}
|
||||
|
||||
// CreateInstanceGroup creates a VM group
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/createInstanceGroup.html
|
||||
type CreateInstanceGroup struct {
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
Name string `json:"name" doc:"the name of the instance group"`
|
||||
Account string `json:"account,omitempty" doc:"the account of the instance group. The account parameter must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the domain ID of account owning the instance group"`
|
||||
_ bool `name:"createInstanceGroup" description:"Creates a vm group"`
|
||||
}
|
||||
|
||||
func (*CreateInstanceGroup) name() string {
|
||||
return "createInstanceGroup"
|
||||
func (CreateInstanceGroup) response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
func (*CreateInstanceGroup) response() interface{} {
|
||||
return new(CreateInstanceGroupResponse)
|
||||
}
|
||||
|
||||
// CreateInstanceGroupResponse represents a freshly created VM group
|
||||
type CreateInstanceGroupResponse InstanceGroupResponse
|
||||
|
||||
// UpdateInstanceGroup creates a VM group
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/updateInstanceGroup.html
|
||||
// UpdateInstanceGroup updates a VM group
|
||||
type UpdateInstanceGroup struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name,omitempty"`
|
||||
ID *UUID `json:"id" doc:"Instance group ID"`
|
||||
Name string `json:"name,omitempty" doc:"new instance group name"`
|
||||
_ bool `name:"updateInstanceGroup" description:"Updates a vm group"`
|
||||
}
|
||||
|
||||
func (*UpdateInstanceGroup) name() string {
|
||||
return "updateInstanceGroup"
|
||||
func (UpdateInstanceGroup) response() interface{} {
|
||||
return new(InstanceGroup)
|
||||
}
|
||||
|
||||
func (*UpdateInstanceGroup) response() interface{} {
|
||||
return new(UpdateInstanceGroupResponse)
|
||||
}
|
||||
|
||||
// UpdateInstanceGroupResponse represents an updated VM group
|
||||
type UpdateInstanceGroupResponse InstanceGroupResponse
|
||||
|
||||
// DeleteInstanceGroup creates a VM group
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/deleteInstanceGroup.html
|
||||
// DeleteInstanceGroup deletes a VM group
|
||||
type DeleteInstanceGroup struct {
|
||||
Name string `json:"name"`
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
ID *UUID `json:"id" doc:"the ID of the instance group"`
|
||||
_ bool `name:"deleteInstanceGroup" description:"Deletes a vm group"`
|
||||
}
|
||||
|
||||
func (*DeleteInstanceGroup) name() string {
|
||||
return "deleteInstanceGroup"
|
||||
}
|
||||
|
||||
func (*DeleteInstanceGroup) response() interface{} {
|
||||
return new(booleanSyncResponse)
|
||||
func (DeleteInstanceGroup) response() interface{} {
|
||||
return new(booleanResponse)
|
||||
}
|
||||
|
||||
// ListInstanceGroups lists VM groups
|
||||
//
|
||||
// CloudStack API: http://cloudstack.apache.org/api/apidocs-4.10/apis/listInstanceGroups.html
|
||||
type ListInstanceGroups struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
ID *UUID `json:"id,omitempty" doc:"list instance groups by ID"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"list instance groups by name"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListInstanceGroups) name() string {
|
||||
return "listInstanceGroups"
|
||||
}
|
||||
|
||||
func (*ListInstanceGroups) response() interface{} {
|
||||
return new(ListInstanceGroupsResponse)
|
||||
_ bool `name:"listInstanceGroups" description:"Lists vm groups"`
|
||||
}
|
||||
|
||||
// ListInstanceGroupsResponse represents a list of instance groups
|
||||
|
@ -104,3 +62,7 @@ type ListInstanceGroupsResponse struct {
|
|||
Count int `json:"count"`
|
||||
InstanceGroup []InstanceGroup `json:"instancegroup"`
|
||||
}
|
||||
|
||||
func (ListInstanceGroups) response() interface{} {
|
||||
return new(ListInstanceGroupsResponse)
|
||||
}
|
||||
|
|
205
vendor/github.com/exoscale/egoscale/volumes.go
generated
vendored
205
vendor/github.com/exoscale/egoscale/volumes.go
generated
vendored
|
@ -6,92 +6,117 @@ import (
|
|||
|
||||
// Volume represents a volume linked to a VM
|
||||
type Volume struct {
|
||||
ID string `json:"id"`
|
||||
Account string `json:"account,omitempty"`
|
||||
Attached string `json:"attached,omitempty"`
|
||||
ChainInfo string `json:"chaininfo,omitempty"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Destroyed bool `json:"destroyed,omitempty"`
|
||||
DisplayVolume bool `json:"displayvolume,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
QuiesceVM bool `json:"quiescevm,omitempty"`
|
||||
ServiceOfferingDisplayText string `json:"serviceofferingdisplaytext,omitempty"`
|
||||
ServiceOfferingID string `json:"serviceofferingid,omitempty"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty"`
|
||||
Size uint64 `json:"size,omitempty"`
|
||||
State string `json:"state,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
VMName string `json:"vmname,omitempty"`
|
||||
VMState string `json:"vmstate,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
ZoneName string `json:"zonename,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
JobID string `json:"jobid,omitempty"`
|
||||
JobStatus JobStatusType `json:"jobstatus,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"the account associated with the disk volume"`
|
||||
Attached string `json:"attached,omitempty" doc:"the date the volume was attached to a VM instance"`
|
||||
ChainInfo string `json:"chaininfo,omitempty" doc:"the chain info of the volume"`
|
||||
ClusterID *UUID `json:"clusterid,omitempty" doc:"ID of the cluster"`
|
||||
ClusterName string `json:"clustername,omitempty" doc:"name of the cluster"`
|
||||
Created string `json:"created,omitempty" doc:"the date the disk volume was created"`
|
||||
Destroyed bool `json:"destroyed,omitempty" doc:"the boolean state of whether the volume is destroyed or not"`
|
||||
DeviceID int64 `json:"deviceid,omitempty" doc:"the ID of the device on user vm the volume is attahed to. This tag is not returned when the volume is detached."`
|
||||
DiskBytesReadRate int64 `json:"diskBytesReadRate,omitempty" doc:"bytes read rate of the disk volume"`
|
||||
DiskBytesWriteRate int64 `json:"diskBytesWriteRate,omitempty" doc:"bytes write rate of the disk volume"`
|
||||
DiskIopsReadRate int64 `json:"diskIopsReadRate,omitempty" doc:"io requests read rate of the disk volume"`
|
||||
DiskIopsWriteRate int64 `json:"diskIopsWriteRate,omitempty" doc:"io requests write rate of the disk volume"`
|
||||
DiskOfferingDisplayText string `json:"diskofferingdisplaytext,omitempty" doc:"the display text of the disk offering"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"ID of the disk offering"`
|
||||
DiskOfferingName string `json:"diskofferingname,omitempty" doc:"name of the disk offering"`
|
||||
DisplayVolume bool `json:"displayvolume,omitempty" doc:"an optional field whether to the display the volume to the end user or not."`
|
||||
Domain string `json:"domain,omitempty" doc:"the domain associated with the disk volume"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the disk volume"`
|
||||
Hypervisor string `json:"hypervisor,omitempty" doc:"Hypervisor the volume belongs to"`
|
||||
ID *UUID `json:"id,omitempty" doc:"ID of the disk volume"`
|
||||
IsExtractable *bool `json:"isextractable,omitempty" doc:"true if the volume is extractable, false otherwise"`
|
||||
IsoDisplayText string `json:"isodisplaytext,omitempty" doc:"an alternate display text of the ISO attached to the virtual machine"`
|
||||
IsoID *UUID `json:"isoid,omitempty" doc:"the ID of the ISO attached to the virtual machine"`
|
||||
IsoName string `json:"isoname,omitempty" doc:"the name of the ISO attached to the virtual machine"`
|
||||
MaxIops int64 `json:"maxiops,omitempty" doc:"max iops of the disk volume"`
|
||||
MinIops int64 `json:"miniops,omitempty" doc:"min iops of the disk volume"`
|
||||
Name string `json:"name,omitempty" doc:"name of the disk volume"`
|
||||
Path string `json:"path,omitempty" doc:"the path of the volume"`
|
||||
PodID *UUID `json:"podid,omitempty" doc:"ID of the pod"`
|
||||
PodName string `json:"podname,omitempty" doc:"name of the pod"`
|
||||
QuiesceVM bool `json:"quiescevm,omitempty" doc:"need quiesce vm or not when taking snapshot"`
|
||||
ServiceOfferingDisplayText string `json:"serviceofferingdisplaytext,omitempty" doc:"the display text of the service offering for root disk"`
|
||||
ServiceOfferingID *UUID `json:"serviceofferingid,omitempty" doc:"ID of the service offering for root disk"`
|
||||
ServiceOfferingName string `json:"serviceofferingname,omitempty" doc:"name of the service offering for root disk"`
|
||||
Size uint64 `json:"size,omitempty" doc:"size of the disk volume"`
|
||||
SnapshotID *UUID `json:"snapshotid,omitempty" doc:"ID of the snapshot from which this volume was created"`
|
||||
State string `json:"state,omitempty" doc:"the state of the disk volume"`
|
||||
Status string `json:"status,omitempty" doc:"the status of the volume"`
|
||||
Storage string `json:"storage,omitempty" doc:"name of the primary storage hosting the disk volume"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"id of the primary storage hosting the disk volume; returned to admin user only"`
|
||||
StorageType string `json:"storagetype,omitempty" doc:"shared or local storage"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with volume"`
|
||||
TemplateDisplayText string `json:"templatedisplaytext,omitempty" doc:"an alternate display text of the template for the virtual machine"`
|
||||
TemplateID string `json:"templateid,omitempty" doc:"the ID of the template for the virtual machine. A -1 is returned if the virtual machine was created from an ISO file."` // no *UUID because of the -1 thingy...
|
||||
TemplateName string `json:"templatename,omitempty" doc:"the name of the template for the virtual machine"`
|
||||
Type string `json:"type,omitempty" doc:"type of the disk volume (ROOT or DATADISK)"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"id of the virtual machine"`
|
||||
VMDisplayName string `json:"vmdisplayname,omitempty" doc:"display name of the virtual machine"`
|
||||
VMName string `json:"vmname,omitempty" doc:"name of the virtual machine"`
|
||||
VMState string `json:"vmstate,omitempty" doc:"state of the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"ID of the availability zone"`
|
||||
ZoneName string `json:"zonename,omitempty" doc:"name of the availability zone"`
|
||||
}
|
||||
|
||||
// ResourceType returns the type of the resource
|
||||
func (*Volume) ResourceType() string {
|
||||
func (Volume) ResourceType() string {
|
||||
return "Volume"
|
||||
}
|
||||
|
||||
// ListRequest builds the ListVolumes request
|
||||
func (vol Volume) ListRequest() (ListCommand, error) {
|
||||
req := &ListVolumes{
|
||||
Account: vol.Account,
|
||||
DomainID: vol.DomainID,
|
||||
Name: vol.Name,
|
||||
Type: vol.Type,
|
||||
VirtualMachineID: vol.VirtualMachineID,
|
||||
ZoneID: vol.ZoneID,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// ResizeVolume (Async) resizes a volume
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/resizeVolume.html
|
||||
type ResizeVolume struct {
|
||||
ID string `json:"id"`
|
||||
DiskOfferingID string `json:"diskofferingid,omitempty"`
|
||||
ShrinkOk bool `json:"shrinkok,omitempty"`
|
||||
Size int64 `json:"size,omitempty"` // in GiB
|
||||
ID *UUID `json:"id" doc:"the ID of the disk volume"`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"new disk offering id"`
|
||||
ShrinkOk *bool `json:"shrinkok,omitempty" doc:"Verify OK to Shrink"`
|
||||
Size int64 `json:"size,omitempty" doc:"New volume size in G"`
|
||||
_ bool `name:"resizeVolume" description:"Resizes a volume"`
|
||||
}
|
||||
|
||||
func (*ResizeVolume) name() string {
|
||||
return "resizeVolume"
|
||||
func (ResizeVolume) response() interface{} {
|
||||
return new(AsyncJobResult)
|
||||
}
|
||||
|
||||
func (*ResizeVolume) asyncResponse() interface{} {
|
||||
return new(ResizeVolumeResponse)
|
||||
}
|
||||
|
||||
// ResizeVolumeResponse represents the new Volume
|
||||
type ResizeVolumeResponse struct {
|
||||
Volume Volume `json:"volume"`
|
||||
func (ResizeVolume) asyncResponse() interface{} {
|
||||
return new(Volume)
|
||||
}
|
||||
|
||||
// ListVolumes represents a query listing volumes
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listVolumes.html
|
||||
type ListVolumes struct {
|
||||
Account string `json:"account,omitempty"`
|
||||
DiskOfferingID string `json:"diskoffering,omitempty"`
|
||||
DisplayVolume string `json:"displayvolume,omitempty"` // root only
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
HostID string `json:"hostid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
IsRecursive bool `json:"isrecursive,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
ListAll bool `json:"listall,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Account string `json:"account,omitempty" doc:"list resources by account. Must be used with the domainId parameter."`
|
||||
DiskOfferingID *UUID `json:"diskofferingid,omitempty" doc:"list volumes by disk offering"`
|
||||
DisplayVolume *bool `json:"displayvolume,omitempty" doc:"list resources by display flag; only ROOT admin is eligible to pass this parameter"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"list only resources belonging to the domain specified"`
|
||||
HostID *UUID `json:"hostid,omitempty" doc:"list volumes on specified host"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the disk volume"`
|
||||
IsRecursive *bool `json:"isrecursive,omitempty" doc:"defaults to false, but if true, lists all resources from the parent specified by the domainId till leaves."`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
ListAll *bool `json:"listall,omitempty" doc:"If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the disk volume"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
PodID string `json:"podid,omitempty"`
|
||||
ProjectID string `json:"projectid,omitempty"`
|
||||
StorageID string `json:"storageid,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
VirtualMachineID string `json:"virtualmachineid,omitempty"`
|
||||
ZoneID string `json:"zoneid,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListVolumes) name() string {
|
||||
return "listVolumes"
|
||||
}
|
||||
|
||||
func (*ListVolumes) response() interface{} {
|
||||
return new(ListVolumesResponse)
|
||||
PodID *UUID `json:"podid,omitempty" doc:"the pod id the disk volume belongs to"`
|
||||
StorageID *UUID `json:"storageid,omitempty" doc:"the ID of the storage pool, available to ROOT admin only"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List resources by tags (key/value pairs)"`
|
||||
Type string `json:"type,omitempty" doc:"the type of disk volume"`
|
||||
VirtualMachineID *UUID `json:"virtualmachineid,omitempty" doc:"the ID of the virtual machine"`
|
||||
ZoneID *UUID `json:"zoneid,omitempty" doc:"the ID of the availability zone"`
|
||||
_ bool `name:"listVolumes" description:"Lists all volumes."`
|
||||
}
|
||||
|
||||
// ListVolumesResponse represents a list of volumes
|
||||
|
@ -100,22 +125,30 @@ type ListVolumesResponse struct {
|
|||
Volume []Volume `json:"volume"`
|
||||
}
|
||||
|
||||
// GetRootVolumeForVirtualMachine returns the root volume of a VM
|
||||
//
|
||||
// Deprecated: helper function shouldn't be used
|
||||
func (exo *Client) GetRootVolumeForVirtualMachine(virtualMachineID string) (*Volume, error) {
|
||||
resp, err := exo.Request(&ListVolumes{
|
||||
VirtualMachineID: virtualMachineID,
|
||||
Type: "ROOT",
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r := resp.(*ListVolumesResponse)
|
||||
if r.Count != 1 {
|
||||
return nil, fmt.Errorf("Expected exactly one volume for %v, got %d", virtualMachineID, r.Count)
|
||||
}
|
||||
|
||||
return &(r.Volume[0]), nil
|
||||
func (ListVolumes) response() interface{} {
|
||||
return new(ListVolumesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListVolumes) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListVolumes) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListVolumes) each(resp interface{}, callback IterateItemFunc) {
|
||||
volumes, ok := resp.(*ListVolumesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListVolumesResponse expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range volumes.Volume {
|
||||
if !callback(&volumes.Volume[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
118
vendor/github.com/exoscale/egoscale/zones.go
generated
vendored
118
vendor/github.com/exoscale/egoscale/zones.go
generated
vendored
|
@ -1,56 +1,62 @@
|
|||
package egoscale
|
||||
|
||||
import "net"
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
// Zone represents a data center
|
||||
//
|
||||
// TODO: represent correctly the capacity field.
|
||||
type Zone struct {
|
||||
ID string `json:"id"`
|
||||
AllocationState string `json:"allocationstate,omitempty"`
|
||||
Capacity string `json:"capacity,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DhcpProvider string `json:"dhcpprovider,omitempty"`
|
||||
DisplayText string `json:"displaytext,omitempty"`
|
||||
DNS1 net.IP `json:"dns1,omitempty"`
|
||||
DNS2 net.IP `json:"dns2,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
DomainName string `json:"domainname,omitempty"`
|
||||
GuestCidrAddress string `json:"guestcidraddress,omitempty"`
|
||||
InternalDNS1 net.IP `json:"internaldns1,omitempty"`
|
||||
InternalDNS2 net.IP `json:"internaldns2,omitempty"`
|
||||
IP6DNS1 net.IP `json:"ip6dns1,omitempty"`
|
||||
IP6DNS2 net.IP `json:"ip6dns2,omitempty"`
|
||||
LocalStorageEnabled bool `json:"localstorageenabled,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NetworkType string `json:"networktype,omitempty"`
|
||||
ResourceDetails map[string]string `json:"resourcedetails,omitempty"`
|
||||
SecurityGroupsEnabled bool `json:"securitygroupsenabled,omitempty"`
|
||||
Vlan string `json:"vlan,omitempty"`
|
||||
ZoneToken string `json:"zonetoken,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
AllocationState string `json:"allocationstate,omitempty" doc:"the allocation state of the cluster"`
|
||||
Description string `json:"description,omitempty" doc:"Zone description"`
|
||||
DhcpProvider string `json:"dhcpprovider,omitempty" doc:"the dhcp Provider for the Zone"`
|
||||
DisplayText string `json:"displaytext,omitempty" doc:"the display text of the zone"`
|
||||
DNS1 net.IP `json:"dns1,omitempty" doc:"the first DNS for the Zone"`
|
||||
DNS2 net.IP `json:"dns2,omitempty" doc:"the second DNS for the Zone"`
|
||||
Domain string `json:"domain,omitempty" doc:"Network domain name for the networks in the zone"`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the UUID of the containing domain, null for public zones"`
|
||||
DomainName string `json:"domainname,omitempty" doc:"the name of the containing domain, null for public zones"`
|
||||
GuestCIDRAddress *CIDR `json:"guestcidraddress,omitempty" doc:"the guest CIDR address for the Zone"`
|
||||
ID *UUID `json:"id,omitempty" doc:"Zone id"`
|
||||
InternalDNS1 net.IP `json:"internaldns1,omitempty" doc:"the first internal DNS for the Zone"`
|
||||
InternalDNS2 net.IP `json:"internaldns2,omitempty" doc:"the second internal DNS for the Zone"`
|
||||
IP6DNS1 net.IP `json:"ip6dns1,omitempty" doc:"the first IPv6 DNS for the Zone"`
|
||||
IP6DNS2 net.IP `json:"ip6dns2,omitempty" doc:"the second IPv6 DNS for the Zone"`
|
||||
LocalStorageEnabled *bool `json:"localstorageenabled,omitempty" doc:"true if local storage offering enabled, false otherwise"`
|
||||
Name string `json:"name,omitempty" doc:"Zone name"`
|
||||
NetworkType string `json:"networktype,omitempty" doc:"the network type of the zone; can be Basic or Advanced"`
|
||||
ResourceDetails map[string]string `json:"resourcedetails,omitempty" doc:"Meta data associated with the zone (key/value pairs)"`
|
||||
SecurityGroupsEnabled *bool `json:"securitygroupsenabled,omitempty" doc:"true if security groups support is enabled, false otherwise"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"the list of resource tags associated with zone."`
|
||||
Vlan string `json:"vlan,omitempty" doc:"the vlan range of the zone"`
|
||||
ZoneToken string `json:"zonetoken,omitempty" doc:"Zone Token"`
|
||||
}
|
||||
|
||||
// ListRequest builds the ListZones request
|
||||
func (zone Zone) ListRequest() (ListCommand, error) {
|
||||
req := &ListZones{
|
||||
DomainID: zone.DomainID,
|
||||
ID: zone.ID,
|
||||
Name: zone.Name,
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// ListZones represents a query for zones
|
||||
//
|
||||
// CloudStack API: https://cloudstack.apache.org/api/apidocs-4.10/apis/listZones.html
|
||||
type ListZones struct {
|
||||
Available bool `json:"available,omitempty"`
|
||||
DomainID string `json:"domainid,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Keyword string `json:"keyword,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Available *bool `json:"available,omitempty" doc:"true if you want to retrieve all available Zones. False if you only want to return the Zones from which you have at least one VM. Default is false."`
|
||||
DomainID *UUID `json:"domainid,omitempty" doc:"the ID of the domain associated with the zone"`
|
||||
ID *UUID `json:"id,omitempty" doc:"the ID of the zone"`
|
||||
Keyword string `json:"keyword,omitempty" doc:"List by keyword"`
|
||||
Name string `json:"name,omitempty" doc:"the name of the zone"`
|
||||
Page int `json:"page,omitempty"`
|
||||
PageSize int `json:"pagesize,omitempty"`
|
||||
ShowCapacities bool `json:"showcapacities,omitempty"`
|
||||
Tags []ResourceTag `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func (*ListZones) name() string {
|
||||
return "listZones"
|
||||
}
|
||||
|
||||
func (*ListZones) response() interface{} {
|
||||
return new(ListZonesResponse)
|
||||
ShowCapacities *bool `json:"showcapacities,omitempty" doc:"flag to display the capacity of the zones"`
|
||||
Tags []ResourceTag `json:"tags,omitempty" doc:"List zones by resource tags (key/value pairs)"`
|
||||
_ bool `name:"listZones" description:"Lists zones"`
|
||||
}
|
||||
|
||||
// ListZonesResponse represents a list of zones
|
||||
|
@ -58,3 +64,31 @@ type ListZonesResponse struct {
|
|||
Count int `json:"count"`
|
||||
Zone []Zone `json:"zone"`
|
||||
}
|
||||
|
||||
func (ListZones) response() interface{} {
|
||||
return new(ListZonesResponse)
|
||||
}
|
||||
|
||||
// SetPage sets the current page
|
||||
func (ls *ListZones) SetPage(page int) {
|
||||
ls.Page = page
|
||||
}
|
||||
|
||||
// SetPageSize sets the page size
|
||||
func (ls *ListZones) SetPageSize(pageSize int) {
|
||||
ls.PageSize = pageSize
|
||||
}
|
||||
|
||||
func (ListZones) each(resp interface{}, callback IterateItemFunc) {
|
||||
zones, ok := resp.(*ListZonesResponse)
|
||||
if !ok {
|
||||
callback(nil, fmt.Errorf("wrong type. ListZonesResponse was expected, got %T", resp))
|
||||
return
|
||||
}
|
||||
|
||||
for i := range zones.Zone {
|
||||
if !callback(&zones.Zone[i], nil) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue