From 00f934af5002e451591d6aa608c9aa1905152144 Mon Sep 17 00:00:00 2001 From: Drew Walters Date: Thu, 30 Apr 2020 16:51:05 +0000 Subject: [PATCH] Fix unknown management type error When using "redfish-dell" as the management type, airshipctl throws an error due to a missing case statement. This change fixes the regression by re-adding "redfish-dell" as a remote type. Change-Id: I8314a1e356d1bb3bb1705762bbeda1adf1db41d2 Signed-off-by: Drew Walters --- pkg/remote/management.go | 17 +++++++++++++++++ pkg/remote/management_test.go | 18 ++++++++++++++++++ pkg/remote/remote_direct.go | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pkg/remote/management.go b/pkg/remote/management.go index c73bce754..577c6598a 100644 --- a/pkg/remote/management.go +++ b/pkg/remote/management.go @@ -21,7 +21,9 @@ import ( "opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/document" "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/pkg/log" "opendev.org/airship/airshipctl/pkg/remote/redfish" + redfishdell "opendev.org/airship/airshipctl/pkg/remote/redfish/vendors/dell" ) // Client is a set of functions that clients created for out-of-band power management and control should implement. The @@ -167,6 +169,7 @@ func newBaremetalHost(mgmtCfg config.ManagementConfiguration, // Select the client that corresponds to the management type specified in the airshipctl config. switch mgmtCfg.Type { case redfish.ClientType: + log.Debug("Remote type: Redfish") ctx, client, err := redfish.NewClient( address, mgmtCfg.Insecure, @@ -178,6 +181,20 @@ func newBaremetalHost(mgmtCfg config.ManagementConfiguration, return host, err } + host = baremetalHost{client, ctx, address, hostDoc.GetName(), username, password} + case redfishdell.ClientType: + log.Debug("Remote type: Redfish for Integrated Dell Remote Access Controller (iDrac) systems") + ctx, client, err := redfishdell.NewClient( + address, + mgmtCfg.Insecure, + mgmtCfg.UseProxy, + username, + password) + + if err != nil { + return host, err + } + host = baremetalHost{client, ctx, address, hostDoc.GetName(), username, password} default: return host, ErrUnknownManagementType{Type: mgmtCfg.Type} diff --git a/pkg/remote/management_test.go b/pkg/remote/management_test.go index 5f20d3c69..54bba9447 100644 --- a/pkg/remote/management_test.go +++ b/pkg/remote/management_test.go @@ -24,6 +24,8 @@ import ( "opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/document" "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/pkg/remote/redfish" + redfishdell "opendev.org/airship/airshipctl/pkg/remote/redfish/vendors/dell" "opendev.org/airship/airshipctl/testutil" ) @@ -107,6 +109,22 @@ func TestNewManagerByLabelNoHostsFound(t *testing.T) { assert.Error(t, err) } +func TestNewManagerRedfish(t *testing.T) { + cfg := &config.ManagementConfiguration{Type: redfish.ClientType} + settings := initSettings(t, withManagementConfig(cfg), withTestDataPath("base")) + + _, err := NewManager(settings, config.BootstrapPhase, ByLabel(document.EphemeralHostSelector)) + assert.NoError(t, err) +} + +func TestNewManagerRedfishDell(t *testing.T) { + cfg := &config.ManagementConfiguration{Type: redfishdell.ClientType} + settings := initSettings(t, withManagementConfig(cfg), withTestDataPath("base")) + + _, err := NewManager(settings, config.BootstrapPhase, ByLabel(document.EphemeralHostSelector)) + assert.NoError(t, err) +} + func TestNewManagerUnknownRemoteType(t *testing.T) { badCfg := &config.ManagementConfiguration{Type: "bad-remote-type"} settings := initSettings(t, withManagementConfig(badCfg), withTestDataPath("base")) diff --git a/pkg/remote/remote_direct.go b/pkg/remote/remote_direct.go index 77172a17d..699217d5e 100644 --- a/pkg/remote/remote_direct.go +++ b/pkg/remote/remote_direct.go @@ -33,7 +33,7 @@ func (b baremetalHost) DoRemoteDirect(settings *environment.AirshipCTLSettings) return config.ErrMissingConfig{What: "RemoteDirect options not defined in bootstrap config"} } - log.Debugf("Using ephemeral node %s with BMCAddress %s", b.NodeID(), b.BMCAddress) + log.Debugf("Using ephemeral node %s with BMC Address %s", b.NodeID(), b.BMCAddress) // Perform remote direct operations if remoteConfig.IsoURL == "" {