Skip to content

Commit

Permalink
API: Set zone attribute for local zone if not specified
Browse files Browse the repository at this point in the history
This allows to sync the object to other nodes in the same
zone on reconnect.

refs #11684
  • Loading branch information
Michael Friedrich authored and gunnarbeutner committed Nov 17, 2016
1 parent e5a6bdc commit 099fc76
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/remote/createobjecthandler.cpp
Expand Up @@ -22,6 +22,7 @@
#include "remote/httputility.hpp"
#include "remote/filterutility.hpp"
#include "remote/apiaction.hpp"
#include "remote/zone.hpp"
#include "base/configtype.hpp"
#include <boost/algorithm/string.hpp>
#include <set>
Expand Down Expand Up @@ -51,6 +52,18 @@ bool CreateObjectHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& r
Array::Ptr templates = params->Get("templates");
Dictionary::Ptr attrs = params->Get("attrs");

/* Put created objects into the local zone if not explicitely defined.
* This allows additional zone members to sync the
* configuration at some later point.
*/
Zone::Ptr localZone = Zone::GetLocalZone();
String localZoneName;

if (localZone && !attrs->Contains("zone")) {
localZoneName = localZone->GetName();
attrs->Set("zone", localZoneName);
}

Dictionary::Ptr result1 = new Dictionary();
int code;
String status;
Expand Down

0 comments on commit 099fc76

Please sign in to comment.