public function createMachine($name) { if ($this->exists($name)) { return false; } $machine = new Machine($name); $machine->save(); $this->addMachine($machine->getName()); return $machine; }
if ($queue->exists()) { jsonResponse(200, $queue->getQueueInfo()); } else { textResponse(404, 'Queue unknown'); } }); /* Queues - Take next job */ $app->get('/queues/waitqueue/:jailname/take', 'isAllowed', function ($jailname) use($app) { $queue = new Queue('waitqueue', $jailname); $job = $queue->getNextJob(); if ($job === false) { textResponse(204); } $machine = new Machine(Session::getMachineId()); $machine->addJob($job->getJobId()); $job->set('machine', $machine->getName()); $job->moveToQueue('runqueue'); jsonResponse(200, $job->getJobData()); }); /* Jobs - Create new job */ $app->post('/jobs/create', 'isAllowed', function () use($app) { $queue = new Queue(); $jail = new Jails(); if (!$jail->exists($_POST['jail'])) { textResponse(404, 'Jail unknown'); } $repos = new Repositories(); if (!$repos->exists($_POST['repository'])) { textResponse(404, 'Repository unknown'); } $jobgroup = new Jobgroup($_POST['jobgroup']);