resourceproviders

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 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",
	ParentProvider: "c7f50b40-6f32-4d7a-9f32-9384057be83b"
}

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

Example to Delete a resource provider

resourceProviderID := "b99b3ab4-3aa6-4fba-b827-69b88b9c544a"
err := resourceproviders.Delete(placementClient, resourceProviderID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Get a resource provider

resourceProviderID := "b99b3ab4-3aa6-4fba-b827-69b88b9c544a"
resourceProvider, err := resourceproviders.Get(placementClient, resourceProviderID).Extract()
if err != nil {
	panic(err)
}

Example to Update a resource provider

resourceProviderID := "b99b3ab4-3aa6-4fba-b827-69b88b9c544a"

updateOpts := resourceproviders.UpdateOpts{
	Name: "new-rp",
	ParentProvider: "c7f50b40-6f32-4d7a-9f32-9384057be83b"
}

placementClient.Microversion = "1.37"
resourceProvider, err := resourceproviders.Update(placementClient, resourceProviderID).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 added in v0.18.0

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

type CreateOpts

type CreateOpts struct {
	Name string `json:"name"`
	UUID string `json:"uuid,omitempty"`
	// The UUID of the immediate parent of the resource provider.
	// Available in version >= 1.14
	ParentProviderUUID string `json:"parent_provider_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 DeleteResult added in v0.25.0

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete added in v0.25.0

func Delete(c *gophercloud.ServiceClient, resourceProviderID string) (r DeleteResult)

Delete accepts a unique ID and deletes the resource provider associated with it.

type GetAllocationsResult added in v0.18.0

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 added in v0.18.0

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

func (GetAllocationsResult) Extract added in v0.18.0

Extract interprets a GetAllocationsResult as a ResourceProviderAllocations.

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 GetResult added in v0.25.0

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult represents the result of a create operation. Call its Extract method to interpret it as a ResourceProvider.

func Get added in v0.25.0

func Get(c *gophercloud.ServiceClient, resourceProviderID string) (r GetResult)

Get retrieves a specific resource provider based on its unique ID.

func (GetResult) Extract added in v0.25.0

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

Extract interpets any resourceProviderResult-base result as a ResourceProvider.

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 ResourceProviderAllocations added in v0.18.0

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

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.

type UpdateOpts added in v0.25.0

type UpdateOpts struct {
	Name *string `json:"name,omitempty"`
	// Available in version >= 1.37. It can be set to any existing provider UUID
	// except to providers that would cause a loop. Also it can be set to null
	// to transform the provider to a new root provider. This operation needs to
	// be used carefully. Moving providers can mean that the original rules used
	// to create the existing resource allocations may be invalidated by that move.
	ParentProviderUUID *string `json:"parent_provider_uuid,omitempty"`
}

UpdateOpts represents options used to update a resource provider.

func (UpdateOpts) ToResourceProviderUpdateMap added in v0.25.0

func (opts UpdateOpts) ToResourceProviderUpdateMap() (map[string]interface{}, error)

ToResourceProviderUpdateMap constructs a request body from UpdateOpts.

type UpdateOptsBuilder added in v0.25.0

type UpdateOptsBuilder interface {
	ToResourceProviderUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult added in v0.25.0

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult represents the result of a update operation. Call its Extract method to interpret it as a ResourceProvider.

func Update added in v0.25.0

func Update(client *gophercloud.ServiceClient, resourceProviderID string, opts UpdateOptsBuilder) (r UpdateResult)

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

func (UpdateResult) Extract added in v0.25.0

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

Extract interpets any resourceProviderResult-base result as a ResourceProvider.

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