servers

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package servers contains functionality for working with ECL Baremetal Server resources.

Example to create server

createOpts := servers.CreateOpts{
	Name: "server-test-1",
	Networks: []servers.CreateOptsNetwork{
		{
			UUID:    "d32019d3-bc6e-4319-9c1d-6722fc136a22",
			FixedIP: "10.0.0.100",
		},
	},
	AdminPass:        "aabbccddeeff",
	ImageRef:         "b5660a6e-4b46-4be3-9707-6b47221b454f",
	FlavorRef:        "05184ba3-00ba-4fbc-b7a2-03b62b884931",
	AvailabilityZone: "zone1-groupa",
	UserData:         "IyEvYmluL2Jhc2gKZWNobyAiS3VtYSBQb3N0IEluc3RhbGwgU2NyaXB0IiA+PiAvaG9tZS9iaWcvcG9zdC1pbnN0YWxsLXNjcmlwdA==",
	RaidArrays: []servers.CreateOptsRaidArray{
		{
			PrimaryStorage: true,
			Partitions: []map[string]interface{}{
				{
					"lvm":             true,
					"partition_label": "primary-part1",
				},
				{
					"lvm":             false,
					"size":            "100G",
					"partition_label": "var",
				},
			},
		},
		{
			RaidCardHardwareID: "raid_card_uuid",
			DiskHardwareIDs: []string{
				"disk1_uuid",
				"disk2_uuid",
				"disk3_uuid",
				"disk4_uuid",
			},
			Partitions: []map[string]interface{}{
				{
					"lvm":             true,
					"partition_label": "secondary-part1",
				},
			},
		},
	},
	LVMVolumeGroups: []servers.CreateOptsLVMVolumeGroup{
		{
			VGLabel: "VG_root",
			PhysicalVolumePartitionLabels: []string{
				"primary-part1",
				"secondary-part1",
			},
			LogicalVolumes: []map[string]string{
				{
					"size":     "300G",
					"lv_label": "LV_root",
				},
				{
					"size":     "2G",
					"lv_label": "LV_swap",
				},
			},
		},
	},
	Filesystems: []servers.CreateOptsFilesystem{
		{
			Label:      "LV_root",
			FSType:     "xfs",
			MountPoint: "/",
		},
		{
			Label:      "var",
			FSType:     "xfs",
			MountPoint: "/var",
		},
		{
			Label:  "LV_swap",
			FSType: "swap",
		},
	},
	Metadata: map[string]string{
		"foo": "bar",
	},
}
server, err := servers.Create(client, createOpts).Extract()

Example to list servers

listOpts := servers.ListOpts{
	Status: "ACTIVE",
}

allPages, err := servers.List(client, listOpts).AllPages()
if err != nil {
	panic(err)
}

allServers, err := servers.ExtractServers(allPages)
if err != nil {
	panic(err)
}

for _, server := range allServers {
	fmt.Printf("%+v", server)
}

Example to delete server

err = servers.Delete(client, "server-id"").ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns Server optionally limited by the conditions provided in ListOpts.

Types

type AttachedPort

type AttachedPort struct {
	PortID    string    `json:"port_id"`
	NetworkID string    `json:"network_id"`
	FixedIPs  []FixedIP `json:"fixed_ips"`
}

AttachedPort represents attached port configuration for the server resource.

type ChassisStatus

type ChassisStatus struct {
	ChassisPower bool `json:"chassis-power"`
	PowerSupply  bool `json:"power-supply"`
	CPU          bool `json:"cpu"`
	Memory       bool `json:"memory"`
	Fan          bool `json:"fan"`
	Disk         int  `json:"disk"`
	NIC          bool `json:"nic"`
	SystemBoard  bool `json:"system-board"`
	Etc          bool `json:"etc"`
}

ChassisStatus represents chassis status for the server resource

type CreateOpts

type CreateOpts struct {
	Name             string                     `json:"name" required:"true"`
	Networks         []CreateOptsNetwork        `json:"networks" required:"true"`
	AdminPass        string                     `json:"adminPass,omitempty"`
	ImageRef         string                     `json:"imageRef,omitempty"`
	FlavorRef        string                     `json:"flavorRef" required:"true"`
	AvailabilityZone string                     `json:"availability_zone,omitempty"`
	KeyName          string                     `json:"key_name,omitempty"`
	UserData         []byte                     `json:"-"`
	RaidArrays       []CreateOptsRaidArray      `json:"raid_arrays,omitempty"`
	LVMVolumeGroups  []CreateOptsLVMVolumeGroup `json:"lvm_volume_groups,omitempty"`
	Filesystems      []CreateOptsFilesystem     `json:"filesystems,omitempty"`
	Metadata         map[string]string          `json:"metadata,omitempty"`
	Personality      []CreateOptsPersonality    `json:"personality,omitempty"`
}

CreateOpts represents options used to create a server.

func (CreateOpts) ToServerCreateMap

func (opts CreateOpts) ToServerCreateMap() (map[string]interface{}, error)

ToServerCreateMap builds a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToServerCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateOptsFilesystem

type CreateOptsFilesystem struct {
	Label      string `json:"label,omitempty"`
	FSType     string `json:"fs_type,omitempty"`
	MountPoint string `json:"mount_point,omitempty"`
}

CreateOptsFilesystem represents file system configuration for the server resource.

type CreateOptsLVMVolumeGroup

type CreateOptsLVMVolumeGroup struct {
	VGLabel                       string                    `json:"vg_label,omitempty"`
	PhysicalVolumePartitionLabels []string                  `json:"physical_volume_partition_labels,omitempty"`
	LogicalVolumes                []CreateOptsLogicalVolume `json:"logical_volumes,omitempty"`
}

CreateOptsLVMVolumeGroup represents LVM volume group configuration for the server resource.

type CreateOptsLogicalVolume

type CreateOptsLogicalVolume struct {
	LVLabel string `json:"lv_label,omitempty"`
	Size    string `json:"size,omitempty"`
}

CreateOptsLogicalVolume represents logical volume configuration for the server resource.

type CreateOptsNetwork

type CreateOptsNetwork struct {
	UUID    string `json:"uuid,omitempty"`
	Port    string `json:"port,omitempty"`
	FixedIP string `json:"fixed_ip,omitempty"`
	Plane   string `json:"plane,omitempty"`
}

CreateOptsNetwork represents networks information in server creation.

type CreateOptsPartition

type CreateOptsPartition struct {
	LVM            bool   `json:"lvm,omitempty"`
	Size           string `json:"size,omitempty"`
	PartitionLabel string `json:"partition_label,omitempty"`
}

CreateOptsPartition represents partition configuration for the server resource.

type CreateOptsPersonality

type CreateOptsPersonality struct {
	Path     string `json:"path,omitempty"`
	Contents string `json:"contents,omitempty"`
}

CreateOptsPersonality represents personal files configuration for the server resource.

type CreateOptsRaidArray

type CreateOptsRaidArray struct {
	PrimaryStorage     bool                  `json:"primary_storage,omitempty"`
	RaidCardHardwareID string                `json:"raid_card_hardware_id,omitempty"`
	DiskHardwareIDs    []string              `json:"disk_hardware_ids,omitempty"`
	RaidLevel          int                   `json:"raid_level,omitempty"`
	Partitions         []CreateOptsPartition `json:"partitions,omitempty"`
}

CreateOptsRaidArray represents raid configuration for the server resource.

type CreateResult

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

CreateResult represents the result of a create operation. Call its Extract method to interpret it as a Server.

func Create

func Create(c *eclcloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create accepts a CreateOpts struct and creates a new server using the values provided. This operation does not actually require a request body, i.e. the CreateOpts struct argument can be empty.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Server, error)

Extract provides access to the individual Server returned by the Get and functions.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(client *eclcloud.ServiceClient, id string) (r DeleteResult)

Delete requests that a server previously provisioned be removed from your account.

type Filesystem

type Filesystem struct {
	Label      string `json:"label"`
	FSType     string `json:"fs_type"`
	MountPoint string `json:"mount_point"`
}

Filesystem represents file system configuration for the server resource.

type FixedIP

type FixedIP struct {
	SubnetID  string `json:"subnet_id"`
	IPAddress string `json:"ip_address"`
}

FixedIP represents fixed IP configuration for the server resource.

type GetResult

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

GetResult is the result of Get operations. Call its Extract method to interpret it as a Server.

func Get

func Get(client *eclcloud.ServiceClient, id string) (r GetResult)

Get retrieves the server with the provided ID. To extract the Server object from the response, call the Extract method on the GetResult.

func (GetResult) Extract

func (r GetResult) Extract() (*Server, error)

Extract provides access to the individual Server returned by the Get and functions.

type LVMVolumeGroup

type LVMVolumeGroup struct {
	VGLabel                       string          `json:"vg_label"`
	PhysicalVolumePartitionLabels []string        `json:"physical_volume_partition_labels"`
	LogicalVolumes                []LogicalVolume `json:"logical_volumes"`
}

LVMVolumeGroup represents LVM volume group configuration for the server resource.

type ListOpts

type ListOpts struct {
	// ChangesSince is a time/date stamp for when the server last changed status.
	ChangesSince string `q:"changes-since"`

	// Image is the name of the image in URL format.
	Image string `q:"image"`

	// Flavor is the name of the flavor in URL format.
	Flavor string `q:"flavor"`

	// Name of the server as a string.
	Name string `q:"name"`

	// Status is the value of the status of the server so that you can filter on
	// "ACTIVE" for example.
	Status string `q:"status"`

	// Marker is a UUID of the server at which you want to set a marker.
	Marker string `q:"marker"`

	// Limit is an integer value for the limit of values to return.
	Limit int `q:"limit"`
}

ListOpts holds options for listing servers. It is passed to the servers.List function.

func (ListOpts) ToServerListQuery

func (opts ListOpts) ToServerListQuery() (string, error)

ToServerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToServerListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type LogicalVolume

type LogicalVolume struct {
	LVLabel string `json:"lv_label"`
	Size    int    `json:"size"`
}

LogicalVolume represents logical volume configuration for the server resource.

type NICPhysicalPort

type NICPhysicalPort struct {
	ID                    string         `json:"id"`
	MacAddr               string         `json:"mac_addr"`
	NetworkPhysicalPortID string         `json:"network_physical_port_id"`
	Plane                 string         `json:"plane"`
	AttachedPorts         []AttachedPort `json:"attached_ports"`
	HardwareID            string         `json:"hardware_id"`
}

NICPhysicalPort represents port configuraion for the server resource.

type Partition

type Partition struct {
	LVM            bool   `json:"lvm"`
	Size           int    `json:"size"`
	PartitionLabel string `json:"partition_label"`
}

Partition represents partition configuration for the server resource.

type Personality

type Personality struct {
	Path     string `json:"path"`
	Contents string `json:"contents"`
}

Personality represents personal files configuration for the server resource.

type RaidArray

type RaidArray struct {
	PrimaryStorage     bool        `json:"primary_storage"`
	RaidCardHardwareID string      `json:"raid_card_hardware_id"`
	DiskHardwareIDs    []string    `json:"disk_hardware_ids"`
	RaidLevel          int         `json:"raid_level"`
	Partitions         []Partition `json:"partitions"`
}

RaidArray represents raid configuration for the server resource.

type Server

type Server struct {
	ID               string                   `json:"id"`
	TenantID         string                   `json:"tenant_id"`
	UserID           string                   `json:"user_id"`
	Name             string                   `json:"name"`
	Updated          time.Time                `json:"-"`
	Created          time.Time                `json:"-"`
	Status           string                   `json:"status"`
	AdminPass        string                   `json:"adminPass"`
	PowerState       string                   `json:"OS-EXT-STS:power_state"`
	TaskState        string                   `json:"OS-EXT-STS:task_state"`
	VMState          string                   `json:"OS-EXT-STS:vm_state"`
	AvailabilityZone string                   `json:"OS-EXT-AZ:availability_zone"`
	Progress         int                      `json:"progress"`
	Image            map[string]interface{}   `json:"image"`
	Flavor           map[string]interface{}   `json:"flavor"`
	Metadata         map[string]string        `json:"metadata"`
	Links            []eclcloud.Link          `json:"links"`
	RaidArrays       []RaidArray              `json:"raid_arrays"`
	LVMVolumeGroups  []LVMVolumeGroup         `json:"lvm_volume_groups"`
	Filesystems      []Filesystem             `json:"filesystems"`
	NICPhysicalPorts []NICPhysicalPort        `json:"nic_physical_ports"`
	ChassisStatus    ChassisStatus            `json:"chassis-status"`
	MediaAttachments []map[string]interface{} `json:"media_attachments"`
	Personality      []Personality            `json:"personality"`
}

Server represents hardware configurations for server resources in a region.

func ExtractServers

func ExtractServers(r pagination.Page) ([]Server, error)

ExtractServers provides access to the list of flavors in a page acquired from the ListDetail operation.

func (*Server) UnmarshalJSON

func (r *Server) UnmarshalJSON(b []byte) error

UnmarshalJSON to override default

type ServerPage

type ServerPage struct {
	pagination.LinkedPageBase
}

ServerPage contains a single page of all servers from a ListDetails call.

func (ServerPage) IsEmpty

func (page ServerPage) IsEmpty() (bool, error)

IsEmpty determines if a FlavorPage contains any results.

func (ServerPage) NextPageURL

func (page ServerPage) NextPageURL() (string, error)

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type UpdateResult

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

UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a Server.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Server, error)

Extract provides access to the individual Server returned by the Get and functions.

Directories

Path Synopsis
Package testing contains baremetal server unit tests
Package testing contains baremetal server unit tests

Jump to

Keyboard shortcuts

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