azureutils

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateValidDiskName

func CreateValidDiskName(volumeName string) string

Disk name must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens. See https://docs.microsoft.com/en-us/rest/api/compute/disks/createorupdate#uri-parameters

Snapshot name must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens. See https://docs.microsoft.com/en-us/rest/api/compute/snapshots/createorupdate#uri-parameters

Since the naming rule of disk is same with snapshot's, here we use the same function to handle disks and snapshots.

func GenerateCSISnapshot

func GenerateCSISnapshot(sourceVolumeID string, snapshot *compute.Snapshot) (*csi.Snapshot, error)

func GetCachingMode

func GetCachingMode(attributes map[string]string) (compute.CachingTypes, error)

func GetCloudProvider

func GetCloudProvider(kubeconfig, secretName, secretNamespace, userAgent string) (*azure.Cloud, error)

GetCloudProvider get Azure Cloud Provider

func GetDiskLUN

func GetDiskLUN(deviceInfo string) (int32, error)

GetDiskLUN : deviceInfo could be a LUN number or a device path, e.g. /dev/disk/azure/scsi1/lun2

func GetDiskName

func GetDiskName(diskURI string) (string, error)

func GetEntriesAndNextToken

func GetEntriesAndNextToken(req *csi.ListSnapshotsRequest, snapshots []compute.Snapshot) (*csi.ListSnapshotsResponse, error)

There are 4 scenarios for listing snapshots. 1. StartingToken is null, and MaxEntries is null. Return all snapshots from zero. 2. StartingToken is null, and MaxEntries is not null. Return `MaxEntries` snapshots from zero. 3. StartingToken is not null, and MaxEntries is null. Return all snapshots from `StartingToken`. 4. StartingToken is not null, and MaxEntries is not null. Return `MaxEntries` snapshots from `StartingToken`.

func GetResourceGroupFromURI

func GetResourceGroupFromURI(diskURI string) (string, error)

func GetSnapshotNameFromURI

func GetSnapshotNameFromURI(snapshotURI string) (string, error)

func GetSourceVolumeID

func GetSourceVolumeID(snapshot *compute.Snapshot) string

func GetValidCreationData

func GetValidCreationData(subscriptionID, resourceGroup, sourceResourceID, sourceType string) (compute.CreationData, error)

func InsertDiskProperties

func InsertDiskProperties(disk *compute.Disk, publishConext map[string]string)

InsertDiskProperties: insert disk properties to map

func IsARMResourceID

func IsARMResourceID(resourceID string) bool

IsARMResourceID check whether resourceID is an ARM ResourceID

func IsAzureStackCloud

func IsAzureStackCloud(cloud string, disableAzureStackCloud bool) bool

IsAzureStackCloud decides whether the driver is running on Azure Stack Cloud.

func IsCorruptedDir

func IsCorruptedDir(dir string) bool

func IsValidAvailabilityZone

func IsValidAvailabilityZone(zone, region string) bool

IsValidAvailabilityZone returns true if the zone is in format of <region>-<zone-id>.

func IsValidDiskURI

func IsValidDiskURI(diskURI string) error

func IsValidVolumeCapabilities

func IsValidVolumeCapabilities(volCaps []*csi.VolumeCapability) bool

func NormalizeCachingMode

func NormalizeCachingMode(cachingMode v1.AzureDataDiskCachingMode) (v1.AzureDataDiskCachingMode, error)

func NormalizeNetworkAccessPolicy

func NormalizeNetworkAccessPolicy(networkAccessPolicy string) (compute.NetworkAccessPolicy, error)

func NormalizeStorageAccountType

func NormalizeStorageAccountType(storageAccountType, cloud string, disableAzureStackCloud bool) (compute.DiskStorageAccountTypes, error)

func PickAvailabilityZone

func PickAvailabilityZone(requirement *csi.TopologyRequirement, region, topologyKey string) string

PickAvailabilityZone selects 1 zone given topology requirement. if not found or topology requirement is not zone format, empty string is returned.

Types

type FakeHostUtil

type FakeHostUtil struct {
	// contains filtered or unexported fields
}

func NewFakeHostUtil

func NewFakeHostUtil() *FakeHostUtil

NewFakeHostUtil returns a FakeHostUtil object suitable for use in unit tests.

func (*FakeHostUtil) PathIsDevice

func (f *FakeHostUtil) PathIsDevice(path string) (bool, error)

PathIsDevice return whether the path references a block device.

func (*FakeHostUtil) SetPathIsDeviceResult

func (f *FakeHostUtil) SetPathIsDeviceResult(path string, isDevice bool, err error)

SetPathIsDeviceResult set the result of calling IsBlockDevicePath for the specified path.

type IOHandler

type IOHandler interface {
	ReadDir(dirname string) ([]os.FileInfo, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
	Readlink(name string) (string, error)
	ReadFile(filename string) ([]byte, error)
}

func NewFakeIOHandler

func NewFakeIOHandler() IOHandler

func NewOSIOHandler

func NewOSIOHandler() IOHandler

Jump to

Keyboard shortcuts

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