Commit a8bbab1f authored by Sigmund Augdal's avatar Sigmund Augdal

Added method to facilitate updating of any type of object, not just virtual machines

parent 16a76549
...@@ -314,15 +314,18 @@ class VMMClient(Client): ...@@ -314,15 +314,18 @@ class VMMClient(Client):
def delete_vm(self, stampid, vmid): def delete_vm(self, stampid, vmid):
self.delete_from_collection("VirtualMachines", StampId=stampid, ID=vmid) self.delete_from_collection("VirtualMachines", StampId=stampid, ID=vmid)
def update_vm(self, stampid, vmid, **kw_args): def update_entry(self, collection, stampid, _id, **kw_args):
url = self._format_url("VirtualMachines", args={"StampId": stampid, "ID": vmid}) url = self._format_url(collection, args={"StampId": stampid, "ID": _id})
entry, vm = create_entry() entry, props = create_entry()
add_property(vm, "StampId", stampid) add_property(props, "StampId", stampid)
add_property(vm, "ID", vmid) add_property(props, "ID", _id)
for key, value in kw_args.items(): for key, value in kw_args.items():
add_property(vm, key, value) add_property(props, key, value)
self._do_request(url, method="PATCH", reqdata=etree.tostring(entry)) self._do_request(url, method="PATCH", reqdata=etree.tostring(entry))
def update_vm(self, stampid, vmid, **kw_args):
self.update_entry("VirtualMachines", stampid, vmid, **kw_args)
def vm_operation(self, stampid, vmid, operation): def vm_operation(self, stampid, vmid, operation):
url = self._format_url("VirtualMachines", args={"StampId": stampid, "ID": vmid}) url = self._format_url("VirtualMachines", args={"StampId": stampid, "ID": vmid})
entry, vm = create_entry() entry, vm = create_entry()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment