openstack

package
v0.0.0-...-c493d5c Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const TriggerNovaFlavorsSynced = "triggers/sync/openstack/nova/types/flavors"

Trigger executed when new flavors are available.

View Source
const TriggerNovaHypervisorsSynced = "triggers/sync/openstack/nova/types/hypervisors"

Trigger executed when new hypervisors are available.

View Source
const TriggerNovaMigrationsSynced = "triggers/sync/openstack/nova/types/migrations"

Trigger executed when new migrations are available.

View Source
const TriggerNovaServersSynced = "triggers/sync/openstack/nova/types/servers"

Trigger executed when new servers are available.

View Source
const TriggerPlacementResourceProvidersSynced = "triggers/sync/openstack/placement/types/resource_providers"

Trigger executed when new resource providers are available.

View Source
const TriggerPlacementTraitsSynced = "triggers/sync/openstack/placement/types/traits"

Trigger executed when new traits are available.

Variables

This section is empty.

Functions

func NewCombinedSyncer

func NewCombinedSyncer(
	ctx context.Context,
	config conf.SyncOpenStackConfig,
	monitor sync.Monitor,
	db db.DB,
	mqttClient mqtt.Client,
) sync.Datasource

Create a new combined syncer that runs multiple syncers in parallel.

Types

type CombinedSyncer

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

Combined syncer that combines multiple syncers.

func (CombinedSyncer) Init

func (s CombinedSyncer) Init(ctx context.Context)

Create all needed database tables if they do not exist.

func (CombinedSyncer) Sync

func (s CombinedSyncer) Sync(context context.Context)

Sync all objects from OpenStack to the database.

type Flavor

type Flavor struct {
	ID          string  `json:"id" db:"id,primarykey"`
	Disk        int     `json:"disk" db:"disk"` // in GB.
	RAM         int     `json:"ram" db:"ram"`   // in MB.
	Name        string  `json:"name" db:"name"`
	RxTxFactor  float64 `json:"rxtx_factor" db:"rxtx_factor"`
	VCPUs       int     `json:"vcpus" db:"vcpus"`
	IsPublic    bool    `json:"os-flavor-access:is_public" db:"is_public"`
	Ephemeral   int     `json:"OS-FLV-EXT-DATA:ephemeral" db:"ephemeral"`
	Description string  `json:"description" db:"description"`
}

OpenStack flavor model as returned by the Nova API under /flavors/detail. See: https://docs.openstack.org/api-ref/compute/#list-flavors

func (Flavor) TableName

func (Flavor) TableName() string

Table in which the openstack model is stored.

type Hypervisor

type Hypervisor struct {
	ID                int    `json:"id" db:"id,primarykey"`
	Hostname          string `json:"hypervisor_hostname" db:"hostname"`
	State             string `json:"state" db:"state"`
	Status            string `json:"status" db:"status"`
	HypervisorType    string `json:"hypervisor_type" db:"hypervisor_type"`
	HypervisorVersion int    `json:"hypervisor_version" db:"hypervisor_version"`
	HostIP            string `json:"host_ip" db:"host_ip"`
	// From nested JSON
	ServiceID             int     `json:"service_id" db:"service_id"`
	ServiceHost           string  `json:"service_host" db:"service_host"` // Used by the scheduler.
	ServiceDisabledReason *string `json:"service_disabled_reason" db:"service_disabled_reason"`
	VCPUs                 int     `json:"vcpus" db:"vcpus"`
	MemoryMB              int     `json:"memory_mb" db:"memory_mb"`
	LocalGB               int     `json:"local_gb" db:"local_gb"`
	VCPUsUsed             int     `json:"vcpus_used" db:"vcpus_used"`
	MemoryMBUsed          int     `json:"memory_mb_used" db:"memory_mb_used"`
	LocalGBUsed           int     `json:"local_gb_used" db:"local_gb_used"`
	FreeRAMMB             int     `json:"free_ram_mb" db:"free_ram_mb"`
	FreeDiskGB            int     `json:"free_disk_gb" db:"free_disk_gb"`
	CurrentWorkload       int     `json:"current_workload" db:"current_workload"`
	RunningVMs            int     `json:"running_vms" db:"running_vms"`
	DiskAvailableLeast    *int    `json:"disk_available_least" db:"disk_available_least"`
	CPUInfo               string  `json:"cpu_info" db:"cpu_info"`
}

OpenStack hypervisor model as returned by the Nova API under /os-hypervisors/detail. See: https://docs.openstack.org/api-ref/compute/#list-hypervisors-details

func (*Hypervisor) MarshalJSON

func (h *Hypervisor) MarshalJSON() ([]byte, error)

Custom marshaler for OpenStackHypervisor to handle nested JSON. Specifically, we wrap the "service" field into a separate JSON object. This is the reverse operation of the UnmarshalJSON method.

func (Hypervisor) TableName

func (Hypervisor) TableName() string

Table in which the openstack model is stored.

func (*Hypervisor) UnmarshalJSON

func (h *Hypervisor) UnmarshalJSON(data []byte) error

Custom unmarshaler for OpenStackHypervisor to handle nested JSON. Specifically, we unwrap the "service" field into separate fields. Flattening these fields makes querying the data easier.

type KeystoneAPI

type KeystoneAPI interface {
	// Authenticate against the OpenStack keystone.
	Authenticate(context.Context) error
	// Get the OpenStack provider client.
	Client() *gophercloud.ProviderClient
	// Find the endpoint for the given service type and availability.
	FindEndpoint(availability, serviceType string) (string, error)
}

KeystoneAPI for OpenStack.

type KeystoneConf

type KeystoneConf = conf.SyncOpenStackKeystoneConfig

Type alias for the OpenStack keystone configuration.

type Migration

type Migration struct {
	ID                int    `json:"id" db:"id,primarykey"`
	UUID              string `json:"uuid" db:"uuid"`
	SourceCompute     string `json:"source_compute" db:"source_compute"`
	DestCompute       string `json:"dest_compute" db:"dest_compute"`
	SourceNode        string `json:"source_node" db:"source_node"`
	DestNode          string `json:"dest_node" db:"dest_node"`
	DestHost          string `json:"dest_host" db:"dest_host"`
	OldInstanceTypeID int    `json:"old_instance_type_id" db:"old_instance_type_id"`
	NewInstanceTypeID int    `json:"new_instance_type_id" db:"new_instance_type_id"`
	InstanceUUID      string `json:"instance_uuid" db:"instance_uuid"`
	Status            string `json:"status" db:"status"`
	MigrationType     string `json:"migration_type" db:"migration_type"`
	UserID            string `json:"user_id" db:"user_id"`
	ProjectID         string `json:"project_id" db:"project_id"`
	CreatedAt         string `json:"created_at" db:"created_at"`
	UpdatedAt         string `json:"updated_at" db:"updated_at"`
}

OpenStack migration model as returned by the Nova API under /os-migrations. See: https://docs.openstack.org/api-ref/compute/#list-migrations

func (Migration) TableName

func (Migration) TableName() string

Table in which the openstack model is stored.

type NovaAPI

type NovaAPI interface {
	// Init the nova API.
	Init(ctx context.Context)
	// Get all changed nova servers since the timestamp.
	GetChangedServers(ctx context.Context, changedSince *time.Time) ([]Server, error)
	// Get all changed nova hypervisors since the timestamp.
	GetChangedHypervisors(ctx context.Context, changedSince *time.Time) ([]Hypervisor, error)
	// Get all changed nova flavors since the timestamp.
	// Note: This should only include the public flavors.
	GetChangedFlavors(ctx context.Context, changedSince *time.Time) ([]Flavor, error)
	// Get all changed nova migrations since the timestamp.
	GetChangedMigrations(ctx context.Context, changedSince *time.Time) ([]Migration, error)
}

type NovaConf

type NovaConf = conf.SyncOpenStackNovaConfig

Type alias for the OpenStack nova configuration.

type PlacementAPI

type PlacementAPI interface {
	// Init the placement API.
	Init(ctx context.Context)
	// Fetch all resource providers from the placement API.
	GetAllResourceProviders(ctx context.Context) ([]ResourceProvider, error)
	// Fetch all traits for the given resource providers from the placement API.
	GetAllTraits(ctx context.Context, providers []ResourceProvider) ([]Trait, error)
}

type PlacementConf

type PlacementConf = conf.SyncOpenStackPlacementConfig

Type alias for the OpenStack placement configuration.

type ResourceProvider

type ResourceProvider struct {
	UUID                       string `json:"uuid" db:"uuid,primarykey"`
	Name                       string `json:"name" db:"name"`
	ParentProviderUUID         string `json:"parent_provider_uuid" db:"parent_provider_uuid"`
	RootProviderUUID           string `json:"root_provider_uuid" db:"root_provider_uuid"`
	ResourceProviderGeneration int    `json:"resource_provider_generation" db:"resource_provider_generation"`
}

Resource provider model from the OpenStack placement API. This model is returned when listing resource providers.

func (ResourceProvider) TableName

func (r ResourceProvider) TableName() string

Table in which the openstack model is stored.

type Server

type Server struct {
	ID                             string  `json:"id" db:"id,primarykey"`
	Name                           string  `json:"name" db:"name"`
	Status                         string  `json:"status" db:"status"`
	TenantID                       string  `json:"tenant_id" db:"tenant_id"`
	UserID                         string  `json:"user_id" db:"user_id"`
	HostID                         string  `json:"hostId" db:"host_id"`
	Created                        string  `json:"created" db:"created"`
	Updated                        string  `json:"updated" db:"updated"`
	AccessIPv4                     string  `json:"accessIPv4" db:"access_ipv4"`
	AccessIPv6                     string  `json:"accessIPv6" db:"access_ipv6"`
	OSDCFdiskConfig                string  `json:"OS-DCF:diskConfig" db:"os_dcf_disk_config"`
	Progress                       int     `json:"progress" db:"progress"`
	OSEXTAvailabilityZone          string  `json:"OS-EXT-AZ:availability_zone" db:"os_ext_az_availability_zone"`
	ConfigDrive                    string  `json:"config_drive" db:"config_drive"`
	KeyName                        string  `json:"key_name" db:"key_name"`
	OSSRVUSGLaunchedAt             string  `json:"OS-SRV-USG:launched_at" db:"os_srv_usg_launched_at"`
	OSSRVUSGTerminatedAt           *string `json:"OS-SRV-USG:terminated_at" db:"os_srv_usg_terminated_at"`
	OSEXTSRVATTRHost               string  `json:"OS-EXT-SRV-ATTR:host" db:"os_ext_srv_attr_host"`
	OSEXTSRVATTRInstanceName       string  `json:"OS-EXT-SRV-ATTR:instance_name" db:"os_ext_srv_attr_instance_name"`
	OSEXTSRVATTRHypervisorHostname string  `json:"OS-EXT-SRV-ATTR:hypervisor_hostname" db:"os_ext_srv_attr_hypervisor_hostname"`
	OSEXTSTSTaskState              *string `json:"OS-EXT-STS:task_state" db:"os_ext_sts_task_state"`
	OSEXTSTSVmState                string  `json:"OS-EXT-STS:vm_state" db:"os_ext_sts_vm_state"`
	OSEXTSTSPowerState             int     `json:"OS-EXT-STS:power_state" db:"os_ext_sts_power_state"`

	// From nested JSON
	FlavorID string `json:"-" db:"flavor_id"`
}

OpenStack server model as returned by the Nova API under /servers/detail. See: https://docs.openstack.org/api-ref/compute/#list-servers-detailed

func (*Server) MarshalJSON

func (s *Server) MarshalJSON() ([]byte, error)

Custom marshaler for OpenStackServer to handle nested JSON.

func (Server) TableName

func (Server) TableName() string

Table in which the openstack model is stored.

func (*Server) UnmarshalJSON

func (s *Server) UnmarshalJSON(data []byte) error

Custom unmarshaler for OpenStackServer to handle nested JSON.

type Syncer

type Syncer interface {
	Init(context.Context)
	Sync(context.Context) error
}

type Trait

type Trait struct {
	ResourceProviderUUID       string `db:"resource_provider_uuid,primarykey"`
	Name                       string `db:"name,primarykey"`
	ResourceProviderGeneration int    `db:"resource_provider_generation"`
}

Resource provider trait model from the OpenStack placement API.

func (Trait) TableName

func (r Trait) TableName() string

Table in which the openstack trait model is stored.

Jump to

Keyboard shortcuts

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