Skip to content
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

Consistent variable names #152

Merged
merged 1 commit into from
Dec 27, 2022
Merged
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
10 changes: 5 additions & 5 deletions helm/csi-powermax/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,13 @@ spec:
{{- if eq .Values.vSphere.enabled true }}
- name: X_CSI_VSPHERE_PORTGROUP
value: {{ required "Must provide portgroup for vsphere" .Values.vSphere.fcPortGroup }}
- name: X_CSI_VSPHERE_HOSTGROUP
value: {{ required "Must provide host group for vsphere" .Values.vSphere.fcHostGroup }}
- name: X_CSI_VCenter_HOST
- name: X_CSI_VSPHERE_HOSTNAME
value: {{ required "Must provide host group for vsphere" .Values.vSphere.fcHostName }}
- name: X_CSI_VCENTER_HOST
value: {{ required "Must provide host url for vsphere" .Values.vSphere.vCenterHost }}
- name: X_CSI_VCenter_USERNAME
- name: X_CSI_VCENTER_USERNAME
value: {{ required "Must provide username for vsphere" .Values.vSphere.vCenterUserName }}
- name: X_CSI_VCenter_PWD
- name: X_CSI_VCENTER_PWD
value: {{ required "Must provide password for vsphere" .Values.vSphere.vCenterPassword }}
{{- end }}
volumeMounts:
Expand Down
10 changes: 5 additions & 5 deletions helm/csi-powermax/templates/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ spec:
{{- if eq .Values.vSphere.enabled true }}
- name: X_CSI_VSPHERE_PORTGROUP
value: {{ required "Must provide portgroup for vsphere" .Values.vSphere.fcPortGroup }}
- name: X_CSI_VSPHERE_HOSTGROUP
value: {{ required "Must provide host group for vsphere" .Values.vSphere.fcHostGroup }}
- name: X_CSI_VCenter_HOST
- name: X_CSI_VSPHERE_HOSTNAME
value: {{ required "Must provide host group for vsphere" .Values.vSphere.fcHostName }}
- name: X_CSI_VCENTER_HOST
value: {{ required "Must provide hosr url for vsphere" .Values.vSphere.vCenterHost }}
- name: X_CSI_VCenter_USERNAME
- name: X_CSI_VCENTER_USERNAME
value: {{ required "Must provide username for vsphere" .Values.vSphere.vCenterUserName }}
- name: X_CSI_VCenter_PWD
- name: X_CSI_VCENTER_PWD
value: {{ required "Must provide password for vsphere" .Values.vSphere.vCenterPassword }}
{{- end }}
volumeMounts:
Expand Down
8 changes: 4 additions & 4 deletions helm/csi-powermax/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ vSphere:
# fcPortGroup: an existing portGroup that driver will use for vSphere
# recommended format: csi-x-VC-PG, x can be anything of user choice
fcPortGroup: "csi-vsphere-VC-PG"
# fcHostGroup: an existing host group that driver will use for vSphere
# this hostGroup should contain initiators from all the ESXs/ESXi host
# fcHostName: an existing host(initiator group) that driver will use for vSphere
# this host should contain initiators from all the ESXs/ESXi host
# where the cluster is deployed
# recommended format: csi-x-VC-HG, x can be anything of user choice
fcHostGroup: "csi-vsphere-VC-HG"
# recommended format: csi-x-VC-HN, x can be anything of user choice
fcHostName: "csi-vsphere-VC-HN"
# vCenterHost: URL/endpoint of the vCenter where all the ESX are present
vCenterHost: "00.000.000.00"
# vCenterUserName: username from the vCenter credentials
Expand Down
4 changes: 2 additions & 2 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ func getMVLockKey(symID, tgtMaskingViewID string) string {
func (s *service) IsNodeISCSI(ctx context.Context, symID, nodeID string, pmaxClient pmax.Pmax) (bool, error) {
if s.opts.IsVsphereEnabled {
// check if FC host exist
fcHost, fcHostErr := pmaxClient.GetHostByID(ctx, symID, s.opts.VSphereHostGroup)
fcHost, fcHostErr := pmaxClient.GetHostByID(ctx, symID, s.opts.VSphereHostName)
if fcHostErr == nil {
if fcHost.HostType == "Fibre" {
return false, nil
Expand Down Expand Up @@ -2006,7 +2006,7 @@ func (s *service) buildHostIDFromTemplate(nodeID string) (
func (s *service) GetVSphereFCHostSGAndMVIDFromNodeID() (string, string, string) {
storageGroupID := CsiNoSrpSGPrefix + s.getClusterPrefix() + "-" + Vsphere
maskingViewID := CsiMVPrefix + s.getClusterPrefix() + "-" + Vsphere
return s.opts.VSphereHostGroup, storageGroupID, maskingViewID
return s.opts.VSphereHostName, storageGroupID, maskingViewID
}

// GetISCSIHostSGAndMVIDFromNodeID - Forms HostID, StorageGroupID, MaskingViewID
Expand Down
10 changes: 5 additions & 5 deletions service/envvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ const (
// EnvVSpherePortGroup is an env variable which has FC portGroup for vSphere
EnvVSpherePortGroup = "X_CSI_VSPHERE_PORTGROUP"

// EnvVSphereHostGroup is an env variable which has FC hostGroup for vSphere
EnvVSphereHostGroup = "X_CSI_VSPHERE_HOSTGROUP"
// EnvVSphereHostName is an env variable which has FC host for vSphere
EnvVSphereHostName = "X_CSI_VSPHERE_HOSTNAME"

// EnvVCHost is an env variable that has vCenter Host endpoint
EnvVCHost = "X_CSI_VCenter_HOST"
EnvVCHost = "X_CSI_VCENTER_HOST"

// EnvVCUsername is an env variable that has vCenter username
EnvVCUsername = "X_CSI_VCenter_USERNAME"
EnvVCUsername = "X_CSI_VCENTER_USERNAME"

// EnvVCPassword is an env variable that has vCenter password
EnvVCPassword = "X_CSI_VCenter_PWD" // #nosec G101
EnvVCPassword = "X_CSI_VCENTER_PWD" // #nosec G101
)
12 changes: 7 additions & 5 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type Opts struct {
IsTopologyControlEnabled bool // used to filter topology keys based on user config
IsVsphereEnabled bool // used to check if vSphere is enabled
VSpherePortGroup string // port group for vsphere
VSphereHostGroup string // host group for vsphere
VSphereHostName string // host (initiator group) for vsphere
VCenterHostURL string // vCenter host url
VCenterHostUserName string // vCenter host username
VCenterHostPassword string // vCenter password
Expand Down Expand Up @@ -267,7 +267,9 @@ func (s *service) BeforeServe(
"isTopologyControlEnabled": s.opts.IsTopologyControlEnabled,
"isVsphereEnabled": s.opts.IsVsphereEnabled,
"VspherePortGroups": s.opts.VSpherePortGroup,
"VsphereHostGroups": s.opts.VSphereHostGroup,
"VsphereHostNames": s.opts.VSphereHostName,
"VsphereHostURL": s.opts.VCenterHostURL,
"VsphereHostUsername": s.opts.VCenterHostUserName,
}

if s.opts.Password != "" {
Expand Down Expand Up @@ -461,9 +463,9 @@ func (s *service) BeforeServe(
if vPG, ok := csictx.LookupEnv(ctx, EnvVSpherePortGroup); ok {
opts.VSpherePortGroup = vPG
}
// read host group
if vHG, ok := csictx.LookupEnv(ctx, EnvVSphereHostGroup); ok {
opts.VSphereHostGroup = vHG
// read host (initiator group)
if vHN, ok := csictx.LookupEnv(ctx, EnvVSphereHostName); ok {
opts.VSphereHostName = vHN
}
// read vCenter host url
if vURL, ok := csictx.LookupEnv(ctx, EnvVCHost); ok {
Expand Down
9 changes: 5 additions & 4 deletions service/vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"reflect"
"strings"

log "github.com/sirupsen/logrus"

"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/mo"
Expand Down Expand Up @@ -120,18 +122,17 @@ func (vmh *VMHost) findVM(targetMACAddress string) (vm *object.VirtualMachine, e
for _, datacenter := range allDatacenters {
f.SetDatacenter(datacenter)
allVMs, err := f.VirtualMachineList(vmh.Ctx, "*")
fmt.Printf("all VMS: (%v)", allVMs)
if err != nil {
return nil, errors.New("Could not get List of VMs")
}
for _, vm := range allVMs {
VMMac, err := vmh.getMACAddressOfVM(vm)
fmt.Printf("VM: %v , mac(%s)", vm, VMMac)
VMMac = strings.ToUpper(VMMac)
if err != nil {
return nil, errors.New("Could not get MAC Address of VM")
log.Debugf("Could not get MAC Address of VM (%v), datacenter (%v)", vm, datacenter)
}
if VMMac == targetMACAddress {
if VMMac == targetMACAddress && err == nil {
log.Debugf("Found VM: %v , mac(%s)", vm, VMMac)
return vm, nil
}
}
Expand Down