Skip to content
Open
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
13 changes: 10 additions & 3 deletions pkg/provisioner/ironic/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func (f *ironicProvisionerFactory) init(havePreprovImgBuilder bool) error {
"deployRamdiskURL", f.config.deployRamdiskURL,
"deployISOURL", f.config.deployISOURL,
"liveISOForcePersistentBootDevice", f.config.liveISOForcePersistentBootDevice,
"directDeployForcePersistentBootDevice", f.config.directDeployForcePersistentBootDevice,
"CACertFile", tlsConf.TrustedCAFile,
"ClientCertFile", tlsConf.ClientCertificateFile,
"ClientPrivKeyFile", tlsConf.ClientPrivateKeyFile,
Expand Down Expand Up @@ -197,11 +198,17 @@ func loadConfigFromEnv(havePreprovImgBuilder bool) (ironicConfig, error) {
c.maxBusyHosts = value
}

if forcePersistentBootDevice := os.Getenv("LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE"); forcePersistentBootDevice != "" {
if forcePersistentBootDevice != "Default" && forcePersistentBootDevice != "Always" && forcePersistentBootDevice != "Never" {
if liveISOForcePersistentBootDevice := os.Getenv("LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE"); liveISOForcePersistentBootDevice != "" {
if liveISOForcePersistentBootDevice != "Default" && liveISOForcePersistentBootDevice != "Always" && liveISOForcePersistentBootDevice != "Never" {
return c, errors.New("invalid value for variable LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE, must be one of Default, Always or Never")
}
c.liveISOForcePersistentBootDevice = forcePersistentBootDevice
c.liveISOForcePersistentBootDevice = liveISOForcePersistentBootDevice
}
if directDeployForcePersistentBootDevice := os.Getenv("DIRECT_DEPLOY_FORCE_PERSISTENT_BOOT_DEVICE"); directDeployForcePersistentBootDevice != "" {
if directDeployForcePersistentBootDevice != "Default" && directDeployForcePersistentBootDevice != "Always" && directDeployForcePersistentBootDevice != "Never" {
return c, errors.New("invalid value for variable DIRECT_DEPLOY_FORCE_PERSISTENT_BOOT_DEVICE, must be one of Default, Always or Never")
}
c.directDeployForcePersistentBootDevice = directDeployForcePersistentBootDevice
}

c.externalURL = os.Getenv("IRONIC_EXTERNAL_URL_V6")
Expand Down
68 changes: 54 additions & 14 deletions pkg/provisioner/ironic/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import (
)

type EnvFixture struct {
ironicEndpoint string
kernelURL string
ramdiskURL string
isoURL string
liveISOForcePersistentBootDevice string
ironicCACertFile string
ironicClientCertFile string
ironicClientPrivateKeyFile string
ironicInsecure string
ironicSkipClientSANVerify string
ironicEndpoint string
kernelURL string
ramdiskURL string
isoURL string
liveISOForcePersistentBootDevice string
directDeployForcePersistentBootDevice string
ironicCACertFile string
ironicClientCertFile string
ironicClientPrivateKeyFile string
ironicInsecure string
ironicSkipClientSANVerify string

origEnv map[string]string
}
Expand Down Expand Up @@ -50,6 +51,7 @@ func (f *EnvFixture) SetUp() {
f.replace("DEPLOY_RAMDISK_URL", f.ramdiskURL)
f.replace("DEPLOY_ISO_URL", f.isoURL)
f.replace("LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE", f.liveISOForcePersistentBootDevice)
f.replace("DIRECT_DEPLOY_FORCE_PERSISTENT_BOOT_DEVICE", f.directDeployForcePersistentBootDevice)
f.replace("IRONIC_CACERT_FILE", f.ironicCACertFile)
f.replace("IRONIC_CLIENT_CERT_FILE", f.ironicClientCertFile)
f.replace("IRONIC_CLIENT_PRIVATE_KEY_FILE", f.ironicClientPrivateKeyFile)
Expand All @@ -62,6 +64,7 @@ func (f EnvFixture) VerifyConfig(t *testing.T, c ironicConfig, _ string) {
assert.Equal(t, f.ramdiskURL, c.deployRamdiskURL)
assert.Equal(t, f.isoURL, c.deployISOURL)
assert.Equal(t, f.liveISOForcePersistentBootDevice, c.liveISOForcePersistentBootDevice)
assert.Equal(t, f.directDeployForcePersistentBootDevice, c.directDeployForcePersistentBootDevice)
}

func (f EnvFixture) VerifyEndpoints(t *testing.T, ironic string) {
Expand Down Expand Up @@ -131,38 +134,75 @@ func TestLoadConfigFromEnv(t *testing.T) {
expectedImgBuildError: "DEPLOY_RAMDISK_URL requires DEPLOY_KERNEL_URL to be set also",
},
{
name: "Force Persistent Default",
name: "ISO Force Persistent Default",
env: EnvFixture{
isoURL: "http://iso",
liveISOForcePersistentBootDevice: "Default",
},
forcePersistent: "Default",
},
{
name: "Force Persistent Never",
name: "ISO Force Persistent Never",
env: EnvFixture{
isoURL: "http://iso",
liveISOForcePersistentBootDevice: "Never",
},
forcePersistent: "Never",
},
{
name: "Force Persistent Always",
name: "ISO Force Persistent Always",
env: EnvFixture{
isoURL: "http://iso",
liveISOForcePersistentBootDevice: "Always",
},
forcePersistent: "Always",
},
{
name: "Force Persistent Invalid",
name: "ISO Force Persistent Invalid",
env: EnvFixture{
isoURL: "http://iso",
liveISOForcePersistentBootDevice: "NotAValidOption",
},
expectedError: "invalid value for variable LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE",
expectedImgBuildError: "invalid value for variable LIVE_ISO_FORCE_PERSISTENT_BOOT_DEVICE",
},
{
name: "kernel/ramdisk Force Persistent Default",
env: EnvFixture{
kernelURL: "http://kernel",
ramdiskURL: "http://ramdisk",
directDeployForcePersistentBootDevice: "Default",
},
forcePersistent: "Default",
},
{
name: "kernel/ramdisk Force Persistent Never",
env: EnvFixture{
kernelURL: "http://kernel",
ramdiskURL: "http://ramdisk",
directDeployForcePersistentBootDevice: "Never",
},
forcePersistent: "Never",
},
{
name: "kernel/ramdisk Force Persistent Always",
env: EnvFixture{
kernelURL: "http://kernel",
ramdiskURL: "http://ramdisk",
directDeployForcePersistentBootDevice: "Always",
},
forcePersistent: "Always",
},
{
name: "kernel/ramdisk Force Persistent Invalid",
env: EnvFixture{
kernelURL: "http://kernel",
ramdiskURL: "http://ramdisk",
directDeployForcePersistentBootDevice: "NotAValidOption",
},
expectedError: "invalid value for variable DIRECT_DEPLOY_FORCE_PERSISTENT_BOOT_DEVICE",
expectedImgBuildError: "invalid value for variable DIRECT_DEPLOY_FORCE_PERSISTENT_BOOT_DEVICE",
},
}

for _, tt := range []string{"", " (with img builder)"} {
Expand Down
22 changes: 14 additions & 8 deletions pkg/provisioner/ironic/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ func NewMacAddressConflictError(address, node string) error {
}

type ironicConfig struct {
havePreprovImgBuilder bool
deployKernelURL string
deployRamdiskURL string
deployISOURL string
liveISOForcePersistentBootDevice string
maxBusyHosts int
externalURL string
provNetDisabled bool
havePreprovImgBuilder bool
deployKernelURL string
deployRamdiskURL string
deployISOURL string
liveISOForcePersistentBootDevice string
directDeployForcePersistentBootDevice string
maxBusyHosts int
externalURL string
provNetDisabled bool
}

// Provisioner implements the provisioning.Provisioner interface
Expand Down Expand Up @@ -632,6 +633,11 @@ func (p *ironicProvisioner) setDirectDeployUpdateOptsForNode(ironicNode *nodes.N
driverOptValues := clients.UpdateOptsData{
"force_persistent_boot_device": "Default",
}
if p.config.directDeployForcePersistentBootDevice != "" {
driverOptValues = clients.UpdateOptsData{
"force_persistent_boot_device": p.config.directDeployForcePersistentBootDevice,
}
}
updater.SetDriverInfoOpts(driverOptValues, ironicNode)
}

Expand Down