diff options
author | Ashley Cui <acui@redhat.com> | 2022-04-21 09:09:49 -0400 |
---|---|---|
committer | Ashley Cui <acui@redhat.com> | 2022-04-27 13:56:14 -0400 |
commit | e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d (patch) | |
tree | c0b962e598a1643f6f91cfd365c04cf0dc2a2d86 /pkg/machine/e2e/config_set.go | |
parent | 5ac00a7287e4a9e6292f4a6ca5dfa9a02e5ca907 (diff) | |
download | podman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.tar.gz podman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.tar.bz2 podman-e7390f30b95daf90c0f32e8cf963dce3f8d5cf9d.zip |
Allow changing of CPUs, Memory, and Disk Size
Allow podman machine set to change CPUs, Memory and Disk size of a QEMU machine after its been created.
Disk size can only be increased.
If one setting fails to be changed, the other settings will still be applied.
Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'pkg/machine/e2e/config_set.go')
-rw-r--r-- | pkg/machine/e2e/config_set.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/machine/e2e/config_set.go b/pkg/machine/e2e/config_set.go new file mode 100644 index 000000000..b310ab1b9 --- /dev/null +++ b/pkg/machine/e2e/config_set.go @@ -0,0 +1,43 @@ +package e2e + +import ( + "strconv" +) + +type setMachine struct { + cpus *uint + diskSize *uint + memory *uint + + cmd []string +} + +func (i *setMachine) buildCmd(m *machineTestBuilder) []string { + cmd := []string{"machine", "set"} + if i.cpus != nil { + cmd = append(cmd, "--cpus", strconv.Itoa(int(*i.cpus))) + } + if i.diskSize != nil { + cmd = append(cmd, "--disk-size", strconv.Itoa(int(*i.diskSize))) + } + if i.memory != nil { + cmd = append(cmd, "--memory", strconv.Itoa(int(*i.memory))) + } + cmd = append(cmd, m.name) + i.cmd = cmd + return cmd +} + +func (i *setMachine) withCPUs(num uint) *setMachine { + i.cpus = &num + return i +} +func (i *setMachine) withDiskSize(size uint) *setMachine { + i.diskSize = &size + return i +} + +func (i *setMachine) withMemory(num uint) *setMachine { + i.memory = &num + return i +} |