resourceproviders

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Overview

Package resourceproviders creates and lists all resource providers from the OpenStack Placement service.

Example to list resource providers

allPages, err := resourceproviders.List(placementClient, resourceproviders.ListOpts{}).AllPages()
if err != nil {
	panic(err)
}

allResourceProviders, err := resourceproviders.ExtractResourceProviders(allPages)
if err != nil {
	panic(err)
}

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

Example to create resource providers

createOpts := resourceproviders.CreateOpts{
	Name: "new-rp",
	UUID: "b99b3ab4-3aa6-4fba-b827-69b88b9c544a",
}

rp, err := resourceproviders.Create(placementClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to get resource providers usages

rp, err := resourceproviders.GetUsages(placementClient, resourceProviderID).Extract()
if err != nil {
	panic(err)
}

Example to get resource providers inventories

rp, err := resourceproviders.GetInventories(placementClient, resourceProviderID).Extract()
if err != nil {
	panic(err)
}

Example to get resource providers traits

rp, err := resourceproviders.GetTraits(placementClient, resourceProviderID).Extract()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List makes a request against the API to list resource providers.

Types

type CreateOpts

type CreateOpts struct {
	Name string `json:"name"`
	UUID string `json:"uuid,omitempty"`
}

CreateOpts represents options used to create a resource provider.

func (CreateOpts) ToResourceProviderCreateMap

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

ToResourceProviderCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToResourceProviderCreateMap() (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 result of a Create operation. Call its Extract method to interpret it as a ResourceProvider.

func Create

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

Create makes a request against the API to create a resource provider

func (CreateResult) Extract

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

Extract interpets any resourceProviderResult-base result as a ResourceProvider.

type GetInventoriesResult added in v0.9.0

type GetInventoriesResult struct {
	gophercloud.Result
}

GetInventoriesResult is the response of a Get inventories operations. Call its Extract method to interpret it as a ResourceProviderInventories.

func GetInventories added in v0.9.0

func GetInventories(client *gophercloud.ServiceClient, resourceProviderID string) (r GetInventoriesResult)

func (GetInventoriesResult) Extract added in v0.9.0

Extract interprets a GetInventoriesResult as a ResourceProviderInventories.

type GetTraitsResult added in v0.10.0

type GetTraitsResult struct {
	gophercloud.Result
}

GetTraitsResult is the response of a Get traits operations. Call its Extract method to interpret it as a ResourceProviderTraits.

func GetTraits added in v0.10.0

func GetTraits(client *gophercloud.ServiceClient, resourceProviderID string) (r GetTraitsResult)

func (GetTraitsResult) Extract added in v0.10.0

Extract interprets a GetTraitsResult as a ResourceProviderTraits.

type GetUsagesResult added in v0.9.0

type GetUsagesResult struct {
	gophercloud.Result
}

GetUsagesResult is the response of a Get usage operations. Call its Extract method to interpret it as a ResourceProviderUsage.

func GetUsages added in v0.9.0

func GetUsages(client *gophercloud.ServiceClient, resourceProviderID string) (r GetUsagesResult)

func (GetUsagesResult) Extract added in v0.9.0

Extract interprets a GetUsagesResult as a ResourceProviderUsage.

type Inventory added in v0.9.0

type Inventory struct {
	AllocationRatio float32 `json:"allocation_ratio"`
	MaxUnit         int     `json:"max_unit"`
	MinUnit         int     `json:"min_unit"`
	Reserved        int     `json:"reserved"`
	StepSize        int     `json:"step_size"`
	Total           int     `json:"total"`
}

type ListOpts

type ListOpts struct {
	// Name is the name of the resource provider to filter the list
	Name string `q:"name"`

	// UUID is the uuid of the resource provider to filter the list
	UUID string `q:"uuid"`

	// MemberOf is a string representing aggregate uuids to filter or exclude from the list
	MemberOf string `q:"member_of"`

	// Resources is a comma-separated list of string indicating an amount of resource
	// of a specified class that a provider must have the capacity and availability to serve
	Resources string `q:"resources"`

	// InTree is a string that represents a resource provider UUID.  The returned resource
	// providers will be in the same provider tree as the specified provider.
	InTree string `q:"in_tree"`

	// Required is comma-delimited list of string trait names.
	Required string `q:"required"`
}

ListOpts allows the filtering resource providers. Filtering is achieved by passing in struct field values that map to the resource provider attributes you want to see returned.

func (ListOpts) ToResourceProviderListQuery

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

ToResourceProviderListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request.

type ResourceProvider

type ResourceProvider struct {
	// Generation is a consistent view marker that assists with the management of concurrent resource provider updates.
	Generation int `json:"generation"`

	// UUID of a resource provider.
	UUID string `json:"uuid"`

	// Links is a list of links associated with one resource provider.
	Links []ResourceProviderLinks `json:"links"`

	// Name of one resource provider.
	Name string `json:"name"`

	// The ParentProviderUUID contains the UUID of the immediate parent of the resource provider.
	// Requires microversion 1.14 or above
	ParentProviderUUID string `json:"parent_provider_uuid"`

	// The RootProviderUUID contains the read-only UUID of the top-most provider in this provider tree.
	// Requires microversion 1.14 or above
	RootProviderUUID string `json:"root_provider_uuid"`
}

ResourceProvider are entities which provider consumable inventory of one or more classes of resource

func ExtractResourceProviders

func ExtractResourceProviders(r pagination.Page) ([]ResourceProvider, error)

ExtractResourceProviders returns a slice of ResourceProvider from a List operation.

type ResourceProviderInventories added in v0.9.0

type ResourceProviderInventories struct {
	ResourceProviderGeneration int                  `json:"resource_provider_generation"`
	Inventories                map[string]Inventory `json:"inventories"`
}
type ResourceProviderLinks struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

type ResourceProviderTraits added in v0.10.0

type ResourceProviderTraits struct {
	ResourceProviderGeneration int      `json:"resource_provider_generation"`
	Traits                     []string `json:"traits"`
}

type ResourceProviderUsage added in v0.9.0

type ResourceProviderUsage struct {
	ResourceProviderGeneration int            `json:"resource_provider_generation"`
	Usages                     map[string]int `json:"usages"`
}

type ResourceProvidersPage

type ResourceProvidersPage struct {
	pagination.SinglePageBase
}

ResourceProvidersPage contains a single page of all resource providers from a List call.

func (ResourceProvidersPage) IsEmpty

func (page ResourceProvidersPage) IsEmpty() (bool, error)

IsEmpty determines if a ResourceProvidersPage contains any results.

Directories

Path Synopsis
placement resource providers
placement resource providers

Jump to

Keyboard shortcuts

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