mock

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion      = "{apiversion}"
	PREFIX          = "/univmax/restapi/" + APIVersion
	PREFIXNOVERSION = "/univmax/restapi"
	PRIVATEPREFIX   = "/univmax/restapi/private/" + APIVersion
	INTERNALPREFIX  = "/univmax/restapi/internal/100"

	Debug                        = false
	DefaultStorageGroup          = "CSI-Test-SG-1"
	DefaultStorageGroup1         = "CSI-Test-SG-2"
	DefaultProtectedStorageGroup = "CSI-no-srp-async-test-13"
	DefaultSymmetrixID           = "000197900046"
	DefaultRemoteSymID           = "000000000013"
	DefaultRDFDir                = "OR-1C"
	DefaultRDFPort               = 3
	PostELMSRSymmetrixID         = "000197900047"
	DefaultStoragePool           = "SRP_1"
	DefaultServiceLevel          = "Optimized"
	DefaultFcStoragePortWWN      = "5000000000000001"
	DefaultRDFGNo                = 13
	DefaultRemoteRDFGNo          = 13
	DefaultRDFLabel              = "csi-mock-test"
	RemoteArrayHeaderKey         = "RemoteArray"
	RemoteArrayHeaderValue       = "true"
	DefaultNASServerID           = "64xxx7a6-03b5-xxx-xxx-0zzzz8200209"
	DefaultNASServerName         = "nas-1"
	DefaultFSID                  = "64xxx7a6-03b5-xxx-xxx-0zzzz8200208"
	DefaultFSName                = "fs-ds-1"
)

constants

View Source
const (

	// KiB ...
	KiB
	// MiB ...
	MiB
	// GiB ...
	GiB
	// TiB ...
	TiB
	// PiB ...
	PiB
)

Variables

View Source
var Data struct {
	VolumeIDToIdentifier          map[string]string
	VolumeIDToSize                map[string]int
	VolumeIDIteratorList          []string
	VolumeIDToSGList              map[string][]string
	MaskingViewIDToHostID         map[string]string
	MaskingViewIDToHostGroupID    map[string]string
	MaskingViewIDToPortGroupID    map[string]string
	MaskingViewIDToStorageGroupID map[string]string
	StorageGroupIDToMaskingViewID map[string]string
	JobIDToMockJob                map[string]*JobInfo
	StorageGroupIDToNVolumes      map[string]int
	StorageGroupIDToStorageGroup  map[string]*types.StorageGroup
	StorageGroupIDToVolumes       map[string][]string
	MaskingViewIDToMaskingView    map[string]*types.MaskingView
	InitiatorIDToInitiator        map[string]*types.Initiator
	HostIDToHost                  map[string]*types.Host
	PortGroupIDToPortGroup        map[string]*types.PortGroup
	PortIDToSymmetrixPortType     map[string]*types.SymmetrixPortType
	VolumeIDToVolume              map[string]*types.Volume
	HostGroupIDToHostGroup        map[string]*types.HostGroup
	JSONDir                       string
	InitiatorHost                 string

	// Snapshots
	VolIDToSnapshots  map[string]map[string]*types.Snapshot
	SnapIDToLinkedVol map[string]map[string]*types.LinkedVolumes

	// SRDF
	StorageGroupIDToRDFStorageGroup map[string]*types.RDFStorageGroup
	RDFGroup                        *types.RDFGroup
	SGRDFInfo                       *types.SGRDFInfo

	// File
	FileSysIDToFileSystem  map[string]*types.FileSystem
	NFSExportIDToNFSExport map[string]*types.NFSExport
	NASServerIDToNASServer map[string]*types.NASServer
}

Data are internal tables the Mock Unisphere uses to provide functionality.

View Source
var InducedErrors struct {
	NoConnection                           bool
	InvalidJSON                            bool
	BadHTTPStatus                          int
	GetSymmetrixError                      bool
	GetVolumeIteratorError                 bool
	GetVolumeError                         bool
	UpdateVolumeError                      bool
	DeleteVolumeError                      bool
	DeviceInSGError                        bool
	GetStorageGroupError                   bool
	GetStorageGroupSnapshotPolicyError     bool
	InvalidResponse                        bool
	GetStoragePoolError                    bool
	UpdateStorageGroupError                bool
	GetJobError                            bool
	JobFailedError                         bool
	VolumeNotCreatedError                  bool
	GetJobCannotFindRoleForUser            bool
	CreateStorageGroupError                bool
	StorageGroupAlreadyExists              bool
	DeleteStorageGroupError                bool
	GetStoragePoolListError                bool
	GetPortGroupError                      bool
	GetPortError                           bool
	GetSpecificPortError                   bool
	GetPortISCSITargetError                bool
	GetPortGigEError                       bool
	GetDirectorError                       bool
	GetInitiatorError                      bool
	GetInitiatorByIDError                  bool
	GetHostError                           bool
	CreateHostError                        bool
	DeleteHostError                        bool
	UpdateHostError                        bool
	GetMaskingViewError                    bool
	CreateMaskingViewError                 bool
	UpdateMaskingViewError                 bool
	MaskingViewAlreadyExists               bool
	DeleteMaskingViewError                 bool
	PortGroupNotFoundError                 bool
	InitiatorGroupNotFoundError            bool
	StorageGroupNotFoundError              bool
	VolumeNotAddedError                    bool
	GetMaskingViewConnectionsError         bool
	ResetAfterFirstError                   bool
	CreateSnapshotError                    bool
	DeleteSnapshotError                    bool
	LinkSnapshotError                      bool
	RenameSnapshotError                    bool
	GetSymVolumeError                      bool
	GetVolSnapsError                       bool
	GetGenerationError                     bool
	GetPrivateVolumeIterator               bool
	SnapshotNotLicensed                    bool
	UnisphereMismatchError                 bool
	TargetNotDefinedError                  bool
	SnapshotExpired                        bool
	InvalidSnapshotName                    bool
	GetPrivVolumeByIDError                 bool
	CreatePortGroupError                   bool
	UpdatePortGroupError                   bool
	DeletePortGroupError                   bool
	ExpandVolumeError                      bool
	MaxSnapSessionError                    bool
	GetSRDFInfoError                       bool
	VolumeRdfTypesError                    bool
	GetSRDFPairInfoError                   bool
	GetProtectedStorageGroupError          bool
	CreateSGReplicaError                   bool
	GetRDFGroupError                       bool
	GetSGOnRemote                          bool
	GetSGWithVolOnRemote                   bool
	RDFGroupHasPairError                   bool
	GetRemoteVolumeError                   bool
	InvalidLocalVolumeError                bool
	InvalidRemoteVolumeError               bool
	FetchResponseError                     bool
	RemoveVolumesFromSG                    bool
	ModifyMobilityError                    bool
	GetHostGroupError                      bool
	CreateHostGroupError                   bool
	DeleteHostGroupError                   bool
	UpdateHostGroupError                   bool
	GetHostGroupListError                  bool
	GetStorageGroupMetricsError            bool
	GetVolumesMetricsError                 bool
	GetStorageGroupPerfKeyError            bool
	GetArrayPerfKeyError                   bool
	GetFreeRDFGError                       bool
	GetLocalOnlineRDFDirsError             bool
	GetRemoteRDFPortOnSANError             bool
	GetLocalOnlineRDFPortsError            bool
	GetLocalRDFPortDetailsError            bool
	CreateRDFGroupError                    bool
	GetStorageGroupSnapshotError           bool
	DeleteStorageGroupSnapshotError        bool
	GetStorageGroupSnapshotSnapError       bool
	GetStorageGroupSnapshotSnapDetailError bool
	GetStorageGroupSnapshotSnapModifyError bool
	GetSnapshotPolicyError                 bool
	GetSnapshotPolicyListError             bool
	CreateSnapshotPolicyError              bool
	ModifySnapshotPolicyError              bool
	DeleteSnapshotPolicyError              bool
	GetFileSystemListError                 bool
	GetNFSExportListError                  bool
	GetNASServerListError                  bool
	GetFileSystemError                     bool
	CreateFileSystemError                  bool
	UpdateFileSystemError                  bool
	DeleteFileSystemError                  bool
	GetNASServerError                      bool
	UpdateNASServerError                   bool
	DeleteNASServerError                   bool
	GetNFSExportError                      bool
	CreateNFSExportError                   bool
	UpdateNFSExportError                   bool
	DeleteNFSExportError                   bool
}

InducedErrors constants

Functions

func AddFileObjects added in v2.4.0

func AddFileObjects()

AddFileObjects adds file objects for mock objects

func AddHost

func AddHost(hostID string, hostType string, initiatorIDs []string) (*types.Host, error)

AddHost - Adds a host to the mock data cache

func AddHostGroup added in v2.2.0

func AddHostGroup(hostGroupID string, hostIDs []string, hostFlags *types.HostFlags) (*types.HostGroup, error)

AddHostGroup - Adds a host group to the mock data cache

func AddInitiator

func AddInitiator(initiatorID string, initiatorName string, initiatorType string, dirPortKeys []string, hostID string) (*types.Initiator, error)

AddInitiator - Adds an initiator to the mock data cache

func AddMaskingView

func AddMaskingView(maskingViewID string, storageGroupID string, hostID string, portGroupID string) (*types.MaskingView, error)

AddMaskingView - Adds a masking view to the mock data cache

func AddNewFileSystem added in v2.4.0

func AddNewFileSystem(id, name string, sizeInMiB int64)

AddNewFileSystem adds a new file system into mock

func AddNewNASServer added in v2.4.0

func AddNewNASServer(id, name string)

AddNewNASServer adds new NAS server into mock

func AddNewNFSExport added in v2.4.0

func AddNewNFSExport(id, name string)

AddNewNFSExport new NFS Export into mock

func AddNewSnapshot

func AddNewSnapshot(source, SnapID string)

AddNewSnapshot adds a snapshot to the mock cache

func AddNewVolume

func AddNewVolume(volumeID, volumeIdentifier string, size int, storageGroupID string) error

AddNewVolume - Add a volume to the mock data cache

func AddOneVolumeToStorageGroup

func AddOneVolumeToStorageGroup(volumeID, volumeIdentifier, sgID string, size int) error

AddOneVolumeToStorageGroup - Adds volume to a storage group in the mock cache

func AddPort

func AddPort(id, identifier, portType string)

AddPort adds a port entry. Port type can either be "FibreChannel" or "GigE", or "" for a non existent port.

func AddPortGroup

func AddPortGroup(portGroupID string, portGroupType string, portIdentifiers []string) (*types.PortGroup, error)

AddPortGroup - Adds a port group to the mock data cache

func AddPortGroupFromCreateParams

func AddPortGroupFromCreateParams(createParams *types.CreatePortGroupParams)

AddPortGroupFromCreateParams - Adds a storage group from create params

func AddRDFStorageGroup

func AddRDFStorageGroup(storageGroupID, symmetrixID string) (*types.RDFStorageGroup, error)

AddRDFStorageGroup ...

func AddSpecificVolumeToStorageGroup

func AddSpecificVolumeToStorageGroup(w http.ResponseWriter, volumeIDs []string, sgID string)

AddSpecificVolumeToStorageGroup - Add volume based on volumeids to storage group mock cache

func AddStorageGroup

func AddStorageGroup(storageGroupID string, storageResourcePoolID string,
	serviceLevel string) (*types.StorageGroup, error)

AddStorageGroup - Adds a storage group to the mock data cache

func AddStorageGroupFromCreateParams

func AddStorageGroupFromCreateParams(createParams *types.CreateStorageGroupParam)

AddStorageGroupFromCreateParams - Adds a storage group from create params

func AddTempSnapshots

func AddTempSnapshots()

AddTempSnapshots adds marked for deletion snapshots into mock to help snapcleanup thread to be functional

func AddVolumeToStorageGroupTest

func AddVolumeToStorageGroupTest(w http.ResponseWriter, name, size, sgID string)

AddVolumeToStorageGroupTest - Adds volume to storage group and updates mock cache

func CreateSnapshot

func CreateSnapshot(w http.ResponseWriter, r *http.Request, SnapID, executionOption string, sourceVolumeList []types.VolumeList)

CreateSnapshot - Creates a snapshot and updates mock cache

func DeletePortGroup

func DeletePortGroup(portGroupID string) (*types.PortGroup, error)

DeletePortGroup - Remove PortGroup by ID 'portGroupID'

func DeleteSnapshot

func DeleteSnapshot(w http.ResponseWriter, r *http.Request, SnapID string, executionOption string, deviceNameListSource []types.VolumeList, genID int64)

DeleteSnapshot - Deletes a snapshot and updates mock cache

func DeleteVolume

func DeleteVolume(volID string) error

DeleteVolume - Deletes volume from cache

func ExpandVolume

func ExpandVolume(w http.ResponseWriter, param *types.ExpandVolumeParam, volID string, executionOption string)

ExpandVolume - Expands volume size in cache

func FreeVolume

func FreeVolume(w http.ResponseWriter, param *types.FreeVolumeParam, volID string, executionOption string)

FreeVolume - handler for free volume job

func GetHandler

func GetHandler() http.Handler

GetHandler returns the http handler

func LinkSnapshot

func LinkSnapshot(w http.ResponseWriter, r *http.Request, sourceVolumeList []types.VolumeList, targetVolumeList []types.VolumeList, executionOption, SnapID string)

LinkSnapshot - Links a snapshot and updates a mock cache

func ModifyMobility added in v2.1.0

func ModifyMobility(w http.ResponseWriter, param *types.EnableMobilityIDParam, volID string, executionOption string)

ModifyMobility modifes the mobility-id-enabled parameter of volume

func NewVolume

func NewVolume(volumeID, volumeIdentifier string, size int, sgList []string)

NewVolume creates a new mock volume with the specified characteristics.

func RemoveFileSystem added in v2.4.0

func RemoveFileSystem(w http.ResponseWriter, fsID string)

RemoveFileSystem removes File system from mock

func RemoveHost

func RemoveHost(hostID string) error

RemoveHost - Removes host from mock cache

func RemoveHostGroup added in v2.2.0

func RemoveHostGroup(hostGroupID string) error

RemoveHostGroup - Removes hostGroup from mock cache

func RemoveMaskingView

func RemoveMaskingView(w http.ResponseWriter, maskingViewID string)

RemoveMaskingView - Removes a masking view from the mock data cache

func RemoveNASServer added in v2.4.0

func RemoveNASServer(w http.ResponseWriter, nasID string)

RemoveNASServer removes NAS server

func RemoveNFSExport added in v2.4.0

func RemoveNFSExport(w http.ResponseWriter, nfsID string)

RemoveNFSExport removes NFS export object

func RemoveStorageGroup

func RemoveStorageGroup(w http.ResponseWriter, storageGroupID string)

RemoveStorageGroup - Removes a storage group from the mock data cache

func RemoveVolumeFromStorageGroup

func RemoveVolumeFromStorageGroup(w http.ResponseWriter, volumeIDs []string, sgID string)

RemoveVolumeFromStorageGroup - Remove volumes from storage group mock cache

func RenameMaskingView added in v2.1.0

func RenameMaskingView(w http.ResponseWriter, param *types.RenameMaskingViewParam, maskingViewID string, executionOption string)

RenameMaskingView - Renames masking view

func RenameSnapshot

func RenameSnapshot(w http.ResponseWriter, r *http.Request, sourceVolumeList []types.VolumeList, executionOption, oldSnapID, newSnapID string)

RenameSnapshot - Renames a snapshot and updates mock cache

func RenameVolume

func RenameVolume(w http.ResponseWriter, param *types.ModifyVolumeIdentifierParam, volID string, executionOption string, remote bool)

RenameVolume - renames volume in cache

func Reset

func Reset()

Reset : re-initializes the variables

func ReturnFileSystem added in v2.4.0

func ReturnFileSystem(w http.ResponseWriter, fsID string)

ReturnFileSystem returns File System object

func ReturnHost

func ReturnHost(w http.ResponseWriter, hostID string)

ReturnHost - Returns a host from cache

func ReturnHostGroup added in v2.2.0

func ReturnHostGroup(w http.ResponseWriter, hostGroupID string)

ReturnHostGroup - Returns a hostGroup from cache

func ReturnInitiator

func ReturnInitiator(w http.ResponseWriter, initiatorID string)

ReturnInitiator - Returns initiator from mock cache based on initiator id

func ReturnJobByID

func ReturnJobByID(w http.ResponseWriter, jobID string)

ReturnJobByID - Returns job based on ID from mock cache

func ReturnNASServer added in v2.4.0

func ReturnNASServer(w http.ResponseWriter, nasID string)

ReturnNASServer returns NAS server object

func ReturnNFSExport added in v2.4.0

func ReturnNFSExport(w http.ResponseWriter, nfsID string)

ReturnNFSExport NFS export

func ReturnPortGroup

func ReturnPortGroup(w http.ResponseWriter, portGroupID string)

ReturnPortGroup - Returns port group information from cache

func ReturnRDFGroup added in v2.2.0

func ReturnRDFGroup(w http.ResponseWriter, rdfg string)

ReturnRDFGroup - Returns RDF group information from mock cache

func ReturnStorageGroup

func ReturnStorageGroup(w http.ResponseWriter, sgID string, remote bool)

ReturnStorageGroup - Returns storage group information from mock cache

func UnlinkSnapshot

func UnlinkSnapshot(w http.ResponseWriter, r *http.Request, sourceVolumeList []types.VolumeList, targetVolumeList []types.VolumeList, executionOption, SnapID string)

UnlinkSnapshot - Unlinks a snapshot and updates mock cache

func UpdateFileSystem added in v2.4.0

func UpdateFileSystem(id string, payload types.ModifyFileSystem)

UpdateFileSystem updates an existing FileSystem

func UpdateHostGroupFromParams added in v2.2.0

func UpdateHostGroupFromParams(hostGroupID string, updateParams *types.UpdateHostGroupParam)

UpdateHostGroupFromParams - Updates HostGroup given an UpdateHostGroupParam payload

func UpdateNASServer added in v2.4.0

func UpdateNASServer(nasID string, payload types.ModifyNASServer)

UpdateNASServer updates NAS server

func UpdateNFSExport added in v2.4.0

func UpdateNFSExport(id string, payload types.ModifyNFSExport)

UpdateNFSExport updates NFS Export

func UpdatePortGroupFromParams

func UpdatePortGroupFromParams(portGroupID string, updateParams *types.EditPortGroup)

UpdatePortGroupFromParams - Updates PortGroup given an EditPortGroup payload

Types

type JobInfo

type JobInfo struct {
	Job          types.Job
	InitialState string
	FinalState   string
}

JobInfo is used to simulate a job in Unisphere. The first call to read it returns Status as the InitialState. Subsequent calls return the Status as the FinalState.

func NewMockJob

func NewMockJob(jobID string, initialState string, finalState string, resourceLink string) *JobInfo

NewMockJob creates a JobInfo that can be queried

Jump to

Keyboard shortcuts

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