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

Check nfs #185

Merged
merged 17 commits into from
Apr 25, 2023
52 changes: 41 additions & 11 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ var Log = logrus.New()

// ArrayConnectionData contains data required to connect to array
type ArrayConnectionData struct {
SystemID string `json:"systemID"`
Username string `json:"username"`
Password string `json:"password"`
Endpoint string `json:"endpoint"`
SkipCertificateValidation bool `json:"skipCertificateValidation,omitempty"`
Insecure bool `json:"insecure,omitempty"`
IsDefault bool `json:"isDefault,omitempty"`
AllSystemNames string `json:"allSystemNames"`
NasName string `json:"nasName"`
NfsAcls string `json:"nfsAcls"`
SystemID string `json:"systemID"`
Username string `json:"username"`
Password string `json:"password"`
Endpoint string `json:"endpoint"`
SkipCertificateValidation bool `json:"skipCertificateValidation,omitempty"`
Insecure bool `json:"insecure,omitempty"`
IsDefault bool `json:"isDefault,omitempty"`
AllSystemNames string `json:"allSystemNames"`
NasName *string `json:"nasName"`
NfsAcls string `json:"nfsAcls"`
}

// Manifest is the SP's manifest.
Expand Down Expand Up @@ -458,6 +458,36 @@ func (s *service) BeforeServe(
return nil
}

func (s *service) checkNFS(ctx context.Context, systemID string) (bool, error) {

err := s.systemProbeAll(ctx)
if err != nil {
return false, err
}
c := s.adminClients[systemID]

version, err := c.GetVersion()
if err != nil {
return false, err
}
ver, err := strconv.ParseFloat(version, 64)
if err != nil {
return false, err
}
if ver >= 4.0 {
arrayConData, err := getArrayConfig(ctx)
if err != nil {
return false, err
}
array := arrayConData[systemID]
if array.NasName == nil || *(array.NasName) == "" {
return false, nil
}
return true, nil
}
return false, nil
}

// Probe all systems managed by driver
func (s *service) doProbe(ctx context.Context) error {

Expand Down Expand Up @@ -703,7 +733,7 @@ func getArrayConfig(ctx context.Context) (map[string]*ArrayConnectionData, error

// for PowerFlex v4.0
var s *service
if c.NasName == "" {
if *(c.NasName) == "" {
return nil, fmt.Errorf(fmt.Sprintf("invalid value for NasName at index %d", i))
}
if c.NfsAcls == "" {
Expand Down