Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-15271: Append kargs to installer for s390x #5665

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions internal/host/hostcommands/install_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ import (
"gorm.io/gorm"
)

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"
)

type installCmd struct {
baseCmd
db *gorm.DB
Expand Down Expand Up @@ -298,6 +310,31 @@ func constructHostInstallerArgs(cluster *common.Cluster, host *models.Host, inve
installerArgs = append(installerArgs, "--copy-network")
}

// 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) {
// 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
// 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.dasd=0.0.5235 rd.dasd=0.0.5236 random.trust_cpu=on rd.luks.options=discard ignition.firstboot ignition.platform.id=metal console=tty1 console=ttyS1,115200n8
// For nmstate and FCP device the parmline might look like:
// 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"
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) ||
strings.HasPrefix(strings.ToLower(part), ZVM_FCP) {
installerArgs = append(installerArgs, "--append-karg", part)
}
}
}

return toJSONString(installerArgs)
}

Expand Down
94 changes: 94 additions & 0 deletions internal/host/hostcommands/install_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,100 @@ 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() {
host.Inventory = `{
"interfaces":[
{
"name": "eth0",
"ipv4_addresses":["192.186.10.12/24"]
}
]
}`
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.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.dasd=0.0.5235 rd.dasd=0.0.5236 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.dasd=0.0.5235","--append-karg","rd.dasd=0.0.5236"]`))
})
It("s390x and z/VM - static ip w/o nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
"name": "eth0",
"ipv4_addresses":["192.186.10.12/24"]
}
]
}`
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.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"]`))
})
It("s390x and LPAR - static ip w/o nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
"name": "eth0",
"ipv4_addresses":["192.186.10.12/24"]
}
]
}`
cluster.MachineNetworks = []*models.MachineNetwork{{Cidr: "2001:db8::/120"}}
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"}

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"]`))
})
It("s390x and LPAR - static ip w/ nmstate, fcp", func() {
host.Inventory = `{
"interfaces":[
{
"name": "eth0",
"ipv4_addresses":["192.186.10.12/24"]
}
]
}`
cluster.MachineNetworks = []*models.MachineNetwork{{Cidr: "2001:db8::/120"}}
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 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","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 KVM - DHCP", func() {
host.Inventory = `{
"interfaces":[
{
"name": "eth0",
"ipv4_addresses":["192.186.10.12/24"]
}
]
}`
cluster.MachineNetworks = []*models.MachineNetwork{{Cidr: "2001:db8::/120"}}
inventory, _ := common.UnmarshalInventory(host.Inventory)
inventory.SystemVendor = &models.SystemVendor{Manufacturer: "IBM/S390"}
inventory.SystemVendor.ProductName = "KVM/Linux"
inventory.Boot = &models.Boot{CommandLine: "coreos.liveiso=rhcos-413.92.202307260246-0 ignition.firstboot ignition.platform.id=metal"}

args, err := constructHostInstallerArgs(cluster, host, inventory, infraEnv, log)
Expect(err).NotTo(HaveOccurred())
Expect(args).To(Equal(""))
})
})

func getBootableDiskNames(disks []*models.Disk) []string {
Expand Down