resourceproviders

package
v0.0.0-...-cd80d89 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

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)
}

Example to get resource providers allocations

rp, err := resourceproviders.GetAllocations(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 Allocation

type Allocation struct {
	Resources map[string]int `json:"resources"`
}

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 GetAllocationsResult

type GetAllocationsResult struct {
	gophercloud.Result
}

GetAllocationsResult is the response of a Get allocations operations. Call its Extract method to interpret it as a ResourceProviderAllocations.

func GetAllocations

func GetAllocations(client *gophercloud.ServiceClient, resourceProviderID string) (r GetAllocationsResult)

func (GetAllocationsResult) Extract

Extract interprets a GetAllocationsResult as a ResourceProviderAllocations.

type GetInventoriesResult

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

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

func (GetInventoriesResult) Extract

Extract interprets a GetInventoriesResult as a ResourceProviderInventories.

type GetTraitsResult

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

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

func (GetTraitsResult) Extract

Extract interprets a GetTraitsResult as a ResourceProviderTraits.

type GetUsagesResult

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

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

func (GetUsagesResult) Extract

Extract interprets a GetUsagesResult as a ResourceProviderUsage.

type Inventory

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 ResourceProviderAllocations

type ResourceProviderAllocations struct {
	ResourceProviderGeneration int                   `json:"resource_provider_generation"`
	Allocations                map[string]Allocation `json:"allocations"`
}

type ResourceProviderInventories

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

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

type ResourceProviderUsage

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