Documentation
¶
Index ¶
- Constants
- Variables
- func AbortMigration(ctx context.Context, sc *gophercloud.ServiceClient, instanceUUID string, ...) error
- func ApplyAggregates(ctx context.Context, serviceClient *gophercloud.ServiceClient, host string, ...) ([]kvmv1.Aggregate, error)
- func CleanupResourceProvider(ctx context.Context, client *gophercloud.ServiceClient, ...) error
- func GetHypervisorByName(ctx context.Context, sc *gophercloud.ServiceClient, ...) (*hypervisors.Hypervisor, error)
- func GetServiceClient(ctx context.Context, serviceType string, authInfo *clientconfig.AuthInfo) (*gophercloud.ServiceClient, error)
- func NewProviderClient(ctx context.Context, authInfo *clientconfig.AuthInfo) (*gophercloud.ProviderClient, error)
- func ResourceProviderInUse(ctx context.Context, client *gophercloud.ServiceClient, providerID string) (bool, error)
- func ServiceClientFromProvider(provider *gophercloud.ProviderClient, serviceType string) (*gophercloud.ServiceClient, error)
- type ConsumerAllocations
- type HyperVisorsDetails
- type ListAllocationsResult
- type MigrationInfo
- type UpdateServiceOpts
- type UpdateTraitsOpts
- type UpdateTraitsOptsBuilder
- type UpdateTraitsResult
Constants ¶
const IncomingMigrationsLookbackWindow = 6 * time.Hour
IncomingMigrationsLookbackWindow defines how far back we query Nova for migrations. Nova's live-migration monitor updates Migration.updated_at every ~5 seconds on both libvirt/kvm and libvirt/cloud-hypervisor backends, so any in-flight migration is guaranteed to appear in this window.
Variables ¶
var ErrMultipleHypervisors = errors.New("multiple hypervisors found")
var ErrNoHypervisor = errors.New("no hypervisor found")
Functions ¶
func AbortMigration ¶ added in v1.3.0
func AbortMigration(ctx context.Context, sc *gophercloud.ServiceClient, instanceUUID string, migrationID int) error
AbortMigration issues DELETE /servers/{instanceUUID}/migrations/{migrationID} to abort a live-migration. Treats HTTP 404 and 409 as non-fatal (the migration already transitioned past an abortable state or was deleted).
func ApplyAggregates ¶
func ApplyAggregates(ctx context.Context, serviceClient *gophercloud.ServiceClient, host string, desiredAggregates []string) ([]kvmv1.Aggregate, error)
ApplyAggregates ensures a host is in exactly the specified aggregates.
The function performs a two-phase operation to maintain security: 1. Verifies that all desired aggregates exist 2. Adds the host to all aggregates it should be in but isn't already 3. Removes the host from any aggregates it shouldn't be in
This ordering prevents leaving the host unprotected between operations when aggregates have filter criteria. However, conflicts may still occur with aggregates in different availability zones, in which case errors are collected and returned together for eventual convergence.
All specified aggregates must already exist in OpenStack. If any desired aggregate is not found, an error is returned listing the missing aggregates.
Pass an empty list to remove the host from all aggregates.
func CleanupResourceProvider ¶
func CleanupResourceProvider(ctx context.Context, client *gophercloud.ServiceClient, provider *resourceproviders.ResourceProvider) error
Remove all empty Allocations for a certain provider, and if it is empty, delete it
func GetHypervisorByName ¶
func GetHypervisorByName(ctx context.Context, sc *gophercloud.ServiceClient, hypervisorHostnamePattern string, withServers bool) (*hypervisors.Hypervisor, error)
func GetServiceClient ¶
func GetServiceClient(ctx context.Context, serviceType string, authInfo *clientconfig.AuthInfo) (*gophercloud.ServiceClient, error)
GetServiceClient returns a ServiceClient for the given serviceType. Providers are cached per auth context so Keystone is only hit once per unique set of credentials across all SetupWithManager calls. Concurrent callers with the same key share a single in-flight request via singleflight, preventing duplicate Keystone round-trips on startup.
func NewProviderClient ¶ added in v1.3.0
func NewProviderClient(ctx context.Context, authInfo *clientconfig.AuthInfo) (*gophercloud.ProviderClient, error)
NewProviderClient authenticates against OpenStack and returns a ProviderClient that can be reused across multiple service clients via ServiceClientFromProvider, avoiding repeated Keystone round-trips and catalog deserialisations.
func ResourceProviderInUse ¶ added in v1.4.1
func ResourceProviderInUse(ctx context.Context, client *gophercloud.ServiceClient, providerID string) (bool, error)
ResourceProviderInUse reports whether the resource provider has any non-zero usage. A missing provider is treated as not in use.
func ServiceClientFromProvider ¶ added in v1.3.0
func ServiceClientFromProvider(provider *gophercloud.ProviderClient, serviceType string) (*gophercloud.ServiceClient, error)
ServiceClientFromProvider returns a ServiceClient for the given serviceType using an already-authenticated ProviderClient.
Types ¶
type ConsumerAllocations ¶
type ConsumerAllocations struct {
Allocations map[string]resourceproviders.Allocation `json:"allocations"`
ConsumerGeneration int `json:"consumer_generation"`
ProjectID string `json:"project_id"`
UserID string `json:"user_id"`
ConsumerType string `json:"consumer_type"`
}
type HyperVisorsDetails ¶
type HyperVisorsDetails struct {
Hypervisors []hypervisors.Hypervisor `json:"hypervisors"`
}
type ListAllocationsResult ¶
type ListAllocationsResult struct {
gophercloud.Result
}
ListAllocationsResult is the response of a Get allocations operations. Call its Extract method to interpret it as a Allocations.
func (ListAllocationsResult) Extract ¶
func (r ListAllocationsResult) Extract() (*ConsumerAllocations, error)
Extract interprets a ListAllocationsResult as a Allocations.
type MigrationInfo ¶ added in v1.3.0
type MigrationInfo struct {
ID int `json:"id"`
UUID string `json:"uuid"`
InstanceUUID string `json:"instance_uuid"`
Status string `json:"status"`
SourceCompute string `json:"source_compute"`
DestCompute string `json:"dest_compute"`
MigrationType string `json:"migration_type"`
}
MigrationInfo holds the subset of Nova migration fields relevant to settling incoming migrations on a host being drained.
func ListActiveIncomingMigrations ¶ added in v1.3.0
func ListActiveIncomingMigrations(ctx context.Context, sc *gophercloud.ServiceClient, host string) ([]MigrationInfo, error)
ListActiveIncomingMigrations queries Nova for migrations that target the given host and are still in a non-terminal state. It issues a single call with a changes-since window of IncomingMigrationsLookbackWindow, then filters client-side for dest_compute==host and non-terminal status.
func SettleIncomingMigrations ¶ added in v1.3.0
func SettleIncomingMigrations(ctx context.Context, sc *gophercloud.ServiceClient, host string) (aborted, waiting []MigrationInfo, err error)
SettleIncomingMigrations combines listing and aborting: it lists all active incoming migrations for the host, aborts those in abortable states, and returns both the aborted and the waiting (post-migrating) sets.
The caller should treat:
- len(aborted) > 0 as "just issued aborts, recheck on next reconcile"
- len(waiting) > 0 as "cannot abort, must wait for completion"
- both empty as "no incoming migrations; host is settled"
type UpdateServiceOpts ¶
type UpdateServiceOpts struct {
// Status represents the new service status. One of enabled or disabled.
Status services.ServiceStatus `json:"status,omitempty"`
// DisabledReason represents the reason for disabling a service.
DisabledReason string `json:"disabled_reason,omitempty"`
// ForcedDown is a manual override to tell nova that the service in question
// has been fenced manually by the operations team.
ForcedDown *bool `json:"forced_down,omitempty"`
}
func (UpdateServiceOpts) ToServiceUpdateMap ¶
func (opts UpdateServiceOpts) ToServiceUpdateMap() (map[string]any, error)
ToServiceUpdateMap formats an UpdateServiceOpts structure into a request body.
type UpdateTraitsOpts ¶
type UpdateTraitsOpts struct {
Traits []string `json:"traits"`
ResourceProviderGeneration int `json:"resource_provider_generation"`
}
UpdateTraitsOpts represents options used to create a resource provider.
func (UpdateTraitsOpts) ToResourceProviderUpdateTraitsMap ¶
func (opts UpdateTraitsOpts) ToResourceProviderUpdateTraitsMap() (map[string]any, error)
ToResourceProviderUpdateTraitsMap constructs a request body from UpdateTraitsOpts.
type UpdateTraitsOptsBuilder ¶
type UpdateTraitsOptsBuilder interface {
ToResourceProviderUpdateTraitsMap() (map[string]any, error)
}
UpdateTraitsOptsBuilder allows extensions to add additional parameters to the UpdateTraits request.
type UpdateTraitsResult ¶
type UpdateTraitsResult struct {
gophercloud.Result
}
UpdateTraitsResult is the response of a Put traits operations. Call its Extract method to interpret it as a ResourceProviderTraits.
func UpdateTraits ¶
func UpdateTraits(ctx context.Context, client *gophercloud.ServiceClient, resourceProviderID string, opts UpdateTraitsOptsBuilder) (r UpdateTraitsResult)