Skip to content
Draft
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
3 changes: 2 additions & 1 deletion ci_tools/fsas_nodedriver_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ metadata:
passwordFields: credentialsPassword,slesRegistrationCode
privateCredentialFields: credentialsPassword,slesRegistrationCode
publicCredentialFields: credentialsUsername,tenantUuid,apiUrl,ntpUrl,dnsIp,slesRegistrationEmail
Comment thread
lukasz-piotrowski-fujitsu marked this conversation as resolved.
nodedriver.cattle.io/file-to-field-aliases: firstLoginSshKey:firstLoginSshKey
name: fsas
spec:
active: true
addCloudCredential: true
builtin: false
checksum: <sha256_checksum>
description: ''
displayName: fsas
displayName: 'Fsas'
externalId: ''
uiUrl: ''
url: <fsas_nodedriver_binary_url>
13 changes: 13 additions & 0 deletions pkg/drivers/fsas/fsas.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Driver struct {
Keycloak keycloak.Keycloak `json:"-"`
SshManager sshutils.SshManager `json:"-"`
CfgManager cfgutils.CfgManager `json:"-"`
FirstLoginSshKey string `json:"firstLoginSshKey"` // Matches the name used in annotations
}

// NewDriver creates and returns a new instance of the FSAS CDI driver
Expand Down Expand Up @@ -249,6 +250,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Usage: "Warning: this field should remain empty as custom userdata are not supported!",
EnvVar: "FSAS_USERDATA",
},
mcnflag.StringFlag{
Name: "fsas-first-login-ssh-key",
Usage: "SSH private key for first log in",
EnvVar: "FSAS_FIRST_LOGIN_SSH_KEY",
},
}
}

Expand Down Expand Up @@ -398,6 +404,9 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SlesRegistrationEmail = strings.TrimSpace(flags.String("fsas-sles-registration-email"))
slog.Debug("Driver", "FSAS SLES registration email", d.SlesRegistrationEmail)

d.FirstLoginSshKey = strings.TrimSpace(flags.String("fsas-first-login-ssh-key"))
slog.Debug("Driver ", "FSAS first login SSH key", d.FirstLoginSshKey)

return d.checkConfig()
}

Expand Down Expand Up @@ -520,6 +529,10 @@ func (d *Driver) checkConfig() error {
return fmt.Errorf(errorMandatoryOption, "OS image name", "--fsas-os-image-name")
}

if d.FirstLoginSshKey == "" {
return fmt.Errorf(errorMandatoryOption, "First login SSH key", "--fsas-first-login-ssh-key")
}

if err := d.FabricManager.ValidateTenant(d.TenantUuid, d.Keycloak.GetToken()); err != nil {
slog.Error("tenant_uuid validation unsuccessful", "err", err)
return err
Expand Down
6 changes: 6 additions & 0 deletions pkg/drivers/fsas/fsas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func TestSetConfigFromFlagsTrimsWhitespace(t *testing.T) {
"fsas-image-os-ssh-host-pub-key": " " + hostPublicKey + " ",
"fsas-sles-registration-code": "",
"fsas-sles-registration-email": "",
"fsas-first-login-ssh-key": "111-222-333",
},
}

Expand Down Expand Up @@ -291,6 +292,7 @@ func TestCheckConfigTenantSuccess(t *testing.T) {
OsImageName: "Ubuntu",
UserDataFile: "userData.json",
OsImageSshHostPubKey: hostPublicKey,
FirstLoginSshKey: "111-222-333",
}
driver.SSHUser = "user"

Expand Down Expand Up @@ -325,6 +327,7 @@ func TestCheckConfigEmptySshHostPubKey(t *testing.T) {
OsImageName: "Ubuntu",
UserDataFile: "userData.json",
OsImageSshHostPubKey: "",
FirstLoginSshKey: "111-222-333",
}
driver.SSHUser = "user"

Expand Down Expand Up @@ -358,6 +361,7 @@ func TestCheckConfigInvalidSshHostPubKey(t *testing.T) {
OsImageName: "Ubuntu",
UserDataFile: "userData.json",
OsImageSshHostPubKey: "not-a-valid ssh-key",
FirstLoginSshKey: "111-222-333",
}
driver.SSHUser = "user"

Expand Down Expand Up @@ -393,6 +397,7 @@ func TestCheckConfig_SlesParamsFail(t *testing.T) {
UserDataFile: "userData.json",
OsImageSshHostPubKey: hostPublicKey,
SlesRegistrationCode: "123",
FirstLoginSshKey: "111-222-333",
}
driver.SSHUser = "user"

Expand Down Expand Up @@ -460,6 +465,7 @@ func TestCheckConfigTenantFailed(t *testing.T) {
TenantUuid: "cdi-test",
OsImageName: "Ubuntu",
UserDataFile: "userData.json",
FirstLoginSshKey: "111-222-333",
}
driver.SSHUser = "user"

Expand Down
Loading