Skip to content

Support for additional Bus Types #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,21 @@ kubectl apply -f https://raw.githubusercontent.com/vmware/cloud-director-named-d
| Storage Type | Independent Shareable Named Disks of VCD |
|Provisioning|<ul><li>Static Provisioning</li><li>Dynamic Provisioning</li></ul>|
|Access Modes|<ul><li>ReadOnlyMany</li><li>ReadWriteOnce</li></ul>|
|Volume|Block|
|Volume|<ul><li>Block</ul></li>|
|VolumeMode|<ul><li>FileSystem</li></ul>|
|Topology|<ul><li>Static Provisioning: reuses VCD topology capabilities</li><li>Dynamic Provisioning: places disk in the OVDC of the `ClusterAdminUser` based on the StorageProfile specified.</li></ul>|

## Supported Bus Types
| Bus Type | `bustype` Parameter in `StorageClass` |
| :--------- | :----------------------- |
| Paravirtual (SCSI) | `scsi_paravirtual` (default) |
| LSI Logic Parallel (SCSI) | `scsi_lsi_logic_parallel` |
| LSI Logic SAS (SCSI) | `scsi_lsi_logic_sas` |
| Bus Logic (SCSI) | `scsi_buslogic` |
| SATA | `sata` |
| NVME | `nvme` |


## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.

Expand Down
8 changes: 7 additions & 1 deletion artifacts/default-csi-node-crs-airgap.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ spec:
mountPath: /etc/kubernetes/vcloud
- name: vcloud-basic-auth-volume
mountPath: /etc/kubernetes/vcloud/basic-auth
- mountPath: /run
name: host-run-dir
mountPropagation: "HostToContainer"
volumes:
- name: socket-dir
hostPath:
Expand Down Expand Up @@ -147,4 +150,7 @@ spec:
- name: vcloud-basic-auth-volume
secret:
secretName: vcloud-basic-auth
---
- name: host-run-dir
hostPath:
path: /run
type: Directory
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ require (
)

require (
github.com/jaypipes/ghw v0.10.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.19.0
k8s.io/api v0.22.1
k8s.io/apimachinery v0.22.1
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/antihax/optional v1.0.0 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/araddon/dateparse v0.0.0-20190622164848-0fb0a474d195 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand All @@ -45,13 +49,16 @@ require (
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/imdario/mergo v0.3.5 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jaypipes/pcidb v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/peterhellberg/link v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/net v0.7.0 // indirect
Expand All @@ -63,6 +70,7 @@ require (
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
howett.net/plist v1.0.0 // indirect
k8s.io/client-go v0.22.1 // indirect
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
Expand Down
17 changes: 17 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/akutz/gofsutil v0.1.2 h1:aCdWrZdxajx8kllNQSKaMDpRJWSE2wcyKNy7eDMXkrI=
github.com/akutz/gofsutil v0.1.2/go.mod h1:09JEF8dR0bTTZMQ1m3/+O1rqQyH2lG1ET34POnpzyxw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
Expand Down Expand Up @@ -113,6 +115,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand All @@ -126,6 +129,9 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.4.0 h1:K7/B1jt6fIBQVd4Owv2MqGQClcgf0R266+7C/QjRcLc=
github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-openapi/errors v0.20.2 h1:dxy7PGTqEh94zj2E3h1cUmQQWiM1+aeCROfAr02EmK8=
github.com/go-openapi/errors v0.20.2/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
Expand Down Expand Up @@ -237,6 +243,11 @@ github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jaypipes/ghw v0.10.0 h1:UHu9UX08Py315iPojADFPOkmjTsNzHj4g4adsNKKteY=
github.com/jaypipes/ghw v0.10.0/go.mod h1:jeJGbkRB2lL3/gxYzNYzEDETV1ZJ56OKr+CSeSEym+g=
github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8=
github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
Expand Down Expand Up @@ -272,6 +283,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
Expand Down Expand Up @@ -315,6 +327,7 @@ github.com/peterhellberg/link v1.1.0 h1:s2+RH8EGuI/mI4QwrWGSYQCRz7uNgip9BaM04HKu
github.com/peterhellberg/link v1.1.0/go.mod h1:gtSlOT4jmkY8P47hbTc8PTgiDDWpdPbFYl75keYyBB8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -528,6 +541,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -736,6 +750,7 @@ gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand All @@ -760,6 +775,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
k8s.io/api v0.22.1 h1:ISu3tD/jRhYfSW8jI/Q1e+lRxkR7w9UwQEZ7FgslrwY=
k8s.io/api v0.22.1/go.mod h1:bh13rkTp3F1XEaLGykbyRD2QaTTzPm0e/BMd8ptFONY=
k8s.io/apimachinery v0.22.1 h1:DTARnyzmdHMz7bFWFDDm22AM4pLWTQECMpRTFu2d2OM=
Expand Down
8 changes: 7 additions & 1 deletion manifests/csi-node-crs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ spec:
mountPath: /etc/kubernetes/vcloud
- name: vcloud-basic-auth-volume
mountPath: /etc/kubernetes/vcloud/basic-auth
- mountPath: /run
name: host-run-dir
mountPropagation: "HostToContainer"
volumes:
- name: socket-dir
hostPath:
Expand Down Expand Up @@ -147,4 +150,7 @@ spec:
- name: vcloud-basic-auth-volume
secret:
secretName: vcloud-basic-auth
---
- name: host-run-dir
hostPath:
path: /run
type: Directory
8 changes: 7 additions & 1 deletion manifests/csi-node-crs.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ spec:
mountPath: /etc/kubernetes/vcloud
- name: vcloud-basic-auth-volume
mountPath: /etc/kubernetes/vcloud/basic-auth
- mountPath: /run
name: host-run-dir
mountPropagation: "HostToContainer"
volumes:
- name: socket-dir
hostPath:
Expand Down Expand Up @@ -147,4 +150,7 @@ spec:
- name: vcloud-basic-auth-volume
secret:
secretName: vcloud-basic-auth
---
- name: host-run-dir
hostPath:
path: /run
type: Directory
8 changes: 7 additions & 1 deletion manifests/csi-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ spec:
mountPath: /etc/kubernetes/vcloud
- name: vcloud-basic-auth-volume
mountPath: /etc/kubernetes/vcloud/basic-auth
- mountPath: /run
name: host-run-dir
mountPropagation: "HostToContainer"
volumes:
- name: socket-dir
hostPath:
Expand Down Expand Up @@ -142,4 +145,7 @@ spec:
- name: vcloud-basic-auth-volume
secret:
secretName: vcloud-basic-auth
---
- name: host-run-dir
hostPath:
path: /run
type: Directory
8 changes: 7 additions & 1 deletion manifests/csi-node.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ spec:
mountPath: /etc/kubernetes/vcloud
- name: vcloud-basic-auth-volume
mountPath: /etc/kubernetes/vcloud/basic-auth
- mountPath: /run
name: host-run-dir
mountPropagation: "HostToContainer"
volumes:
- name: socket-dir
hostPath:
Expand Down Expand Up @@ -142,4 +145,7 @@ spec:
- name: vcloud-basic-auth-volume
secret:
secretName: vcloud-basic-auth
---
- name: host-run-dir
hostPath:
path: /run
type: Directory
67 changes: 36 additions & 31 deletions pkg/csi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package csi
import (
"context"
"fmt"
"math"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/vmware/cloud-director-named-disk-csi-driver/pkg/util"
"github.com/vmware/cloud-director-named-disk-csi-driver/pkg/vcdcsiclient"
Expand All @@ -16,7 +18,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"math"
)

const (
Expand All @@ -27,7 +28,6 @@ const (

const (
BusTypeParameter = "busType"
BusSubTypeParameter = "busSubType"
StorageProfileParameter = "storageProfile"
FileSystemParameter = "filesystem"
EphemeralVolumeContext = "csi.storage.k8s.io/ephemeral"
Expand All @@ -36,15 +36,8 @@ const (
VMFullNameAttribute = "vmID"
DiskUUIDAttribute = "diskUUID"
FileSystemAttribute = "filesystem"
)

var (
// BusTypesFromValues is a map of different possible BusTypes from id to string
BusTypesFromValues = map[string]string{
"5": "IDE",
"6": "SCSI",
"20": "SATA",
}
DefaultFSType = "ext4"
DefaultBusType = "scsi_paravirtual"
)

type controllerServer struct {
Expand Down Expand Up @@ -97,7 +90,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context,
}

volumeCapabilities := req.GetVolumeCapabilities()
if volumeCapabilities == nil || len(volumeCapabilities) == 0 {
if len(volumeCapabilities) == 0 { // should omit nil check; len() for []*github.com/container-storage-interface/spec/lib/go/csi.VolumeCapability is defined as zero (S1009)
return nil, status.Error(codes.InvalidArgument, "CreateVolume: VolumeCapabilities should be provided")
}
for _, volumeCapability := range volumeCapabilities {
Expand All @@ -117,39 +110,51 @@ func (cs *controllerServer) CreateVolume(ctx context.Context,
klog.Infof("CreateVolume: requesting volume [%s] with size [%d] MiB, shareable [%v]",
diskName, sizeMB, shareable)

busType := vcdcsiclient.VCDBusTypeSCSI
busSubType := vcdcsiclient.VCDBusSubTypeVirtualSCSI
var (
storageProfile string
fsType string
busType string
tuple vcdcsiclient.BusTuple
ok bool
)

storageProfile, _ := req.Parameters[StorageProfileParameter]
if busType, ok = req.Parameters[BusTypeParameter]; !ok {
busType = DefaultBusType
klog.Infof("No parameter [%s] specified for raw disk [%s]. Hence defaulting to [%s].", BusTypeParameter, diskName, DefaultBusType)
}

disk, err := cs.DiskManager.CreateDisk(diskName, sizeMB, busType,
busSubType, cs.DiskManager.ClusterID, storageProfile, shareable)
tuple, ok = vcdcsiclient.BusTypesSet[busType]
if !ok {
return nil, fmt.Errorf("invalid busType: [%s]", busType)
}

if storageProfile, ok = req.Parameters[StorageProfileParameter]; !ok {
klog.Infof("No parameter [%s] specified for raw disk [%s]. ", StorageProfileParameter, diskName)
}

if fsType, ok = req.Parameters[FileSystemParameter]; !ok {
fsType = DefaultFSType
klog.Infof("No parameter [%s] specified for raw disk [%s]. Hence defaulting to [%s].", FileSystemParameter, diskName, DefaultFSType)
}

disk, err := cs.DiskManager.CreateDisk(diskName, sizeMB, tuple.BusType, tuple.BusSubType, "", storageProfile, shareable)
if err != nil {
if rdeErr := cs.DiskManager.AddToErrorSet(util.DiskCreateError, "", diskName, map[string]interface{}{"Detailed Error": err.Error()}); rdeErr != nil {
klog.Errorf("unable to add error [%s] into [CSI.Errors] in RDE [%s], %v", util.DiskCreateError, cs.DiskManager.ClusterID, rdeErr)
}
return nil, fmt.Errorf("unable to create disk [%s] with sise [%d]MB: [%v]",
diskName, sizeMB, err)
return nil, fmt.Errorf("unable to create disk [%s] with size [%d]MB: [%v]", diskName, sizeMB, err)
}
if removeErrorRdeErr := cs.DiskManager.RemoveFromErrorSet(util.DiskCreateError, "", diskName); removeErrorRdeErr != nil {
klog.Errorf("unable to remove error [%s] from [CSI.Errors] in RDE [%s]", util.DiskCreateError, cs.DiskManager.ClusterID)
}
klog.Infof("Successfully created disk [%s] of size [%d]MB", diskName, sizeMB)

attributes := make(map[string]string)
attributes[BusTypeParameter] = BusTypesFromValues[disk.BusType]
attributes[BusSubTypeParameter] = disk.BusSubType
attributes[StorageProfileParameter] = disk.StorageProfile.Name
attributes[DiskIDAttribute] = disk.Id

fsType := ""
ok := false
if fsType, ok = req.Parameters[FileSystemParameter]; !ok {
fsType = "ext4"
klog.Infof("No FS specified for raw disk [%s]. Hence defaulting to [%s].", diskName, fsType)
attributes := map[string]string{
BusTypeParameter: vcdcsiclient.BusSubTypesFromValues[disk.BusSubType], // BusSubType defines better the busType since SATA and NVME share the same ID=20
StorageProfileParameter: disk.StorageProfile.Name,
DiskIDAttribute: disk.Id,
FileSystemParameter: fsType,
}
attributes[FileSystemParameter] = fsType

resp := &csi.CreateVolumeResponse{
Volume: &csi.Volume{
Expand Down
Loading