Documentation
¶
Overview ¶
The approach for providing VM policy-based integration has the following design constraints:
- Validation must never block updating the data model.
- Real-time validation is best effort.
- A scheduled search for VMs that needs to be validated ensures that all VMs eventually get validated.
Real-time validation is triggered by VM create/update model events. If the validation service is unavailable or fails, the condition is only logged with the intent that the next scheduled search will validate the latest version of VM. The scheduled search is a goroutine that periodically queries the DB for VMs with: revision != revisionValidated. Each matched VM is validated. To reduce overlap between the scheduled validation and event-driven validation, Each model event is "reported" (though a channel) to the search (loop). Reported are omitted from the search result. Both Cluster and Host model events result in all of the VMs in their respective containment trees will be updated with: revisionValidated = 0 which triggers (re)validation.
Index ¶
- Constants
- Variables
- func GetInsecureSkipVerifyFlag(secret *core.Secret) bool
- type Adapter
- type Base
- type BaseAdapter
- type Client
- type Cluster
- type ClusterAdapter
- type ClusterEventHandler
- type ClusterList
- type Collector
- type Context
- type DataCenter
- type DataCenterAdapter
- type DataCenterList
- type Disk
- type DiskAdapter
- type DiskList
- type DiskProfile
- type DiskProfileAdapter
- type DiskProfileHandler
- type DiskProfileList
- type Event
- type EventList
- type Host
- type HostAdapter
- type HostEventHandler
- type HostList
- type NICProfile
- type NICProfileAdapter
- type NICProfileHandler
- type NICProfileList
- type Network
- type NetworkAdapter
- type NetworkList
- type NotFound
- type Ref
- type StorageDomain
- type StorageDomainAdapter
- type StorageDomainList
- type System
- type Updater
- type VM
- type VMAdapter
- type VMEventHandler
- type VMList
Constants ¶
const ( // Retry interval. RetryInterval = 5 * time.Second // Refresh interval. RefreshInterval = 10 * time.Second )
Settings
const ( Started = "" Load = "load" Loaded = "loaded" Parity = "parity" Refresh = "refresh" )
Phases
const ( // DataCenter USER_ADD_STORAGE_POOL = 950 USER_UPDATE_STORAGE_POOL = 952 USER_REMOVE_STORAGE_POOL = 954 // Network NETWORK_ADD_NETWORK = 942 NETWORK_UPDATE_NETWORK = 1114 NETWORK_REMOVE_NETWORK = 944 // Storage Domain USER_ADD_STORAGE_DOMAIN = 956 USER_UPDATE_STORAGE_DOMAIN = 958 USER_REMOVE_STORAGE_DOMAIN = 960 USER_FORCE_REMOVE_STORAGE_DOMAIN = 981 USER_DETACH_STORAGE_DOMAIN_FROM_POOL = 964 // vNIC Profile ADD_VNIC_PROFILE = 1122 UPDATE_VNIC_PROFILE = 1124 REMOVE_VNIC_PROFILE = 1126 // Disk Profile USER_ADD_DISK_PROFILE = 10120 USER_UPDATE_DISK_PROFILE = 10124 USER_REMOVE_DISK_PROFILE = 10122 // Cluster USER_ADD_CLUSTER = 809 USER_UPDATE_CLUSTER = 811 USER_REMOVE_CLUSTER = 813 // Host USER_ADD_VDS = 42 USER_UPDATE_VDS = 43 USER_REMOVE_VDS = 44 USER_VDS_MAINTENANCE = 600 USER_VDS_MAINTENANCE_WITHOUT_REASON = 620 USER_VDS_MAINTENANCE_MANUAL_HA = 10453 VDS_DETECTED = 13 // VM USER_ADD_VM = 34 USER_ADD_VM_FINISHED_SUCCESS = 53 USER_UPDATE_VM = 35 SYSTEM_UPDATE_VM = 253 USER_REMOVE_VM = 113 USER_REMOVE_VM_FINISHED_INTERNAL = 1130 USER_REMOVE_VM_FINISHED_ILLEGAL_DISKS = 172 USER_REMOVE_VM_FINISHED_ILLEGAL_DISKS_INTERNAL = 1720 IMPORTEXPORT_IMPORT_VM = 1152 USER_ADD_DISK_TO_VM_SUCCESS = 97 USER_UPDATE_VM_DISK = 88 USER_REMOVE_DISK_FROM_VM = 80 USER_ATTACH_DISK_TO_VM = 2016 USER_DETACH_DISK_FROM_VM = 2018 USER_EJECT_VM_DISK = 521 USER_CHANGE_DISK_VM = 38 NETWORK_USER_ADD_VM_INTERFACE = 932 NETWORK_USER_UPDATE_VM_INTERFACE = 934 NETWORK_USER_REMOVE_VM_INTERFACE = 930 USER_CREATE_SNAPSHOT_FINISHED_SUCCESS = 68 USER_REMOVE_SNAPSHOT_FINISHED_SUCCESS = 356 VM_ADD_HOST_DEVICES = 10800 VM_REMOVE_HOST_DEVICES = 10801 USER_RUN_VM = 32 USER_SUSPEND_VM_OK = 503 USER_PAUSE_VM = 39 USER_RESUME_VM = 40 VM_DOWN = 61 // Disk USER_ADD_DISK_FINISHED_SUCCESS = 2021 USER_REMOVE_DISK = 2014 USER_FINISHED_REMOVE_DISK_ATTACHED_TO_VMS = 2042 )
Event codes.
const ( // The (max) number of batched task results. MaxBatch = 1024 // Transaction label. ValidationLabel = "VM-validated" )
const ( BaseEndpoint = "/v1/data/io/konveyor/forklift/ovirt/" VersionEndpoint = BaseEndpoint + "rules_version" ValidationEndpoint = BaseEndpoint + "validate" )
Endpoints.
Variables ¶
var Settings = &settings.Settings
Application settings.
Functions ¶
func GetInsecureSkipVerifyFlag ¶
GetInsecureSkipVerifyFlag gets the insecureSkipVerify boolean flag value from the ovirt connection secret.
Types ¶
type Adapter ¶
type Adapter interface { // List REST collections. List(ctx *Context) (itr fb.Iterator, err error) // Apply an event to the inventory model. Apply(ctx *Context, event *Event) (updater Updater, err error) // List handled event (codes). Event() []int }
Model adapter. Provides integration between the REST resource model and the inventory model.
type Cluster ¶
type Cluster struct { Base DataCenter Ref `json:"data_center"` HaReservation string `json:"ha_reservation"` KSM struct { Enabled string `json:"enabled"` } `json:"ksm"` BiosType string `json:"bios_type"` }
Cluster.
type ClusterAdapter ¶
type ClusterAdapter struct {
BaseAdapter
}
Cluster adapter.
type ClusterEventHandler ¶
type ClusterEventHandler struct { libmodel.StockEventHandler // DB. DB libmodel.DB // contains filtered or unexported fields }
Watch for cluster changes and validate as needed.
func (*ClusterEventHandler) Updated ¶
func (r *ClusterEventHandler) Updated(event libmodel.Event)
Cluster updated. Analyze all related VMs.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
oVirt data collector.
type DataCenter ¶
type DataCenter struct {
Base
}
DataCenter.
func (*DataCenter) ApplyTo ¶
func (r *DataCenter) ApplyTo(m *model.DataCenter)
Apply to (update) the model.
type DataCenterAdapter ¶
type DataCenterAdapter struct {
BaseAdapter
}
DataCenter.
type DataCenterList ¶
type DataCenterList struct {
Items []DataCenter `json:"data_center"`
}
DataCenter (list).
type Disk ¶
type Disk struct { Base Sharable string `json:"sharable"` Profile Ref `json:"disk_profile"` ProvisionedSize string `json:"provisioned_size"` StorageDomains struct { List []Ref `json:"storage_domain"` } `json:"storage_domains"` Status string `json:"status"` ActualSize string `json:"actual_size"` Backup string `json:"backup"` StorageType string `json:"storage_type"` }
Disk.
type DiskAdapter ¶
type DiskAdapter struct {
BaseAdapter
}
Disk adapter.
type DiskProfile ¶
Disk profile.
func (*DiskProfile) ApplyTo ¶
func (r *DiskProfile) ApplyTo(m *model.DiskProfile)
Apply to (update) the model.
type DiskProfileAdapter ¶
type DiskProfileAdapter struct {
BaseAdapter
}
DiskProfile adapter.
type DiskProfileHandler ¶
type DiskProfileHandler struct { libmodel.StockEventHandler // DB. DB libmodel.DB // contains filtered or unexported fields }
Watch for DiskProfile changes and validate VMs as needed.
func (*DiskProfileHandler) Updated ¶
func (r *DiskProfileHandler) Updated(event libmodel.Event)
Profile updated. Analyze all referencing VMs.
type DiskProfileList ¶
type DiskProfileList struct {
Items []DiskProfile `json:"disk_profile"`
}
NICProfile (list).
type Event ¶
type Event struct { ID string `json:"id"` Code string `json:"code"` Description string `json:"description"` DataCenter struct { Ref string `json:"href"` ID string `json:"id"` } `json:"data_center"` Cluster struct { Ref string `json:"href"` ID string `json:"id"` } `json:"cluster"` Host struct { Ref string `json:"href"` ID string `json:"id"` } `json:"host"` VM struct { Ref string `json:"href"` ID string `json:"id"` } `json:"vm"` }
Event.
type Host ¶
type Host struct { Base Cluster Ref `json:"cluster"` Status string `json:"status"` OS struct { Type string `json:"type"` Version struct { Full string `json:"full_version"` } `json:"version"` } `json:"os"` CPU struct { Topology struct { Sockets string `json:"sockets"` Cores string `json:"cores"` } `json:"topology"` } `json:"cpu"` SSH struct { Thumbprint string `json:"thumbprint"` } `json:"ssh"` NICs struct { List []struct { ID string `json:"id"` Name string `json:"name"` LinkSpeed string `json:"speed"` MTU string `json:"mtu"` VLan struct { ID string `json:"id"` } `json:"vlan"` } `json:"host_nic"` } `json:"nics"` Networks struct { Attachment []struct { ID string `json:"id"` Network Ref `json:"network"` } `json:"network_attachment"` } `json:"network_attachments"` }
Host.
type HostAdapter ¶
type HostAdapter struct {
BaseAdapter
}
Host (VDS) adapter.
type HostEventHandler ¶
type HostEventHandler struct { libmodel.StockEventHandler // DB. DB libmodel.DB // contains filtered or unexported fields }
Watch for host changes and validate as needed.
func (*HostEventHandler) Updated ¶
func (r *HostEventHandler) Updated(event libmodel.Event)
Host updated. Analyze all related VMs.
type NICProfile ¶
type NICProfile struct { Base Network Ref `json:"network"` QoS Ref `json:"qos"` NetworkFilter Ref `json:"network_filter"` PortMirroring string `json:"port_mirroring"` Properties struct { List []struct { Name string `json:"name"` Value string `json:"value"` } `json:"custom_property"` } `json:"custom_properties"` PassThrough struct { Mode string `json:"mode"` } `json:"pass_through"` }
vNIC profile.
func (*NICProfile) ApplyTo ¶
func (r *NICProfile) ApplyTo(m *model.NICProfile)
Apply to (update) the model.
type NICProfileAdapter ¶
type NICProfileAdapter struct {
BaseAdapter
}
NICProfileAdapter adapter.
type NICProfileHandler ¶
type NICProfileHandler struct { libmodel.StockEventHandler // DB. DB libmodel.DB // contains filtered or unexported fields }
Watch for NICProfile changes and validate VMs as needed.
func (*NICProfileHandler) Updated ¶
func (r *NICProfileHandler) Updated(event libmodel.Event)
Profile updated. Analyze all referencing VMs.
type NICProfileList ¶
type NICProfileList struct {
Items []NICProfile `json:"vnic_profile"`
}
NICProfile (list).
type Network ¶
type Network struct { Base DataCenter Ref `json:"data_center"` VLan Ref `json:"vlan"` Usages struct { Usage []string `json:"usage"` } `json:"usages"` // Profiles struct { List []struct { ID string `json:"id"` } `json:"vnic_profile"` } `json:"vnic_profiles"` }
Network.
type NetworkAdapter ¶
type NetworkAdapter struct {
BaseAdapter
}
Network adapter.
type StorageDomain ¶
type StorageDomain struct { Base Type string `json:"type"` Storage struct { Type string `json:"type"` } `json:"storage"` Available string `json:"available"` Used string `json:"used"` DataCenter struct { List []Ref `json:"data_center"` } `json:"data_centers"` }
StorageDomain.
func (*StorageDomain) ApplyTo ¶
func (r *StorageDomain) ApplyTo(m *model.StorageDomain)
Apply to (update) the model.
type StorageDomainAdapter ¶
type StorageDomainAdapter struct {
BaseAdapter
}
StorageDomain adapter.
type StorageDomainList ¶
type StorageDomainList struct {
Items []StorageDomain `json:"storage_domain"`
}
StorageDomain (list).
type System ¶
type System struct { Product struct { Name string `json:"name"` Vendor string `json:"vendor"` Version struct { Build string `json:"build"` Major string `json:"major"` Minor string `json:"minor"` Revision string `json:"revision"` } `json:"version"` } `json:"product_info"` }
System.
type VM ¶
type VM struct { Base Cluster Ref `json:"cluster"` Host Ref `json:"host"` Guest struct { Distribution string `json:"distribution"` Version struct { Full string `json:"full_version"` } `json:"version"` } `json:"guest_operating_system"` OS struct { Type string `json:"type"` Version struct { Full string `json:"full_version"` } `json:"os"` } CPU struct { Tune struct { Pin struct { List []struct { Set string `json:"cpu_set"` Cpu string `json:"vcpu"` } `json:"vcpu_pin"` } `json:"vcpu_pins"` } `json:"cpu_tune"` Topology struct { Sockets string `json:"sockets"` Cores string `json:"cores"` Threads string `json:"threads"` } `json:"topology"` } `json:"cpu"` USB struct { Enabled string `json:"enabled"` } `json:"usb"` Timezone struct { Name string `json:"name"` } `json:"time_zone"` Status string `json:"status"` Stateless string `json:"stateless"` SerialNumber struct { Value string `json:"value"` } `json:"serial_number"` PlacementPolicy struct { Affinity string `json:"affinity"` } `json:"placement_policy"` Memory string `json:"memory"` IO struct { Threads string `json:"threads"` } `json:"io"` BIOS struct { Type string `json:"type"` BootMenu struct { Enabled string `json:"enabled"` } `json:"boot_menu"` } `json:"bios"` Display struct { Type string `json:"type"` } `json:"display"` HasIllegalImages string `json:"has_illegal_images"` Lease struct { StorageDomain Ref `json:"storage_domain"` } `json:"lease"` StorageErrorResumeBehaviour string `json:"storage_error_resume_behaviour"` MemoryPolicy struct { Ballooning string `json:"ballooning"` } `json:"memory_policy"` HA struct { Enabled string `json:"enabled"` } `json:"high_availability"` HostDevices struct { List []struct { Capability string `json:"capability"` Vendor struct { Name string `json:"name"` } `json:"vendor"` Product struct { Name string `json:"name"` } `json:"product"` } `json:"host_device"` } `json:"host_devices"` CDROMs struct { List []struct { ID string `json:"id"` File struct { ID string `json:"id"` } `json:"file"` } `json:"cdrom"` } `json:"cdroms"` NICs struct { List []struct { ID string `json:"id"` Name string `json:"name"` Interface string `json:"interface"` MAC struct { Address string `json:"address"` } `json:"mac"` Plugged string `json:"plugged"` Profile Ref `json:"vnic_profile"` Devices struct { List []struct { IPS struct { IP []struct { Address string `json:"address"` Version string `json:"version"` } `json:"ip"` } `json:"ips"` } `json:"reported_device"` } `json:"reported_devices"` } `json:"nic"` } `json:"nics"` Disks struct { Attachment []struct { ID string `json:"id"` Name string Interface string `json:"interface"` SCSIReservation string `json:"uses_scsi_reservation"` Disk Ref `json:"disk"` } `json:"disk_attachment"` } `json:"disk_attachments"` WatchDogs struct { List []struct { ID string `json:"id"` Action string `json:"action"` Model string `json:"model"` } `json:"watchdog"` } `json:"watchdogs"` Properties struct { List []struct { Name string `json:"name"` Value string `json:"value"` } `json:"custom_property"` } `json:"custom_properties"` Snapshots struct { List []struct { ID string `json:"id"` Description string `json:"description"` PersistMemory string `json:"persist_memorystate"` Type string `json:"snapshot_type"` } `json:"snapshot"` } `json:"snapshots"` }
VM.
type VMAdapter ¶
type VMAdapter struct {
BaseAdapter
}
VM adapter.
type VMEventHandler ¶
type VMEventHandler struct { libmodel.StockEventHandler // Provider. Provider *api.Provider // DB. DB libmodel.DB // contains filtered or unexported fields }
Watch for VM changes and validate as needed.
func (*VMEventHandler) Created ¶
func (r *VMEventHandler) Created(event libmodel.Event)
VM Created. The VM is scheduled (and reported as scheduled). This is best-effort. If the validate() fails, it wil be picked up in the next search().
func (*VMEventHandler) Updated ¶
func (r *VMEventHandler) Updated(event libmodel.Event)
VM Updated. The VM is scheduled (and reported as scheduled). This is best-effort. If the validate() fails, it wil be picked up in the next search().