Repository: metal3-io/baremetal-operator
Pull request #1041 (2021-11-24 09:34:46)

Support ilo4 virtual media
This hardware seems pretty popular still, no reason not to support it.



Patch:
diff --git a/docs/api.md b/docs/api.md
index b9634262..159ec6c3 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -50,6 +50,8 @@ communicate with them.
 * HPE iLO 4
   * `ilo4://<host>:<port>` for iLO 4 based systems and the port is optional,
     if using the default one (443).
+  * `ilo4-virtualmedia://<host>:<port>` to use virtual media instead of PXE
+    for iLO 4 based systems.
 * HPE iLO 5
   * `ilo5://<host>:<port>` for iLO 5 based systems and the port is optional,
     if using the default one (443).
diff --git a/pkg/ironic/bmc/ilo4.go b/pkg/ironic/bmc/ilo4.go
index 6dffa10f..bff98bc6 100644
--- a/pkg/ironic/bmc/ilo4.go
+++ b/pkg/ironic/bmc/ilo4.go
@@ -8,6 +8,7 @@ import (
 
 func init() {
 	RegisterFactory("ilo4", newILOAccessDetails, []string{"https"})
+	RegisterFactory("ilo4-virtualmedia", newILOVirtualMediaAccessDetails, []string{"https"})
 }
 
 func newILOAccessDetails(parsedURL *url.URL, disableCertificateVerification bool) (AccessDetails, error) {
@@ -19,11 +20,22 @@ func newILOAccessDetails(parsedURL *url.URL, disableCertificateVerification bool
 	}, nil
 }
 
+func newILOVirtualMediaAccessDetails(parsedURL *url.URL, disableCertificateVerification bool) (AccessDetails, error) {
+	return &iLOAccessDetails{
+		bmcType:                        parsedURL.Scheme,
+		portNum:                        parsedURL.Port(),
+		hostname:                       parsedURL.Hostname(),
+		disableCertificateVerification: disableCertificateVerification,
+		useVirtualMedia:                true,
+	}, nil
+}
+
 type iLOAccessDetails struct {
 	bmcType                        string
 	portNum                        string
 	hostname                       string
 	disableCertificateVerification bool
+	useVirtualMedia                bool
 }
 
 func (a *iLOAccessDetails) Type() string {
@@ -75,7 +87,11 @@ func (a *iLOAccessDetails) BIOSInterface() string {
 }
 
 func (a *iLOAccessDetails) BootInterface() string {
-	return "ilo-ipxe"
+	if a.useVirtualMedia {
+		return "ilo-virtual-media"
+	} else {
+		return "ilo-ipxe"
+	}
 }
 
 func (a *iLOAccessDetails) ManagementInterface() string {
@@ -99,11 +115,11 @@ func (a *iLOAccessDetails) SupportsSecureBoot() bool {
 }
 
 func (a *iLOAccessDetails) SupportsISOPreprovisioningImage() bool {
-	return false
+	return a.useVirtualMedia
 }
 
 func (a *iLOAccessDetails) RequiresProvisioningNetwork() bool {
-	return true
+	return !a.useVirtualMedia
 }
 
 func (a *iLOAccessDetails) BuildBIOSSettings(firmwareConfig *FirmwareConfig) (settings []map[string]string, err error) {


Test patch:
diff --git a/pkg/ironic/bmc/access_test.go b/pkg/ironic/bmc/access_test.go
index cc67f4f7..612d5f46 100644
--- a/pkg/ironic/bmc/access_test.go
+++ b/pkg/ironic/bmc/access_test.go
@@ -636,6 +636,18 @@ func TestStaticDriverInfo(t *testing.T) {
 			raid:       "no-raid",
 		},
 
+		{
+			Scenario:   "ilo4 virtual media",
+			input:      "ilo4-virtualmedia://192.168.122.1",
+			needsMac:   true,
+			driver:     "ilo",
+			bios:       "",
+			boot:       "ilo-virtual-media",
+			management: "",
+			power:      "",
+			raid:       "no-raid",
+		},
+
 		{
 			Scenario:   "ilo5",
 			input:      "ilo5://192.168.122.1",
@@ -1071,6 +1083,17 @@ func TestDriverInfo(t *testing.T) {
 			},
 		},
 
+		{
+			Scenario: "ilo4 virtual media",
+			input:    "ilo4-virtualmedia://192.168.122.1",
+			expects: map[string]interface{}{
+				"ilo_address":   "192.168.122.1",
+				"ilo_password":  "",
+				"ilo_username":  "",
+				"ilo_verify_ca": false,
+			},
+		},
+
 		{
 			Scenario: "ilo5",
 			input:    "ilo5://192.168.122.1",