Documentation
¶
Index ¶
- type InternalNSXSource
- func (s *InternalNSXSource) AddSegmentData(ctx context.Context, segment *internalAPI.NSXSegment, ...) (*internalAPI.NSXSegment, error)
- func (s *InternalNSXSource) Connect(ctx context.Context) error
- func (s *InternalNSXSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
- func (s *InternalNSXSource) FetchSourceData(ctx context.Context) error
- func (s *InternalNSXSource) GetComputeManagers(ctx context.Context) ([]internalAPI.NSXComputeManager, error)
- func (s *InternalNSXSource) GetEdgeNodes(ctx context.Context) ([]internalAPI.NSXEdgeTransportNode, error)
- func (s *InternalNSXSource) GetSecurityPolicies(ctx context.Context) ([]internalAPI.NSXSecurityPolicy, error)
- func (s *InternalNSXSource) GetSegment(ctx context.Context, segmentPath string, vms []internalAPI.NSXVirtualMachine) (*internalAPI.NSXSegment, error)
- func (s *InternalNSXSource) GetSegments(ctx context.Context, populateData bool) ([]internalAPI.NSXSegment, error)
- func (s *InternalNSXSource) GetTransportZone(ctx context.Context, zoneUUID uuid.UUID) (*internalAPI.NSXTransportZone, error)
- func (s *InternalNSXSource) GetVMs(ctx context.Context) ([]internalAPI.NSXVirtualMachine, error)
- type InternalNSXSourceSpecific
- type InternalSource
- func (s *InternalSource) Connect(ctx context.Context) error
- func (s *InternalSource) DeleteVMSnapshot(ctx context.Context, vmName string, snapshotName string) error
- func (s *InternalSource) Disconnect(ctx context.Context) error
- func (s *InternalSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
- func (s *InternalSource) GetAllNetworks(ctx context.Context) ([]api.Network, error)
- func (s *InternalSource) GetAllVMs(ctx context.Context) (migration.Instances, error)
- func (s *InternalSource) GetName() string
- func (s *InternalSource) ImportDisks(ctx context.Context, vmName string, statusCallback func(string, bool)) error
- func (s *InternalSource) IsConnected() bool
- func (s *InternalSource) PowerOffVM(ctx context.Context, vmName string) error
- func (s *InternalSource) WithAdditionalRootCertificate(rootCert *x509.Certificate)
- type InternalVMwareSource
- func (s *InternalVMwareSource) Connect(ctx context.Context) error
- func (s *InternalVMwareSource) DeleteVMSnapshot(ctx context.Context, vmName string, snapshotName string) error
- func (s *InternalVMwareSource) Disconnect(ctx context.Context) error
- func (s *InternalVMwareSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
- func (s *InternalVMwareSource) GetAllNetworks(ctx context.Context) (migration.Networks, error)
- func (s *InternalVMwareSource) GetAllVMs(ctx context.Context) (migration.Instances, error)
- func (s *InternalVMwareSource) GetNSXManagerIP(ctx context.Context) (string, error)
- func (s *InternalVMwareSource) ImportDisks(ctx context.Context, vmName string, statusCallback func(string, bool)) error
- func (s *InternalVMwareSource) PowerOffVM(ctx context.Context, vmName string) error
- func (s *InternalVMwareSource) PowerOnVM(ctx context.Context, vmLocation string) error
- func (s *InternalVMwareSource) WithAdditionalRootCertificate(rootCert *x509.Certificate)
- type InternalVMwareSourceSpecific
- type PaginationResponse
- type Source
- type SourceMock
- func (mock *SourceMock) Connect(ctx context.Context) error
- func (mock *SourceMock) ConnectCalls() []struct{ ... }
- func (mock *SourceMock) DeleteVMSnapshot(ctx context.Context, vmName string, snapshotName string) error
- func (mock *SourceMock) DeleteVMSnapshotCalls() []struct{ ... }
- func (mock *SourceMock) Disconnect(ctx context.Context) error
- func (mock *SourceMock) DisconnectCalls() []struct{ ... }
- func (mock *SourceMock) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
- func (mock *SourceMock) DoBasicConnectivityCheckCalls() []struct{}
- func (mock *SourceMock) GetAllNetworks(ctx context.Context) (migration.Networks, error)
- func (mock *SourceMock) GetAllNetworksCalls() []struct{ ... }
- func (mock *SourceMock) GetAllVMs(ctx context.Context) (migration.Instances, error)
- func (mock *SourceMock) GetAllVMsCalls() []struct{ ... }
- func (mock *SourceMock) GetName() string
- func (mock *SourceMock) GetNameCalls() []struct{}
- func (mock *SourceMock) ImportDisks(ctx context.Context, vmName string, statusCallback func(string, bool)) error
- func (mock *SourceMock) ImportDisksCalls() []struct{ ... }
- func (mock *SourceMock) IsConnected() bool
- func (mock *SourceMock) IsConnectedCalls() []struct{}
- func (mock *SourceMock) PowerOffVM(ctx context.Context, vmName string) error
- func (mock *SourceMock) PowerOffVMCalls() []struct{ ... }
- func (mock *SourceMock) WithAdditionalRootCertificate(rootCert *x509.Certificate)
- func (mock *SourceMock) WithAdditionalRootCertificateCalls() []struct{ ... }
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InternalNSXSource ¶
type InternalNSXSource struct { InternalSource `yaml:",inline"` InternalNSXSourceSpecific `yaml:",inline"` }
func NewInternalNSXSourceFrom ¶
func NewInternalNSXSourceFrom(apiSource api.Source) (*InternalNSXSource, error)
func (*InternalNSXSource) AddSegmentData ¶
func (s *InternalNSXSource) AddSegmentData(ctx context.Context, segment *internalAPI.NSXSegment, vms []internalAPI.NSXVirtualMachine) (*internalAPI.NSXSegment, error)
AddSegmentData populates the segment data with firewall rules, and adds the VMs from the given set that exist on the segment.
func (*InternalNSXSource) Connect ¶
func (s *InternalNSXSource) Connect(ctx context.Context) error
Connect verifies the NSX server cert against the trusted fingerprint, and fetches the NSX Manager version.
func (*InternalNSXSource) DoBasicConnectivityCheck ¶
func (s *InternalNSXSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
DoBasicConnectivityCheck performs a connectivity check and verifies the server certificate against the trusted fingerprint.
func (*InternalNSXSource) FetchSourceData ¶
func (s *InternalNSXSource) FetchSourceData(ctx context.Context) error
func (*InternalNSXSource) GetComputeManagers ¶
func (s *InternalNSXSource) GetComputeManagers(ctx context.Context) ([]internalAPI.NSXComputeManager, error)
GetComputeManagers gets all compute managers registered with the NSX Manager.
func (*InternalNSXSource) GetEdgeNodes ¶
func (s *InternalNSXSource) GetEdgeNodes(ctx context.Context) ([]internalAPI.NSXEdgeTransportNode, error)
GetEdgeNodes fetches all edge transport nodes of the NSX Manager.
func (*InternalNSXSource) GetSecurityPolicies ¶
func (s *InternalNSXSource) GetSecurityPolicies(ctx context.Context) ([]internalAPI.NSXSecurityPolicy, error)
GetSecurityPolicies fetches all security policies for all domains.
func (*InternalNSXSource) GetSegment ¶
func (s *InternalNSXSource) GetSegment(ctx context.Context, segmentPath string, vms []internalAPI.NSXVirtualMachine) (*internalAPI.NSXSegment, error)
GetSegment fetches a segment by its segment path, and includes any VMs from the supplied list if their VIFs use a logical port on the segment.
func (*InternalNSXSource) GetSegments ¶
func (s *InternalNSXSource) GetSegments(ctx context.Context, populateData bool) ([]internalAPI.NSXSegment, error)
GetSegments fetches all segments, their VMs, and gateway policies.
func (*InternalNSXSource) GetTransportZone ¶
func (s *InternalNSXSource) GetTransportZone(ctx context.Context, zoneUUID uuid.UUID) (*internalAPI.NSXTransportZone, error)
GetTransportZone fetches a transport zone by its UUID.
func (*InternalNSXSource) GetVMs ¶
func (s *InternalNSXSource) GetVMs(ctx context.Context) ([]internalAPI.NSXVirtualMachine, error)
GetVMs fetches all VMs and their VIFs.
type InternalNSXSourceSpecific ¶
type InternalNSXSourceSpecific struct { internalAPI.NSXSourceProperties `yaml:",inline"` // contains filtered or unexported fields }
type InternalSource ¶
type InternalSource struct { api.Source `yaml:",inline"` // contains filtered or unexported fields }
func (*InternalSource) DeleteVMSnapshot ¶
func (*InternalSource) Disconnect ¶
func (s *InternalSource) Disconnect(ctx context.Context) error
func (*InternalSource) DoBasicConnectivityCheck ¶
func (s *InternalSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
func (*InternalSource) GetAllNetworks ¶
func (*InternalSource) GetName ¶
func (s *InternalSource) GetName() string
func (*InternalSource) ImportDisks ¶
func (*InternalSource) IsConnected ¶
func (s *InternalSource) IsConnected() bool
func (*InternalSource) PowerOffVM ¶
func (s *InternalSource) PowerOffVM(ctx context.Context, vmName string) error
func (*InternalSource) WithAdditionalRootCertificate ¶
func (s *InternalSource) WithAdditionalRootCertificate(rootCert *x509.Certificate)
type InternalVMwareSource ¶
type InternalVMwareSource struct { InternalSource `yaml:",inline"` InternalVMwareSourceSpecific `yaml:",inline"` }
func NewInternalVMwareSourceFrom ¶
func NewInternalVMwareSourceFrom(apiSource api.Source) (*InternalVMwareSource, error)
func (*InternalVMwareSource) Connect ¶
func (s *InternalVMwareSource) Connect(ctx context.Context) error
func (*InternalVMwareSource) DeleteVMSnapshot ¶
func (*InternalVMwareSource) Disconnect ¶
func (s *InternalVMwareSource) Disconnect(ctx context.Context) error
func (*InternalVMwareSource) DoBasicConnectivityCheck ¶
func (s *InternalVMwareSource) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
func (*InternalVMwareSource) GetAllNetworks ¶
func (*InternalVMwareSource) GetNSXManagerIP ¶
func (s *InternalVMwareSource) GetNSXManagerIP(ctx context.Context) (string, error)
func (*InternalVMwareSource) ImportDisks ¶
func (*InternalVMwareSource) PowerOffVM ¶
func (s *InternalVMwareSource) PowerOffVM(ctx context.Context, vmName string) error
func (*InternalVMwareSource) PowerOnVM ¶
func (s *InternalVMwareSource) PowerOnVM(ctx context.Context, vmLocation string) error
func (*InternalVMwareSource) WithAdditionalRootCertificate ¶
func (s *InternalVMwareSource) WithAdditionalRootCertificate(rootCert *x509.Certificate)
type InternalVMwareSourceSpecific ¶
type InternalVMwareSourceSpecific struct { api.VMwareProperties `yaml:",inline"` // contains filtered or unexported fields }
type PaginationResponse ¶
type PaginationResponse struct { Results []any `json:"results"` Count int `json:"result_count"` Cursor string `json:"cursor"` }
PaginationResponse handles paginated API responses.
type Source ¶
type Source interface { // Connects to the source, using any source-specific details when the object was created. // // Returns an error if unable to connect (unable to reach remote host, bad credentials, etc). Connect(ctx context.Context) error // Performs a basic HTTP connectivity test to the source. // // Returns a status flag indicating the status and if a TLS certificate error occurred a copy of the untrusted TLS certificate. DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate) // Disconnects from the source. // // Returns an error if there was a problem disconnecting from the source. Disconnect(ctx context.Context) error // WithAdditionalRootCertificate accepts an additional certificate, which // is added to the default CertPool used to validate server certificates // while connecting to the Source using TLS. WithAdditionalRootCertificate(rootCert *x509.Certificate) // Returns whether currently connected to the source or not. IsConnected() bool // Returns the human-readable name for this source. GetName() string // Returns an array of all VMs available from the source, encoded as Instances. // // Returns an error if there is a problem fetching VMs or their properties. GetAllVMs(ctx context.Context) (migration.Instances, error) // Returns an array of all networks available from the source, encoded as Networks. // // Returns an error if there is a problem fetching networks or their properties. GetAllNetworks(ctx context.Context) (migration.Networks, error) // Deletes a given snapshot, if it exists, from the specified VM. // // Returns an error if there is a problem deleting the snapshot. DeleteVMSnapshot(ctx context.Context, vmName string, snapshotName string) error // Initiates a disk import cycle from the source to the locally running VM. // // Important: This should only be called from the migration manager worker, as it will attempt to // directly write to raw disk devices, overwriting any data that might already be present. // // Returns an error if there is a problem importing the disk(s). ImportDisks(ctx context.Context, vmName string, statusCallback func(string, bool)) error // Powers off a VM. // // Returns an error if there was a problem shutting down the VM. PowerOffVM(ctx context.Context, vmName string) error }
Source interface definition for all migration manager sources.
type SourceMock ¶
type SourceMock struct { // ConnectFunc mocks the Connect method. ConnectFunc func(ctx context.Context) error // DeleteVMSnapshotFunc mocks the DeleteVMSnapshot method. DeleteVMSnapshotFunc func(ctx context.Context, vmName string, snapshotName string) error // DisconnectFunc mocks the Disconnect method. DisconnectFunc func(ctx context.Context) error // DoBasicConnectivityCheckFunc mocks the DoBasicConnectivityCheck method. DoBasicConnectivityCheckFunc func() (api.ExternalConnectivityStatus, *x509.Certificate) // GetAllNetworksFunc mocks the GetAllNetworks method. GetAllNetworksFunc func(ctx context.Context) (migration.Networks, error) // GetAllVMsFunc mocks the GetAllVMs method. GetAllVMsFunc func(ctx context.Context) (migration.Instances, error) // GetNameFunc mocks the GetName method. GetNameFunc func() string // ImportDisksFunc mocks the ImportDisks method. ImportDisksFunc func(ctx context.Context, vmName string, statusCallback func(string, bool)) error // IsConnectedFunc mocks the IsConnected method. IsConnectedFunc func() bool // PowerOffVMFunc mocks the PowerOffVM method. PowerOffVMFunc func(ctx context.Context, vmName string) error // WithAdditionalRootCertificateFunc mocks the WithAdditionalRootCertificate method. WithAdditionalRootCertificateFunc func(rootCert *x509.Certificate) // contains filtered or unexported fields }
SourceMock is a mock implementation of Source.
func TestSomethingThatUsesSource(t *testing.T) { // make and configure a mocked Source mockedSource := &SourceMock{ ConnectFunc: func(ctx context.Context) error { panic("mock out the Connect method") }, DeleteVMSnapshotFunc: func(ctx context.Context, vmName string, snapshotName string) error { panic("mock out the DeleteVMSnapshot method") }, DisconnectFunc: func(ctx context.Context) error { panic("mock out the Disconnect method") }, DoBasicConnectivityCheckFunc: func() (api.ExternalConnectivityStatus, *x509.Certificate) { panic("mock out the DoBasicConnectivityCheck method") }, GetAllNetworksFunc: func(ctx context.Context) (migration.Networks, error) { panic("mock out the GetAllNetworks method") }, GetAllVMsFunc: func(ctx context.Context) (migration.Instances, error) { panic("mock out the GetAllVMs method") }, GetNameFunc: func() string { panic("mock out the GetName method") }, ImportDisksFunc: func(ctx context.Context, vmName string, statusCallback func(string, bool)) error { panic("mock out the ImportDisks method") }, IsConnectedFunc: func() bool { panic("mock out the IsConnected method") }, PowerOffVMFunc: func(ctx context.Context, vmName string) error { panic("mock out the PowerOffVM method") }, WithAdditionalRootCertificateFunc: func(rootCert *x509.Certificate) { panic("mock out the WithAdditionalRootCertificate method") }, } // use mockedSource in code that requires Source // and then make assertions. }
func (*SourceMock) Connect ¶
func (mock *SourceMock) Connect(ctx context.Context) error
Connect calls ConnectFunc.
func (*SourceMock) ConnectCalls ¶
func (mock *SourceMock) ConnectCalls() []struct { Ctx context.Context }
ConnectCalls gets all the calls that were made to Connect. Check the length with:
len(mockedSource.ConnectCalls())
func (*SourceMock) DeleteVMSnapshot ¶
func (mock *SourceMock) DeleteVMSnapshot(ctx context.Context, vmName string, snapshotName string) error
DeleteVMSnapshot calls DeleteVMSnapshotFunc.
func (*SourceMock) DeleteVMSnapshotCalls ¶
func (mock *SourceMock) DeleteVMSnapshotCalls() []struct { Ctx context.Context VmName string SnapshotName string }
DeleteVMSnapshotCalls gets all the calls that were made to DeleteVMSnapshot. Check the length with:
len(mockedSource.DeleteVMSnapshotCalls())
func (*SourceMock) Disconnect ¶
func (mock *SourceMock) Disconnect(ctx context.Context) error
Disconnect calls DisconnectFunc.
func (*SourceMock) DisconnectCalls ¶
func (mock *SourceMock) DisconnectCalls() []struct { Ctx context.Context }
DisconnectCalls gets all the calls that were made to Disconnect. Check the length with:
len(mockedSource.DisconnectCalls())
func (*SourceMock) DoBasicConnectivityCheck ¶
func (mock *SourceMock) DoBasicConnectivityCheck() (api.ExternalConnectivityStatus, *x509.Certificate)
DoBasicConnectivityCheck calls DoBasicConnectivityCheckFunc.
func (*SourceMock) DoBasicConnectivityCheckCalls ¶
func (mock *SourceMock) DoBasicConnectivityCheckCalls() []struct { }
DoBasicConnectivityCheckCalls gets all the calls that were made to DoBasicConnectivityCheck. Check the length with:
len(mockedSource.DoBasicConnectivityCheckCalls())
func (*SourceMock) GetAllNetworks ¶
GetAllNetworks calls GetAllNetworksFunc.
func (*SourceMock) GetAllNetworksCalls ¶
func (mock *SourceMock) GetAllNetworksCalls() []struct { Ctx context.Context }
GetAllNetworksCalls gets all the calls that were made to GetAllNetworks. Check the length with:
len(mockedSource.GetAllNetworksCalls())
func (*SourceMock) GetAllVMsCalls ¶
func (mock *SourceMock) GetAllVMsCalls() []struct { Ctx context.Context }
GetAllVMsCalls gets all the calls that were made to GetAllVMs. Check the length with:
len(mockedSource.GetAllVMsCalls())
func (*SourceMock) GetNameCalls ¶
func (mock *SourceMock) GetNameCalls() []struct { }
GetNameCalls gets all the calls that were made to GetName. Check the length with:
len(mockedSource.GetNameCalls())
func (*SourceMock) ImportDisks ¶
func (mock *SourceMock) ImportDisks(ctx context.Context, vmName string, statusCallback func(string, bool)) error
ImportDisks calls ImportDisksFunc.
func (*SourceMock) ImportDisksCalls ¶
func (mock *SourceMock) ImportDisksCalls() []struct { Ctx context.Context VmName string StatusCallback func(string, bool) }
ImportDisksCalls gets all the calls that were made to ImportDisks. Check the length with:
len(mockedSource.ImportDisksCalls())
func (*SourceMock) IsConnected ¶
func (mock *SourceMock) IsConnected() bool
IsConnected calls IsConnectedFunc.
func (*SourceMock) IsConnectedCalls ¶
func (mock *SourceMock) IsConnectedCalls() []struct { }
IsConnectedCalls gets all the calls that were made to IsConnected. Check the length with:
len(mockedSource.IsConnectedCalls())
func (*SourceMock) PowerOffVM ¶
func (mock *SourceMock) PowerOffVM(ctx context.Context, vmName string) error
PowerOffVM calls PowerOffVMFunc.
func (*SourceMock) PowerOffVMCalls ¶
func (mock *SourceMock) PowerOffVMCalls() []struct { Ctx context.Context VmName string }
PowerOffVMCalls gets all the calls that were made to PowerOffVM. Check the length with:
len(mockedSource.PowerOffVMCalls())
func (*SourceMock) WithAdditionalRootCertificate ¶
func (mock *SourceMock) WithAdditionalRootCertificate(rootCert *x509.Certificate)
WithAdditionalRootCertificate calls WithAdditionalRootCertificateFunc.
func (*SourceMock) WithAdditionalRootCertificateCalls ¶
func (mock *SourceMock) WithAdditionalRootCertificateCalls() []struct { RootCert *x509.Certificate }
WithAdditionalRootCertificateCalls gets all the calls that were made to WithAdditionalRootCertificate. Check the length with:
len(mockedSource.WithAdditionalRootCertificateCalls())
type VersionResponse ¶
type VersionResponse struct { Version string `json:"product_version"` Build string `json:"product_build_number"` }
VersionResponse is returned from the NSX API when fetching the version.