distro: add custom image size
When creating a pipeline the assembler includes an image size. This image size can be set when creating the pipeline but if it is 0 then a default image size will be used. The default is 2 GB except for ami images which are 6 GB.
This commit is contained in:
parent
481c1dd048
commit
a86e697171
27 changed files with 113 additions and 62 deletions
|
|
@ -34,7 +34,7 @@ type Distro interface {
|
|||
// Returns an osbuild pipeline that generates an image in the given
|
||||
// output format with all packages and customizations specified in the
|
||||
// given blueprint.
|
||||
Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error)
|
||||
Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*pipeline.Pipeline, error)
|
||||
|
||||
// Returns a osbuild runner that can be used on this distro.
|
||||
Runner() string
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func TestDistro_Pipeline(t *testing.T) {
|
|||
t.Errorf("unknown distro: %v", tt.Compose.Distro)
|
||||
return
|
||||
}
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, nil, tt.Compose.Checksums, tt.Compose.Arch, tt.Compose.OutputFormat)
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, nil, tt.Compose.Checksums, tt.Compose.Arch, tt.Compose.OutputFormat, 0)
|
||||
if (err != nil) != (tt.Pipeline == nil) {
|
||||
t.Errorf("distro.Pipeline() error = %v", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -36,12 +36,15 @@ type output struct {
|
|||
DisabledServices []string
|
||||
KernelOptions string
|
||||
Bootable bool
|
||||
Assembler func(uefi bool) *pipeline.Assembler
|
||||
DefaultSize uint64
|
||||
Assembler func(uefi bool, size uint64) *pipeline.Assembler
|
||||
}
|
||||
|
||||
const Name = "fedora-30"
|
||||
|
||||
func New(confPaths []string) *Fedora30 {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
||||
r := Fedora30{
|
||||
arches: map[string]arch{},
|
||||
outputs: map[string]output{},
|
||||
|
|
@ -110,7 +113,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro no_timer_check console=ttyS0,115200n8 console=tty1 biosdevname=0 net.ifnames=0 console=ttyS0,115200",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("raw.xz", "image.raw.xz", uefi) },
|
||||
DefaultSize: 6 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("raw.xz", "image.raw.xz", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["ext4-filesystem"] = output{
|
||||
|
|
@ -129,7 +135,8 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: false,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.rawFSAssembler("filesystem.img") },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler { return r.rawFSAssembler("filesystem.img", size) },
|
||||
}
|
||||
|
||||
r.outputs["partitioned-disk"] = output{
|
||||
|
|
@ -148,7 +155,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("raw", "disk.img", uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("raw", "disk.img", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["qcow2"] = output{
|
||||
|
|
@ -172,7 +182,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("qcow2", "disk.qcow2", uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("qcow2", "disk.qcow2", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["openstack"] = output{
|
||||
|
|
@ -195,7 +208,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("qcow2", "disk.qcow2", uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("qcow2", "disk.qcow2", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["tar"] = output{
|
||||
|
|
@ -214,7 +230,8 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: false,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.tarAssembler("root.tar.xz", "xz") },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler { return r.tarAssembler("root.tar.xz", "xz") },
|
||||
}
|
||||
|
||||
r.outputs["vhd"] = output{
|
||||
|
|
@ -248,7 +265,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
// These kernel parameters are required by Azure documentation
|
||||
KernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("vpc", "disk.vhd", uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("vpc", "disk.vhd", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["vmdk"] = output{
|
||||
|
|
@ -268,7 +288,10 @@ func New(confPaths []string) *Fedora30 {
|
|||
},
|
||||
KernelOptions: "ro biosdevname=0 net.ifnames=0",
|
||||
Bootable: true,
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("vmdk", "disk.vmdk", uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("vmdk", "disk.vmdk", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
return &r
|
||||
|
|
@ -298,7 +321,7 @@ func (r *Fedora30) FilenameFromType(outputFormat string) (string, string, error)
|
|||
return "", "", errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*pipeline.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -373,7 +396,11 @@ func (r *Fedora30) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.Repo
|
|||
}
|
||||
|
||||
p.AddStage(pipeline.NewSELinuxStage(r.selinuxStageOptions()))
|
||||
p.Assembler = output.Assembler(arch.UEFI)
|
||||
|
||||
if size == 0 {
|
||||
size = output.DefaultSize
|
||||
}
|
||||
p.Assembler = output.Assembler(arch.UEFI, size)
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
|
@ -552,14 +579,14 @@ func (r *Fedora30) selinuxStageOptions() *pipeline.SELinuxStageOptions {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Fedora30) qemuAssembler(format string, filename string, uefi bool) *pipeline.Assembler {
|
||||
func (r *Fedora30) qemuAssembler(format string, filename string, uefi bool, size uint64) *pipeline.Assembler {
|
||||
var options pipeline.QEMUAssemblerOptions
|
||||
if uefi {
|
||||
fstype := uuid.MustParse("C12A7328-F81F-11D2-BA4B-00A0C93EC93B")
|
||||
options = pipeline.QEMUAssemblerOptions{
|
||||
Format: format,
|
||||
Filename: filename,
|
||||
Size: 3222274048,
|
||||
Size: size,
|
||||
PTUUID: "8DFDFF87-C96E-EA48-A3A6-9408F1F6B1EF",
|
||||
PTType: "gpt",
|
||||
Partitions: []pipeline.QEMUPartition{
|
||||
|
|
@ -588,7 +615,7 @@ func (r *Fedora30) qemuAssembler(format string, filename string, uefi bool) *pip
|
|||
options = pipeline.QEMUAssemblerOptions{
|
||||
Format: format,
|
||||
Filename: filename,
|
||||
Size: 3222274048,
|
||||
Size: size,
|
||||
PTUUID: "0x14fc63d2",
|
||||
PTType: "mbr",
|
||||
Partitions: []pipeline.QEMUPartition{
|
||||
|
|
@ -615,7 +642,7 @@ func (r *Fedora30) tarAssembler(filename, compression string) *pipeline.Assemble
|
|||
})
|
||||
}
|
||||
|
||||
func (r *Fedora30) rawFSAssembler(filename string) *pipeline.Assembler {
|
||||
func (r *Fedora30) rawFSAssembler(filename string, size uint64) *pipeline.Assembler {
|
||||
id, err := uuid.Parse("76a22bf4-f153-4541-b6c7-0332c0dfaeac")
|
||||
if err != nil {
|
||||
panic("invalid UUID")
|
||||
|
|
@ -624,6 +651,6 @@ func (r *Fedora30) rawFSAssembler(filename string) *pipeline.Assembler {
|
|||
&pipeline.RawFSAssemblerOptions{
|
||||
Filename: filename,
|
||||
RootFilesystemUUDI: id,
|
||||
Size: 3222274048,
|
||||
Size: size,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ type output struct {
|
|||
Bootable bool
|
||||
DefaultTarget string
|
||||
KernelOptions string
|
||||
Assembler func(uefi bool) *pipeline.Assembler
|
||||
DefaultSize uint64
|
||||
Assembler func(uefi bool, size uint64) *pipeline.Assembler
|
||||
}
|
||||
|
||||
const Name = "rhel-8.2"
|
||||
|
|
@ -161,8 +162,9 @@ func New(confPaths []string) *RHEL82 {
|
|||
DefaultTarget: "multi-user.target",
|
||||
Bootable: true,
|
||||
KernelOptions: "ro console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler {
|
||||
return r.qemuAssembler("raw.xz", "image.raw.xz", 6*GigaByte, uefi)
|
||||
DefaultSize: 6 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("raw.xz", "image.raw.xz", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +189,8 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: false,
|
||||
KernelOptions: "ro net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.rawFSAssembler("filesystem.img") },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler { return r.rawFSAssembler("filesystem.img", size) },
|
||||
}
|
||||
|
||||
r.outputs["partitioned-disk"] = output{
|
||||
|
|
@ -211,7 +214,10 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: true,
|
||||
KernelOptions: "ro net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("raw", "disk.img", 3*GigaByte, uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("raw", "disk.img", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["qcow2"] = output{
|
||||
|
|
@ -292,7 +298,10 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: true,
|
||||
KernelOptions: "console=ttyS0 console=ttyS0,115200n8 no_timer_check crashkernel=auto net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("qcow2", "disk.qcow2", 3*GigaByte, uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("qcow2", "disk.qcow2", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["openstack"] = output{
|
||||
|
|
@ -319,7 +328,10 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: true,
|
||||
KernelOptions: "ro net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("qcow2", "disk.qcow2", 3*GigaByte, uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("qcow2", "disk.qcow2", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["tar"] = output{
|
||||
|
|
@ -343,7 +355,7 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: false,
|
||||
KernelOptions: "ro net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.tarAssembler("root.tar.xz", "xz") },
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler { return r.tarAssembler("root.tar.xz", "xz") },
|
||||
}
|
||||
|
||||
r.outputs["vhd"] = output{
|
||||
|
|
@ -383,7 +395,10 @@ func New(confPaths []string) *RHEL82 {
|
|||
DefaultTarget: "multi-user.target",
|
||||
Bootable: true,
|
||||
KernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("vpc", "disk.vhd", 3*GigaByte, uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("vpc", "disk.vhd", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
r.outputs["vmdk"] = output{
|
||||
|
|
@ -408,7 +423,10 @@ func New(confPaths []string) *RHEL82 {
|
|||
},
|
||||
Bootable: true,
|
||||
KernelOptions: "ro net.ifnames=0",
|
||||
Assembler: func(uefi bool) *pipeline.Assembler { return r.qemuAssembler("vmdk", "disk.vmdk", 3*GigaByte, uefi) },
|
||||
DefaultSize: 2 * GigaByte,
|
||||
Assembler: func(uefi bool, size uint64) *pipeline.Assembler {
|
||||
return r.qemuAssembler("vmdk", "disk.vmdk", uefi, size)
|
||||
},
|
||||
}
|
||||
|
||||
return &r
|
||||
|
|
@ -438,7 +456,7 @@ func (r *RHEL82) FilenameFromType(outputFormat string) (string, string, error) {
|
|||
return "", "", errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*pipeline.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
@ -518,7 +536,11 @@ func (r *RHEL82) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoCo
|
|||
}
|
||||
|
||||
p.AddStage(pipeline.NewSELinuxStage(r.selinuxStageOptions()))
|
||||
p.Assembler = output.Assembler(arch.UEFI)
|
||||
|
||||
if size == 0 {
|
||||
size = output.DefaultSize
|
||||
}
|
||||
p.Assembler = output.Assembler(arch.UEFI, size)
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
|
@ -696,7 +718,7 @@ func (r *RHEL82) selinuxStageOptions() *pipeline.SELinuxStageOptions {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *RHEL82) qemuAssembler(format string, filename string, size uint64, uefi bool) *pipeline.Assembler {
|
||||
func (r *RHEL82) qemuAssembler(format string, filename string, uefi bool, size uint64) *pipeline.Assembler {
|
||||
var options pipeline.QEMUAssemblerOptions
|
||||
if uefi {
|
||||
fstype := uuid.MustParse("C12A7328-F81F-11D2-BA4B-00A0C93EC93B")
|
||||
|
|
@ -759,7 +781,7 @@ func (r *RHEL82) tarAssembler(filename, compression string) *pipeline.Assembler
|
|||
})
|
||||
}
|
||||
|
||||
func (r *RHEL82) rawFSAssembler(filename string) *pipeline.Assembler {
|
||||
func (r *RHEL82) rawFSAssembler(filename string, size uint64) *pipeline.Assembler {
|
||||
id, err := uuid.Parse("0bd700f8-090f-4556-b797-b340297ea1bd")
|
||||
if err != nil {
|
||||
panic("invalid UUID")
|
||||
|
|
@ -768,7 +790,7 @@ func (r *RHEL82) rawFSAssembler(filename string) *pipeline.Assembler {
|
|||
&pipeline.RawFSAssemblerOptions{
|
||||
Filename: filename,
|
||||
RootFilesystemUUDI: id,
|
||||
Size: 3221225472,
|
||||
Size: size,
|
||||
FilesystemType: "xfs",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, erro
|
|||
}
|
||||
}
|
||||
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArch, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArch, outputFormat string, size uint64) (*pipeline.Pipeline, error) {
|
||||
if outputFormat == "test_output" && outputArch == "test_arch" {
|
||||
return &pipeline.Pipeline{}, nil
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package pipeline
|
|||
// compression type, and stores the output with the given filename.
|
||||
type TarAssemblerOptions struct {
|
||||
Filename string `json:"filename"`
|
||||
Size uint64 `json:"size"`
|
||||
Compression string `json:"compression,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -13,9 +14,10 @@ func (TarAssemblerOptions) isAssemblerOptions() {}
|
|||
|
||||
// NewTarAssemblerOptions creates a new TarAssemblerOptions object, with the
|
||||
// mandatory options set.
|
||||
func NewTarAssemblerOptions(filename string) *TarAssemblerOptions {
|
||||
func NewTarAssemblerOptions(filename string, size uint64) *TarAssemblerOptions {
|
||||
return &TarAssemblerOptions{
|
||||
Filename: filename,
|
||||
Size: size,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checks
|
|||
repos = append(repos, source.RepoConfig())
|
||||
}
|
||||
|
||||
pipeline, err := s.distro.Pipeline(bp, repos, checksums, arch, composeType)
|
||||
pipeline, err := s.distro.Pipeline(bp, repos, checksums, arch, composeType, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue