brain

package
v3.0.0-...-c77a060 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterAdminPrivilege allows a user to administer the cluster managed by the brain, and do things like create/delete VMs on accounts they have no explicit right on, grant others AccountAdminPrivilege, and set disc iops_limit
	ClusterAdminPrivilege PrivilegeLevel = "cluster_admin"
	// AccountAdminPrivilege allows a user to create, modify & delete groups and servers in an account.
	AccountAdminPrivilege = "account_admin"
	// GroupAdminPrivilege allows a user to create, modify & delete servers in a specific group.
	GroupAdminPrivilege = "group_admin"
	// VMAdminPrivilege allows a user to modify & administer a server, including increasing the performance (and hence the price on the uk0 cluster) and accessing the console.
	VMAdminPrivilege = "vm_admin"
	// VMConsolePrivilege allows a user to access the console for a particular server.
	VMConsolePrivilege = "vm_console"
)
View Source
const (
	// PrivilegeTargetTypeVM is the prefix for all privilege levels that affect VMs
	PrivilegeTargetTypeVM = "vm"
	// PrivilegeTargetTypeGroup is the prefix for all privilege levels that affect Groups
	PrivilegeTargetTypeGroup = "group"
	// PrivilegeTargetTypeAccount is the prefix for all privilege levels that affect Accounts
	PrivilegeTargetTypeAccount = "account"
	// PrivilegeTargetTypeCluster is the prefix for all privilege levels that affect the whole cluster.
	PrivilegeTargetTypeCluster = "cluster"
)

Variables

View Source
var ColdStorageGrade = "iceberg"

ColdStorageGrade is the name for the storage grade used as 'cold storage' - i.e. where backups get sent after being taken.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	// ID must not be set during creation.
	ID       int    `json:"id,omitempty"`
	UserID   int    `json:"user_id,omitempty"`
	Username string `json:"username,omitempty"`
	// Label is a friendly display name for this API key
	Label string `json:"label,omitempty"`
	// API key is the actual key. To use it, it must be prepended with
	// 'apikey.' in the HTTP Authorization header. For example, if the api key
	// is xpq21, the HTTP headers should include `Authorization: Bearer apikey.xpq21`
	APIKey string `json:"api_key,omitempty"`
	// ExpiresAt should be a time or datetime in HH:MM:SS or
	// YYYY-MM-DDTHH:MM:SS.msZ where T is a literal T, .ms are optional
	// microseconds and Z is either literal Z (meaning UTC) or a timezone
	// specified like -600 or +1200
	ExpiresAt string `json:"expires_at,omitempty"`
	// Privileges cannot be set at creation or update time, but are returned by
	// the brain when view=overview.
	Privileges Privileges `json:"privileges,omitempty"`
}

APIKey represents an api_key in the brain.

func (APIKey) DefaultFields

func (key APIKey) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (APIKey) Expired

func (key APIKey) Expired() bool

Expired returns true if ExpiresAt is in the past. This assumes ExpiresAt is in ISO8601 format, which it will be if the APIKey was set by a unmarshalling a response from the brain.

func (APIKey) PrettyPrint

func (key APIKey) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the api key, including what privileges it has, to the given writer.

type APIKeys

type APIKeys []APIKey

APIKeys is a slice of APIKey implementing output.Outputtable

func (APIKeys) DefaultFields

func (keys APIKeys) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (APIKeys) PrettyPrint

func (keys APIKeys) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the API keys to the given writer.

type Account

type Account struct {
	Name string `json:"name"`

	// the following cannot be set
	ID        int    `json:"id"`
	Suspended bool   `json:"suspended"`
	Groups    Groups `json:"groups"`
}

Account represents an account object that's returned by the brain

func (Account) DefaultFields

func (a Account) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Account) PrettyPrint

func (a Account) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the account to the given writer.

type Backup

type Backup struct {
	Disc
	ParentDiscID int  `json:"parent_disc_id"`
	Manual       bool `json:"manual"`
}

Backup represents a single backup of a disc. Backups are taken on the same tail as the disc, and then migrated to a different storage grade immediately.

func (Backup) DefaultFields

func (b Backup) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Backup) OnColdStorage

func (b Backup) OnColdStorage() bool

OnColdStorage returns true if the disc is currently on cold storage (whatever storage grade that is)

func (Backup) PrettyPrint

func (b Backup) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nicely-formatted string detailing the backup to the given writer.

type BackupSchedule

type BackupSchedule struct {
	ID        int    `json:"id,omitempty"`
	StartDate string `json:"start_at"`
	Interval  int    `json:"interval_seconds"`
	// Capacity is how many backups will be kept
	Capacity int `json:"capacity"`
}

BackupSchedule represents a schedule to take backups on. It is represented as a start date in YYYY-MM-DD hh:mm:ss format (and assuming UK timezones of some kind.)

func (BackupSchedule) DefaultFields

func (sched BackupSchedule) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (BackupSchedule) IntervalInWords

func (sched BackupSchedule) IntervalInWords() string

IntervalInWords returns a nice human readable version of the interval for this BackupSchedule Formats include "every %d weeks/days/hours/seconds", "weekly", "daily", and "hourly"

func (BackupSchedule) PrettyPrint

func (sched BackupSchedule) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nicely-formatted human-readable version of the schedule to the given writer. All the detail levels are the same.

func (BackupSchedule) String

func (sched BackupSchedule) String() string

type BackupSchedules

type BackupSchedules []BackupSchedule

BackupSchedules represents multiple backup schedules

func (BackupSchedules) MapTemplateFragment

func (scheds BackupSchedules) MapTemplateFragment(templateFrag string) (strs []string, err error)

MapTemplateFragment takes a template fragment (as if it was starting within a {{ }}) and executes it against every schedule in scheds, returning all the results as a slice of strings, or an error if one occurred. it is called by the 'map' template function, as used in BackupSchedules.PrettyPrint Is this the most heinous thing ever?

func (BackupSchedules) PrettyPrint

func (scheds BackupSchedules) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nicely-formatted human-readable version of the schedules to the given writer. detail levels: SingleLine - outputs one line "Backups are taken every m, n, o, & p seconds" or "No backups scheduled" Medium - same Full - outputs one line per schedule, "• #ID - " followed by the SingleLine PrettyPrint of the schedule

type Backups

type Backups []Backup

Backups represents a collection of backups

func (Backups) DefaultFields

func (bs Backups) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Backups) PrettyPrint

func (bs Backups) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint outputs a nicely-formatted string detailing the backup to the given writer.

type Disc

type Disc struct {
	Label        string `json:"label,omitempty"`
	StorageGrade string `json:"storage_grade,omitempty"`
	Size         int    `json:"size,omitempty"`

	ID               int    `json:"id,omitempty"`
	VirtualMachineID int    `json:"virtual_machine_id,omitempty"`
	StoragePool      string `json:"storage_pool,omitempty"`

	BackupCount     int             `json:"backup_count,omitempty"`
	BackupSchedules BackupSchedules `json:"backup_schedules,omitempty"`
	BackupsEnabled  bool            `json:"backups_enabled,omitempty"`

	ResourceName      string `json:"resource_name,omitempty"`
	MigrationProgress int    `json:"migration_progress,omitempty"`
	MigrationEta      int    `json:"migration_eta,omitempty"`
	MigrationSpeed    int    `json:"migration_speed,omitempty"`

	NewStorageGrade string `json:"new_storage_grade,omitempty"`
	NewStoragePool  string `json:"new_storage_pool,omitempty"`
}

Disc is a representation of a VM's disc.

func (Disc) DefaultFields

func (d Disc) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Disc) EstimateBackupScheduleSize

func (d Disc) EstimateBackupScheduleSize() int

EstimateBackupScheduleSize returns an estimate for the maximum amount of iceberg storage this disk will use for its backups, in MiB

func (Disc) PrettyPrint

func (d Disc) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs the disc nicely-formatted to the writer.

func (Disc) String

func (d Disc) String() string

String returns the disc formatted as a string (the same as PrettyPrint with prettyprint.SingleLine detail)

func (Disc) Validate

func (d Disc) Validate() (*Disc, error)

Validate makes sure the disc has a storage grade.

type Discs

type Discs []Disc

Discs represents multiple Disc objects in an output.Outputtable form.

func (Discs) DefaultFields

func (ds Discs) DefaultFields(f output.Format) string

DefaultFields provides the default fields for Discs, which is the same as those of Disc.

func (Discs) PrettyPrint

func (ds Discs) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the discs to wr at the given detail level.

type DistributionDefinition

type DistributionDefinition struct {
	Name        string
	Description string
}

DistributionDefinition is an object we assemble from distributions and distribution_descriptions from the /definitions API call in the future (bytemark-client 3.0?) a slice of these this will replace the Definitions.Distributions slice and Definitions.DistributionDescriptions map.

func (DistributionDefinition) DefaultFields

func (d DistributionDefinition) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (DistributionDefinition) PrettyPrint

func (d DistributionDefinition) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a vaguely human-readable version of the definition to wr.

type DistributionDefinitions

type DistributionDefinitions []DistributionDefinition

DistributionDefinitions represents more than one definition in output.Outputtable form.

func (DistributionDefinitions) DefaultFields

func (ds DistributionDefinitions) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (DistributionDefinitions) PrettyPrint

func (ds DistributionDefinitions) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint writes a human-readable summary of the definitions to wr at the given detail level.

type Group

type Group struct {
	Name string `json:"name"`

	// the following cannot be set
	AccountID       int              `json:"account_id"`
	ID              int              `json:"id"`
	VirtualMachines []VirtualMachine `json:"virtual_machines"`
}

Group represents a group

func (Group) CountVirtualMachines

func (g Group) CountVirtualMachines() int

CountVirtualMachines returns the number of virtual machines in this group

func (Group) DefaultFields

func (g Group) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Group) PrettyPrint

func (g Group) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a vaguely human-readable version of the definition to wr.

func (Group) String

func (g Group) String() string

String formats the Group as a string - a single line in a human-readable form.

type Groups

type Groups []Group

Groups represents multiple Group objects in output.Outputtable form.

func (Groups) DefaultFields

func (gs Groups) DefaultFields(f output.Format) string

DefaultFields provides the default fields for Groups, which is the same as those of Group.

func (Groups) PrettyPrint

func (gs Groups) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a summary of the groups to wr at the provided detail level.

type HardwareProfileDefinition

type HardwareProfileDefinition struct {
	Name        string
	Description string
}

HardwareProfileDefinition is an object we assemble from hardwareprofiles from the /definitions API call in the future (bytemark-client 3.0?) a slice of these this will replace the Definitions.HardwareProfiles slice.

func (HardwareProfileDefinition) DefaultFields

func (hp HardwareProfileDefinition) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (HardwareProfileDefinition) PrettyPrint

func (hp HardwareProfileDefinition) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a vaguely human-readable version of the definition to wr.

type HardwareProfileDefinitions

type HardwareProfileDefinitions []HardwareProfileDefinition

HardwareProfileDefinitions represents more than one definition in output.Outputtable form.

func (HardwareProfileDefinitions) DefaultFields

func (ds HardwareProfileDefinitions) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (HardwareProfileDefinitions) PrettyPrint

func (ds HardwareProfileDefinitions) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint writes a human-readable summary of the definitions to wr at the given detail level.

type Head struct {
	ID       int    `json:"id,omitempty"`
	UUID     string `json:"uuid,omitempty"`
	Label    string `json:"label,omitempty"`
	ZoneName string `json:"zone,omit_empty"`

	Architecture  string   `json:"arch,omitempty"`
	CCAddress     *net.IP  `json:"cnc_address,omitempty"`
	LastNote      string   `json:"last_note,omitempty"`
	TotalMemory   int      `json:"total_memory,omitempty"`
	UsageStrategy string   `json:"usage_strategy,omitempty"`
	Models        []string `json:"models,omitempty"`

	FreeMemory int  `json:"free_memory,omitempty"`
	IsOnline   bool `json:"online,omitempty"`
	UsedCores  int  `json:"used_cores,omitempty"`

	VirtualMachineCount int      `json:"virtual_machines_count,omitempty"`
	VirtualMachines     []string `json:"virtual_machines,omitempty"`
}

Head represents a Bytemark Cloud Servers head server.

func (Head) CountVirtualMachines

func (h Head) CountVirtualMachines() int

CountVirtualMachines returns the number of virtual machines running on this head

func (Head) DefaultFields

func (h Head) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Head) PrettyPrint

func (h Head) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes an overview of this head out to the given writer.

type Heads

type Heads []Head

Heads represents multiple Head objects in output.Outputtable form

func (Heads) DefaultFields

func (hs Heads) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as Head.DefaultFields

func (Heads) PrettyPrint

func (hs Heads) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the heads to writer at the given detail level.

type IP

type IP struct {
	RDns string `json:"rdns"`

	// this cannot be set.
	IP net.IP `json:"ip"`
}

IP represents an IP for the purpose of setting RDNS

func (IP) DefaultFields

func (ip IP) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (IP) PrettyPrint

func (ip IP) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint outputs a vaguely human-readable version of the IP and reverse DNS to wr. Detail is ignored.

type IPCreateRequest

type IPCreateRequest struct {
	Addresses  int    `json:"addresses"`
	Family     string `json:"family"`
	Reason     string `json:"reason"`
	Contiguous bool   `json:"contiguous"`
	// don't actually specify the IPs - this is for filling in from the response!
	IPs IPs `json:"ips,omitempty"`
}

IPCreateRequest is used by the create_ip endpoint on a nic

func (IPCreateRequest) DefaultFields

func (ipcr IPCreateRequest) DefaultFields(f output.Format) string

DefaultFields returns the default fields for feeding into github.com/BytemarkHosting/row.From

func (IPCreateRequest) PrettyPrint

func (ipcr IPCreateRequest) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs this create request/response in a human-readable form TODO: support the response

type IPRange

type IPRange struct {
	ID        int      `json:"id"`
	Spec      string   `json:"spec"`
	VLANNum   int      `json:"vlan_num"`
	Zones     []string `json:"zones"`
	Available *big.Int `json:"available"` // wants to be a pointer because MarshalText is defined on the pointer type and we need it for the tests (but not for non-tests)

}

IPRange is a representation of an IP range

func (IPRange) DefaultFields

func (ipr IPRange) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (IPRange) PrettyPrint

func (ipr IPRange) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes an overview of this IP range out to the given writer.

func (IPRange) String

func (ipr IPRange) String() string

String serialises an IP range to easily be output

type IPRanges

type IPRanges []IPRange

IPRanges represents more than one ip range in output.Outputtable form.

func (IPRanges) DefaultFields

func (iprs IPRanges) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as IPRange.DefaultFields

func (IPRanges) PrettyPrint

func (iprs IPRanges) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the ranges to writer at the given detail level.

type IPSpec

type IPSpec struct {
	IPv4 string `json:"ipv4"`
	IPv6 string `json:"ipv6"`
}

IPSpec represents one v4 and one v6 address to assign to a server during creation.

type IPs

type IPs []net.IP

IPs represent multiple net.IPs

func (IPs) Len

func (ips IPs) Len() int

Len returns how many ips there are in this IPs

func (IPs) Less

func (ips IPs) Less(i, j int) bool

Less looks at the ips at index i and j, and returns true if i should come before j.

func (IPs) Sort

func (ips IPs) Sort() IPs

Sort sorts the given IPs in-place and also returns it, for daisy chaining. Sorting is done by the golang sort package, which uses the Less, Len and Swap functions defined below

func (IPs) String

func (ips IPs) String() string

func (IPs) StringSep

func (ips IPs) StringSep(sep string) string

StringSep combines all the IPs into a single string with the given separator

func (IPs) Strings

func (ips IPs) Strings() (strings []string)

Strings returns each IP in this IPs as a string.

func (IPs) Swap

func (ips IPs) Swap(i, j int)

Swap moves the ip at i to j, and vice versa.

type ImageInstall

type ImageInstall struct {
	Distribution    string `json:"distribution"`
	FirstbootScript string `json:"firstboot_script"`
	RootPassword    string `json:"root_password"`
	PublicKeys      string `json:"ssh_public_key"`
}

ImageInstall represents what image was most recently installed on a VM along with its root password. This might only be returned when creating a VM.

func (ImageInstall) DefaultFields

func (ii ImageInstall) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (ImageInstall) PrettyPrint

func (ii ImageInstall) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs the image install with the given level of detail. TODO(telyn): rewrite to use templates & prettyprint.Run

type Key

type Key struct {
	Key string
}

Key is an SSH public key which can be output nicely in a table.

func (Key) DefaultFields

func (k Key) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Key) PrettyPrint

func (k Key) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes the key to the given writer

func (Key) String

func (k Key) String() string

String returns this key as a simple string.

func (*Key) UnmarshalText

func (k *Key) UnmarshalText(text []byte) error

UnmarshalText fills Key with the text

type Keys

type Keys []Key

Keys is a collection of Key objects - used to allow us to nicely display keys in a table.

func (Keys) DefaultFields

func (k Keys) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Keys) MarshalText

func (k Keys) MarshalText() ([]byte, error)

MarshalText converts this Keys into text in the same format as a ssh authorized_keys file. This is to allow the AuthorizedKeys field of User to be automatically marshalled by json.Marshal

func (Keys) PrettyPrint

func (k Keys) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint outputs the keys, one per line, with no indent.

func (Keys) Strings

func (k Keys) Strings() (strs []string)

Strings converts each Key in this Keys into a string and returns them all

func (*Keys) UnmarshalText

func (k *Keys) UnmarshalText(text []byte) error

UnmarshalText fills in this Keys from a bunch of text (same format as a ssh authorized_keys file) this is to allow the AuthorizedKeys field of User to be automatically unmarshalled by json.Unmarshal

type Migration

type Migration struct {
	ID             int    `json:"id,omitempty"`
	TailID         int    `json:"tail_id,omitempty"`
	DiscID         int    `json:"disc_id,omitempty"`
	Port           int    `json:"port,omitempty"`
	CreatedAt      string `json:"created_at,omitempty"`
	UpdatedAt      string `json:"updated_at,omitempty"`
	MigrationJobID int    `json:"migration_job_id,omitempty"`
}

Migration represents the migration of a single disc. The json returned from the brain can also represent virtual machine migrations, but we're ignoring that for now.

func (Migration) DefaultFields

func (m Migration) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Migration) PrettyPrint

func (m Migration) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint formats a Migration for display

type MigrationJob

type MigrationJob struct {
	ID           int                      `json:"id,omitempty"`
	Args         MigrationJobSpec         `json:"args,omitempty"`
	Queue        MigrationJobQueue        `json:"queue,omitempty"`
	Destinations MigrationJobDestinations `json:"destinations,omitempty"`
	Active       Migrations               `json:"active,omitempty"`
	Status       MigrationJobStatus       `json:"status,omitempty"`
	Priority     int                      `json:"priority,omitempty"`
	StartedAt    string                   `json:"started_at,omitempty"`
	FinishedAt   string                   `json:"finished_at,omitempty"`
	CreatedAt    string                   `json:"created_at,omitempty"`
	UpdatedAt    string                   `json:"updated_at,omitempty"`
}

MigrationJob is a representation of a migration job.

func (MigrationJob) DefaultFields

func (mj MigrationJob) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (MigrationJob) PrettyPrint

func (mj MigrationJob) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the migration

type MigrationJobDestinations

type MigrationJobDestinations struct {
	Pools []int `json:"pools,omitempty"`
}

MigrationJobDestinations represents available desintations for a migration job. Unlike MigrationJobLocations, these are represented using ID number only.

type MigrationJobDiscStatus

type MigrationJobDiscStatus struct {
	Done      []int `json:"done,omitempty"`
	Errored   []int `json:"errored,omitempty"`
	Cancelled []int `json:"cancelled,omitempty"`
	Skipped   []int `json:"skipped,omitempty"`
}

MigrationJobDiscStatus represents the current status of a migration job. Each entry is a list of disc IDs indicating the fate of discs that have been removed from the queue.

type MigrationJobLocations

type MigrationJobLocations struct {
	Discs []util.NumberOrString `json:"discs,omitempty"`
	Pools []util.NumberOrString `json:"pools,omitempty"`
	Tails []util.NumberOrString `json:"tails,omitempty"`
}

MigrationJobLocations represents source or target locations for a migration job. Discs, pools and tails maybe represented by ID number, label or UUID.

type MigrationJobModification

type MigrationJobModification struct {
	Cancel  MigrationJobLocations `json:"cancel,omitempty"`
	Options MigrationJobOptions   `json:"options,omitempty"`
}

MigrationJobModification represents the modifications possible on a migration job

type MigrationJobOptions

type MigrationJobOptions struct {
	Priority int `json:"priority,omitempty"`
}

MigrationJobOptions represents options on a migration job.

type MigrationJobQueue

type MigrationJobQueue struct {
	Discs []int `json:"discs,omitempty"`
}

MigrationJobQueue is a list of disc IDs that are still to be migrated as part of a migration job.

func (MigrationJobQueue) DefaultFields

func (mjq MigrationJobQueue) DefaultFields(f output.Format) string

DefaultFields appeases quality tests

func (MigrationJobQueue) PrettyPrint

func (mjq MigrationJobQueue) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint formats a MigrationJobQueue for display

type MigrationJobSpec

type MigrationJobSpec struct {
	Options      MigrationJobOptions   `json:"options,omitempty"`
	Sources      MigrationJobLocations `json:"sources,omitempty"`
	Destinations MigrationJobLocations `json:"destinations,omitempty"`
}

MigrationJobSpec is a specification of a migration job to be created

type MigrationJobStatus

type MigrationJobStatus struct {
	Discs MigrationJobDiscStatus `json:"discs,omitempty"`
}

MigrationJobStatus captures the status of a migration job, currently only discs.

func (MigrationJobStatus) DefaultFields

func (mjs MigrationJobStatus) DefaultFields(f output.Format) string

DefaultFields appeases quality tests

func (MigrationJobStatus) PrettyPrint

func (mjs MigrationJobStatus) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint formats a MigrationJobStatus for display

type MigrationJobs

type MigrationJobs []MigrationJob

MigrationJobs represents more than one migration job in output.Outputtable form.

func (MigrationJobs) DefaultFields

func (mjs MigrationJobs) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as MigrationJob.DefaultFields.

func (MigrationJobs) PrettyPrint

func (mjs MigrationJobs) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the migration jobs to writer at the given detail level.

type Migrations

type Migrations []Migration

Migrations represents more than one migration in output.Outputtable form.

func (Migrations) DefaultFields

func (ms Migrations) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as Migration.DefaultFields.

func (Migrations) PrettyPrint

func (ms Migrations) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the migrations to writer at the given detail level.

type NetworkInterface

type NetworkInterface struct {
	Label string `json:"label"`

	Mac string `json:"mac"`

	ID      int `json:"id"`
	VlanNum int `json:"vlan_num"`
	IPs     IPs `json:"ips"`
	// sadly we can't use map[net.IP]net.IP because net.IP is a slice and slices don't have equality
	// and we can't use map[*net.IP]net.IP because we could have two identical IPs in different memory locations and they wouldn't be equal. Rubbish.
	ExtraIPs         map[string]net.IP `json:"extra_ips"`
	VirtualMachineID int               `json:"virtual_machine_id"`
}

NetworkInterface represents a virtual NIC and what IPs it has routed.

func (NetworkInterface) DefaultFields

func (nic NetworkInterface) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (NetworkInterface) ExtraIPStrings

func (nic NetworkInterface) ExtraIPStrings() (ips []string)

ExtraIPStrings represents the extra IPs as a set of strings of the format "extra_ip -> routed_to"

func (NetworkInterface) PrettyPrint

func (nic NetworkInterface) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs the network interface in a human-readable form to the supplied writer.

func (NetworkInterface) String

func (nic NetworkInterface) String() string

String formats the network interface as a single descriptive line of text.

type Privilege

type Privilege struct {
	// ID is the numeric ID used mostly by the brain
	ID int `json:"id,omitempty"`
	// Username is the user who the privilege is granted to
	Username string `json:"username,omitempty"`
	// VirtualMachineID is the ID of the virtual machine the privilege is granted on
	VirtualMachineID int `json:"virtual_machine_id,omitempty"`
	// VirtualMachineName is the name of the virtual machine the privilege is granted on
	VirtualMachineName string `json:"virtual_machine_name,omitempty"`
	// AccountID is the ID of the account the privilege is granted on
	AccountID int `json:"account_id,omitempty"`
	// AccountID is the name of the account the privilege is granted on
	AccountName string `json:"account_name,omitempty"`
	// GroupID is the ID of the group the privilege is granted on
	GroupID int `json:"group_id,omitempty"`
	// GroupID is the name of the group the privilege is granted on
	GroupName string `json:"group_name,omitempty"`
	// APIKeyID is the ID of the api key required in order to use this Privilege. If not set, privilege relates to normal logins using auth.
	APIKeyID int `json:"api_key_id,omitempty"`
	// Level is the PrivilegeLevel they have
	Level PrivilegeLevel `json:"level,omitempty"`
	// PasswordRequired is true for all privileges requiring a password (all except api key privileges)
	PasswordRequired bool `json:"password_required"`
	// YubikeyRequired is true if the user should have to authenticate with a yubikey in order to use this privilege. Only set it to true if you're sure the user has a yubikey set up on their account, and that they know where it is!
	YubikeyRequired bool `json:"yubikey_required"`
	// YubikeyOTPMaxAge should set how long (in seconds) a yubikey one-time-password would be accepted for, but it might not be used?
	YubikeyOTPMaxAge int `json:"yubikey_otp_max_age,omitempty"`
}

Privilege represents a privilege on the brain. A user may have multiple privileges, and multiple privileges may be granted on the same object. At the moment we're not worried about the extra fields that privileges have on the brain (IP restrictions) because they're unused

func (Privilege) DefaultFields

func (p Privilege) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Privilege) PrettyPrint

func (p Privilege) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint nicely formats the Privilege and sends it to the given writer. At the moment, the detail parameter is ignored.

func (Privilege) String

func (p Privilege) String() string

String returns a string representation of the Privilege in English. Privileges are a little tricky to represent in English because the Privilege itself doesn't know if it exists on a user or if it has just been removed from a user, nor does it now anything about the target it's been granted on/revoked from other than a numerical ID. So we do the best we can.

func (Privilege) Target

func (p Privilege) Target() string

Target returns a formatted string containing the target type and its ID.

func (Privilege) TargetType

func (p Privilege) TargetType() string

TargetType returns the prefix of the PrivilegeLevel, which should be one of the PrivilegeTargetType* constants.

type PrivilegeLevel

type PrivilegeLevel string

PrivilegeLevel is a type to represent different privilege levels. since privilege levels in the brain are just strings, they're just a string type here too.

func (PrivilegeLevel) String

func (pl PrivilegeLevel) String() string

String returns the privilege level cast to a string.

type Privileges

type Privileges []Privilege

Privileges is used to allow API consumers to use IndexOf on the array of privileges.

func (Privileges) DefaultFields

func (ps Privileges) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as Privilege.DefaultFields.

func (Privileges) IndexOf

func (ps Privileges) IndexOf(priv Privilege) int

IndexOf finds the privilege given in the list of privileges, ignoring the Privilege ID and returns the index. If it couldn't find it, returns -1.

func (Privileges) PrettyPrint

func (ps Privileges) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the privileges to writer at the given detail level.

type StorageGradeDefinition

type StorageGradeDefinition struct {
	Name        string
	Description string
}

StorageGradeDefinition is an object we assemble from storage_grades and storage_grade_descriptions from the /definitions API call in the future (bytemark-client 3.0?) a slice of these this will replace the Definitions.StorageGrades slice and Definitions.StorageGradeDescriptions map.

func (StorageGradeDefinition) DefaultFields

func (sg StorageGradeDefinition) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (StorageGradeDefinition) PrettyPrint

func (sg StorageGradeDefinition) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a vaguely human-readable version of the definition to wr.

type StorageGradeDefinitions

type StorageGradeDefinitions []StorageGradeDefinition

StorageGradeDefinitions represents more than one definition in output.Outputtable form.

func (StorageGradeDefinitions) DefaultFields

func (ds StorageGradeDefinitions) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (StorageGradeDefinitions) PrettyPrint

func (ds StorageGradeDefinitions) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint writes a human-readable summary of the definitions to wr at the given detail level.

type StoragePool

type StoragePool struct {
	Name                 string `json:"name,omitempty"`
	Label                string `json:"label,omitempty"`
	ZoneName             string `json:"zone,omitempty"`
	Size                 int    `json:"size,omitempty"`
	FreeSpace            int    `json:"free_space,omitempty"`
	Ceiling              int    `json:"ceiling,omitempty"`
	AllocatedSpace       int    `json:"alloc,omitempty"`
	Discs                int    `json:"discs,omitempty"`
	Backups              int    `json:"backups,omitempty"`
	OvercommitRatio      int    `json:"overcommit_ratio,omitempty"`
	MigrationConcurrency int    `json:"migration_concurrency,omitempty"`
	UsageStrategy        string `json:"usage_strategy,omitempty"`
	StorageGrade         string `json:"grade,omitempty"`
	Note                 string `json:"note,omitempty"`
	IOPSLimit            int    `json:"iops_limit,omitempty"`
}

StoragePool represents a Bytemark Cloud Servers disk storage pool, as returned by the admin API.

func (StoragePool) DefaultFields

func (sp StoragePool) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (StoragePool) PercentFull

func (sp StoragePool) PercentFull() int

PercentFull gives us the (numeric) percentage of how full the disc is

func (StoragePool) PrettyPrint

func (sp StoragePool) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes an overview of this storage pool out to the given writer.

type StoragePools

type StoragePools []StoragePool

StoragePools represents more than one storage pool in output.Outputtable form.

func (StoragePools) DefaultFields

func (sps StoragePools) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as StoragePool.DefaultFields

func (StoragePools) PrettyPrint

func (sps StoragePools) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the storage pools to writer at the given detail level.

type Tail

type Tail struct {
	ID    int    `json:"id"`
	UUID  string `json:"uuid"`
	Label string `json:"label"`

	CCAddress net.IP `json:"cnc_address"`
	ZoneName  string `json:"zone"`

	IsOnline     bool     `json:"online"`
	StoragePools []string `json:"pools"`
}

Tail represents a Bytemark Cloud Servers tail (disk storage machine), as returned by the admin API.

func (Tail) DefaultFields

func (t Tail) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (Tail) PrettyPrint

func (t Tail) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes an overview of this tail out to the given writer.

type Tails

type Tails []Tail

Tails represents more than one tail in output.Outputtable form.

func (Tails) DefaultFields

func (ts Tails) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as Tail.DefaultFields.

func (Tails) PrettyPrint

func (ts Tails) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the tails to writer at the given detail level.

type User

type User struct {
	ID             int    `json:"id,omitempty"`
	Username       string `json:"username,omitempty"`
	Email          string `json:"email,omitempty"`
	AuthorizedKeys Keys   `json:"authorized_keys,omitempty"`
}

User represents a Bytemark user.

func (User) DefaultFields

func (user User) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (User) PrettyPrint

func (user User) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs human-readable information about the user to the given writer at some level of detail.

type VLAN

type VLAN struct {
	ID        int      `json:"id"`
	Num       int      `json:"num"`
	UsageType string   `json:"usage_type"`
	IPRanges  IPRanges `json:"ip_ranges"`
}

VLAN is a representation of a VLAN, as used by admin endpoints

func (VLAN) DefaultFields

func (v VLAN) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (VLAN) PrettyPrint

func (v VLAN) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes an overview of this VLAN out to the given writer.

type VLANs

type VLANs []VLAN

VLANs represents more than one VLAN in output.Outputtable form.

func (VLANs) DefaultFields

func (vs VLANs) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as VLAN.DefaultFields

func (VLANs) PrettyPrint

func (vs VLANs) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the VLANs to writer at the given detail level.

type VirtualMachine

type VirtualMachine struct {
	Autoreboot            bool   `json:"autoreboot_on,omitempty"`
	CdromURL              string `json:"cdrom_url,omitempty"`
	Cores                 int    `json:"cores,omitempty"`
	Memory                int    `json:"memory,omitempty"`
	Name                  string `json:"name,omitempty"`
	PowerOn               bool   `json:"power_on,omitempty"`
	HardwareProfile       string `json:"hardware_profile,omitempty"`
	HardwareProfileLocked bool   `json:"hardware_profile_locked,omitempty"`
	GroupID               int    `json:"group_id,omitempty"`

	// zone name can be set during creation but not changed
	ZoneName string `json:"zone_name,omitempty"`

	// the following cannot be set
	Discs             Discs              `json:"discs,omitempty"`
	ID                int                `json:"id,omitempty"`
	ManagementAddress net.IP             `json:"management_address,omitempty"`
	Deleted           bool               `json:"deleted,omitempty"`
	Hostname          string             `json:"hostname,omitempty"`
	Head              string             `json:"head,omitempty"`
	NetworkInterfaces []NetworkInterface `json:"network_interfaces,omitempty"`
}

VirtualMachine represents a VirtualMachine, as passed around from the virtual_machines endpoint

func (VirtualMachine) AllIPv4Addresses

func (vm VirtualMachine) AllIPv4Addresses() (ips IPs)

AllIPv4Addresses flattens all the IPs for a VM into a single IPs (a []*net.IP with some convenience methods)

func (VirtualMachine) AllIPv6Addresses

func (vm VirtualMachine) AllIPv6Addresses() (ips IPs)

AllIPv6Addresses flattens all the v6 IPs for a VM into a single IPs (a []*net.IP with some convenience methods)

func (VirtualMachine) DefaultFields

func (vm VirtualMachine) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (VirtualMachine) FullName

func (vm VirtualMachine) FullName() string

FullName returns the first three parts of the hostname (i.e. name.group.account)

func (VirtualMachine) GetDiscLabelOffset

func (vm VirtualMachine) GetDiscLabelOffset() (offset int)

GetDiscLabelOffset gets the highest disc number for this VM, by looking for discs labelled disc-N and using N or the number of discs attached to the VM, whichever is higher

func (VirtualMachine) PrettyPrint

func (vm VirtualMachine) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the server to the given writer.

func (VirtualMachine) PrimaryIP

func (vm VirtualMachine) PrimaryIP() net.IP

PrimaryIP returns the VM's primary IP - the (usually) IPv4 address that was created first.

func (VirtualMachine) ShortName

func (vm VirtualMachine) ShortName() string

ShortName returns the first two parts of the hostname (i.e. name.group)

func (VirtualMachine) String

func (vm VirtualMachine) String() string

func (VirtualMachine) TotalDiscSize

func (vm VirtualMachine) TotalDiscSize(storageGrade string) (total int)

TotalDiscSize returns the sum of all disc capacities in the VM for the given storage grade. Provide the empty string to sum all discs regardless of storage grade.

type VirtualMachineDefault

type VirtualMachineDefault struct {
	ID             int                `json:"id,omitempty"`
	AccountID      int                `json:"account_id,omitempty"`
	Name           string             `json:"name"`
	Public         bool               `json:"public"`
	ServerSettings VirtualMachineSpec `json:"server_settings"`
}

VirtualMachineDefault is a default (or perhaps better, template) for virtual machines. They're essentially a VirtualMachineSpec which the panel picks details from and populates the virtual machine creation screen with. Public defaults can be made by setting Public: true.

func (VirtualMachineDefault) DefaultFields

func (vmd VirtualMachineDefault) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (VirtualMachineDefault) PrettyPrint

func (vmd VirtualMachineDefault) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a nice human-readable overview of the VM Default to the given writer.

func (VirtualMachineDefault) TotalDiscSize

func (vmd VirtualMachineDefault) TotalDiscSize(storageGrade string) (total int)

TotalDiscSize returns the sum of all disc capacities in the VM for the given storage grade. Provide the empty string to sum all discs regardless of storage grade.

type VirtualMachineSpec

type VirtualMachineSpec struct {
	VirtualMachine VirtualMachine `json:"virtual_machine"`
	Discs          []Disc         `json:"discs,omitempty"`
	Reimage        *ImageInstall  `json:"reimage,omitempty"` // may want to be null, so is a pointer
	IPs            *IPSpec        `json:"ips,omitempty"`     // may want to be null, so is a pointer
}

VirtualMachineSpec represents the specification for a VM that is passed to the create_vm endpoint

func (VirtualMachineSpec) DefaultFields

func (spec VirtualMachineSpec) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (VirtualMachineSpec) PrettyPrint

func (spec VirtualMachineSpec) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a human-readable spec to the given writer. TODO(telyn): rewrite using templates

func (VirtualMachineSpec) String

func (spec VirtualMachineSpec) String() string

type VirtualMachines

type VirtualMachines []VirtualMachine

VirtualMachines represents more than one account in output.Outputtable form.

func (VirtualMachines) DefaultFields

func (vs VirtualMachines) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type, which is the same as VirtualMachine.DefaultFields.

func (VirtualMachines) PrettyPrint

func (vs VirtualMachines) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint writes a human-readable summary of the virtual machines to writer at the given detail level.

type ZoneDefinition

type ZoneDefinition struct {
	Name        string
	Description string
}

ZoneDefinition is an object we assemble from zone_names from the /definitions API call and some static data in lib/definitions.go in the future (bytemark-client 3.0?) a slice of these this will replace the Definitions.ZoneNames slice.

func (ZoneDefinition) DefaultFields

func (z ZoneDefinition) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (ZoneDefinition) PrettyPrint

func (z ZoneDefinition) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) error

PrettyPrint outputs a vaguely human-readable version of the definition to wr.

type ZoneDefinitions

type ZoneDefinitions []ZoneDefinition

ZoneDefinitions represents more than one definition in output.Outputtable form.

func (ZoneDefinitions) DefaultFields

func (ds ZoneDefinitions) DefaultFields(f output.Format) string

DefaultFields returns the list of default fields to feed to github.com/BytemarkHosting/row.From for this type.

func (ZoneDefinitions) PrettyPrint

func (ds ZoneDefinitions) PrettyPrint(wr io.Writer, detail prettyprint.DetailLevel) (err error)

PrettyPrint writes a human-readable summary of the definitions to wr at the given detail level.

Jump to

Keyboard shortcuts

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