You are asked to implement a simple in-memory virtual machine (VM) manager that can:
Each VM has a set of attributes. For this exercise, you can assume at least the following attributes:
id
(string or integer,
must be unique
)
name
(string)
cpu_cores
(integer)
memory_gb
(integer)
status
(string, e.g.,
"running"
,
"stopped"
)
id
is treated as the unique identifier for each VM.
create_vm(vm)
id
).
list_vms()
update_vm(id, updated_fields)
id
of the VM to update, and a set/dictionary of fields to update.
id
.
delete_vm(id)
id
of the VM to delete.
id
from the manager.
create_vm
is called with an
id
that already exists, you must detect this and handle it as an error.
update_vm
or
delete_vm
is called with an
id
that does
not
exist, you must detect this and handle it as an error.
id
.
Explain your design choices (data structures and API shape) in brief comments or docstrings within your code.