| 1007 | |
| 1008 | |
| 1009 | Future<Response> Master::Http::_destroyVolumes( |
| 1010 | const SlaveID& slaveId, |
| 1011 | const RepeatedPtrField<Resource>& volumes, |
| 1012 | const Option<Principal>& principal) const |
| 1013 | { |
| 1014 | Slave* slave = master->slaves.registered.get(slaveId); |
| 1015 | if (slave == nullptr) { |
| 1016 | return BadRequest("No agent found with specified ID"); |
| 1017 | } |
| 1018 | |
| 1019 | // Create an operation. |
| 1020 | Offer::Operation operation; |
| 1021 | operation.set_type(Offer::Operation::DESTROY); |
| 1022 | operation.mutable_destroy()->mutable_volumes()->CopyFrom(volumes); |
| 1023 | |
| 1024 | Option<Error> error = validateAndUpgradeResources(&operation); |
| 1025 | if (error.isSome()) { |
| 1026 | return BadRequest(error->message); |
| 1027 | } |
| 1028 | |
| 1029 | error = validation::operation::validate( |
| 1030 | operation.destroy(), |
| 1031 | slave->checkpointedResources, |
| 1032 | slave->usedResources); |
| 1033 | |
| 1034 | if (error.isSome()) { |
| 1035 | return BadRequest("Invalid DESTROY operation: " + error->message); |
| 1036 | } |
| 1037 | |
| 1038 | return master->authorize( |
| 1039 | principal, ActionObject::destroyVolume(operation.destroy())) |
| 1040 | .then(defer(master->self(), [=](bool authorized) -> Future<Response> { |
| 1041 | if (!authorized) { |
| 1042 | return Forbidden(); |
| 1043 | } |
| 1044 | |
| 1045 | return _operation(slaveId, operation); |
| 1046 | })); |
| 1047 | } |
| 1048 | |
| 1049 | |
| 1050 | Future<Response> Master::Http::destroyVolumes( |
nothing calls this directly
no test coverage detected