Add reinstall abilities and cleanup process for new servers

This commit is contained in:
Dane Everitt 2017-04-20 18:52:43 -04:00
parent 3fe5d162f5
commit 8dc24471ae
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
9 changed files with 91 additions and 3 deletions

View file

@ -173,6 +173,8 @@ class OptionRepository
$validator = Validator::make($data, [
'script_install' => 'sometimes|nullable|string',
'script_is_privileged' => 'sometimes|required|boolean',
'script_entry' => 'sometimes|required|string',
'script_container' => 'sometimes|required|string',
]);
if ($validator->fails()) {

View file

@ -864,4 +864,25 @@ class ServerRepository
]);
});
}
/**
* Marks a server for reinstallation on the node.
*
* @param int $id
* @return void
*/
public function reinstall($id)
{
$server = Models\Server::with('node')->findOrFail($id);
DB::transaction(function () use ($server) {
$server->installed = 0;
$server->save();
$server->node->guzzleClient([
'X-Access-Token' => $server->node->daemonSecret,
'X-Access-Server' => $server->uuid,
])->request('POST', '/server/reinstall');
});
}
}