vsphere

package
v0.0.0-...-e73b65a Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

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

View Source
const (
	// Connect retry delay.
	RetryDelay = time.Second * 5
	// Max object in each update.
	MaxObjectUpdates = 10000
)

Settings

View Source
const (
	Folder          = "Folder"
	VirtualMachine  = "VirtualMachine"
	Datacenter      = "Datacenter"
	Cluster         = "ClusterComputeResource"
	ComputeResource = "ComputeResource"
	Host            = "HostSystem"
	Network         = "Network"
	DVPortGroup     = "DistributedVirtualPortgroup"
	DVSwitch        = "VmwareDistributedVirtualSwitch"
	Datastore       = "Datastore"
)

Types

View Source
const (
	Enter  = "enter"
	Leave  = "leave"
	Modify = "modify"
	Assign = "assign"
)

Actions

View Source
const (
	// The (max) number of batched task results.
	MaxBatch = 1024
	// Transaction label.
	ValidationLabel = "VM-validated"
)
View Source
const (
	BaseEndpoint       = "/v1/data/io/konveyor/forklift/vmware/"
	VersionEndpoint    = BaseEndpoint + "rules_version"
	ValidationEndpoint = BaseEndpoint + "validate"
)

Endpoints.

View Source
const (
	TraverseFolders = "traverseFolders"
)

Selections

Variables

View Source
var Settings = &settings.Settings

Application settings.

View Source
var TsComputeResourceHost = &types.TraversalSpec{
	Type: ComputeResource,
	Path: fHost,
	SelectSet: []types.BaseSelectionSpec{
		&types.SelectionSpec{
			Name: TraverseFolders,
		},
	},
}

ComputeResource/Host traversal Spec.

View Source
var TsDatacenterDatastore = &types.TraversalSpec{
	Type: Datacenter,
	Path: fDsFolder,
	SelectSet: []types.BaseSelectionSpec{
		&types.SelectionSpec{
			Name: TraverseFolders,
		},
	},
}

Datacenter/Datastore traversal Spec.

View Source
var TsDatacenterHost = &types.TraversalSpec{
	Type: Datacenter,
	Path: fHostFolder,
	SelectSet: []types.BaseSelectionSpec{
		&types.SelectionSpec{
			Name: TraverseFolders,
		},
	},
}

Datacenter/Host traversal Spec.

View Source
var TsDatacenterNet = &types.TraversalSpec{
	Type: Datacenter,
	Path: fNetFolder,
	SelectSet: []types.BaseSelectionSpec{
		&types.SelectionSpec{
			Name: TraverseFolders,
		},
	},
}

Datacenter/Host traversal Spec.

View Source
var TsDatacenterVM = &types.TraversalSpec{
	Type: Datacenter,
	Path: fVmFolder,
	SelectSet: []types.BaseSelectionSpec{
		&types.SelectionSpec{
			Name: TraverseFolders,
		},
	},
}

Datacenter/VM traversal Spec.

Root Folder traversal Spec

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	// The adapter model.
	Model() model.Model
	// Apply the update to the model.
	Apply(types.ObjectUpdate)
}

Model adapter. Each adapter provides provider-specific management of a model.

type Base

type Base struct {
}

Base adapter.

func (*Base) Apply

func (b *Base) Apply(m *model.Base, u types.ObjectUpdate)

Apply the update to the model `Base`.

func (*Base) Decoded

func (b *Base) Decoded(in types.AnyType) (s string)

URL decoded string. Some property values returned by the property collector are URL-encoded.

func (*Base) Ref

func (b *Base) Ref(in types.AnyType) (ref model.Ref)

Build ref.

func (*Base) RefList

func (b *Base) RefList(in types.AnyType) (list []model.Ref)

Build a []Ref.

type ClusterAdapter

type ClusterAdapter struct {
	Base
	// contains filtered or unexported fields
}

Cluster model adapter.

func (*ClusterAdapter) Apply

func (v *ClusterAdapter) Apply(u types.ObjectUpdate)

func (*ClusterAdapter) Model

func (v *ClusterAdapter) Model() model.Model

The adapter model.

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

func (r *ClusterEventHandler) Error(err error)

Report errors.

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
}

A VMWare collector.

func New

func New(db libmodel.DB, provider *api.Provider, secret *core.Secret) *Collector

New collector.

func (*Collector) DB

func (r *Collector) DB() libmodel.DB

Get the DB.

func (*Collector) HasParity

func (r *Collector) HasParity() bool

Reset.

func (*Collector) Name

func (r *Collector) Name() string

The name.

func (*Collector) Owner

func (r *Collector) Owner() meta.Object

The owner.

func (*Collector) Reset

func (r *Collector) Reset()

Reset.

func (*Collector) Shutdown

func (r *Collector) Shutdown()

Shutdown the collector.

func (*Collector) Start

func (r *Collector) Start() error

Start the collector.

func (*Collector) Test

func (r *Collector) Test() (err error)

Test connect/logout.

type DVSwitchAdapter

type DVSwitchAdapter struct {
	Base
	// contains filtered or unexported fields
}

DVSwitch model adapter.

func (*DVSwitchAdapter) Apply

func (v *DVSwitchAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*DVSwitchAdapter) Model

func (v *DVSwitchAdapter) Model() model.Model

The adapter model.

type DatacenterAdapter

type DatacenterAdapter struct {
	Base
	// contains filtered or unexported fields
}

Datacenter model adapter.

func (*DatacenterAdapter) Apply

func (v *DatacenterAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*DatacenterAdapter) Model

func (v *DatacenterAdapter) Model() model.Model

The adapter model.

type DatastoreAdapter

type DatastoreAdapter struct {
	Base
	// contains filtered or unexported fields
}

Datastore model adapter.

func (*DatastoreAdapter) Apply

func (v *DatastoreAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*DatastoreAdapter) Model

func (v *DatastoreAdapter) Model() model.Model

The adapter model.

type FolderAdapter

type FolderAdapter struct {
	Base
	// contains filtered or unexported fields
}

Folder model adapter.

func (*FolderAdapter) Apply

func (v *FolderAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*FolderAdapter) Model

func (v *FolderAdapter) Model() model.Model

The new model.

type HostAdapter

type HostAdapter struct {
	Base
	// contains filtered or unexported fields
}

Host model adapter.

func (*HostAdapter) Apply

func (v *HostAdapter) Apply(u types.ObjectUpdate)

func (*HostAdapter) Model

func (v *HostAdapter) Model() model.Model

The adapter model.

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

func (r *HostEventHandler) Error(err error)

Report errors.

func (*HostEventHandler) Updated

func (r *HostEventHandler) Updated(event libmodel.Event)

Host updated. Analyze all related VMs.

type NetworkAdapter

type NetworkAdapter struct {
	Base
	// contains filtered or unexported fields
}

Network model adapter.

func (*NetworkAdapter) Apply

func (v *NetworkAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*NetworkAdapter) Model

func (v *NetworkAdapter) Model() model.Model

The adapter model.

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

func (r *VMEventHandler) End()

Watch ended.

func (*VMEventHandler) Error

func (r *VMEventHandler) Error(err error)

Report errors.

func (*VMEventHandler) Started

func (r *VMEventHandler) Started(uint64)

Watch ended.

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().

type VmAdapter

type VmAdapter struct {
	Base
	// contains filtered or unexported fields
}

VM model adapter.

func (*VmAdapter) Apply

func (v *VmAdapter) Apply(u types.ObjectUpdate)

Apply the update to the model.

func (*VmAdapter) Model

func (v *VmAdapter) Model() model.Model

The adapter model.

Jump to

Keyboard shortcuts

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