nova

package
v0.0.0-...-a25a10f Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TriggerNovaAggregatesSynced = "triggers/sync/openstack/nova/types/aggregates"

Trigger executed when new aggregates are available.

View Source
const TriggerNovaDeletedServersSynced = "triggers/sync/openstack/nova/types/deleted_servers"

Trigger executed when new deleted servers are available.

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.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate struct {
	UUID             string  `json:"uuid" db:"uuid"`
	Name             string  `json:"name" db:"name"`
	AvailabilityZone *string `json:"availability_zone" db:"availability_zone"`
	ComputeHost      *string `json:"compute_host" db:"compute_host"` // Host that the aggregate is associated with.
	Metadata         string  `json:"metadata" db:"metadata"`         // JSON string of properties.
}

Aggregate as converted to be handled efficiently in a database.

func (Aggregate) Indexes

func (Aggregate) Indexes() []db.Index

Index for the openstack model.

func (Aggregate) TableName

func (Aggregate) TableName() string

Table in which the openstack model is stored.

type DeletedServer

type DeletedServer 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"`
	OSEXTAvailabilityZone          string  `json:"OS-EXT-AZ:availability_zone" db:"os_ext_az_availability_zone"`
	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"`

	// From nested JSON
	FlavorName string `json:"-" db:"flavor_name"`
}

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

func (DeletedServer) Indexes

func (DeletedServer) Indexes() []db.Index

Index for the openstack model.

func (*DeletedServer) MarshalJSON

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

Custom marshaler for OpenStackServer to handle nested JSON.

func (DeletedServer) TableName

func (DeletedServer) TableName() string

Table in which the openstack model is stored.

func (*DeletedServer) UnmarshalJSON

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

Custom unmarshaler for OpenStackServer to handle nested JSON.

type Flavor

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

	// JSON string of extra specifications used when scheduling the flavor.
	ExtraSpecs string `json:"extra_specs" db:"extra_specs"`
}

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

func (Flavor) Indexes

func (Flavor) Indexes() []db.Index

Index for the openstack model.

func (*Flavor) MarshalJSON

func (f *Flavor) MarshalJSON() ([]byte, error)

Custom marshaler for OpenStackFlavor to handle nested JSON.

func (Flavor) TableName

func (Flavor) TableName() string

Table in which the openstack model is stored.

func (*Flavor) UnmarshalJSON

func (f *Flavor) UnmarshalJSON(data []byte) error

Custom unmarshaler for OpenStackFlavor to handle nested JSON.

type Hypervisor

type Hypervisor struct {
	ID                string `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             string  `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) Indexes

func (Hypervisor) Indexes() []db.Index

Index for the openstack model.

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

func (Migration) Indexes() []db.Index

Index for the openstack model.

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 nova servers that are NOT deleted. (Includes ERROR, SHUTOFF etc)
	GetAllServers(ctx context.Context) ([]Server, error)
	// Get all deleted nova servers since the timestamp.
	GetDeletedServers(ctx context.Context, since time.Time) ([]DeletedServer, error)
	// Get all nova hypervisors.
	GetAllHypervisors(ctx context.Context) ([]Hypervisor, error)
	// Get all nova flavors.
	GetAllFlavors(ctx context.Context) ([]Flavor, error)
	// Get all nova migrations.
	GetAllMigrations(ctx context.Context) ([]Migration, error)
	// Get all aggregates.
	GetAllAggregates(ctx context.Context) ([]Aggregate, error)
}

func NewNovaAPI

func NewNovaAPI(mon sync.Monitor, k keystone.KeystoneAPI, conf NovaConf) NovaAPI

Create a new OpenStack server syncer.

type NovaConf

type NovaConf = conf.SyncOpenStackNovaConfig

Type alias for the OpenStack nova configuration.

type NovaSyncer

type NovaSyncer struct {
	// Database to store the nova objects in.
	DB db.DB
	// Monitor to track the syncer.
	Mon sync.Monitor
	// Configuration for the nova syncer.
	Conf NovaConf
	// Nova API client to fetch the data.
	API NovaAPI
	// MQTT client to publish mqtt data.
	MqttClient mqtt.Client
}

Syncer for OpenStack nova.

func (*NovaSyncer) Init

func (s *NovaSyncer) Init(ctx context.Context)

Init the OpenStack nova syncer.

func (*NovaSyncer) Sync

func (s *NovaSyncer) Sync(ctx context.Context) error

Sync the OpenStack nova objects and publish triggers.

func (*NovaSyncer) SyncAllAggregates

func (s *NovaSyncer) SyncAllAggregates(ctx context.Context) ([]Aggregate, error)

Sync the OpenStack aggregates into the database.

func (*NovaSyncer) SyncAllFlavors

func (s *NovaSyncer) SyncAllFlavors(ctx context.Context) ([]Flavor, error)

Sync the OpenStack flavors into the database.

func (*NovaSyncer) SyncAllHypervisors

func (s *NovaSyncer) SyncAllHypervisors(ctx context.Context) ([]Hypervisor, error)

Sync the OpenStack hypervisors into the database.

func (*NovaSyncer) SyncAllMigrations

func (s *NovaSyncer) SyncAllMigrations(ctx context.Context) ([]Migration, error)

Sync the OpenStack migrations into the database.

func (*NovaSyncer) SyncAllServers

func (s *NovaSyncer) SyncAllServers(ctx context.Context) ([]Server, error)

Sync all the active OpenStack servers into the database. (Includes ERROR, SHUTOFF, etc. state)

func (*NovaSyncer) SyncDeletedServers

func (s *NovaSyncer) SyncDeletedServers(ctx context.Context) ([]DeletedServer, error)

Sync all the deleted OpenStack servers into the database. Only fetch servers that were deleted since the last sync run.

type RawAggregate

type RawAggregate struct {
	UUID             string            `json:"uuid"`
	Name             string            `json:"name"`
	AvailabilityZone *string           `json:"availability_zone"`
	Hosts            []string          `json:"hosts"`
	Metadata         map[string]string `json:"metadata"`
}

Raw aggregate as returned by the Nova API under /os-aggregates.

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
	FlavorName string `json:"-" db:"flavor_name"`
}

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

func (Server) Indexes() []db.Index

Index for the openstack model.

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.

Jump to

Keyboard shortcuts

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