api

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2016 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RunStateStart = "running"
	RunStateStop  = "stopped"
	RunStatePause = "suspended"
	RunStateKill  = "halted"
	RunStateBusy  = "busy"
	RunStateReset = "reset"
)
View Source
const (
	NetworkPath   = "networks"
	InterfacePath = "interfaces"
	VpnPath       = "vpns"
)
View Source
const (
	AcceptHeaderV2 = "application/vnd.skytap.api.v2+json"
	AcceptHeaderV1 = "application/json"
	BaseUriV1      = "https://cloud.skytap.com"
	BaseUriV2      = "https://cloud.skytap.com/v2"
	MetadataUri    = "http://gw/skytap"
)
View Source
const (
	EnvironmentPath = "configurations"
)
View Source
const (
	TemplatePath = "templates"
)
View Source
const (
	VmPath = "vms"
)

Variables

This section is empty.

Functions

func DeleteEnvironment

func DeleteEnvironment(client SkytapClient, envId string) error

Delete an environment by id.

func DeleteVirtualMachine

func DeleteVirtualMachine(client SkytapClient, vmId string) error

Delete a VM.

func GetSkytapResource

func GetSkytapResource(client SkytapClient, url string, respObj interface{}) (*http.Response, error)

Return a skytap resource specified as complete GET based URL.

func IsRunningInSkytap added in v0.2.0

func IsRunningInSkytap() bool

func RunSkytapRequest

func RunSkytapRequest(client SkytapClient, useV2 bool, respJson interface{}, slingDecorator SlingDecorator) (*http.Response, error)

Runs an initial skytap API request attempt, with retries.

Returns the resulting response, or error. If no error occurs, the response json will be present in respJson.

useV2 - If true the request should use V2 API path. respJson - Interface to fill with response JSON. slingDecorator - Decorate request with specifics, set request path relative to root, add body, etc.

Types

type AttachVpnBody

type AttachVpnBody struct {
	VpnId string `json:"vpn_id"`
}

Request body for VPN attach commands.

type AttachVpnResult

type AttachVpnResult struct {
	Id        string           `json:"id"`
	Connected bool             `json:"connected"`
	Network   NetworkInterface `json:"network"`
	Vpn       interface{}      `json:"vpn"`
}

Response body for VPN attach commands.

type ConnectVpnBody

type ConnectVpnBody struct {
	Connected bool `json:"connected"`
}

Request body for VPN connect commands.

type ContainerHostQuery added in v0.3.0

type ContainerHostQuery struct {
	ContainerHost bool `url:"container_host"`
}

type CopyEnvironmentBody

type CopyEnvironmentBody struct {
	EnvironmentId string   `json:"configuration_id"`
	VmIds         []string `json:"vm_ids"`
}

Request body for copy environment commands.

type CreateEnvironmentBody

type CreateEnvironmentBody struct {
	TemplateId string `json:"template_id"`
}

Request body for create commands.

type Environment

type Environment struct {
	Id          string            `json:"id"`
	Url         string            `json:"url"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Error       []string          `json:"errors"`
	Runstate    string            `json:"runstate"`
	Vms         []*VirtualMachine `json:"vms"`
	Networks    []Network         `json:"networks"`
}

* Skytap Environment resource.

func CopyEnvironmentWithVms

func CopyEnvironmentWithVms(client SkytapClient, sourceEnvId string, vmIds []string) (*Environment, error)

Create a new environment from a source environment, including only specific VMs, which must be a part of the template.

func CreateNewEnvironment

func CreateNewEnvironment(client SkytapClient, templateId string) (*Environment, error)

Create a new environment from a template.

func CreateNewEnvironmentWithVms

func CreateNewEnvironmentWithVms(client SkytapClient, templateId string, vmIds []string) (*Environment, error)

Create a new environment from a source template, including only specific VMs, which must be a part of the template.

func GetEnvironment

func GetEnvironment(client SkytapClient, envId string) (*Environment, error)

Return an existing environment by id.

func (*Environment) AddVirtualMachine

func (e *Environment) AddVirtualMachine(client SkytapClient, vmId string) (*Environment, error)

Adds a VM to an existing environment.

func (*Environment) ChangeRunstate

func (e *Environment) ChangeRunstate(client SkytapClient, runstate string, desiredRunstate string) (*Environment, error)

Changes the runstate of the Environment to the specified state and waits until the Environment is in the desired state.

func (*Environment) MergeEnvironmentVirtualMachine

func (e *Environment) MergeEnvironmentVirtualMachine(client SkytapClient, envId string, vmId string) (*Environment, error)

Merge an environment based VM into this environment (the VM must be in an existing environment).

func (*Environment) MergeTemplateVirtualMachine

func (e *Environment) MergeTemplateVirtualMachine(client SkytapClient, templateId string, vmId string) (*Environment, error)

Merge a template based VM into this environment (the VM must be in an existing template).

func (*Environment) MergeVirtualMachine

func (e *Environment) MergeVirtualMachine(client SkytapClient, mergeBody interface{}) (*Environment, error)

Merge arbitrary VM into this environment.

mergeBody - The correct representation of the request body, see the MergeEnvironmentVirtualMachine and MergeTemplateVirtualMachine methods.

func (*Environment) Refresh

func (e *Environment) Refresh(client SkytapClient) (RunstateAwareResource, error)

func (*Environment) RunstateStr

func (e *Environment) RunstateStr() string

func (*Environment) Start

func (e *Environment) Start(client SkytapClient) (*Environment, error)

Starts an environment.

func (*Environment) Suspend

func (e *Environment) Suspend(client SkytapClient) (*Environment, error)

Suspends an environment.

func (*Environment) WaitUntilInState

func (e *Environment) WaitUntilInState(client SkytapClient, desiredStates []string, requireStateChange bool) (*Environment, error)

func (*Environment) WaitUntilReady

func (e *Environment) WaitUntilReady(client SkytapClient) (*Environment, error)

type Hardware

type Hardware struct {
	Cpus          *int `json:"cpus,omitempty"`
	CpusPerSocket *int `json:"cpus_per_socket,omitempty"`
	Ram           *int `json:"ram,omitempty"`
}

type HardwareUpdate

type HardwareUpdate struct {
	Hardware Hardware `json:"hardware"`
}

type MergeEnvironmentBody

type MergeEnvironmentBody struct {
	EnvironmentId string   `json:"merge_configuration"`
	VmIds         []string `json:"vm_ids"`
}

Request body for merge commands.

type MergeTemplateBody

type MergeTemplateBody struct {
	TemplateId string   `json:"template_id"`
	VmIds      []string `json:"vm_ids"`
}

Request body for merge commands.

type NameQuery

type NameQuery struct {
	Name string `url:"name"`
}

type NameUpdate

type NameUpdate struct {
	Hostname string `json:"hostname"`
}

type NatAddresses

type NatAddresses struct {
	VpnNatAddresses     []VpnNatAddress     `json:"vpn_nat_addresses"`
	NetworkNatAddresses []NetworkNatAddress `json:"network_nat_addresses"`
}

Nat addresses stored inside network interface.

type Network

type Network struct {
	Id                  string          `json:"id"`
	Url                 string          `json:"url"`
	Name                string          `json:"name"`
	Subnet              string          `json:"subnet"`
	Domain              string          `json:"domain"`
	Gateway             string          `json:"gateway"`
	NetworkType         string          `json:"network_type"`
	Tunnelable          bool            `json:"tunnelable"`
	Tunnels             interface{}     `json:"tunnels"`
	PrimaryNameserver   string          `json:"primary_nameserver"`
	SecondaryNameserver string          `json:"secondary_nameserver"`
	Region              string          `json:"region"`
	NatSubnet           string          `json:"nat_subnet"`
	NatPoolSize         int             `json:"nat_pool_size"`
	NatPoolRemaining    int             `json:"nat_pool_remaining"`
	VpnAttachments      []VpnAttachment `json:"vpn_attachments"`
}

Network resource.

func (*Network) AttachToVpn

func (n *Network) AttachToVpn(client SkytapClient, envId string, vpnId string) (*AttachVpnResult, error)

Attach a network to a VPN, in the context of the given environment.

func (*Network) ChangeConnectionToVpn

func (n *Network) ChangeConnectionToVpn(client SkytapClient, envId string, vpnId string, connected bool) error

General method for manipulating VPN connection state.

func (*Network) ConnectToVpn

func (n *Network) ConnectToVpn(client SkytapClient, envId string, vpnId string) error

Connect to a given VPN in the context of a given environment.

func (*Network) DetachFromVpn

func (n *Network) DetachFromVpn(client SkytapClient, envId string, vpnId string) error

Detach a network from a VPN in the context of the given environment.

func (*Network) DisconnectFromVpn

func (n *Network) DisconnectFromVpn(client SkytapClient, envId string, vpnId string) error

Disconnect an environment's network from a VPN.

type NetworkInterface

type NetworkInterface struct {
	Id              string       `json:"id"`
	Ip              string       `json:"ip"`
	PublicIpsCount  int          `json:"public_ips_count"`
	Hostname        string       `json:"hostname"`
	PublicIps       []PublicIp   `json:"public_ips"`
	NatAddresses    NatAddresses `json:"nat_addresses"`
	Status          string       `json:"status"`
	ExternalAddress string       `json:"external_address"`
}

Network interface inside a VM.

type NetworkNatAddress

type NetworkNatAddress struct {
	IpAddress        string `json:"ip_address"`
	NetworkId        string `json:"network_id"`
	NetworkName      string `json:"network_name"`
	NetworkUrl       string `json:"network_url"`
	ConfigurationId  string `json:"configuration_id"`
	ConfigurationUrl string `json:"configuration_url"`
}

Network based NAT address.

type PublicIp

type PublicIp struct {
	Id      string      `json:"id"`
	Address string      `json:"address"`
	Region  string      `json:"region"`
	Nics    interface{} `json:"nics"`
	VpnId   string      `json:"vpn_id"`
}

IP type.

type RunstateAwareResource

type RunstateAwareResource interface {
	//
	RunstateStr() string
	// Should fetch a fresh representation of the resource and return the current runstate, or error
	Refresh(client SkytapClient) (RunstateAwareResource, error)
}

A runstate aware resource has a runstate in its representation, which can be used when waiting for a specific state.

func WaitUntilInState

func WaitUntilInState(client SkytapClient, desiredStates []string, r RunstateAwareResource, requireStateChange bool) (RunstateAwareResource, error)

Wait until the given resource is in one of the desired states.

If the resource reaches the desired state, a recently fetched representation is returned. Otherwise an error is returned, along with the result of the last attempt.

If requireStateChange is set, a transition must occur. The function will wait until the state changes or timeout.

type RunstateBody

type RunstateBody struct {
	Runstate string `json:"runstate"`
}

Some skytap resources have a runstate in response, use this for monitoring.

type SkytapApiError

type SkytapApiError struct {
	Error string `json:error`
}

General skytap json error response.

type SkytapClient

type SkytapClient struct {
	HttpClient  *http.Client
	Credentials SkytapCredentials
}

Skytap client object, needed for all REST calls.

func NewSkytapClient

func NewSkytapClient(username string, apiKey string) *SkytapClient

Create a new client from username and key.

func NewSkytapClientFromCredentials

func NewSkytapClientFromCredentials(credentials SkytapCredentials) *SkytapClient

Create a new client from credentials

type SkytapCredentials

type SkytapCredentials struct {
	Username string
	ApiKey   string
}

Credentials for accessing skytap REST API.

type SkytapMetadata added in v0.2.0

type SkytapMetadata struct {
	Id string `json:"id"`
}

Skytap metadata service response.

type SlingDecorator

type SlingDecorator func(*sling.Sling) *sling.Sling

Request methods use this to create/customize the requests.

type Template

type Template struct {
	Id     string `json:"id"`
	Url    string `json:"url"`
	Name   string `json:"name"`
	Region string `json:"region"`
}

Skytap template resource.

type VirtualMachine

type VirtualMachine struct {
	Id             string              `json:"id"`
	Name           string              `json:"name"`
	Runstate       string              `json:"runstate"`
	Error          interface{}         `json:"error"`
	TemplateUrl    string              `json:"template_url,omitempty"`
	EnvironmentUrl string              `json:"configuration_url,omitempty"`
	Interfaces     []*NetworkInterface `json:"interfaces`
	Hardware       Hardware            `json:"hardware"`
}

Skytap VM resource.

func GetVirtualMachine

func GetVirtualMachine(client SkytapClient, vmId string) (*VirtualMachine, error)

Get a VM without reference to environment or template. The result object should contain information on its source.

func GetVirtualMachineInEnvironment

func GetVirtualMachineInEnvironment(client SkytapClient, envId string, vmId string) (*VirtualMachine, error)
Get a VM from an existing environment.

TODO see if we can trap the JSON unmarshall error

func GetVirtualMachineInTemplate

func GetVirtualMachineInTemplate(client SkytapClient, templateId string, vmId string) (*VirtualMachine, error)

Get a VM from an existing template.

func (*VirtualMachine) ChangeAttribute

func (vm *VirtualMachine) ChangeAttribute(client SkytapClient, queryStruct interface{}) (*VirtualMachine, error)

func (*VirtualMachine) ChangeRunstate

func (vm *VirtualMachine) ChangeRunstate(client SkytapClient, runstate string, desiredRunstates ...string) (*VirtualMachine, error)

Changes the runstate of the VM to the specified state and waits until the VM is in the desired state.

func (*VirtualMachine) GetCredentials

func (vm *VirtualMachine) GetCredentials(client SkytapClient) ([]VmCredential, error)

func (*VirtualMachine) GetEnvironment

func (vm *VirtualMachine) GetEnvironment(client SkytapClient) (*Environment, error)

If a VM is in an environment, returns the environment, otherwise nil.

func (*VirtualMachine) GetTemplate

func (vm *VirtualMachine) GetTemplate(client SkytapClient) (*Template, error)

If VM is in a template, returns the template, otherwise nil.

func (*VirtualMachine) Kill

func (vm *VirtualMachine) Kill(client SkytapClient) (*VirtualMachine, error)

Kills a VM forcefully.

func (*VirtualMachine) Refresh

func (vm *VirtualMachine) Refresh(client SkytapClient) (RunstateAwareResource, error)

Fetch fresh representation.

func (*VirtualMachine) RenameNetworkInterface

func (vm *VirtualMachine) RenameNetworkInterface(client SkytapClient, envId string, interfaceId string, name string) (*NetworkInterface, error)

func (*VirtualMachine) RunstateStr

func (vm *VirtualMachine) RunstateStr() string

func (*VirtualMachine) SetContainerHost added in v0.3.0

func (vm *VirtualMachine) SetContainerHost(client SkytapClient) (*VirtualMachine, error)

func (*VirtualMachine) SetName

func (vm *VirtualMachine) SetName(client SkytapClient, name string) (*VirtualMachine, error)

func (*VirtualMachine) Start

func (vm *VirtualMachine) Start(client SkytapClient) (*VirtualMachine, error)

Starts a VM.

func (*VirtualMachine) Stop

func (vm *VirtualMachine) Stop(client SkytapClient) (*VirtualMachine, error)

Stops a VM. Note that some VMs may require user input and cannot be stopped with the method.

func (*VirtualMachine) Suspend

func (vm *VirtualMachine) Suspend(client SkytapClient) (*VirtualMachine, error)

Suspends a VM.

func (*VirtualMachine) UpdateHardware

func (vm *VirtualMachine) UpdateHardware(client SkytapClient, hardware Hardware, restartVm bool) (*VirtualMachine, error)

func (*VirtualMachine) WaitUntilInState

func (vm *VirtualMachine) WaitUntilInState(client SkytapClient, desiredStates []string, requireStateChange bool) (*VirtualMachine, error)

Wait until the VM is in one of the desired states.

func (*VirtualMachine) WaitUntilReady

func (vm *VirtualMachine) WaitUntilReady(client SkytapClient) (*VirtualMachine, error)

Waits until VM is either stopped or started.

type VmCredential

type VmCredential struct {
	Id   string `json:"id"`
	Text string `json:"text"`
}

func (*VmCredential) Password

func (c *VmCredential) Password() (string, error)

func (*VmCredential) Username

func (c *VmCredential) Username() (string, error)

type Vpn

type Vpn struct {
	Id            string `json:"id"`
	Name          string `json:"name"`
	Enabled       bool   `json:"enabled"`
	NatEnabled    bool   `json:"nat_enabled"`
	RemoteSubnets string `json:"remote_subnets"`
	RemotePeerIp  string `json:"remote_subnets"`
	CanReconnect  bool   `json:"can_reconnect"`
}

func GetVpn added in v0.2.0

func GetVpn(client SkytapClient, vpnId string) (*Vpn, error)

Return an existing VPN by id.

type VpnAttachment

type VpnAttachment struct {
	Id        string `json:"id"`
	Connected bool   `json:"connected"`
	Vpn       Vpn    `json:"vpn"`
}

VPN attachments to network.

type VpnNatAddress

type VpnNatAddress struct {
	IpAddress string `json:"ip_address"`
	VpnId     string `json:"vpn_id"`
	VpnName   string `json:"vpn_name"`
	VpnUrl    string `json:"vpn_url"`
}

VPN based NAT address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL