mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
Allow creating VMs with implicit CPU and memory (#243)
* Allow creating VMs with implicit CPU and memory * Clarify why cpu/memory can be 0 a bit better * Controller(API): don't forget to update DefaultCPU and DefaultMemory * Add an integration test for implicit CPU and memory
This commit is contained in:
@@ -65,8 +65,21 @@ func runGetVM(cmd *cobra.Command, args []string) error {
|
||||
table.AddRow("Created", createdAtInfo)
|
||||
table.AddRow("Image", vm.Image)
|
||||
table.AddRow("Image pull policy", vm.ImagePullPolicy)
|
||||
table.AddRow("CPU", vm.CPU)
|
||||
table.AddRow("Memory", vm.Memory)
|
||||
|
||||
cpu := vm.CPU
|
||||
if cpu == 0 {
|
||||
// Implicit CPU assignment, CPU will always be 0
|
||||
cpu = vm.AssignedCPU
|
||||
}
|
||||
table.AddRow("CPU", cpu)
|
||||
|
||||
memory := vm.Memory
|
||||
if memory == 0 {
|
||||
// Implicit memory assignment, memory will always be 0
|
||||
memory = vm.AssignedMemory
|
||||
}
|
||||
table.AddRow("Memory", memory)
|
||||
|
||||
table.AddRow("Softnet enabled", vm.NetSoftnet)
|
||||
table.AddRow("Bridged networking interface", nonEmptyOrNone(vm.NetBridged))
|
||||
table.AddRow("Headless mode", vm.Headless)
|
||||
|
||||
@@ -29,6 +29,8 @@ var bootstrapTokenStdin bool
|
||||
var logFilePath string
|
||||
var stringToStringResources map[string]string
|
||||
var noPKI bool
|
||||
var defaultCPU uint64
|
||||
var defaultMemory uint64
|
||||
var debug bool
|
||||
|
||||
func newRunCommand() *cobra.Command {
|
||||
@@ -53,6 +55,10 @@ func newRunCommand() *cobra.Command {
|
||||
"do not use the host's root CA set and instead validate the Controller's presented "+
|
||||
"certificate using a bootstrap token (or manually via fingerprint, "+
|
||||
"if no bootstrap token is provided)")
|
||||
cmd.PersistentFlags().Uint64Var(&defaultCPU, "default-cpu", 4, "number of CPUs to use for VMs "+
|
||||
"that do not explicitly specify a value")
|
||||
cmd.PersistentFlags().Uint64Var(&defaultMemory, "default-memory", 8*1024, "megabytes of memory "+
|
||||
"to use for VMs that do not explicitly specify a value")
|
||||
cmd.PersistentFlags().BoolVar(&debug, "debug", false, "enable debug logging")
|
||||
|
||||
return cmd
|
||||
@@ -116,6 +122,7 @@ func runWorker(cmd *cobra.Command, args []string) (err error) {
|
||||
controllerClient,
|
||||
worker.WithName(name),
|
||||
worker.WithResources(resources),
|
||||
worker.WithDefaultCPUAndMemory(defaultCPU, defaultMemory),
|
||||
worker.WithLogger(logger),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user