github.com/openshift/installer@v1.4.17/pkg/asset/agent/image/kargs.go (about)

     1  package image
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/sirupsen/logrus"
     8  
     9  	hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
    10  	"github.com/openshift/assisted-service/models"
    11  	"github.com/openshift/installer/pkg/asset"
    12  	"github.com/openshift/installer/pkg/asset/agent/joiner"
    13  	"github.com/openshift/installer/pkg/asset/agent/manifests"
    14  	"github.com/openshift/installer/pkg/asset/agent/workflow"
    15  )
    16  
    17  // Kargs is an Asset that generates the additional kernel args.
    18  type Kargs struct {
    19  	consoleArgs string
    20  	fips        bool
    21  }
    22  
    23  // Dependencies returns the assets on which the Kargs asset depends.
    24  func (a *Kargs) Dependencies() []asset.Asset {
    25  	return []asset.Asset{
    26  		&workflow.AgentWorkflow{},
    27  		&joiner.ClusterInfo{},
    28  		&manifests.AgentClusterInstall{},
    29  	}
    30  }
    31  
    32  // Generate generates the kernel args configurations for the agent ISO image and PXE assets.
    33  func (a *Kargs) Generate(_ context.Context, dependencies asset.Parents) error {
    34  	agentWorkflow := &workflow.AgentWorkflow{}
    35  	clusterInfo := &joiner.ClusterInfo{}
    36  	agentClusterInstall := &manifests.AgentClusterInstall{}
    37  	dependencies.Get(agentClusterInstall, agentWorkflow, clusterInfo)
    38  
    39  	switch agentWorkflow.Workflow {
    40  	case workflow.AgentWorkflowTypeInstall:
    41  		a.fips = agentClusterInstall.FIPSEnabled()
    42  		// Add kernel args for external oci platform
    43  		if agentClusterInstall.GetExternalPlatformName() == string(models.PlatformTypeOci) {
    44  			logrus.Debugf("Added kernel args to enable serial console for %s %s platform", hiveext.ExternalPlatformType, string(models.PlatformTypeOci))
    45  			a.consoleArgs = " console=ttyS0"
    46  		}
    47  
    48  	case workflow.AgentWorkflowTypeAddNodes:
    49  		a.fips = clusterInfo.FIPS
    50  
    51  	default:
    52  		return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow)
    53  	}
    54  
    55  	return nil
    56  }
    57  
    58  // Name returns the human-friendly name of the asset.
    59  func (a *Kargs) Name() string {
    60  	return "Agent ISO/PXE files Kernel Arguments"
    61  }
    62  
    63  // KernelCmdLine returns the data to be appended to the kernel arguments.
    64  func (a *Kargs) KernelCmdLine() string {
    65  	cmdLine := a.consoleArgs
    66  	if a.fips {
    67  		cmdLine += " fips=1"
    68  	}
    69  	return cmdLine
    70  }