| 262 | |
| 263 | |
| 264 | Try<Nothing> machines(const RepeatedPtrField<MachineID>& ids) |
| 265 | { |
| 266 | if (ids.size() <= 0) { |
| 267 | return Error("List of machines is empty"); |
| 268 | } |
| 269 | |
| 270 | // Verify that the machine has at least one non-empty field value. |
| 271 | hashset<MachineID> uniques; |
| 272 | foreach (const MachineID& id, ids) { |
| 273 | // Validate the single machine. |
| 274 | Try<Nothing> validId = validation::machine(id); |
| 275 | if (validId.isError()) { |
| 276 | return Error(validId.error()); |
| 277 | } |
| 278 | |
| 279 | // Check machine uniqueness. |
| 280 | if (uniques.contains(id)) { |
| 281 | return Error( |
| 282 | "Machine '" + stringify(JSON::protobuf(id)) + |
| 283 | "' appears more than once in the schedule"); |
| 284 | } |
| 285 | |
| 286 | uniques.insert(id); |
| 287 | } |
| 288 | |
| 289 | return Nothing(); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | Try<Nothing> machine(const MachineID& id) |
no test coverage detected