1
0
Fork 0

Update Lego

This commit is contained in:
Ludovic Fernandez 2018-09-14 10:06:03 +02:00 committed by Traefiker Bot
parent 36966da701
commit 253060b4f3
185 changed files with 16653 additions and 3210 deletions

View file

@ -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)
}