def create_combox(vm): cmds = createvm(vm) cmds += modifyvm(vm) if not config['vm'].get('storage'): storage_path = os.path.join(get_combox_images_directory(), config['vm']['name'] + '-' + str(uuid.uuid1()) + ".vmdk") cmds += createhd(vm, storage_path) cmds += storagectl(vm) cmds += storageattach(vm, storage_path) ret = exec_cmds(cmds) # Return on errors if not ret: return False # Add the shares for share in vm['shares']: ret = exec_cmds(['VBoxManage sharedfolder add "%s" --name "%s" --hostpath "%s"' % (vm['name'], share['name'], share['target'])]) if not ret: return False return True
def create_combox(vm): cmds = createvm(vm) cmds += modifyvm(vm) cmds += createhd(vm) cmds += storagectl(vm) cmds += storageattach(vm) ret = exec_cmds(cmds) # Return on errors if not ret: return False # Add the shares for share in vm["shares"]: ret = exec_cmds( [ 'VBoxManage sharedfolder add "%s" --name "%s" --hostpath "%s" --readonly' % (vm["name"], share["name"], share["target"]) ] ) if not ret: return False return True
def teardown(): # Script print "Teardown of development environment" client = Client(config['api'], config['username'], config['password']) env = client.get_environment(config['organization'], "Development") # First detroy the VM exec_cmds(['VBoxManage controlvm "%s" poweroff' % config['vm']['name'], 'VBoxManage unregistervm "%s" --delete' % config['vm']['name']], False) # Then delete the comodit hosts for h in env.hosts(): try: print "Deleting instance of", h.name h.get_instance().delete() except Exception: print "Could not delete host ", h.name h.delete()
def stop(): print "Stopping virtual machine" success = exec_cmds(['VBoxManage controlvm "%s" poweroff' % config["vm"]["name"]])