MXS-1883 Maintenance is now the only user-modifiable bit for a monitored server

The request to turn maintenance off/on is a separate flag, although the actual
status is still contained in the status bitfield.
This commit is contained in:
Esa Korhonen
2018-05-24 13:47:56 +03:00
parent 2f48d079db
commit c039821467
11 changed files with 182 additions and 40 deletions

View File

@ -25,6 +25,7 @@
#include <maxscale/adminusers.h>
#include <maxscale/modulecmd.h>
#include <maxscale/semaphore.hh>
#include <maxscale/server.hh>
#include "internal/httprequest.hh"
#include "internal/httpresponse.hh"
@ -658,8 +659,15 @@ HttpResponse cb_set_server(const HttpRequest& request)
if (opt)
{
server_set_status(server, opt);
return HttpResponse(MHD_HTTP_NO_CONTENT);
string errmsg;
if (mxs::server_set_status(server, opt, &errmsg))
{
return HttpResponse(MHD_HTTP_NO_CONTENT);
}
else
{
return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error(errmsg.c_str()));
}
}
return HttpResponse(MHD_HTTP_FORBIDDEN,
@ -674,8 +682,15 @@ HttpResponse cb_clear_server(const HttpRequest& request)
if (opt)
{
server_clear_status(server, opt);
return HttpResponse(MHD_HTTP_NO_CONTENT);
string errmsg;
if (mxs::server_clear_status(server, opt, &errmsg))
{
return HttpResponse(MHD_HTTP_NO_CONTENT);
}
else
{
return HttpResponse(MHD_HTTP_FORBIDDEN, mxs_json_error(errmsg.c_str()));
}
}
return HttpResponse(MHD_HTTP_FORBIDDEN,