nova

package
v1.0.0-...-3228e4f Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: LGPL-3.0 Imports: 9 Imported by: 9

Documentation

Index

Constants

View Source
const (
	StatusActive        = "ACTIVE"          // The server is active.
	StatusBuild         = "BUILD"           // The server has not finished the original build process.
	StatusBuildSpawning = "BUILD(spawning)" // The server has not finished the original build process but networking works (HP Cloud specific)
	StatusDeleted       = "DELETED"         // The server is deleted.
	StatusError         = "ERROR"           // The server is in error.
	StatusHardReboot    = "HARD_REBOOT"     // The server is hard rebooting.
	StatusPassword      = "PASSWORD"        // The password is being reset on the server.
	StatusReboot        = "REBOOT"          // The server is in a soft reboot state.
	StatusRebuild       = "REBUILD"         // The server is currently being rebuilt from an image.
	StatusRescue        = "RESCUE"          // The server is in rescue mode.
	StatusResize        = "RESIZE"          // Server is performing the differential copy of data that changed during its initial copy.
	StatusShutoff       = "SHUTOFF"         // The virtual machine (VM) was powered down by the user, but not through the OpenStack Compute API.
	StatusSuspended     = "SUSPENDED"       // The server is suspended, either by request or necessity.
	StatusUnknown       = "UNKNOWN"         // The state of the server is unknown. Contact your cloud provider.
	StatusVerifyResize  = "VERIFY_RESIZE"   // System is awaiting confirmation that the server is operational after a move or resize.
)

Server status values.

View Source
const (
	FilterStatus       = "status"        // The server status. See Server Status Values.
	FilterImage        = "image"         // The image reference specified as an ID or full URL.
	FilterFlavor       = "flavor"        // The flavor reference specified as an ID or full URL.
	FilterServer       = "name"          // The server name.
	FilterMarker       = "marker"        // The ID of the last item in the previous list.
	FilterLimit        = "limit"         // The page size.
	FilterChangesSince = "changes-since" // The changes-since time. The list contains servers that have been deleted since the changes-since time.
)

Filter keys.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityZone

type AvailabilityZone struct {
	Name  string                `json:"zoneName"`
	State AvailabilityZoneState `json:"zoneState"`
}

AvailabilityZone identifies an availability zone, and describes its state.

type AvailabilityZoneState

type AvailabilityZoneState struct {
	Available bool
}

AvailabilityZoneState describes an availability zone's state.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a means to access the OpenStack Compute Service.

func New

func New(client client.Client) *Client

New creates a new Client.

func (*Client) AddServerFloatingIP

func (c *Client) AddServerFloatingIP(serverId, address string) error

AddServerFloatingIP assigns a floating IP address to the specified server.

func (*Client) AddServerSecurityGroup

func (c *Client) AddServerSecurityGroup(serverId, groupName string) error

AddServerSecurityGroup adds a security group to the specified server.

func (*Client) AllocateFloatingIP

func (c *Client) AllocateFloatingIP() (*FloatingIP, error)

AllocateFloatingIP allocates a new floating IP address to a tenant or account.

func (*Client) AttachVolume

func (c *Client) AttachVolume(serverId, volumeId, device string) (*VolumeAttachment, error)

AttachVolume attaches the given volumeId to the given serverId at mount point specified in device. Note that the server must support the os-volume_attachments attachment; if it does not, an error will be returned stating such.

func (*Client) CreateSecurityGroup

func (c *Client) CreateSecurityGroup(name, description string) (*SecurityGroup, error)

CreateSecurityGroup creates a new security group.

func (*Client) CreateSecurityGroupRule

func (c *Client) CreateSecurityGroupRule(ruleInfo RuleInfo) (*SecurityGroupRule, error)

CreateSecurityGroupRule creates a security group rule. It can either be an ingress rule or group rule (see the description of RuleInfo).

func (*Client) DeleteFloatingIP

func (c *Client) DeleteFloatingIP(ipId string) error

DeleteFloatingIP deallocates the floating IP address associated with the specified id.

func (*Client) DeleteSecurityGroup

func (c *Client) DeleteSecurityGroup(groupId string) error

DeleteSecurityGroup deletes the specified security group.

func (*Client) DeleteSecurityGroupRule

func (c *Client) DeleteSecurityGroupRule(ruleId string) error

DeleteSecurityGroupRule deletes the specified security group rule.

func (*Client) DeleteServer

func (c *Client) DeleteServer(serverId string) error

DeleteServer terminates the specified server.

func (*Client) DetachVolume

func (c *Client) DetachVolume(serverId, attachmentId string) error

DetachVolume detaches the volume with the given attachmentId from the server with the given serverId.

func (*Client) GetFloatingIP

func (c *Client) GetFloatingIP(ipId string) (*FloatingIP, error)

GetFloatingIP lists details of the floating IP address associated with specified id.

func (*Client) GetServer

func (c *Client) GetServer(serverId string) (*ServerDetail, error)

GetServer lists details for the specified server.

func (*Client) GetServerSecurityGroups

func (c *Client) GetServerSecurityGroups(serverId string) ([]SecurityGroup, error)

GetServerSecurityGroups list security groups for a specific server.

func (*Client) ListAvailabilityZones

func (c *Client) ListAvailabilityZones() ([]AvailabilityZone, error)

ListAvailabilityZones lists all availability zones.

Availability zones are an OpenStack extension; if the server does not support them, then an error satisfying errors.IsNotImplemented will be returned.

func (*Client) ListFlavors

func (c *Client) ListFlavors() ([]Entity, error)

ListFlavours lists IDs, names, and links for available flavors.

func (*Client) ListFlavorsDetail

func (c *Client) ListFlavorsDetail() ([]FlavorDetail, error)

ListFlavorsDetail lists all details for available flavors.

func (*Client) ListFloatingIPs

func (c *Client) ListFloatingIPs() ([]FloatingIP, error)

ListFloatingIPs lists floating IP addresses associated with the tenant or account.

func (*Client) ListNetworks

func (c *Client) ListNetworks() ([]Network, error)

ListNetworks gives details on available networks

func (*Client) ListSecurityGroups

func (c *Client) ListSecurityGroups() ([]SecurityGroup, error)

ListSecurityGroups lists IDs, names, and other details for all security groups.

func (*Client) ListServers

func (c *Client) ListServers(filter *Filter) ([]Entity, error)

ListServers lists IDs, names, and links for all servers.

func (*Client) ListServersDetail

func (c *Client) ListServersDetail(filter *Filter) ([]ServerDetail, error)

ListServersDetail lists all details for available servers.

func (*Client) ListVolumeAttachments

func (c *Client) ListVolumeAttachments(serverId string) ([]VolumeAttachment, error)

ListVolumeAttachments lists the volumes currently attached to the server with the given serverId.

func (*Client) RemoveServerFloatingIP

func (c *Client) RemoveServerFloatingIP(serverId, address string) error

RemoveServerFloatingIP removes a floating IP address from the specified server.

func (*Client) RemoveServerSecurityGroup

func (c *Client) RemoveServerSecurityGroup(serverId, groupName string) error

RemoveServerSecurityGroup removes a security group from the specified server.

func (*Client) RunServer

func (c *Client) RunServer(opts RunServerOpts) (*Entity, error)

RunServer creates a new server, based on the given RunServerOpts.

func (*Client) SecurityGroupByName

func (c *Client) SecurityGroupByName(name string) (*SecurityGroup, error)

GetSecurityGroupByName returns the named security group. Note: due to lack of filtering support when querying security groups, this is not an efficient implementation but it's all we can do for now.

func (*Client) SetServerMetadata

func (c *Client) SetServerMetadata(serverId string, metadata map[string]string) error

SetServerMetadata sets metadata on a server. Replaces metadata items that match keys - doesn't modify items that aren't in the request. See https://developer.openstack.org/api-ref/compute/?expanded=update-metadata-items-detail#update-metadata-items

func (*Client) UpdateSecurityGroup

func (c *Client) UpdateSecurityGroup(groupId, name, description string) (*SecurityGroup, error)

UpdateSecurityGroup updates the name and description of the given group.

func (*Client) UpdateServerName

func (c *Client) UpdateServerName(serverID, name string) (*Entity, error)

UpdateServerName updates the name of the given server.

type Entity

type Entity struct {
	Id    string `json:"-"`
	UUID  string `json:"uuid"`
	Links []Link `json:"links"`
	Name  string `json:"name"`
}

Entity describe a basic information about a flavor or server.

func (Entity) MarshalJSON

func (entity Entity) MarshalJSON() ([]byte, error)

func (*Entity) UnmarshalJSON

func (entity *Entity) UnmarshalJSON(b []byte) error

type EntitySortBy

type EntitySortBy struct {
	Attr     string
	Entities []Entity
}

Allow Entity slices to be sorted by named attribute.

func (EntitySortBy) Len

func (e EntitySortBy) Len() int

func (EntitySortBy) Less

func (e EntitySortBy) Less(i, j int) bool

func (EntitySortBy) Swap

func (e EntitySortBy) Swap(i, j int)

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

---------------------------------------------------------------------------- Filtering helper.

Filter builds filtering parameters to be used in an OpenStack query which supports filtering. For example:

filter := NewFilter()
filter.Set(nova.FilterServer, "server_name")
filter.Set(nova.FilterStatus, nova.StatusBuild)
resp, err := nova.ListServers(filter)

func NewFilter

func NewFilter() *Filter

NewFilter creates a new Filter.

func (*Filter) Set

func (f *Filter) Set(filter, value string)

type FlavorDetail

type FlavorDetail struct {
	Name  string
	RAM   int    // Available RAM, in MB
	VCPUs int    // Number of virtual CPU (cores)
	Disk  int    // Available root partition space, in GB
	Id    string `json:"-"`
	Links []Link
}

FlavorDetail describes detailed information about a flavor.

func (FlavorDetail) MarshalJSON

func (flavorDetail FlavorDetail) MarshalJSON() ([]byte, error)

func (*FlavorDetail) UnmarshalJSON

func (flavorDetail *FlavorDetail) UnmarshalJSON(b []byte) error

type FlavorDetailSortBy

type FlavorDetailSortBy struct {
	Attr          string
	FlavorDetails []FlavorDetail
}

Allow FlavorDetail slices to be sorted by named attribute.

func (FlavorDetailSortBy) Len

func (e FlavorDetailSortBy) Len() int

func (FlavorDetailSortBy) Less

func (e FlavorDetailSortBy) Less(i, j int) bool

func (FlavorDetailSortBy) Swap

func (e FlavorDetailSortBy) Swap(i, j int)

type FloatingIP

type FloatingIP struct {
	// FixedIP holds the private IP address of the machine (when assigned)
	FixedIP *string `json:"fixed_ip"`
	Id      string  `json:"-"`
	// InstanceId holds the instance id of the machine, if this FIP is assigned to one
	InstanceId *string `json:"-"`
	IP         string  `json:"ip"`
	Pool       string  `json:"pool"`
}

FloatingIP describes a floating (public) IP address, which can be assigned to a server, thus allowing connections from outside.

func (FloatingIP) MarshalJSON

func (floatingIP FloatingIP) MarshalJSON() ([]byte, error)

func (*FloatingIP) UnmarshalJSON

func (floatingIP *FloatingIP) UnmarshalJSON(b []byte) error

type IPAddress

type IPAddress struct {
	Version int    `json:"version"`
	Address string `json:"addr"`
	Type    string `json:"OS-EXT-IPS:type"` // fixed or floating
}

IPAddress describes a single IPv4/6 address of a server.

type Link struct {
	Href string
	Rel  string
	Type string
}

Link describes a link to a flavor or server.

type Network

type Network struct {
	Id    string `json:"id"`    // UUID of the resource
	Label string `json:"label"` // User-provided name for the network range
	Cidr  string `json:"cidr"`  // IP range covered by the network
}

Network contains details about a labeled network

type RuleInfo

type RuleInfo struct {
	/// IPProtocol is optional, and if specified must be "tcp", "udp" or
	//  "icmp" (in this case, both FromPort and ToPort can be -1).
	IPProtocol string `json:"ip_protocol"`

	// FromPort and ToPort are both optional, and if specifed must be
	// integers between 1 and 65535 (valid TCP port numbers). -1 is a
	// special value, meaning "use default" (e.g. for ICMP).
	FromPort int `json:"from_port"`
	ToPort   int `json:"to_port"`

	// Cidr cannot be specified with GroupId. Ingress rules need a valid
	// subnet mast in CIDR format here, while if GroupID is specifed, it
	// means you're adding a group rule, specifying source group ID, which
	// must exist already and can be equal to ParentGroupId).
	// need Cidr, while
	Cidr    string  `json:"cidr"`
	GroupId *string `json:"-"`

	// ParentGroupId is always required and specifies the group to which
	// the rule is added.
	ParentGroupId string `json:"-"`
}

RuleInfo allows the callers of CreateSecurityGroupRule() to create 2 types of security group rules: ingress rules and group rules. The difference stems from how the "source" is defined. It can be either:

  1. Ingress rules - specified directly with any valid subnet mask in CIDR format (e.g. "192.168.0.0/16");
  2. Group rules - specified indirectly by giving a source group,

which can be any user's group (different tenant ID).

Every rule works as an iptables ACCEPT rule, thus a group/ with no rules does not allow ingress at all. Rules can be added and removed while the server(s) are running. The set of security groups that apply to a server is changed only when the server is started. Adding or removing a security group on a running server will not take effect until that server is restarted. However, changing rules of existing groups will take effect immediately.

For more information: http://docs.openstack.org/developer/nova/nova.concepts.html#concept-security-groups Nova source: https://github.com/openstack/nova.git

func (RuleInfo) MarshalJSON

func (ruleInfo RuleInfo) MarshalJSON() ([]byte, error)

func (*RuleInfo) UnmarshalJSON

func (ruleInfo *RuleInfo) UnmarshalJSON(b []byte) error

type RunServerOpts

type RunServerOpts struct {
	Name               string              `json:"name"`                        // Required
	FlavorId           string              `json:"flavorRef"`                   // Required
	ImageId            string              `json:"imageRef"`                    // Required
	UserData           []byte              `json:"user_data"`                   // Optional
	SecurityGroupNames []SecurityGroupName `json:"security_groups"`             // Optional
	Networks           []ServerNetworks    `json:"networks"`                    // Optional
	AvailabilityZone   string              `json:"availability_zone,omitempty"` // Optional
	Metadata           map[string]string   `json:"metadata,omitempty"`          // Optional
	ConfigDrive        bool                `json:"config_drive,omitempty"`      // Optional
}

RunServerOpts defines required and optional arguments for RunServer().

type SecurityGroup

type SecurityGroup struct {
	Rules       []SecurityGroupRule
	TenantId    string `json:"tenant_id"`
	Id          string `json:"-"`
	Name        string
	Description string
}

SecurityGroup describes a single security group in OpenStack.

func (SecurityGroup) MarshalJSON

func (securityGroup SecurityGroup) MarshalJSON() ([]byte, error)

func (*SecurityGroup) UnmarshalJSON

func (securityGroup *SecurityGroup) UnmarshalJSON(b []byte) error

type SecurityGroupName

type SecurityGroupName struct {
	Name string `json:"name"`
}

type SecurityGroupRef

type SecurityGroupRef struct {
	TenantId string `json:"tenant_id"`
	Name     string `json:"name"`
}

SecurityGroupRef refers to an existing named security group

type SecurityGroupRule

type SecurityGroupRule struct {
	FromPort      *int              `json:"from_port"`   // Can be nil
	IPProtocol    *string           `json:"ip_protocol"` // Can be nil
	ToPort        *int              `json:"to_port"`     // Can be nil
	ParentGroupId string            `json:"-"`
	IPRange       map[string]string `json:"ip_range"` // Can be empty
	Id            string            `json:"-"`
	Group         SecurityGroupRef
}

SecurityGroupRule describes a rule of a security group. There are 2 basic rule types: ingress and group rules (see RuleInfo struct).

func (SecurityGroupRule) MarshalJSON

func (securityGroupRule SecurityGroupRule) MarshalJSON() ([]byte, error)

func (*SecurityGroupRule) UnmarshalJSON

func (securityGroupRule *SecurityGroupRule) UnmarshalJSON(b []byte) error

type ServerDetail

type ServerDetail struct {
	// AddressIPv4 and AddressIPv6 hold the first public IPv4 or IPv6
	// address of the server, or "" if no floating IP is assigned.
	AddressIPv4 string
	AddressIPv6 string

	// Addresses holds the list of all IP addresses assigned to this
	// server, grouped by "network" name ("public", "private" or a
	// custom name).
	Addresses map[string][]IPAddress

	// Created holds the creation timestamp of the server
	// in RFC3339 format.
	Created string

	Flavor   Entity
	HostId   string
	Id       string `json:"-"`
	UUID     string
	Image    Entity
	Links    []Link
	Name     string
	Metadata map[string]string

	// HP Cloud returns security groups in server details.
	Groups []Entity `json:"security_groups"`

	// Progress holds the completion percentage of
	// the current operation
	Progress int

	// Status holds the current status of the server,
	// one of the Status* constants.
	Status string

	TenantId string `json:"tenant_id"`

	// Updated holds the timestamp of the last update
	// to the server in RFC3339 format.
	Updated string

	UserId string `json:"user_id"`

	AvailabilityZone string `json:"OS-EXT-AZ:availability_zone"`
}

ServerDetail describes a server in more detail. See: http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html#ServersCBSJ

func (ServerDetail) MarshalJSON

func (serverDetail ServerDetail) MarshalJSON() ([]byte, error)

func (*ServerDetail) UnmarshalJSON

func (serverDetail *ServerDetail) UnmarshalJSON(b []byte) error

type ServerNetworks

type ServerNetworks struct {
	NetworkId string `json:"uuid,omitempty"`
	FixedIp   string `json:"fixed_ip,omitempty"`
	PortId    string `json:"port,omitempty"`
}

ServerNetworks sets what networks a server should be connected to on boot. - FixedIp may be supplied only when NetworkId is also given. - PortId may be supplied only if neither NetworkId or FixedIp is set.

type VolumeAttachment

type VolumeAttachment struct {
	Device   *string `json:"device,omitempty"`
	Id       string  `json:"id,omitempty"`
	ServerId string  `json:"serverId,omitempty"`
	VolumeId string  `json:"volumeId"`
}

VolumeAttachment represents both the request and response for attaching volumes.

Jump to

Keyboard shortcuts

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