Documentation ¶
Index ¶
- Constants
- Variables
- func AccessModeToString(accessModeArray []corev1.PersistentVolumeAccessMode) string
- func CheckErr(err error, handleErr func(string))
- func CheckError(err error)
- func CheckVersion(versionDetail v1.VersionDetails) string
- func ColorStringOnStatus(stringToColor string) string
- func ColorText(s string, c Color) string
- func ConvertToIBytes(value string) string
- func Duration(d time.Duration) string
- func Fatal(msg string)
- func GetAvailableCapacity(total string, used string) string
- func GetCasType(v1PV *corev1.PersistentVolume, v1SC *v1.StorageClass) string
- func GetCasTypeFromPV(v1PV *corev1.PersistentVolume) string
- func GetCasTypeFromSC(v1SC *v1.StorageClass) string
- func GetReadyContainers(containers []corev1.ContainerStatus) string
- func GetUsedCapacityFromCVR(cvrList *cstorv1.CStorVolumeReplicaList) string
- func GetUsedPercentage(total string, used string) float64
- func HandleEmptyTableError(resource string, ns string, casType string) error
- func IsValidCasType(casType string) bool
- func PrintByTemplate(templateName string, resourceTemplate string, resource interface{}) error
- func TablePrinter(columns []metav1.TableColumnDefinition, rows []metav1.TableRow, ...)
- func TemplatePrinter(template string, obj runtime.Object)
- type BlockDevicesInfoInPool
- type CStorReplicaInfo
- type CVRInfo
- type Color
- type ComponentData
- type CstorPVCInfo
- type CstorVolumeResources
- type JivaPVCInfo
- type Key
- type LVMPVCInfo
- type LVMVolDesc
- type LocalHostPathVolInfo
- type MapOptions
- type PVCInfo
- type PoolInfo
- type PortalInfo
- type ReturnType
- type Volume
- type VolumeInfo
- type ZFSPVCInfo
- type ZFSVolDesc
Constants ¶
const ( // OpenEBSCasTypeKey present in label of PV OpenEBSCasTypeKey = "openebs.io/cas-type" // Unknown to be retuned when cas type is not known Unknown = "unknown" // OpenEBSCasTypeKeySc present in parameter of SC OpenEBSCasTypeKeySc = "cas-type" // CstorCasType cas type name CstorCasType = "cstor" // ZFSCasType cas type name ZFSCasType = "localpv-zfs" // JivaCasType is the cas type name for Jiva JivaCasType = "jiva" // LVMCasType cas type name LVMCasType = "localpv-lvm" // LocalPvHostpathCasType cas type name LocalPvHostpathCasType = "localpv-hostpath" // LocalDeviceCasType cas type name LocalDeviceCasType = "localpv-device" // LocalHostpathCasLabel cas-type label in dynamic-localpv-provisioner LocalHostpathCasLabel = "local-hostpath" // Healthy cstor volume status Healthy = "Healthy" // StorageKey key present in pvc status.capacity StorageKey = "storage" //NotAttached to show when CVA is not present NotAttached = "N/A" // CVAVolnameKey present in label of CVA CVAVolnameKey = "Volname" // UnicodeCross stores the character representation of U+2718 UnicodeCross = "✘" // UnicodeCheck stores the character representation of U+2714 UnicodeCheck = "✔" // NotFound stores the Not Found Status NotFound = "Not Found" // CVANotAttached stores CVA Not Attached status CVANotAttached = "Not Attached to Application" // Attached stores CVA Attached Status Attached = "Attached" )
const ( // CStorCSIDriver is the name of CStor CSI driver CStorCSIDriver = "cstor.csi.openebs.io" // JivaCSIDriver is the name of the Jiva CSI driver JivaCSIDriver = "jiva.csi.openebs.io" // ZFSCSIDriver is the name of the ZFS localpv CSI driver ZFSCSIDriver = "zfs.csi.openebs.io" // LocalPVLVMCSIDriver is the name of the LVM LocalPV CSI driver // NOTE: This might also mean local-hostpath, local-device or zfs-localpv later. LocalPVLVMCSIDriver = "local.csi.openebs.io" )
const ( // CStorCSIControllerLabelValue is the label value of CSI controller STS & pod CStorCSIControllerLabelValue = "openebs-cstor-csi-controller" // JivaCSIControllerLabelValue is the label value of CSI controller STS & pod JivaCSIControllerLabelValue = "openebs-jiva-csi-controller" // LVMLocalPVcsiControllerLabelValue is the label value of CSI controller STS & pod LVMLocalPVcsiControllerLabelValue = "openebs-lvm-controller" // ZFSLocalPVcsiControllerLabelValue is the label value of CSI controller STS & pod ZFSLocalPVcsiControllerLabelValue = "openebs-zfs-controller" )
Constant CSI component-name label values
const ( // CstorComponentNames for the cstor control plane components CstorComponentNames = "cspc-operator,cvc-operator,cstor-admission-webhook,openebs-cstor-csi-node,openebs-cstor-csi-controller" // NDMComponentNames for the ndm components NDMComponentNames = "openebs-ndm-operator,ndm" // JivaComponentNames for the jiva control plane components JivaComponentNames = "openebs-jiva-csi-node,openebs-jiva-csi-controller,jiva-operator" // LVMComponentNames for the lvm control plane components LVMComponentNames = "openebs-lvm-controller,openebs-lvm-node" // ZFSComponentNames for the zfs control plane components ZFSComponentNames = "openebs-zfs-controller,openebs-zfs-node" // HostpathComponentNames for the hostpath control plane components HostpathComponentNames = "openebs-localpv-provisioner" )
const ( // List If we want the return type as a list List ReturnType = "list" // Map If we want the return type as a map Map ReturnType = "map" // Name key if we want the keys to be made on name Name Key = "name" // Label key if want to make the keys on labels Label Key = "label" )
Variables ¶
var ( // CasTypeAndComponentNameMap stores the component name of the corresponding cas type // NOTE: Not including ZFSLocalPV as it'd break existing code CasTypeAndComponentNameMap = map[string]string{ CstorCasType: CStorCSIControllerLabelValue, JivaCasType: JivaCSIControllerLabelValue, LVMCasType: LVMLocalPVcsiControllerLabelValue, ZFSCasType: ZFSLocalPVcsiControllerLabelValue, LocalPvHostpathCasType: HostpathComponentNames, } // ComponentNameToCasTypeMap is a reverse map of CasTypeAndComponentNameMap // NOTE: Not including ZFSLocalPV as it'd break existing code ComponentNameToCasTypeMap = map[string]string{ CStorCSIControllerLabelValue: CstorCasType, JivaCSIControllerLabelValue: JivaCasType, LVMLocalPVcsiControllerLabelValue: LVMCasType, ZFSLocalPVcsiControllerLabelValue: ZFSCasType, HostpathComponentNames: LocalPvHostpathCasType, } // ProvsionerAndCasTypeMap stores the cas type name of the corresponding provisioner ProvsionerAndCasTypeMap = map[string]string{ CStorCSIDriver: CstorCasType, JivaCSIDriver: JivaCasType, LocalPVLVMCSIDriver: LVMCasType, ZFSCSIDriver: ZFSCasType, } // CasTypeToComponentNamesMap stores the names of the control-plane components of each cas-types. // To show statuses of new CasTypes, please update this map. CasTypeToComponentNamesMap = map[string]string{ CstorCasType: CstorComponentNames + "," + NDMComponentNames, JivaCasType: JivaComponentNames + "," + HostpathComponentNames, LocalPvHostpathCasType: HostpathComponentNames, LocalDeviceCasType: HostpathComponentNames + "," + NDMComponentNames, ZFSCasType: ZFSComponentNames, LVMCasType: LVMComponentNames, } // CstorReplicaColumnDefinations stores the Table headers for CVR Details CstorReplicaColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Total", Type: "string"}, {Name: "Used", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "Age", Type: "string"}, } // PodDetailsColumnDefinations stores the Table headers for Pod Details PodDetailsColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Namespace", Type: "string"}, {Name: "Name", Type: "string"}, {Name: "Ready", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "Age", Type: "string"}, {Name: "IP", Type: "string"}, {Name: "Node", Type: "string"}, } // JivaPodDetailsColumnDefinations stores the Table headers for Jiva Pod Details JivaPodDetailsColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Namespace", Type: "string"}, {Name: "Name", Type: "string"}, {Name: "Mode", Type: "string"}, {Name: "Node", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "IP", Type: "string"}, {Name: "Ready", Type: "string"}, {Name: "Age", Type: "string"}, } // VolumeListColumnDefinations stores the Table headers for Volume Details VolumeListColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Namespace", Type: "string"}, {Name: "Name", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "Version", Type: "string"}, {Name: "Capacity", Type: "string"}, {Name: "Storage Class", Type: "string"}, {Name: "Attached", Type: "string"}, {Name: "Access Mode", Type: "string"}, {Name: "Attached Node", Type: "string"}, } // CstorPoolListColumnDefinations stores the Table headers for Cstor Pool Details CstorPoolListColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "HostName", Type: "string"}, {Name: "Free", Type: "string"}, {Name: "Capacity", Type: "string"}, {Name: "Read Only", Type: "bool"}, {Name: "Provisioned Replicas", Type: "int"}, {Name: "Healthy Replicas", Type: "int"}, {Name: "Status", Type: "string"}, {Name: "Age", Type: "string"}, } // BDListColumnDefinations stores the Table headers for Block Device Details BDListColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Capacity", Type: "string"}, {Name: "State", Type: "string"}, } // PoolReplicaColumnDefinations stores the Table headers for Pool Replica Details PoolReplicaColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "PVC Name", Type: "string"}, {Name: "Size", Type: "string"}, {Name: "State", Type: "string"}, } // CstorBackupColumnDefinations stores the Table headers for Cstor Backup Details CstorBackupColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Backup Name", Type: "string"}, {Name: "Volume Name", Type: "string"}, {Name: "Backup Destination", Type: "string"}, {Name: "Snap Name", Type: "string"}, {Name: "Status", Type: "string"}, } // CstorCompletedBackupColumnDefinations stores the Table headers for Cstor Completed Backup Details CstorCompletedBackupColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Backup Name", Type: "string"}, {Name: "Volume Name", Type: "string"}, {Name: "Last Snap Name", Type: "string"}, } // CstorRestoreColumnDefinations stores the Table headers for Cstor Restore Details CstorRestoreColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Restore Name", Type: "string"}, {Name: "Volume Name", Type: "string"}, {Name: "Restore Source", Type: "string"}, {Name: "Storage Class", Type: "string"}, {Name: "Status", Type: "string"}, } // BDTreeListColumnDefinations stores the Table headers for Block Device Details, when displayed as tree BDTreeListColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Path", Type: "string"}, {Name: "Size", Type: "string"}, {Name: "ClaimState", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "FsType", Type: "string"}, {Name: "MountPoint", Type: "string"}, } // LVMvolgroupListColumnDefinitions stores the table headers for listing lvm vg-group when displayed as tree LVMvolgroupListColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "FreeSize", Type: "string"}, {Name: "TotalSize", Type: "string"}, } // ZFSPoolListColumnDefinitions stores the table headers for listing zfs pools when displayed as tree ZFSPoolListColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "FreeSize", Type: "string"}, } // JivaReplicaPVCColumnDefinations stores the Table headers for Jiva Replica PVC details JivaReplicaPVCColumnDefinations = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Status", Type: "string"}, {Name: "Volume", Type: "string"}, {Name: "Capacity", Type: "string"}, {Name: "Storageclass", Type: "string"}, {Name: "Age", Type: "string"}, } // CstorVolumeCRStatusColumnDefinitions stores the Table headers for Cstor CRs status details CstorVolumeCRStatusColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Kind", Type: "string"}, {Name: "Name", Type: "string"}, {Name: "Status", Type: "string"}, } // VolumeTotalAndUsageDetailColumnDefinitions stores the Table headers for volume usage details VolumeTotalAndUsageDetailColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Total Capacity", Type: "string"}, {Name: "Used Capacity", Type: "string"}, {Name: "Available Capacity", Type: "string"}, } // EventsColumnDefinitions stores the Table headers for events details EventsColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Name", Type: "string"}, {Name: "Action", Type: "string"}, {Name: "Reason", Type: "string"}, {Name: "Message", Type: "string"}, {Name: "Type", Type: "string"}, } VersionColumnDefinition = []metav1.TableColumnDefinition{ {Name: "Component", Type: "string"}, {Name: "Version", Type: "string"}, } // ClusterInfoColumnDefinitions stores the Table headers for Cluster-Info details ClusterInfoColumnDefinitions = []metav1.TableColumnDefinition{ {Name: "Cas-Type", Type: "string"}, {Name: "Namespace", Type: "string"}, {Name: "Version", Type: "string"}, {Name: "Working", Type: "string"}, {Name: "Status", Type: "string"}, } )
Functions ¶
func AccessModeToString ¶
func AccessModeToString(accessModeArray []corev1.PersistentVolumeAccessMode) string
AccessModeToString Flattens the arrat of AccessModes and returns a string fit to display in the output
func CheckError ¶
func CheckError(err error)
CheckError prints err to stderr and exits with code 1 if err is not nil. Otherwise, it is a no-op.
func CheckVersion ¶
func CheckVersion(versionDetail v1.VersionDetails) string
CheckVersion returns a message based on the status of the version
func ColorStringOnStatus ¶ added in v0.3.0
ColorStringOnStatus is used for coloring the strings based on statuses
func ConvertToIBytes ¶
ConvertToIBytes humanizes all the passed units to IBytes format
func Duration ¶
Duration return the time.Duration in no.of days,hour, mins, seconds format. The number of terms to be shown can be increased or decreased using maxTerms constant.
func Fatal ¶
func Fatal(msg string)
Fatal prints the message (if provided) and then exits. If V(2) or greater, klog.Fatal is invoked for extended information.
func GetAvailableCapacity ¶ added in v0.3.0
GetAvailableCapacity returns the available capacity irrespective of units
func GetCasType ¶
func GetCasType(v1PV *corev1.PersistentVolume, v1SC *v1.StorageClass) string
GetCasType from the v1pv and v1sc, this is a fallback checker method, it checks both the resource only if the castype is not found.
func GetCasTypeFromPV ¶
func GetCasTypeFromPV(v1PV *corev1.PersistentVolume) string
GetCasTypeFromPV from the passed PersistentVolume or the Stora
func GetCasTypeFromSC ¶
func GetCasTypeFromSC(v1SC *v1.StorageClass) string
GetCasTypeFromSC by passing the storage class
func GetReadyContainers ¶
func GetReadyContainers(containers []corev1.ContainerStatus) string
GetReadyContainers to show the number of ready vs total containers of pod i.e 2/3
func GetUsedCapacityFromCVR ¶
func GetUsedCapacityFromCVR(cvrList *cstorv1.CStorVolumeReplicaList) string
GetUsedCapacityFromCVR as the healthy replicas would have the correct used capacity details
func GetUsedPercentage ¶ added in v0.3.0
GetUsedPercentage returns the usage percentage irrespective of units
func HandleEmptyTableError ¶ added in v0.4.0
HandleEmptyTableError handles error when resources or set of resources are not found
func IsValidCasType ¶ added in v0.4.0
IsValidCasType to return true if the casType is supported
func PrintByTemplate ¶
PrintByTemplate of the provided template and resource
func TablePrinter ¶
func TablePrinter(columns []metav1.TableColumnDefinition, rows []metav1.TableRow, options printers.PrintOptions)
TablePrinter uses cli-runtime TablePrinter to create a similar UI for the ctl
func TemplatePrinter ¶
TemplatePrinter uses cli-runtime TemplatePrinter to print by template without extra type
Types ¶
type BlockDevicesInfoInPool ¶
type BlockDevicesInfoInPool struct { Name string Capacity uint64 State v1alpha1.BlockDeviceState }
BlockDevicesInfoInPool struct will have all the details we want to give in the output for describe pool details section for block devices in the cstor pool instance
type CStorReplicaInfo ¶
type CStorReplicaInfo struct { // Replica name present on ObjectMetadata Name string // Node on which the replica is present NodeName string ID v1.ReplicaID //Replica Status reflects the phase, i.e hold result of last action. // ec. Healthy, Offline ,Degraded etc. Status string }
CStorReplicaInfo holds information about the cStor replicas
type CVRInfo ¶
type CVRInfo struct { Name string PvcName string Size string Status v1.CStorVolumeReplicaPhase }
CVRInfo struct will have all the details we want to give in the output for describe pool details section for provisional replicas in the cstor pool instance
type ComponentData ¶ added in v0.4.0
ComponentData stores the data for each component of an engine
type CstorPVCInfo ¶
type CstorPVCInfo struct { Name string Namespace string CasType string BoundVolume string AttachedToNode string Pool string StorageClassName string Size string Used string CVStatus v1.CStorVolumePhase PVStatus corev1.PersistentVolumePhase }
CstorPVCInfo struct will have all the details we want to give in the output for describe pvc details section for cstor pvc
type CstorVolumeResources ¶ added in v0.3.0
type CstorVolumeResources struct { PV *corev1.PersistentVolume PVC *corev1.PersistentVolumeClaim CV *v1.CStorVolume CVC *v1.CStorVolumeConfig CVA *v1.CStorVolumeAttachment CVRs *v1.CStorVolumeReplicaList PresentBDs *v1alpha1.BlockDeviceList ExpectedBDs map[string]bool BDCs *v1alpha1.BlockDeviceClaimList CSPIs *v1.CStorPoolInstanceList CSPC *v1.CStorPoolCluster }
CstorVolumeResources would contain all the resources needed for debugging a Cstor Volume
type JivaPVCInfo ¶
type JivaPVCInfo struct { Name string Namespace string CasType string BoundVolume string AttachedToNode string JVP string StorageClassName string Size string JVStatus string PVStatus corev1.PersistentVolumePhase }
JivaPVCInfo struct will have all the details we want to give in the output for describe pvc details section for jiva pvc
type Key ¶
type Key string
Key defines what should be the key if we create a map, i.e. Label or Name
type LVMPVCInfo ¶ added in v0.4.0
type LVMPVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVCStatus corev1.PersistentVolumeClaimPhase }
LVMPVCInfo struct will have all the details we want to give in the output for describe pvc details section for lvm pvc
type LVMVolDesc ¶ added in v0.3.0
type LVMVolDesc struct { Name string Namespace string AccessMode string CSIDriver string Capacity string PVC string VolumePhase corev1.PersistentVolumePhase StorageClass string Version string Status string VolumeGroup string ThinProvisioned string NodeID string }
LVMVolDesc is the output helper for LVMVolDesc
type LocalHostPathVolInfo ¶ added in v0.4.0
type LocalHostPathVolInfo struct { VolumeInfo Path string ReclaimPolicy string CasType string }
type MapOptions ¶
MapOptions struct to get the resources as Map with the provided options Key defines what to use as a key, ex:- name, label, currently these two are supported, add more according to need. LabelKey defines which Label to use as key.
type PVCInfo ¶
type PVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVStatus corev1.PersistentVolumePhase }
PVCInfo struct will have all the details we want to give in the output for describe pvc details section for non-cstor pvc
type PoolInfo ¶
type PoolInfo struct { Name string HostName string Size string FreeCapacity string ReadOnlyStatus bool Status v1.CStorPoolInstancePhase RaidType string }
PoolInfo struct will have all the details we want to give in the output for describe pool details section for cstor pool instance
type PortalInfo ¶
type PortalInfo struct { // Target iSCSI Qualified Name.combination of nodeBase IQN string VolumeName string // iSCSI Target Portal. The Portal is combination of IP:port // (typically TCP ports 3260) Portal string // TargetIP IP of the iSCSI target service TargetIP string //Node Name on which the application pod is running TargetNodeName string }
PortalInfo keep info about the ISCSI Target Portal.
type ReturnType ¶
type ReturnType string
ReturnType defines in which format the object needs to be returned i.e. List or Map
type Volume ¶
type Volume struct { // AccessModes contains all ways the volume can be mounted AccessMode string // Attachment status of the PV and it's claim AttachementStatus string // Represents the actual capacity of the underlying volume. Capacity string // CStorPoolCluster that this volume belongs to CSPC string // The unique volume name returned by the CSI volume plugin to // refer to the volume on all subsequent calls. CSIVolumeAttachmentName string Name string //Namespace defines the space within each name must be unique. // An empty namespace is equivalent to the "default" namespace Namespace string Node string // Name of the PVClaim of the underlying Persistent Volume PVC string // Status of the CStor Volume Status v1.CStorVolumePhase // Name of StorageClass to which this persistent volume belongs. StorageClass string // will be cStorVolume for all cStor volumes VolType string // version of the spec used to create the volumes Version string }
Volume struct will have all the details we want to give in the output for openebsctl commands
type VolumeInfo ¶
type VolumeInfo struct { AccessMode string // Capacity of the underlying PV Capacity string // CStorPoolCluster that the volume belongs to CSPC string // cStor Instance Driver CSIDriver string CSIVolumeAttachmentName string // Name of the volume & Namespace on which it exists Name string Namespace string // Name of the underlying PVC PVC string // ReplicationFactor represents number of volume replica created during // volume provisioning connect to the target ReplicaCount int // Phase indicates if a volume is available, bound to a claim, or released // by a claim. VolumePhase corev1.PersistentVolumePhase // Name of StorageClass to which this persistent volume belongs. StorageClass string // Version of the OpenEBS resource definition being used Version string Size string // Status of the CStor volume Status string // JVP is the name of the JivaVolumePolicy JVP string }
VolumeInfo struct will have all the details we want to give in the output for openebsctl command volume describe
type ZFSPVCInfo ¶ added in v0.4.0
type ZFSPVCInfo struct { Name string Namespace string CasType string BoundVolume string StorageClassName string Size string PVCStatus corev1.PersistentVolumeClaimPhase }
ZFSPVCInfo struct will have all the details we want to give in the output for describe pvc details section for zfs pvc
type ZFSVolDesc ¶ added in v0.3.0
type ZFSVolDesc struct { Name string Namespace string AccessMode string CSIDriver string Capacity string PVC string VolumePhase corev1.PersistentVolumePhase StorageClass string Version string Status string VolumeType string PoolName string FileSystem string Compression string Dedup string NodeID string Recordsize string }
ZFSVolDesc is the output helper for ZfsVolDesc