MCPcopy Create free account
hub / github.com/apache/mesos / addResourceProviderConfig

Method addResourceProviderConfig

src/slave/http.cpp:4028–4069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4026
4027
4028Future<Response> Http::addResourceProviderConfig(
4029 const mesos::agent::Call& call,
4030 const Option<Principal>& principal) const
4031{
4032 CHECK_EQ(mesos::agent::Call::ADD_RESOURCE_PROVIDER_CONFIG, call.type());
4033 CHECK(call.has_add_resource_provider_config());
4034
4035 const ResourceProviderInfo& info = call.add_resource_provider_config().info();
4036
4037 LOG(INFO)
4038 << "Processing ADD_RESOURCE_PROVIDER_CONFIG call with"
4039 << " type '" << info.type() << "' and name '" << info.name() << "'";
4040
4041 return ObjectApprovers::create(
4042 slave->authorizer, principal, {MODIFY_RESOURCE_PROVIDER_CONFIG})
4043 .then(defer(
4044 slave->self(),
4045 [=](const Owned<ObjectApprovers>& approvers) -> Future<Response> {
4046 if (!approvers->approved<MODIFY_RESOURCE_PROVIDER_CONFIG>()) {
4047 return Forbidden();
4048 }
4049
4050 Option<Error> error = LocalResourceProvider::validate(info);
4051 if (error.isSome()) {
4052 return BadRequest(
4053 "Failed to validate resource provider config with type '" +
4054 info.type() + "' and name '" + info.name() + "': " +
4055 error->message);
4056 }
4057
4058 return slave->localResourceProviderDaemon->add(info)
4059 .then([info](bool added) -> Response {
4060 if (!added) {
4061 return Conflict(
4062 "Resource provider with type '" + info.type() +
4063 "' and name '" + info.name() + "' already exists");
4064 }
4065
4066 return OK();
4067 });
4068 }));
4069}
4070
4071
4072Future<Response> Http::updateResourceProviderConfig(

Callers

nothing calls this directly

Calls 14

deferFunction · 0.85
ForbiddenClass · 0.85
BadRequestClass · 0.85
ConflictClass · 0.85
OKClass · 0.85
typeMethod · 0.80
infoMethod · 0.80
validateFunction · 0.70
createFunction · 0.50
nameMethod · 0.45
thenMethod · 0.45
selfMethod · 0.45

Tested by

no test coverage detected