Documentation ¶
Index ¶
- Constants
- type AvailabilityZone
- type AvailabilityZoneState
- type BlockDeviceMapping
- type Client
- func (c *Client) AddServerFloatingIP(serverId, address string) error
- func (c *Client) AddServerSecurityGroup(serverId, groupName string) error
- func (c *Client) AllocateFloatingIP() (*FloatingIP, error)
- func (c *Client) AttachVolume(serverId, volumeId, device string) (*VolumeAttachment, error)
- func (c *Client) CreateSecurityGroup(name, description string) (*SecurityGroup, error)
- func (c *Client) CreateSecurityGroupRule(ruleInfo RuleInfo) (*SecurityGroupRule, error)
- func (c *Client) DeleteFloatingIP(ipId string) error
- func (c *Client) DeleteSecurityGroup(groupId string) error
- func (c *Client) DeleteSecurityGroupRule(ruleId string) error
- func (c *Client) DeleteServer(serverId string) error
- func (c *Client) DetachVolume(serverId, attachmentId string) error
- func (c *Client) GetFloatingIP(ipId string) (*FloatingIP, error)
- func (c *Client) GetServer(serverId string) (*ServerDetail, error)
- func (c *Client) GetServerSecurityGroups(serverId string) ([]SecurityGroup, error)
- func (c *Client) ListAvailabilityZones() ([]AvailabilityZone, error)
- func (c *Client) ListFlavors() ([]Entity, error)
- func (c *Client) ListFlavorsDetail() ([]FlavorDetail, error)
- func (c *Client) ListFloatingIPs() ([]FloatingIP, error)
- func (c *Client) ListNetworks() ([]Network, error)
- func (c *Client) ListOSInterfaces(serverId string) ([]OSInterface, error)
- func (c *Client) ListSecurityGroups() ([]SecurityGroup, error)
- func (c *Client) ListServers(filter *Filter) ([]Entity, error)
- func (c *Client) ListServersDetail(filter *Filter) ([]ServerDetail, error)
- func (c *Client) ListVolumeAttachments(serverId string) ([]VolumeAttachment, error)
- func (c *Client) RemoveServerFloatingIP(serverId, address string) error
- func (c *Client) RemoveServerSecurityGroup(serverId, groupName string) error
- func (c *Client) RunServer(opts RunServerOpts) (*Entity, error)
- func (c *Client) SecurityGroupByName(name string) (*SecurityGroup, error)
- func (c *Client) SetServerMetadata(serverId string, metadata map[string]string) error
- func (c *Client) UpdateSecurityGroup(groupId, name, description string) (*SecurityGroup, error)
- func (c *Client) UpdateServerName(serverID, name string) (*Entity, error)
- type Entity
- type EntitySortBy
- type Filter
- type FlavorDetail
- type FlavorDetailSortBy
- type FloatingIP
- type IPAddress
- type Link
- type Network
- type OSInterface
- type PortFixedIP
- type RuleInfo
- type RunServerOpts
- type SecurityGroup
- type SecurityGroupName
- type SecurityGroupRef
- type SecurityGroupRule
- type ServerDetail
- type ServerFault
- type ServerNetworks
- type VolumeAttachment
Constants ¶
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.
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 BlockDeviceMapping ¶
type BlockDeviceMapping struct { BootIndex int `json:"boot_index"` UUID string `json:"uuid,omitempty"` SourceType string `json:"source_type,omitempty"` DestinationType string `json:"destination_type,omitempty"` VolumeSize int `json:"volume_size,omitempty"` VolumeType string `json:"volume_type,omitempty"` DeleteOnTermination bool `json:"delete_on_termination,omitempty"` DeviceName string `json:"device_name,omitempty"` DeviceType string `json:"device_type,omitempty"` DiskBus string `json:"disk_bus,omitempty"` GuestFormat string `json:"guest_format,omitempty"` NoDevice bool `json:"no_device,omitempty"` Tag string `json:"tag,omitempty"` }
BlockDeviceMapping defines block devices to be attached to the Server created by RunServer(). See: https://developer.openstack.org/api-ref/compute/?expanded=create-server-detail
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a means to access the OpenStack Compute Service.
func (*Client) AddServerFloatingIP ¶
AddServerFloatingIP assigns a floating IP address to the specified server.
func (*Client) AddServerSecurityGroup ¶
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 ¶
DeleteFloatingIP deallocates the floating IP address associated with the specified id.
func (*Client) DeleteSecurityGroup ¶
DeleteSecurityGroup deletes the specified security group.
func (*Client) DeleteSecurityGroupRule ¶
DeleteSecurityGroupRule deletes the specified security group rule.
func (*Client) DeleteServer ¶
DeleteServer terminates the specified server.
func (*Client) DetachVolume ¶
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 ¶
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 ¶
ListNetworks gives details on available networks
func (*Client) ListOSInterfaces ¶
func (c *Client) ListOSInterfaces(serverId string) ([]OSInterface, error)
ListOSInterfaces lists all the os-interfaces (port interfaces) associated with a given server. https://docs.openstack.org/api-ref/compute/?expanded=list-port-interfaces-detail
func (*Client) ListSecurityGroups ¶
func (c *Client) ListSecurityGroups() ([]SecurityGroup, error)
ListSecurityGroups lists IDs, names, and other details for all security groups.
func (*Client) ListServers ¶
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 ¶
RemoveServerFloatingIP removes a floating IP address from the specified server.
func (*Client) RemoveServerSecurityGroup ¶
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)
SecurityGroupByName 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 ¶
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.
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) UnmarshalJSON ¶
type EntitySortBy ¶
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)
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 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 OSInterface ¶
type OSInterface struct { FixedIPs []PortFixedIP `json:"fixed_ips,omitempty"` IPAddress string `json:"ip_address"` MacAddress string `json:"mac_addr,omitempty"` NetID string `json:"net_id,omitempty"` PortID string `json:"port_id,omitempty"` PortState string `json:"port_state,omitempty"` Tag string `json:"tag,omitempty"` }
OSInterface represents an interface attachment to a server.
type PortFixedIP ¶
PortFixedIP represents a FixedIP with ip addresses and an associated subnet id.
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 specified 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 specified, 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:
- Ingress rules - specified directly with any valid subnet mask in CIDR format (e.g. "192.168.0.0/16");
- 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) UnmarshalJSON ¶
type RunServerOpts ¶
type RunServerOpts struct { Name string `json:"name"` // Required FlavorId string `json:"flavorRef"` // Required ImageId string `json:"imageRef,omitempty"` // Optional UserData []byte `json:"user_data,omitempty"` // Optional SecurityGroupNames []SecurityGroupName `json:"security_groups,omitempty"` // 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 BlockDeviceMappings []BlockDeviceMapping `json:"block_device_mapping_v2,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 ¶
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 `json:"hostId"` Id string `json:"-"` UUID string Image Entity Links []Link Name string Metadata map[string]string Groups *[]SecurityGroupName `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 // Only returned if status is Error Fault *ServerFault `json:"fault"` 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 ServerFault ¶
type ServerFault struct { Code int `json:"code"` // Response code Created string `json:"created"` Message string `json:"message"` Details string `json:"details,omitempty"` }
ServerFault describes a single server fault. Details (stack trace) are available for those with administrator privileges.
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.