schedulerhints

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: Apache-2.0 Imports: 6 Imported by: 157

Documentation

Overview

Package schedulerhints extends the server create request with the ability to specify additional parameters which determine where the server will be created in the OpenStack cloud.

Example to Add a Server to a Server Group

schedulerHints := schedulerhints.SchedulerHints{
	Group: "servergroup-uuid",
}

serverCreateOpts := servers.CreateOpts{
	Name:      "server_name",
	ImageRef:  "image-uuid",
	FlavorRef: "flavor-uuid",
}

createOpts := schedulerhints.CreateOptsExt{
	CreateOptsBuilder: serverCreateOpts,
	SchedulerHints:    schedulerHints,
}

server, err := servers.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Place Server B on a Different Host than Server A

schedulerHints := schedulerhints.SchedulerHints{
	DifferentHost: []string{
		"server-a-uuid",
	}
}

serverCreateOpts := servers.CreateOpts{
	Name:      "server_b",
	ImageRef:  "image-uuid",
	FlavorRef: "flavor-uuid",
}

createOpts := schedulerhints.CreateOptsExt{
	CreateOptsBuilder: serverCreateOpts,
	SchedulerHints:    schedulerHints,
}

server, err := servers.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Place Server B on the Same Host as Server A

schedulerHints := schedulerhints.SchedulerHints{
	SameHost: []string{
		"server-a-uuid",
	}
}

serverCreateOpts := servers.CreateOpts{
	Name:      "server_b",
	ImageRef:  "image-uuid",
	FlavorRef: "flavor-uuid",
}

createOpts := schedulerhints.CreateOptsExt{
	CreateOptsBuilder: serverCreateOpts,
	SchedulerHints:    schedulerHints,
}

server, err := servers.Create(computeClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOptsBuilder

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

CreateOptsBuilder builds the scheduler hints into a serializable format.

type CreateOptsExt

type CreateOptsExt struct {
	servers.CreateOptsBuilder

	// SchedulerHints provides a set of hints to the scheduler.
	SchedulerHints CreateOptsBuilder
}

CreateOptsExt adds a SchedulerHints option to the base CreateOpts.

func (CreateOptsExt) ToServerCreateMap

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

ToServerCreateMap adds the SchedulerHints option to the base server creation options.

type SchedulerHints

type SchedulerHints struct {
	// Group specifies a Server Group to place the instance in.
	Group string

	// DifferentHost will place the instance on a compute node that does not
	// host the given instances.
	DifferentHost []string

	// SameHost will place the instance on a compute node that hosts the given
	// instances.
	SameHost []string

	// Query is a conditional statement that results in compute nodes able to
	// host the instance.
	Query []interface{}

	// TargetCell specifies a cell name where the instance will be placed.
	TargetCell string `json:"target_cell,omitempty"`

	// DifferentCell specifies cells names where an instance should not be placed.
	DifferentCell []string `json:"different_cell,omitempty"`

	// BuildNearHostIP specifies a subnet of compute nodes to host the instance.
	BuildNearHostIP string

	// AdditionalProperies are arbitrary key/values that are not validated by nova.
	AdditionalProperties map[string]interface{}
}

SchedulerHints represents a set of scheduling hints that are passed to the OpenStack scheduler.

func (SchedulerHints) ToServerSchedulerHintsCreateMap

func (opts SchedulerHints) ToServerSchedulerHintsCreateMap() (map[string]interface{}, error)

ToServerSchedulerHintsMap builds the scheduler hints into a serializable format.

Directories

Path Synopsis
schedulerhints unit tests
schedulerhints unit tests

Jump to

Keyboard shortcuts

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