distro/rhel85: introduce the openstack image type

This commit is contained in:
Achilleas Koutsou 2021-07-07 19:29:36 +02:00 committed by Ondřej Budai
parent ceba83dcca
commit 876a67ccb0
3 changed files with 70 additions and 2 deletions

View file

@ -475,6 +475,20 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
exports: []string{"vmdk"},
}
openstackImgType := imageType{
name: "openstack",
filename: "disk.qcow2",
mimeType: "application/x-qemu-disk",
packageSets: map[string]rpmmd.PackageSet{
"packages": openstackCommonPackageSet(),
},
kernelOptions: "ro net.ifnames=0",
bootable: true,
defaultSize: 4 * GigaByte,
pipelines: openstackPipelines,
exports: []string{"qcow2"},
}
tarImgType := imageType{
name: "tar",
filename: "root.tar.xz",
@ -534,8 +548,8 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
exports: []string{"container"},
}
x86_64.addImageTypes(qcow2ImgType, vhdImgType, vmdkImgType, tarImgType, tarInstallerImgTypeX86_64, edgeCommitImgTypeX86_64, edgeInstallerImgTypeX86_64, edgeOCIImgTypeX86_64)
aarch64.addImageTypes(qcow2ImgType, tarImgType, edgeCommitImgTypeAarch64, edgeOCIImgTypeAarch64)
x86_64.addImageTypes(qcow2ImgType, vhdImgType, vmdkImgType, openstackImgType, tarImgType, tarInstallerImgTypeX86_64, edgeCommitImgTypeX86_64, edgeInstallerImgTypeX86_64, edgeOCIImgTypeX86_64)
aarch64.addImageTypes(qcow2ImgType, openstackImgType, tarImgType, edgeCommitImgTypeAarch64, edgeOCIImgTypeAarch64)
ppc64le.addImageTypes(qcow2ImgType, tarImgType)
s390x.addImageTypes(qcow2ImgType, tarImgType)

View file

@ -184,6 +184,23 @@ func vmdkCommonPackageSet() rpmmd.PackageSet {
}
func openstackCommonPackageSet() rpmmd.PackageSet {
return rpmmd.PackageSet{
Include: []string{
// Defaults
"@Core", "langpacks-en",
// From the lorax kickstart
"selinux-policy-targeted", "cloud-init", "qemu-guest-agent",
"spice-vdagent",
},
Exclude: []string{
"dracut-config-rescue", "rng-tools",
},
}
}
// edge commit OS package set
func edgeCommitCommonPackageSet() rpmmd.PackageSet {
return rpmmd.PackageSet{

View file

@ -135,6 +135,43 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio
return pipelines, nil
}
func openstackPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
pipelines := make([]osbuild.Pipeline, 0)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
if options.Subscription != nil {
commands := []string{
fmt.Sprintf("/usr/sbin/subscription-manager register --org=%d --activationkey=%s --serverurl %s --baseurl %s", options.Subscription.Organization, options.Subscription.ActivationKey, options.Subscription.ServerUrl, options.Subscription.BaseUrl),
}
if options.Subscription.Insights {
commands = append(commands, "/usr/bin/insights-client --register")
}
treePipeline.AddStage(osbuild.NewFirstBootStage(&osbuild.FirstBootStageOptions{
Commands: commands,
WaitForNetwork: true,
},
))
}
partitionTable := defaultPartitionTable(options, t.arch, rng)
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
treePipeline.AddStage(osbuild.NewGRUB2Stage(grub2StageOptions(&partitionTable, t.kernelOptions, customizations.GetKernel(), packageSetSpecs["packages"], t.arch.uefi, t.arch.legacy)))
pipelines = append(pipelines, *treePipeline)
diskfile := "disk.img"
imagePipeline := liveImagePipeline(treePipeline.Name, diskfile, &partitionTable, t.arch.legacy)
pipelines = append(pipelines, *imagePipeline)
if err != nil {
return nil, err
}
qemuPipeline := qemuPipeline(imagePipeline.Name, diskfile, t.filename, "qcow2", "")
pipelines = append(pipelines, *qemuPipeline)
return pipelines, nil
}
func tarPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
pipelines := make([]osbuild.Pipeline, 0)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))