| 78 | |
| 79 | |
| 80 | vector<ActionObject> ActionObject::agentRegistration( |
| 81 | const SlaveInfo& slaveInfo) |
| 82 | { |
| 83 | vector<ActionObject> result; |
| 84 | |
| 85 | if (!Resources(slaveInfo.resources()).reserved().empty()) { |
| 86 | // If static reservations exist, we also need to authorize them. |
| 87 | // |
| 88 | // NOTE: We don't look at dynamic reservations in checkpointed |
| 89 | // resources because they should have gone through authorization |
| 90 | // against the framework / operator's principal when they were |
| 91 | // created. In constrast, static reservations are initiated by the |
| 92 | // agent's principal and authorizing them helps prevent agents from |
| 93 | // advertising reserved resources of arbitrary roles. |
| 94 | Offer::Operation::Reserve reserve; |
| 95 | *reserve.mutable_resources() = slaveInfo.resources(); |
| 96 | result = ActionObject::reserve(reserve); |
| 97 | } |
| 98 | |
| 99 | result.push_back(ActionObject(authorization::REGISTER_AGENT, None())); |
| 100 | return result; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | // Returns effective reservation role of resource for the purpose |