You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
930 B
29 lines
930 B
import logging |
|
|
|
from zhypervisor.clients.qmachine import QMachine |
|
|
|
|
|
class MachineSpec(object): |
|
def __init__(self, master, machine_id, machine_type, spec): |
|
logging.info("Initting machine %s", machine_id) |
|
self.master = master |
|
self.machine_id = machine_id |
|
self.machine_type = machine_type |
|
|
|
self.options = {} # hypervisor-level stuff like Autostart |
|
self.properties = {} # machine level stuff like processor count |
|
|
|
# TODO replace if/else with better system |
|
if machine_type == "q": |
|
self.machine = QMachine(self) |
|
self.options = spec["options"] |
|
self.properties = spec["properties"] |
|
else: |
|
raise Exception("Unknown machine type: {}".format(machine_type)) |
|
|
|
def start(self): |
|
self.machine.start_machine() |
|
|
|
def stop(self): |
|
self.machine.block_respawns = True |
|
self.machine.stop_machine()
|
|
|