Make remote parameters configurable

Remove constants and define these parameteres
in config file for remote configuration.

Closes: #138

Change-Id: Ib9250b8d39c01ef43a1262b62e4d37215481bc43
This commit is contained in:
Vladislav Kuzmin 2020-05-06 18:42:34 +04:00
parent 90f80d55b9
commit 9c1724f6d8
11 changed files with 136 additions and 96 deletions

View File

@ -55,3 +55,9 @@ const (
AirshipDefaultIsoURL = "http://localhost:8099/debian-custom.iso"
AirshipDefaultRemoteType = redfish.ClientType
)
// Default values for remote operations
const (
DefaultSystemActionRetries = 30
DefaultSystemRebootDelay = 2
)

View File

@ -79,4 +79,8 @@ type ManagementConfiguration struct {
// UseProxy indicates whether airshipctl should transmit remote management requests through a proxy server when
// one is configured in an environment.
UseProxy bool `json:"useproxy,omitempty"`
// Number of attempts to reach host during reboot process and ejecting virtual media
SystemActionRetries int `json:"systemActionRetries,omitempty"`
// Number of seconds to wait after reboot if host isn't available
SystemRebootDelay int `json:"systemRebootDelay,omitempty"`
}

View File

@ -56,9 +56,11 @@ func NewConfig() *Config {
},
ManagementConfiguration: map[string]*ManagementConfiguration{
AirshipDefaultContext: {
Type: redfish.ClientType,
Insecure: true,
UseProxy: false,
Type: redfish.ClientType,
Insecure: true,
UseProxy: false,
SystemActionRetries: DefaultSystemActionRetries,
SystemRebootDelay: DefaultSystemRebootDelay,
},
},
Manifests: map[string]*Manifest{

View File

@ -178,7 +178,9 @@ func newBaremetalHost(mgmtCfg config.ManagementConfiguration,
mgmtCfg.Insecure,
mgmtCfg.UseProxy,
username,
password)
password,
mgmtCfg.SystemActionRetries,
mgmtCfg.SystemRebootDelay)
if err != nil {
return host, err
@ -192,7 +194,9 @@ func newBaremetalHost(mgmtCfg config.ManagementConfiguration,
mgmtCfg.Insecure,
mgmtCfg.UseProxy,
username,
password)
password,
mgmtCfg.SystemActionRetries,
mgmtCfg.SystemRebootDelay)
if err != nil {
return host, err

View File

@ -27,23 +27,18 @@ import (
"opendev.org/airship/airshipctl/pkg/remote/power"
)
// contextKey is used by the redfish package as a unique key type in order to prevent collisions
// with context keys in other packages.
type contextKey string
const (
// ClientType is used by other packages as the identifier of the Redfish client.
ClientType string = "redfish"
systemActionRetries = 30
systemRebootDelay = 30 * time.Second
ctxKeyNumRetries contextKey = "numRetries"
ClientType string = "redfish"
)
// Client holds details about a Redfish out-of-band system required for out-of-band management.
type Client struct {
nodeID string
RedfishAPI redfishAPI.RedfishAPI
RedfishCFG *redfishClient.Configuration
nodeID string
RedfishAPI redfishAPI.RedfishAPI
RedfishCFG *redfishClient.Configuration
systemActionRetries int
systemRebootDelay int
// Sleep is meant to be mocked out for tests
Sleep func(d time.Duration)
@ -54,16 +49,20 @@ func (c *Client) NodeID() string {
return c.nodeID
}
// SystemActionRetries returns number of attempts to reach host during reboot process and ejecting virtual media
func (c *Client) SystemActionRetries() int {
return c.systemActionRetries
}
// SystemRebootDelay returns number of seconds to wait after reboot if host isn't available
func (c *Client) SystemRebootDelay() int {
return c.systemRebootDelay
}
// EjectVirtualMedia ejects a virtual media device attached to a host.
func (c *Client) EjectVirtualMedia(ctx context.Context) error {
waitForEjectMedia := func(managerID string, mediaID string) error {
// Check if number of retries is defined in context
totalRetries, ok := ctx.Value(ctxKeyNumRetries).(int)
if !ok {
totalRetries = systemActionRetries
}
for retry := 0; retry < totalRetries; retry++ {
for retry := 0; retry < c.systemActionRetries; retry++ {
vMediaMgr, httpResp, err := c.RedfishAPI.GetManagerVirtualMedia(ctx, managerID, mediaID)
if err = ScreenRedfishError(httpResp, err); err != nil {
return err
@ -75,7 +74,7 @@ func (c *Client) EjectVirtualMedia(ctx context.Context) error {
}
}
return ErrOperationRetriesExceeded{What: fmt.Sprintf("eject media %s", mediaID), Retries: totalRetries}
return ErrOperationRetriesExceeded{What: fmt.Sprintf("eject media %s", mediaID), Retries: c.systemActionRetries}
}
managerID, err := getManagerID(ctx, c.RedfishAPI, c.nodeID)
@ -268,7 +267,9 @@ func NewClient(redfishURL string,
insecure bool,
useProxy bool,
username string,
password string) (context.Context, *Client, error) {
password string,
systemActionRetries int,
systemRebootDelay int) (context.Context, *Client, error) {
var ctx context.Context
if username != "" && password != "" {
ctx = context.WithValue(
@ -323,9 +324,12 @@ func NewClient(redfishURL string,
}
c := &Client{
nodeID: systemID,
RedfishAPI: redfishClient.NewAPIClient(cfg).DefaultApi,
RedfishCFG: cfg,
nodeID: systemID,
RedfishAPI: redfishClient.NewAPIClient(cfg).DefaultApi,
RedfishCFG: cfg,
systemActionRetries: systemActionRetries,
systemRebootDelay: systemRebootDelay,
Sleep: func(d time.Duration) {
time.Sleep(d)
},

View File

@ -32,20 +32,31 @@ import (
)
const (
nodeID = "System.Embedded.1"
isoPath = "https://localhost:8080/debian.iso"
redfishURL = "redfish+https://localhost:2224/Systems/System.Embedded.1"
nodeID = "System.Embedded.1"
isoPath = "https://localhost:8080/debian.iso"
redfishURL = "redfish+https://localhost:2224/Systems/System.Embedded.1"
systemActionRetries = 1
systemRebootDelay = 0
)
func TestNewClient(t *testing.T) {
_, _, err := NewClient(redfishURL, false, false, "", "")
_, _, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
}
func TestNewClientDefaultValues(t *testing.T) {
sysActRetr := 111
sysRebDel := 999
_, c, err := NewClient(redfishURL, false, false, "", "", sysActRetr, sysRebDel)
assert.Equal(t, c.systemActionRetries, sysActRetr)
assert.Equal(t, c.systemRebootDelay, sysRebDel)
assert.NoError(t, err)
}
func TestNewClientMissingSystemID(t *testing.T) {
badURL := "redfish+https://localhost:2224"
_, _, err := NewClient(badURL, false, false, "", "")
_, _, err := NewClient(badURL, false, false, "", "", systemActionRetries, systemRebootDelay)
_, ok := err.(ErrRedfishMissingConfig)
assert.True(t, ok)
}
@ -53,12 +64,12 @@ func TestNewClientMissingSystemID(t *testing.T) {
func TestNewClientNoRedfishMarking(t *testing.T) {
url := "https://localhost:2224/Systems/System.Embedded.1"
_, _, err := NewClient(url, false, false, "", "")
_, _, err := NewClient(url, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
}
func TestNewClientAuth(t *testing.T) {
ctx, _, err := NewClient(redfishURL, false, false, "username", "password")
ctx, _, err := NewClient(redfishURL, false, false, "username", "password", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
cAuth := ctx.Value(redfishClient.ContextBasicAuth)
@ -68,21 +79,19 @@ func TestNewClientAuth(t *testing.T) {
func TestNewClientEmptyRedfishURL(t *testing.T) {
// Redfish URL cannot be empty when creating a client.
_, _, err := NewClient("", false, false, "", "")
_, _, err := NewClient("", false, false, "", "", systemActionRetries, systemRebootDelay)
assert.Error(t, err)
}
func TestEjectVirtualMedia(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries+1, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
// Normal retries are 30. Limit them here for test time.
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 2)
ctx := context.Background()
// Mark CD and DVD test media as inserted
inserted := true
@ -127,16 +136,17 @@ func TestEjectVirtualMedia(t *testing.T) {
err = client.EjectVirtualMedia(ctx)
assert.NoError(t, err)
}
func TestEjectVirtualMediaRetriesExceeded(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
// Mark test media as inserted
inserted := true
@ -171,7 +181,7 @@ func TestRebootSystem(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -205,7 +215,7 @@ func TestRebootSystemShutdownError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -231,7 +241,7 @@ func TestRebootSystemStartupError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -268,12 +278,12 @@ func TestRebootSystemTimeout(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
@ -297,7 +307,7 @@ func TestSetBootSourceByTypeGetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -319,7 +329,7 @@ func TestSetBootSourceByTypeSetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -346,7 +356,7 @@ func TestSetBootSourceByTypeBootSourceUnavailable(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -378,13 +388,12 @@ func TestSetVirtualMediaEjectExistingMedia(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
// Normal retries are 30. Limit them here for test time.
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
// Mark test media as inserted
inserted := true
@ -425,13 +434,12 @@ func TestSetVirtualMediaEjectExistingMediaFailure(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
// Normal retries are 30. Limit them here for test time.
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
// Mark test media as inserted
inserted := true
@ -463,7 +471,7 @@ func TestSetVirtualMediaGetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -485,7 +493,7 @@ func TestSetVirtualMediaInsertVirtualMediaError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
client.nodeID = nodeID
@ -519,12 +527,12 @@ func TestSystemPowerOff(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return(
redfishClient.RedfishError{},
@ -552,12 +560,12 @@ func TestSystemPowerOffResetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return(
redfishClient.RedfishError{},
@ -577,12 +585,12 @@ func TestSystemPowerOn(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return(
redfishClient.RedfishError{},
@ -610,12 +618,12 @@ func TestSystemPowerOnResetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return(
redfishClient.RedfishError{},
@ -635,7 +643,7 @@ func TestSystemPowerStatusUnknown(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -658,7 +666,7 @@ func TestSystemPowerStatusOn(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -680,7 +688,7 @@ func TestSystemPowerStatusOff(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -702,7 +710,7 @@ func TestSystemPowerStatusPoweringOn(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -724,7 +732,7 @@ func TestSystemPowerStatusPoweringOff(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -746,7 +754,7 @@ func TestSystemPowerStatusGetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
require.NoError(t, err)
client.nodeID = nodeID
@ -766,10 +774,10 @@ func TestWaitForPowerStateGetSystemFailed(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
@ -790,10 +798,10 @@ func TestWaitForPowerStateNoRetries(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
@ -816,10 +824,10 @@ func TestWaitForPowerStateWithRetries(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
@ -847,10 +855,10 @@ func TestWaitForPowerStateRetriesExceeded(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
@ -878,10 +886,10 @@ func TestWaitForPowerStateDifferentPowerState(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
_, client, err := NewClient(redfishURL, false, false, "", "")
_, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
ctx := context.WithValue(context.Background(), ctxKeyNumRetries, 1)
ctx := context.Background()
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_ON

View File

@ -19,6 +19,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
redfishAPI "opendev.org/airship/go-redfish/api"
redfishClient "opendev.org/airship/go-redfish/client"
@ -255,13 +256,7 @@ func getBasePath(redfishURL string) (string, error) {
func (c Client) waitForPowerState(ctx context.Context, desiredState redfishClient.PowerState) error {
log.Debugf("Waiting for node '%s' to reach power state '%s'.", c.nodeID, desiredState)
// Check if number of retries is defined in context
totalRetries, ok := ctx.Value(ctxKeyNumRetries).(int)
if !ok {
totalRetries = systemActionRetries
}
for retry := 0; retry <= totalRetries; retry++ {
for retry := 0; retry <= c.systemActionRetries; retry++ {
system, httpResp, err := c.RedfishAPI.GetSystem(ctx, c.NodeID())
if err = ScreenRedfishError(httpResp, err); err != nil {
return err
@ -272,11 +267,11 @@ func (c Client) waitForPowerState(ctx context.Context, desiredState redfishClien
return nil
}
c.Sleep(systemRebootDelay)
c.Sleep(time.Duration(c.systemRebootDelay))
}
return ErrOperationRetriesExceeded{
What: fmt.Sprintf("reach desired power state %s", desiredState),
Retries: totalRetries,
Retries: c.systemActionRetries,
}
}

View File

@ -128,8 +128,11 @@ func NewClient(redfishURL string,
insecure bool,
useProxy bool,
username string,
password string) (context.Context, *Client, error) {
ctx, genericClient, err := redfish.NewClient(redfishURL, insecure, useProxy, username, password)
password string,
systemActionRetries int,
systemRebootDelay int) (context.Context, *Client, error) {
ctx, genericClient, err := redfish.NewClient(redfishURL, insecure, useProxy, username, password,
systemActionRetries, systemRebootDelay)
if err != nil {
return ctx, nil, err
}

View File

@ -25,19 +25,29 @@ import (
)
const (
redfishURL = "redfish+https://localhost/Systems/System.Embedded.1"
redfishURL = "redfish+https://localhost/Systems/System.Embedded.1"
systemActionRetries = 0
systemRebootDelay = 0
)
func TestNewClient(t *testing.T) {
_, _, err := NewClient(redfishURL, false, false, "username", "password")
_, _, err := NewClient(redfishURL, false, false, "username", "password", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
}
func TestNewClientDefaultValues(t *testing.T) {
sysActRetr := 222
sysRebDel := 555
_, c, err := NewClient(redfishURL, false, false, "", "", sysActRetr, sysRebDel)
assert.Equal(t, c.SystemActionRetries(), sysActRetr)
assert.Equal(t, c.SystemRebootDelay(), sysRebDel)
assert.NoError(t, err)
}
func TestSetBootSourceByTypeGetSystemError(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
ctx, client, err := NewClient(redfishURL, false, false, "", "")
ctx, client, err := NewClient(redfishURL, false, false, "", "", systemActionRetries, systemRebootDelay)
assert.NoError(t, err)
// Mock redfish get system request

View File

@ -24,6 +24,8 @@ airship_site_name: manifests/site/test-site
remote_type: redfish
remote_insecure: true
remote_proxy: false
system_action_retries: 30
system_reboot_delay: 2
airship_config_ca_data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1USXlOakE0TWpneU5Gb1hEVEk1TVRJeU16QTRNamd5TkZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTTFSClM0d3lnajNpU0JBZjlCR0JUS1p5VTFwYmdDaGQ2WTdJektaZWRoakM2K3k1ZEJpWm81ZUx6Z2tEc2gzOC9YQ1MKenFPS2V5cE5RcDN5QVlLdmJKSHg3ODZxSFZZNjg1ZDVYVDNa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NnM3RklkdDVjOU5aWUFyeUZSYk1mYlY3UnQwbEppZllWb1V3Y3FYUzJkUG5jYzlNUW9qTEdUYXN1TlUKRy9EWmw5ZWtjV3hFSXlLWGNuY2QzZnhiK3p6OUJFbUxaRDduZjlacnhHU2IrZmhGeDdzWFJRRWc1YkQvdHdkbwpFWFcvbTU1YmJEZnhhNzFqZG5NaDJxdVEzRGlWT0ZFNGZMTERxcjlDRWlsaDMySFJNeHJJNGcwWTVRUFFaazMwCnFZTldmbktWUllOTHYrWC9DeGZ6ZkVacGpxRkVPRkVsQW9JQkFRQ0t6R2JGdmx6d1BaUmh4czd2VXYxOXlIUXAKQzFmR3gwb0tpRDFSNWZwWVBrT0VRQWVudEFKRHNyYVRsNy9rSDY5V09VbUQ1T3gxbWpyRFB0a1M4WnhXYlJXeApGYjJLK3JxYzRtcGFacGROV09OTkszK3RNZmsrb0FRcWUySU1JV253NUhmbVpjNE1QY0t0bkZQYlJTTkF0aktwCkQ2aG9oL3BXMmdjRFA0cVpNWVZvRW04MVZYZEZDUGhOYitNYnUvU3gyaFB4U0dXYTVGaTczeEtwWWp5M3BISlQKWFoyY2lHN0VNQ3NKZW9HS2FRdmNCY1kvNGlSRGFoV0hWcmlsSVhJQXJQdXdmVUIybzZCZFR0allHeU5sZ2NmeApxWEt4aXBTaEE2VlNienVnR3pkdEdNeEUyekRHVEkxOXFSQy96OUNEREM1ZTJTQUZqbEJUV0QyUHJjcU4KLS0tLS1FTkQgUlNBIFBSSVZBVEUgS0VZLS0tLS0K

View File

@ -19,6 +19,8 @@ managementConfiguration:
type: {{ remote_type }}
insecure: {{ remote_insecure }}
useproxy: {{ remote_proxy }}
systemActionRetries: {{ system_action_retries }}
systemRebootDelay: {{ system_reboot_delay }}
clusters:
dummycluster: