schedulerhints

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: Apache-2.0 Imports: 6 Imported by: 5

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"`

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

	/*
	   创建弹性云服务器时检查资源是否充足。如果资源不足,则同步返回资源不足结果。不指定该参数时,则不进行资源充足性检查。
	   值为: true或false
	   true:表示进行资源充足性检查。
	   false:表示不进行资源充足性检查。
	   说明:
	   由于资源使用的动态性,资源充足性检查结果存在一定的误差。
	*/
	CheckResources string

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

	//dedicated host or shared host
	Tenancy string `json:"tenancy,omitempty"`

	// dedicated host id
	DedicatedHostID string `json:"dedicated_host_id,omitempty"`

	// host network
	Cidr string `json:"cidr,omitempty"`
}

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