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 ¶
- func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListDetails(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type AddLicenseOpts
- type AddLicenseResult
- type BaremetalServer
- type ChassisStatus
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type Filesystem
- type FixedIP
- type Flavor
- type GetAddLicenseResultOpts
- type GetResult
- type Image
- type Job
- type Link
- type ListOpts
- type ListOptsBuilder
- type LogicalVolume
- type LvmVolumeGroup
- type MediaAttachment
- type Network
- type NicPhysicalPort
- type Partition
- type Port
- type RaidArray
- type RequestedParam
- type Server
- type ServerPage
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 ¶
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 ¶
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.
type DeleteResult ¶
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 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.
type Job ¶
type Job struct {
JobID string `json:"job_id"`
Status string `json:"status"`
RequestedParam RequestedParam `json:"requested_param"`
}
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 ¶
ToResourceListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request
type LogicalVolume ¶
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 NicPhysicalPort ¶
type RequestedParam ¶
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.