Repository: mesos Updated Branches: refs/heads/master e0b672145 -> c13644984
Added support for CNI networks for `--task_group`. Review: https://reviews.apache.org/r/52177/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c1364498 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c1364498 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c1364498 Branch: refs/heads/master Commit: c13644984564179979d5ef5f40c8299fadd10ee7 Parents: e0b6721 Author: Avinash sridharan <avin...@mesosphere.io> Authored: Thu Sep 22 22:35:46 2016 -0700 Committer: Vinod Kone <vinodk...@gmail.com> Committed: Thu Sep 22 22:35:46 2016 -0700 ---------------------------------------------------------------------- src/cli/execute.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/c1364498/src/cli/execute.cpp ---------------------------------------------------------------------- diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp index 79091d6..fcf627b 100644 --- a/src/cli/execute.cpp +++ b/src/cli/execute.cpp @@ -299,7 +299,8 @@ public: const Option<Duration>& _killAfter, const Option<Credential>& _credential, const Option<TaskInfo>& _task, - const Option<TaskGroupInfo> _taskGroup) + const Option<TaskGroupInfo>& _taskGroup, + const Option<string>& _networks) : state(DISCONNECTED), frameworkInfo(_frameworkInfo), master(_master), @@ -307,6 +308,7 @@ public: credential(_credential), task(_task), taskGroup(_taskGroup), + networks(_networks), launched(false), terminatedTaskCount(0) {} @@ -463,6 +465,18 @@ protected: executorInfo->mutable_resources()->CopyFrom( Resources::parse("cpus:0.1;mem:32;disk:32").get()); + // Setup any CNI networks that the `task_group` needs to + // join, in case the `--networks` flag was specified. + if (networks.isSome() && !networks->empty()) { + ContainerInfo* containerInfo = executorInfo->mutable_container(); + containerInfo->set_type(ContainerInfo::MESOS); + + foreach (const string& network, + strings::tokenize(networks.get(), ",")) { + containerInfo->add_network_infos()->set_name(network); + } + } + operation->mutable_launch_group()->mutable_task_group()->CopyFrom( _taskGroup); } @@ -624,6 +638,7 @@ private: const Option<Credential> credential; const Option<TaskInfo> task; const Option<TaskGroupInfo> taskGroup; + const Option<string> networks; bool launched; int terminatedTaskCount; Owned<Mesos> mesos; @@ -1017,7 +1032,8 @@ int main(int argc, char** argv) flags.kill_after, credential, taskInfo, - flags.task_group)); + flags.task_group, + flags.networks)); process::spawn(scheduler.get()); process::wait(scheduler.get());