azureutils

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPathLengthWindows = 260
)

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 *armcompute.Snapshot) (*csi.Snapshot, error)

func GetAttachDiskInitialDelay added in v1.26.5

func GetAttachDiskInitialDelay(attributes map[string]string) int

GetAttachDiskInitialDelay gttachDiskInitialDelay from attributes return -1 if not found

func GetCachingMode

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

func GetCloudProviderFromClient added in v1.9.0

func GetCloudProviderFromClient(ctx context.Context, kubeClient clientset.Interface, secretName, secretNamespace, userAgent string,
	allowEmptyCloudConfig bool, enableTrafficMgr bool, trafficMgrPort int64) (*azure.Cloud, error)

GetCloudProviderFromClient 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 []*armcompute.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 GetFStype added in v1.11.0

func GetFStype(attributes map[string]string) string

func GetKubeClient added in v1.9.0

func GetKubeClient(kubeconfig string) (clientset.Interface, error)

func GetMaxShares added in v1.11.0

func GetMaxShares(attributes map[string]string) (int, error)

func GetResourceGroupFromURI

func GetResourceGroupFromURI(diskURI string) (string, error)

func GetSnapshotNameFromURI

func GetSnapshotNameFromURI(snapshotURI string) (string, error)

func GetSourceVolumeID

func GetSourceVolumeID(snapshot *armcompute.Snapshot) string

func GetSubscriptionIDFromURI added in v1.11.0

func GetSubscriptionIDFromURI(diskURI string) string

func GetValidCreationData

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

func InsertDiskProperties

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

InsertProperties: 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 IsValidAccessModes added in v1.11.0

func IsValidAccessModes(volCaps []*csi.VolumeCapability) 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, maxShares int) error

IsValidVolumeCapabilities checks whether the volume capabilities are valid

func NormalizeCachingMode

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

func NormalizeNetworkAccessPolicy

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

func NormalizePublicNetworkAccess added in v1.28.0

func NormalizePublicNetworkAccess(publicNetworkAccess string) (armcompute.PublicNetworkAccess, error)

func NormalizeStorageAccountType

func NormalizeStorageAccountType(storageAccountType, cloud string, disableAzureStackCloud bool) (armcompute.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.

func RunPowershellCmd added in v1.28.0

func RunPowershellCmd(command string, envs ...string) ([]byte, error)

func SetKeyValueInMap added in v1.26.3

func SetKeyValueInMap(m map[string]string, key, value string)

SetKeyValueInMap set key/value pair in map key in the map is case insensitive, if key already exists, overwrite existing value

func SleepIfThrottled added in v1.9.0

func SleepIfThrottled(err error, defaultSleepSec int)

func ValidateDataAccessAuthMode added in v1.26.3

func ValidateDataAccessAuthMode(dataAccessAuthMode string) error

func ValidateDiskEncryptionType added in v1.18.0

func ValidateDiskEncryptionType(encryptionType string) error

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.DirEntry, 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

type ManagedDiskParameters added in v1.11.0

type ManagedDiskParameters struct {
	AccountType             string
	CachingMode             v1.AzureDataDiskCachingMode
	DeviceSettings          map[string]string
	DiskAccessID            string
	DiskEncryptionSetID     string
	DiskEncryptionType      string
	DiskIOPSReadWrite       string
	DiskMBPSReadWrite       string
	DiskName                string
	EnableBursting          *bool
	PerformancePlus         *bool
	FsType                  string
	Location                string
	LogicalSectorSize       int
	MaxShares               int
	NetworkAccessPolicy     string
	PublicNetworkAccess     string
	PerfProfile             string
	SubscriptionID          string
	ResourceGroup           string
	Tags                    map[string]string
	UserAgent               string
	VolumeContext           map[string]string
	WriteAcceleratorEnabled string
	Zoned                   string
}

func ParseDiskParameters added in v1.11.0

func ParseDiskParameters(parameters map[string]string) (ManagedDiskParameters, error)

Jump to

Keyboard shortcuts

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