Skip to content

Commit

Permalink
MGMT-16371: Fix additionial kargs in case of DHCP (#5818)
Browse files Browse the repository at this point in the history
Signed-off-by: Amadeus Podvratnik <apodvrat@redhat.com>
Co-authored-by: Amadeus Podvratnik <apodvrat@redhat.com>
  • Loading branch information
AmadeusPodvratnik and apodvrat committed Jan 13, 2024
1 parent 7d2a358 commit 7476eeb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
28 changes: 16 additions & 12 deletions internal/host/hostcommands/install_cmd.go
Expand Up @@ -26,15 +26,13 @@ import (
)

const (
ZVM_VENDOR_ID = "IBM/S390"
VM_CTRL_PRG = "KVM/Linux"
ZVM_LUN_SCAN = "zfcp.allow_lun_scan"
ZVM_IP = "ip"
ZVM_NAMESERVER = "nameserver"
ZVM_ZNET = "rd.znet"
ZVM_DASD = "rd.dasd"
ZVM_NEEDNET = "rd.neednet"
ZVM_FCP = "rd.zfcp"
ZVM_VENDOR_ID = "IBM/S390"
VM_CTRL_PRG = "KVM/Linux"
ZVM_LUN_SCAN = "zfcp.allow_lun_scan"
ZVM_ZNET = "rd.znet"
ZVM_DASD = "rd.dasd"
ZVM_NEEDNET = "rd.neednet"
ZVM_FCP = "rd.zfcp"
)

type installCmd struct {
Expand Down Expand Up @@ -321,7 +319,14 @@ func constructHostInstallerArgs(cluster *common.Cluster, host *models.Host, inve

// Check if Manufacturer is IBM/S390 and ProductName is not "KVM/Linux" (the case for z/VM and LPAR).
// If this is the case than we need to extract the necessary z/VM kargs and append them.
if inventory.SystemVendor != nil && strings.EqualFold(inventory.SystemVendor.Manufacturer, ZVM_VENDOR_ID) && !strings.HasSuffix(inventory.SystemVendor.ProductName, VM_CTRL_PRG) {
if inventory.SystemVendor != nil {
log.Debugf("Check for SystemVendor and ProductName: %s:%s\n", inventory.SystemVendor.Manufacturer, inventory.SystemVendor.ProductName)
} else {
log.Debug("Check for SystemVendor and ProductName: <nil>:<nil>\n")
}

if inventory.SystemVendor != nil && strings.EqualFold(inventory.SystemVendor.Manufacturer, ZVM_VENDOR_ID) &&
!strings.HasSuffix(inventory.SystemVendor.ProductName, VM_CTRL_PRG) {
// Commandline for dasd and static IP w/o nmstate might look like:
// rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img
// ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none nameserver=10.14.6.1
Expand All @@ -331,10 +336,9 @@ func constructHostInstallerArgs(cluster *common.Cluster, host *models.Host, inve
// rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img zfcp.allow_lun_scan=0
// rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1 rd.zfcp=0.0.8004,0x500507630400d1e3,0x4000404800000000
// random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal coreos.inst.persistent-kargs="console=tty1 console=ttyS1,115200n8"
log.Debugf("Check current boot cmdline: %s\n", strings.TrimSpace(inventory.Boot.CommandLine))
for _, part := range strings.Split(strings.TrimSpace(inventory.Boot.CommandLine), " ") {
if strings.HasPrefix(strings.ToLower(part), ZVM_NEEDNET) ||
strings.HasPrefix(strings.ToLower(part), ZVM_IP) ||
strings.HasPrefix(strings.ToLower(part), ZVM_NAMESERVER) ||
strings.HasPrefix(strings.ToLower(part), ZVM_LUN_SCAN) ||
strings.HasPrefix(strings.ToLower(part), ZVM_ZNET) ||
strings.HasPrefix(strings.ToLower(part), ZVM_DASD) ||
Expand Down
21 changes: 11 additions & 10 deletions internal/host/hostcommands/install_cmd_test.go
Expand Up @@ -1144,7 +1144,7 @@ var _ = Describe("construct host install arguments", func() {
_, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expect(err).To(HaveOccurred())
})
It("s390x and z/VM - static ip w/o nmstate, multi dasds", func() {
It("s390x and z/VM - DHCP, multi dasds", func() {
host.Inventory = `{
"interfaces":[
{
Expand All @@ -1161,9 +1161,9 @@ var _ = Describe("construct host install arguments", func() {

args, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none","--append-karg","nameserver=10.14.6.1","--append-karg","ip=[fd00::3]::[fd00::1]:64::encbdd0:none","--append-karg","nameserver=[fd00::1]","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.dasd=0.0.5235","--append-karg","rd.dasd=0.0.5236"]`))
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.dasd=0.0.5235","--append-karg","rd.dasd=0.0.5236"]`))
})
It("s390x and z/VM - static ip w/o nmstate, fcp", func() {
It("s390x and LPAR - static ip w/o nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
Expand All @@ -1175,13 +1175,14 @@ var _ = Describe("construct host install arguments", func() {
cluster.MachineNetworks = []*models.MachineNetwork{{Cidr: "2001:db8::/120"}}
inventory, _ := common.UnmarshalInventory(host.Inventory)
inventory.SystemVendor = &models.SystemVendor{Manufacturer: "IBM/S390"}
inventory.SystemVendor.ProductName = "z/VM 7.2.0"
inventory.SystemVendor.ProductName = ""
inventory.Boot = &models.Boot{CommandLine: "rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none nameserver=10.14.6.1 ip=[fd00::3]::[fd00::1]:64::encbdd0:none nameserver=[fd00::1] zfcp.allow_lun_scan=0 rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1 rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000 random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal console=tty1 console=ttyS1,115200n8"}

args, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none","--append-karg","nameserver=10.14.6.1","--append-karg","ip=[fd00::3]::[fd00::1]:64::encbdd0:none","--append-karg","nameserver=[fd00::1]","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000"]`))
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000"]`))
})
It("s390x and LPAR - static ip w/o nmstate, fcp", func() {
It("s390x and LPAR - static ip w/ nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
Expand All @@ -1194,13 +1195,13 @@ var _ = Describe("construct host install arguments", func() {
inventory, _ := common.UnmarshalInventory(host.Inventory)
inventory.SystemVendor = &models.SystemVendor{Manufacturer: "IBM/S390"}
inventory.SystemVendor.ProductName = ""
inventory.Boot = &models.Boot{CommandLine: "rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none nameserver=10.14.6.1 ip=[fd00::3]::[fd00::1]:64::encbdd0:none nameserver=[fd00::1] zfcp.allow_lun_scan=0 rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1 rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000 random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal console=tty1 console=ttyS1,115200n8"}
inventory.Boot = &models.Boot{CommandLine: "rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img zfcp.allow_lun_scan=0 rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1 rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000 random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal console=tty1 console=ttyS1,115200n8"}

args, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","ip=10.14.6.3::10.14.6.1:255.255.255.0:master-0.boea3e06.lnxero1.boe:encbdd0:none","--append-karg","nameserver=10.14.6.1","--append-karg","ip=[fd00::3]::[fd00::1]:64::encbdd0:none","--append-karg","nameserver=[fd00::1]","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000"]`))
Expect(args).To(Equal(`["--append-karg","rd.neednet=1","--append-karg","zfcp.allow_lun_scan=0","--append-karg","rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1","--append-karg","rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000"]`))
})
It("s390x and LPAR - static ip w/ nmstate, fcp", func() {
It("s390x and zVM - static ip w/ nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
Expand All @@ -1212,7 +1213,7 @@ var _ = Describe("construct host install arguments", func() {
cluster.MachineNetworks = []*models.MachineNetwork{{Cidr: "2001:db8::/120"}}
inventory, _ := common.UnmarshalInventory(host.Inventory)
inventory.SystemVendor = &models.SystemVendor{Manufacturer: "IBM/S390"}
inventory.SystemVendor.ProductName = ""
inventory.SystemVendor.ProductName = "z/VM 7.2.0"
inventory.Boot = &models.Boot{CommandLine: "rd.neednet=1 console=ttysclp0 coreos.live.rootfs_url=http://172.23.236.156:8080/assisted-installer/rootfs.img zfcp.allow_lun_scan=0 rd.znet=qeth,0.0.bdd0,0.0.bdd1,0.0.bdd2,layer2=1 rd.zfcp=0.0.8002,0x500507630400d1e3,0x4000404600000000 random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal console=tty1 console=ttyS1,115200n8"}

args, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expand Down

0 comments on commit 7476eeb

Please sign in to comment.