| 572 | |
| 573 | |
| 574 | int main(int argc, char** argv) |
| 575 | { |
| 576 | Flags flags; |
| 577 | |
| 578 | Try<flags::Warnings> load = flags.load("MESOS_EXAMPLE_", argc, argv); |
| 579 | |
| 580 | if (flags.help) { |
| 581 | std::cout << flags.usage() << std::endl; |
| 582 | return EXIT_SUCCESS; |
| 583 | } |
| 584 | |
| 585 | if (load.isError()) { |
| 586 | std::cerr << flags.usage(load.error()) << std::endl; |
| 587 | return EXIT_FAILURE; |
| 588 | } |
| 589 | |
| 590 | mesos::internal::logging::initialize(argv[0], true, flags); // Catch signals. |
| 591 | |
| 592 | // Log any flag warnings. |
| 593 | foreach (const flags::Warning& warning, load->warnings) { |
| 594 | LOG(WARNING) << warning.message; |
| 595 | } |
| 596 | |
| 597 | // Nothing special to say about this framework. |
| 598 | FrameworkInfo framework; |
| 599 | framework.set_user(os::user().get()); |
| 600 | framework.set_name(FRAMEWORK_NAME); |
| 601 | framework.set_role(flags.role); |
| 602 | framework.set_checkpoint(flags.checkpoint); |
| 603 | framework.add_capabilities()->set_type( |
| 604 | FrameworkInfo::Capability::RESERVATION_REFINEMENT); |
| 605 | |
| 606 | Option<Credential> credential = None(); |
| 607 | |
| 608 | if (flags.authenticate) { |
| 609 | LOG(INFO) << "Enabling authentication for the framework"; |
| 610 | |
| 611 | Credential credential_; |
| 612 | credential_.set_principal(flags.principal); |
| 613 | if (flags.secret.isSome()) { |
| 614 | credential_.set_secret(flags.secret.get()); |
| 615 | } |
| 616 | credential = credential_; |
| 617 | } |
| 618 | |
| 619 | if (flags.master == "local") { |
| 620 | // Configure master. |
| 621 | os::setenv("MESOS_ROLES", flags.role); |
| 622 | |
| 623 | os::setenv( |
| 624 | "MESOS_AUTHENTICATE_HTTP_FRAMEWORKS", |
| 625 | stringify(flags.authenticate)); |
| 626 | |
| 627 | os::setenv("MESOS_HTTP_FRAMEWORK_AUTHENTICATORS", "basic"); |
| 628 | |
| 629 | mesos::ACLs acls; |
| 630 | mesos::ACL::RegisterFramework* acl = acls.add_register_frameworks(); |
| 631 | acl->mutable_principals()->set_type(mesos::ACL::Entity::ANY); |
nothing calls this directly
no test coverage detected