def _set_machine_install(self, machine, install=True): settings = self.request.registry.settings filename = pxeconfig_filename(machine.uuid) if install: make_pxeconfig(machine, settings) # FIXME: this makes sure that the key in the database # that the machine will be preseeded with is accepted # by the salt-master. self.mgr.accept_machine(machine, force=True) if not self.has_pxeconfig(machine, filename=filename): raise RuntimeError, "%s doesn't exist." % filename else: remove_pxeconfig(machine.uuid) if self.has_pxeconfig(machine, filename=filename): raise RuntimeError, "%s still exists." % filename
def has_pxeconfig(self, machine, filename=None): if filename is None: filename = pxeconfig_filename(machine.uuid) return os.path.isfile(filename)