From 08c8bef8837ed78f4c54604788166786c73ca9ae Mon Sep 17 00:00:00 2001 From: Lukasz Piotrowski Date: Wed, 25 Mar 2026 21:41:54 +0900 Subject: [PATCH 1/3] add new field for driver LoginSshKey for passing private ssh key for first log in instead of password; --- ci_tools/fsas_nodedriver_template.yml | 4 +++- pkg/drivers/fsas/fsas.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ci_tools/fsas_nodedriver_template.yml b/ci_tools/fsas_nodedriver_template.yml index 33b4027..a53c13e 100644 --- a/ci_tools/fsas_nodedriver_template.yml +++ b/ci_tools/fsas_nodedriver_template.yml @@ -5,6 +5,7 @@ metadata: passwordFields: credentialsPassword,slesRegistrationCode privateCredentialFields: credentialsPassword,slesRegistrationCode publicCredentialFields: credentialsUsername,tenantUuid,apiUrl,ntpUrl,dnsIp,slesRegistrationEmail + nodedriver.cattle.io/file-to-field-aliases: "LoginSshKey:LoginSshKey" name: fsas spec: active: true @@ -12,7 +13,8 @@ spec: builtin: false checksum: description: '' - displayName: fsas + displayName: 'Fsas' externalId: '' uiUrl: '' url: + diff --git a/pkg/drivers/fsas/fsas.go b/pkg/drivers/fsas/fsas.go index ef13362..a0a1b38 100644 --- a/pkg/drivers/fsas/fsas.go +++ b/pkg/drivers/fsas/fsas.go @@ -69,6 +69,7 @@ type Driver struct { Keycloak keycloak.Keycloak `json:"-"` SshManager sshutils.SshManager `json:"-"` CfgManager cfgutils.CfgManager `json:"-"` + LoginSshKey string } // NewDriver creates and returns a new instance of the FSAS CDI driver @@ -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-login-ssh-key", + Usage: "First log in with SSH private key", + EnvVar: "FSAS_LOGIN_SSH_KEY", + }, } } @@ -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.LoginSshKey = strings.TrimSpace(flags.String("fsas-login-ssh-key")) + slog.Debug("Driver ", "FSAS Login SSH key", d.LoginSshKey) + return d.checkConfig() } @@ -520,6 +529,10 @@ func (d *Driver) checkConfig() error { return fmt.Errorf(errorMandatoryOption, "OS image name", "--fsas-os-image-name") } + if d.LoginSshKey == "" { + return fmt.Errorf(errorMandatoryOption, "Login SSH key", "--fsas-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 From cbf65f45e10bda7a19534e01bbcd0affc155ec64 Mon Sep 17 00:00:00 2001 From: Lukasz Piotrowski Date: Wed, 25 Mar 2026 21:54:03 +0900 Subject: [PATCH 2/3] rebase to dev and adjust unit tests; --- ci_tools/fsas_nodedriver_template.yml | 3 +-- pkg/drivers/fsas/fsas.go | 4 ++-- pkg/drivers/fsas/fsas_test.go | 6 ++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ci_tools/fsas_nodedriver_template.yml b/ci_tools/fsas_nodedriver_template.yml index a53c13e..6e9600c 100644 --- a/ci_tools/fsas_nodedriver_template.yml +++ b/ci_tools/fsas_nodedriver_template.yml @@ -5,7 +5,7 @@ metadata: passwordFields: credentialsPassword,slesRegistrationCode privateCredentialFields: credentialsPassword,slesRegistrationCode publicCredentialFields: credentialsUsername,tenantUuid,apiUrl,ntpUrl,dnsIp,slesRegistrationEmail - nodedriver.cattle.io/file-to-field-aliases: "LoginSshKey:LoginSshKey" + nodedriver.cattle.io/file-to-field-aliases: loginSshKey:loginSshKey name: fsas spec: active: true @@ -17,4 +17,3 @@ spec: externalId: '' uiUrl: '' url: - diff --git a/pkg/drivers/fsas/fsas.go b/pkg/drivers/fsas/fsas.go index a0a1b38..3117202 100644 --- a/pkg/drivers/fsas/fsas.go +++ b/pkg/drivers/fsas/fsas.go @@ -69,7 +69,7 @@ type Driver struct { Keycloak keycloak.Keycloak `json:"-"` SshManager sshutils.SshManager `json:"-"` CfgManager cfgutils.CfgManager `json:"-"` - LoginSshKey string + LoginSshKey string `json:"loginSshKey"` // Matches the name used in annotations } // NewDriver creates and returns a new instance of the FSAS CDI driver @@ -252,7 +252,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { }, mcnflag.StringFlag{ Name: "fsas-login-ssh-key", - Usage: "First log in with SSH private key", + Usage: "SSH private key for first log in", EnvVar: "FSAS_LOGIN_SSH_KEY", }, } diff --git a/pkg/drivers/fsas/fsas_test.go b/pkg/drivers/fsas/fsas_test.go index 587df4d..c1b0d8f 100644 --- a/pkg/drivers/fsas/fsas_test.go +++ b/pkg/drivers/fsas/fsas_test.go @@ -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-login-ssh-key": "111-222-333", }, } @@ -291,6 +292,7 @@ func TestCheckConfigTenantSuccess(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: hostPublicKey, + LoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -325,6 +327,7 @@ func TestCheckConfigEmptySshHostPubKey(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: "", + LoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -358,6 +361,7 @@ func TestCheckConfigInvalidSshHostPubKey(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: "not-a-valid ssh-key", + LoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -393,6 +397,7 @@ func TestCheckConfig_SlesParamsFail(t *testing.T) { UserDataFile: "userData.json", OsImageSshHostPubKey: hostPublicKey, SlesRegistrationCode: "123", + LoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -460,6 +465,7 @@ func TestCheckConfigTenantFailed(t *testing.T) { TenantUuid: "cdi-test", OsImageName: "Ubuntu", UserDataFile: "userData.json", + LoginSshKey: "111-222-333", } driver.SSHUser = "user" From 424cc95b5db3dd449df5c6c54078f2f051bff832 Mon Sep 17 00:00:00 2001 From: Lukasz Piotrowski Date: Mon, 30 Mar 2026 19:07:13 +0900 Subject: [PATCH 3/3] change field name according to suggestion; update unit tests; --- ci_tools/fsas_nodedriver_template.yml | 2 +- pkg/drivers/fsas/fsas.go | 14 +++++++------- pkg/drivers/fsas/fsas_test.go | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ci_tools/fsas_nodedriver_template.yml b/ci_tools/fsas_nodedriver_template.yml index 6e9600c..666eafa 100644 --- a/ci_tools/fsas_nodedriver_template.yml +++ b/ci_tools/fsas_nodedriver_template.yml @@ -5,7 +5,7 @@ metadata: passwordFields: credentialsPassword,slesRegistrationCode privateCredentialFields: credentialsPassword,slesRegistrationCode publicCredentialFields: credentialsUsername,tenantUuid,apiUrl,ntpUrl,dnsIp,slesRegistrationEmail - nodedriver.cattle.io/file-to-field-aliases: loginSshKey:loginSshKey + nodedriver.cattle.io/file-to-field-aliases: firstLoginSshKey:firstLoginSshKey name: fsas spec: active: true diff --git a/pkg/drivers/fsas/fsas.go b/pkg/drivers/fsas/fsas.go index 3117202..7b283c1 100644 --- a/pkg/drivers/fsas/fsas.go +++ b/pkg/drivers/fsas/fsas.go @@ -69,7 +69,7 @@ type Driver struct { Keycloak keycloak.Keycloak `json:"-"` SshManager sshutils.SshManager `json:"-"` CfgManager cfgutils.CfgManager `json:"-"` - LoginSshKey string `json:"loginSshKey"` // Matches the name used in annotations + FirstLoginSshKey string `json:"firstLoginSshKey"` // Matches the name used in annotations } // NewDriver creates and returns a new instance of the FSAS CDI driver @@ -251,9 +251,9 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag { EnvVar: "FSAS_USERDATA", }, mcnflag.StringFlag{ - Name: "fsas-login-ssh-key", + Name: "fsas-first-login-ssh-key", Usage: "SSH private key for first log in", - EnvVar: "FSAS_LOGIN_SSH_KEY", + EnvVar: "FSAS_FIRST_LOGIN_SSH_KEY", }, } } @@ -404,8 +404,8 @@ 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.LoginSshKey = strings.TrimSpace(flags.String("fsas-login-ssh-key")) - slog.Debug("Driver ", "FSAS Login SSH key", d.LoginSshKey) + d.FirstLoginSshKey = strings.TrimSpace(flags.String("fsas-first-login-ssh-key")) + slog.Debug("Driver ", "FSAS first login SSH key", d.FirstLoginSshKey) return d.checkConfig() } @@ -529,8 +529,8 @@ func (d *Driver) checkConfig() error { return fmt.Errorf(errorMandatoryOption, "OS image name", "--fsas-os-image-name") } - if d.LoginSshKey == "" { - return fmt.Errorf(errorMandatoryOption, "Login SSH key", "--fsas-login-ssh-key") + 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 { diff --git a/pkg/drivers/fsas/fsas_test.go b/pkg/drivers/fsas/fsas_test.go index c1b0d8f..773e9c9 100644 --- a/pkg/drivers/fsas/fsas_test.go +++ b/pkg/drivers/fsas/fsas_test.go @@ -107,7 +107,7 @@ func TestSetConfigFromFlagsTrimsWhitespace(t *testing.T) { "fsas-image-os-ssh-host-pub-key": " " + hostPublicKey + " ", "fsas-sles-registration-code": "", "fsas-sles-registration-email": "", - "fsas-login-ssh-key": "111-222-333", + "fsas-first-login-ssh-key": "111-222-333", }, } @@ -292,7 +292,7 @@ func TestCheckConfigTenantSuccess(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: hostPublicKey, - LoginSshKey: "111-222-333", + FirstLoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -327,7 +327,7 @@ func TestCheckConfigEmptySshHostPubKey(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: "", - LoginSshKey: "111-222-333", + FirstLoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -361,7 +361,7 @@ func TestCheckConfigInvalidSshHostPubKey(t *testing.T) { OsImageName: "Ubuntu", UserDataFile: "userData.json", OsImageSshHostPubKey: "not-a-valid ssh-key", - LoginSshKey: "111-222-333", + FirstLoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -397,7 +397,7 @@ func TestCheckConfig_SlesParamsFail(t *testing.T) { UserDataFile: "userData.json", OsImageSshHostPubKey: hostPublicKey, SlesRegistrationCode: "123", - LoginSshKey: "111-222-333", + FirstLoginSshKey: "111-222-333", } driver.SSHUser = "user" @@ -465,7 +465,7 @@ func TestCheckConfigTenantFailed(t *testing.T) { TenantUuid: "cdi-test", OsImageName: "Ubuntu", UserDataFile: "userData.json", - LoginSshKey: "111-222-333", + FirstLoginSshKey: "111-222-333", } driver.SSHUser = "user"