You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/03/22 19:29:15 UTC

mesos git commit: Introduced a protobuf message "NetworkConfig".

Repository: mesos
Updated Branches:
  refs/heads/master 7863e2c98 -> 9ba8acf78


Introduced a protobuf message "NetworkConfig".

Review: https://reviews.apache.org/r/44549/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9ba8acf7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9ba8acf7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9ba8acf7

Branch: refs/heads/master
Commit: 9ba8acf78ade2d66bea7c1b68b61902b7109056a
Parents: 7863e2c
Author: Qian Zhang <zh...@cn.ibm.com>
Authored: Tue Mar 22 09:39:56 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Mar 22 11:05:10 2016 -0700

----------------------------------------------------------------------
 src/CMakeLists.txt                              |  3 ++
 src/Makefile.am                                 | 11 +++--
 .../mesos/isolators/network/cni/spec.cpp        | 49 ++++++++++++++++++++
 .../mesos/isolators/network/cni/spec.hpp        | 37 +++++++++++++++
 .../mesos/isolators/network/cni/spec.proto      | 47 +++++++++++++++++++
 5 files changed, 144 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9ba8acf7/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3947329..5d08e04 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -50,6 +50,7 @@ PROTOC_TO_SRC_DIR(LOG      messages/log)
 PROTOC_TO_SRC_DIR(STATE    messages/state)
 
 PROTOC_TO_SRC_DIR(MESSAGE slave/containerizer/mesos/provisioner/docker/message)
+PROTOC_TO_SRC_DIR(CNI_SPEC slave/containerizer/mesos/isolators/network/cni/spec)
 
 set(MESOS_PROTOBUF_SRC
   ${MESOS_PROTO_CC}
@@ -274,6 +275,8 @@ if (NOT WIN32)
     slave/containerizer/mesos/mount.cpp
     slave/containerizer/mesos/isolators/filesystem/posix.cpp
     slave/containerizer/mesos/isolators/posix/disk.cpp
+    slave/containerizer/mesos/isolators/network/cni/spec.proto
+    slave/containerizer/mesos/isolators/network/cni/spec.cpp
     slave/containerizer/mesos/provisioner/docker/local_puller.cpp
     slave/containerizer/mesos/provisioner/paths.cpp
     slave/containerizer/mesos/provisioner/provisioner.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/9ba8acf7/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 9dd21b5..bb95808 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -233,7 +233,9 @@ CXX_PROTOS +=								\
   messages/messages.pb.cc						\
   messages/messages.pb.h						\
   slave/containerizer/mesos/provisioner/docker/message.pb.cc		\
-  slave/containerizer/mesos/provisioner/docker/message.pb.h
+  slave/containerizer/mesos/provisioner/docker/message.pb.h		\
+  slave/containerizer/mesos/isolators/network/cni/spec.pb.cc		\
+  slave/containerizer/mesos/isolators/network/cni/spec.pb.h
 
 CXX_LOG_PROTOS =							\
   messages/log.pb.cc							\
@@ -387,7 +389,7 @@ nodist_pkginclude_HEADERS =						\
 
 appcdir = $(pkgincludedir)/appc
 
-appc_HEADERS =						\
+appc_HEADERS =								\
   $(top_srcdir)/include/mesos/appc/spec.hpp				\
   $(top_srcdir)/include/mesos/appc/spec.proto
 
@@ -587,7 +589,8 @@ libmesos_no_3rdparty_la_SOURCES =					\
   master/registry.proto							\
   messages/flags.proto							\
   messages/messages.proto						\
-  slave/containerizer/mesos/provisioner/docker/message.proto
+  slave/containerizer/mesos/provisioner/docker/message.proto		\
+  slave/containerizer/mesos/isolators/network/cni/spec.proto
 
 # TODO(tillt): Remove authentication/cram_md5/* which will enable us to
 # lose the immediate cyrus-sasl2 dependency.
@@ -670,6 +673,7 @@ libmesos_no_3rdparty_la_SOURCES +=					\
   slave/containerizer/mesos/launcher.cpp				\
   slave/containerizer/mesos/mount.cpp					\
   slave/containerizer/mesos/isolators/filesystem/posix.cpp		\
+  slave/containerizer/mesos/isolators/network/cni/spec.cpp		\
   slave/containerizer/mesos/isolators/posix/disk.cpp			\
   slave/containerizer/mesos/provisioner/backend.cpp			\
   slave/containerizer/mesos/provisioner/paths.cpp			\
@@ -782,6 +786,7 @@ libmesos_no_3rdparty_la_SOURCES +=					\
   slave/containerizer/mesos/isolators/posix.hpp				\
   slave/containerizer/mesos/isolators/filesystem/posix.hpp		\
   slave/containerizer/mesos/isolators/posix/disk.hpp			\
+  slave/containerizer/mesos/isolators/network/cni/spec.hpp		\
   slave/containerizer/mesos/provisioner/backend.hpp			\
   slave/containerizer/mesos/provisioner/paths.hpp			\
   slave/containerizer/mesos/provisioner/provisioner.hpp			\

http://git-wip-us.apache.org/repos/asf/mesos/blob/9ba8acf7/src/slave/containerizer/mesos/isolators/network/cni/spec.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/spec.cpp b/src/slave/containerizer/mesos/isolators/network/cni/spec.cpp
new file mode 100644
index 0000000..f4c7113
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/network/cni/spec.cpp
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stout/json.hpp>
+#include <stout/protobuf.hpp>
+
+#include "slave/containerizer/mesos/isolators/network/cni/spec.hpp"
+
+using std::string;
+
+namespace mesos {
+namespace internal {
+namespace slave {
+namespace cni {
+
+Try<cni::NetworkConfig> parse(const string& s)
+{
+  Try<JSON::Object> json = JSON::parse<JSON::Object>(s);
+  if (json.isError()) {
+    return Error("JSON parse failed: " + json.error());
+  }
+
+  Try<cni::NetworkConfig> parse =
+    ::protobuf::parse<cni::NetworkConfig>(json.get());
+
+  if (parse.isError()) {
+    return Error("Protobuf parse failed: " + parse.error());
+  }
+
+  return parse.get();
+}
+
+} // namespace cni {
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9ba8acf7/src/slave/containerizer/mesos/isolators/network/cni/spec.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/spec.hpp b/src/slave/containerizer/mesos/isolators/network/cni/spec.hpp
new file mode 100644
index 0000000..eb3661a
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/network/cni/spec.hpp
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __ISOLATOR_CNI_SPEC_HPP__
+#define __ISOLATOR_CNI_SPEC_HPP__
+
+#include <stout/try.hpp>
+
+// ONLY USEFUL AFTER RUNNING PROTOC.
+#include "slave/containerizer/mesos/isolators/network/cni/spec.pb.h"
+
+namespace mesos {
+namespace internal {
+namespace slave {
+namespace cni {
+
+Try<cni::NetworkConfig> parse(const std::string& s);
+
+} // namespace cni {
+} // namespace slave {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __ISOLATOR_CNI_SPEC_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/9ba8acf7/src/slave/containerizer/mesos/isolators/network/cni/spec.proto
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/spec.proto b/src/slave/containerizer/mesos/isolators/network/cni/spec.proto
new file mode 100644
index 0000000..0e84ec1
--- /dev/null
+++ b/src/slave/containerizer/mesos/isolators/network/cni/spec.proto
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package mesos.internal.slave.cni;
+
+message Route {
+  required string dst = 1;
+  optional string gw = 2;
+}
+
+
+message DNS {
+  repeated string nameservers = 1;
+  optional string domain = 2;
+  repeated string search = 3;
+  repeated string options = 4;
+}
+
+
+/**
+ * Protobuf for the CNI network configuration JSON schema:
+ * https://github.com/appc/cni/blob/master/SPEC.md#network-configuration
+ */
+message NetworkConfig {
+  message IPAM {
+    required string type = 1;
+    repeated Route routes = 2;
+  }
+
+  required string name = 1;
+  required string type = 2;
+  optional IPAM ipam = 3;
+  optional DNS dns = 4;
+}