servers

package
v4.0.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: 3 Imported by: 0

Documentation

Overview

Package servers manages and retrieves servers in the Enterprise Cloud Dedicated Hypervisor Service.

Example to List servers

listOpts := servers.ListOpts{
	Limit: 10,
}

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

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

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

Example to List servers details

listOpts := servers.ListOpts{
	Limit: 10,
}

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

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

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

Example to Get a server

serverID := "f42dbc37-4642-4628-8b47-50bf95d8fdd5"

result := servers.Get(dhClient, serverID)
if result.Err != nil {
	panic(result.Err)
}

server, err := result.Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", server)

Example to Create a server

createOpts := servers.CreateOpts{
	Name: "test",
	Networks: []servers.Network{
		{
			UUID:           "94055904-6b2c-4839-a14a-c61c93a8bc48",
			Plane:          "data",
			SegmentationID: 6,
		},
		{
			UUID:           "94055904-6b2c-4839-a14a-c61c93a8bc48",
			Plane:          "data",
			SegmentationID: 6,
		},
	},
	ImageRef:  "dfd25820-b368-4012-997b-29a6d0cf8518",
	FlavorRef: "a830b61c-3155-4a61-b7ed-c450862845e6",
}

result := servers.Create(dhClient, createOpts)
if result.Err != nil {
	panic(result.Err)
}

Example to Delete a server

serverID := "f42dbc37-4642-4628-8b47-50bf95d8fdd5"

result := servers.Delete(dhClient, serverID)
if result.Err != nil {
	panic(result.Err)
}

Example to Add license to a server

serverID := "f42dbc37-4642-4628-8b47-50bf95d8fdd5"

addLicenseOpts := servers.AddLicenseOpts{
	VmName: "Alice",
	LicenseTypes: []string{
		"Windows Server",
		"SQL Server Standard 2014",
	},
}

result := servers.AddLicense(dhClient, serverID, addLicenseOpts)
if result.Err != nil {
	panic(result.Err)
}

Example to Get result for add license to a server

serverID := "f42dbc37-4642-4628-8b47-50bf95d8fdd5"

getAddLicenseResultOpts := servers.GetAddLicenseResultOpts{
	JobID: AddLicenseJob.JobID,
}

result := servers.GetAddLicenseResult(dhClient, serverID, getAddLicenseResultOpts)
if result.Err != nil {
	panic(result.Err)
}

job, err := result.Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", job)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

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

List retrieves a list of Servers.

func ListDetails

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

ListDetails retrieves a list of Servers in details.

Types

type AddLicenseOpts

type AddLicenseOpts struct {
	VmName       string   `json:"vm_name,omitempty"`
	VmID         string   `json:"vm_id,omitempty"`
	LicenseTypes []string `json:"license_types"`
}

func (AddLicenseOpts) ToResourceCreateMap

func (opts AddLicenseOpts) ToResourceCreateMap() (map[string]interface{}, error)

type AddLicenseResult

type AddLicenseResult struct {
	eclcloud.Result
}

func AddLicense

func AddLicense(client *eclcloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r AddLicenseResult)

func GetAddLicenseResult

func GetAddLicenseResult(client *eclcloud.ServiceClient, serverID string, opts CreateOptsBuilder) (r AddLicenseResult)

func (AddLicenseResult) Extract

func (r AddLicenseResult) Extract() (*Job, error)

type BaremetalServer

type BaremetalServer struct {
	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"`
	Created                  time.Time         `json:"created"`
	Flavor                   Flavor            `json:"flavor"`
	ID                       string            `json:"id"`
	Image                    Image             `json:"image"`
	Metadata                 map[string]string `json:"metadata"`
	Name                     string            `json:"name"`
	Progress                 int               `json:"progress"`
	Status                   string            `json:"status"`
	TenantID                 string            `json:"tenant_id"`
	Updated                  time.Time         `json:"updated"`
	UserID                   string            `json:"user_id"`
	NicPhysicalPorts         []NicPhysicalPort `json:"nic_physical_ports"`
	ChassisStatus            ChassisStatus     `json:"chassis-status"`
	Links                    []Link            `json:"links"`
	RaidArrays               []RaidArray       `json:"raid_arrays"`
	LvmVolumeGroups          []LvmVolumeGroup  `json:"lvm_volume_groups"`
	Filesystems              []Filesystem      `json:"filesystems"`
	MediaAttachments         []MediaAttachment `json:"media_attachments"`
	ManagedByService         string            `json:"managed_by_service"`
	ManagedServiceResourceID string            `json:"managed_service_resource_id"`
}

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"`
	Console      bool `json:"console"`
}

type CreateOpts

type CreateOpts struct {
	Name             string            `json:"name"`
	Description      string            `json:"description,omitempty"`
	Networks         []Network         `json:"networks"`
	AdminPass        string            `json:"adminPass,omitempty"`
	ImageRef         string            `json:"imageRef"`
	FlavorRef        string            `json:"flavorRef"`
	AvailabilityZone string            `json:"availability_zone,omitempty"`
	Metadata         map[string]string `json:"metadata,omitempty"`
}

CreateOpts provides options used to create a Server.

func (CreateOpts) ToResourceCreateMap

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

ToResourceCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

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

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

type CreateResult

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

CreateResult is the response from a Create operation. Call its Extract method to interpret it as a Server.

func Create

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

Create creates a new Server.

func (CreateResult) Extract

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

Extract interprets any commonResult as a Server.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.

func Delete

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

Delete deletes a Server.

type Filesystem

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

type FixedIP

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

type Flavor

type Flavor struct {
	ID    string `json:"id"`
	Links []Link `json:"links"`
}

type GetAddLicenseResultOpts

type GetAddLicenseResultOpts struct {
	JobID string `json:"job_id"`
}

func (GetAddLicenseResultOpts) ToResourceCreateMap

func (opts GetAddLicenseResultOpts) ToResourceCreateMap() (map[string]interface{}, error)

type GetResult

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

GetResult is the response from a Get operation. Call its Extract method to interpret it as a Server.

func Get

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

Get retrieves details of a Server.

func (GetResult) Extract

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

Extract interprets any commonResult as a Server.

type Image

type Image struct {
	ID    string `json:"id"`
	Links []Link `json:"links"`
}

type Job

type Job struct {
	JobID          string         `json:"job_id"`
	Status         string         `json:"status"`
	RequestedParam RequestedParam `json:"requested_param"`
}
type Link struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

type ListOpts

type ListOpts struct {
	ChangesSince string `q:"changes-since"`
	Marker       string `q:"marker"`
	Limit        int    `q:"limit"`
	Name         string `q:"name"`
	Image        string `q:"image"`
	Flavor       string `q:"flavor"`
	Status       string `q:"status"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToResourceListQuery

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

ToResourceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request

type LogicalVolume

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

type LvmVolumeGroup

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

type MediaAttachment

type MediaAttachment struct {
	Image Image `json:"image"`
}

type Network

type Network struct {
	UUID           string `json:"uuid"`
	Port           string `json:"port,omitempty"`
	FixedIP        string `json:"fixed_ip,omitempty"`
	Plane          string `json:"plane"`
	SegmentationID int    `json:"segmentation_id"`
}

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         []Port `json:"attached_ports"`
	HardwareID            string `json:"hardware_id"`
}

type Partition

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

type Port

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

type RaidArray

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

type RequestedParam

type RequestedParam struct {
	VmName       string   `json:"vm_name"`
	LicenseTypes []string `json:"license_types"`
}

type Server

type Server struct {
	ID              string          `json:"id"`
	Name            string          `json:"name"`
	ImageRef        string          `json:"imageRef"`
	Description     *string         `json:"description"`
	Status          string          `json:"status"`
	HypervisorType  string          `json:"hypervisor_type"`
	BaremetalServer BaremetalServer `json:"baremetal_server"`
	Links           []Link          `json:"links"`
	AdminPass       string          `json:"adminPass"`
}

Server represents dedicated hypervisor server information.

func ExtractServers

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

ExtractServers returns a slice of Servers contained in a single page of results.

type ServerPage

type ServerPage struct {
	pagination.LinkedPageBase
}

ServerPage is a single page of Server results.

func (ServerPage) IsEmpty

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

IsEmpty determines whether or not a page of Servers contains any results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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