extendedserverattributes

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Overview

Package extendedserverattributes provides the ability to extend a server result with the extended usage information.

Example to Get basic extended information:

type serverAttributesExt struct {
  servers.Server
  extendedserverattributes.ServerAttributesExt
}
var serverWithAttributesExt serverAttributesExt

err := servers.Get(computeClient, "d650a0ce-17c3-497d-961a-43c4af80998a").ExtractInto(&serverWithAttributesExt)
if err != nil {
  panic(err)
}

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

Example to get additional fields with microversion 2.3 or later

computeClient.Microversion = "2.3"
result := servers.Get(computeClient, "d650a0ce-17c3-497d-961a-43c4af80998a")

reservationID, err := extendedserverattributes.ExtractReservationID(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", reservationID)

launchIndex, err := extendedserverattributes.ExtractLaunchIndex(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%d\n", launchIndex)

ramdiskID, err := extendedserverattributes.ExtractRamdiskID(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", ramdiskID)

kernelID, err := extendedserverattributes.ExtractKernelID(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", kernelID)

hostname, err := extendedserverattributes.ExtractHostname(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", hostname)

rootDeviceName, err := extendedserverattributes.ExtractRootDeviceName(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", rootDeviceName)

userData, err := extendedserverattributes.ExtractUserData(result.Result)
if err != nil {
  panic(err)
}
fmt.Printf("%s\n", userData)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHostname

func ExtractHostname(r gophercloud.Result) (string, error)

ExtractHostname will extract the hostname attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractKernelID

func ExtractKernelID(r gophercloud.Result) (string, error)

ExtractKernelID will extract the kernel_id attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractLaunchIndex

func ExtractLaunchIndex(r gophercloud.Result) (int, error)

ExtractLaunchIndex will extract the launch_index attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractRamdiskID

func ExtractRamdiskID(r gophercloud.Result) (string, error)

ExtractRamdiskID will extract the ramdisk_id attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractReservationID

func ExtractReservationID(r gophercloud.Result) (string, error)

ExtractReservationID will extract the reservation_id attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractRootDeviceName

func ExtractRootDeviceName(r gophercloud.Result) (string, error)

ExtractRootDeviceName will extract the root_device_name attribute. This requires the client to be set to microversion 2.3 or later.

func ExtractUserData

func ExtractUserData(r gophercloud.Result) (string, error)

ExtractUserData will extract the userdata attribute. This requires the client to be set to microversion 2.3 or later.

Types

type ServerAttributesExt

type ServerAttributesExt struct {
	Host               string `json:"OS-EXT-SRV-ATTR:host"`
	InstanceName       string `json:"OS-EXT-SRV-ATTR:instance_name"`
	HypervisorHostname string `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"`
}

ServerAttributesExt represents basic OS-EXT-SRV-ATTR server response fields. You should use extract methods from microversions.go to retrieve additional fields.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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