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 2017/08/22 22:27:46 UTC

[2/6] mesos git commit: Added CSI client classes to talk to CSI plugins.

Added CSI client classes to talk to CSI plugins.

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


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

Branch: refs/heads/master
Commit: 9bf4e8383d3f19a9cfe5cffec9fdee87cff254a7
Parents: 07b76c0
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:32:02 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:34 2017 -0700

----------------------------------------------------------------------
 src/csi/client.cpp | 174 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/csi/client.hpp |  96 ++++++++++++++++++++++++++
 src/csi/spec.hpp   |  23 +++++++
 3 files changed, 293 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/client.cpp
----------------------------------------------------------------------
diff --git a/src/csi/client.cpp b/src/csi/client.cpp
new file mode 100644
index 0000000..e171f03
--- /dev/null
+++ b/src/csi/client.cpp
@@ -0,0 +1,174 @@
+// 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 "csi/client.hpp"
+
+using process::Future;
+
+namespace mesos {
+namespace csi {
+
+Future<GetSupportedVersionsResponse> Client::GetSupportedVersions(
+    const GetSupportedVersionsRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Identity, GetSupportedVersions),
+      request);
+}
+
+
+Future<GetPluginInfoResponse> Client::GetPluginInfo(
+    const GetPluginInfoRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Identity, GetPluginInfo),
+      request);
+}
+
+
+Future<CreateVolumeResponse> Client::CreateVolume(
+    const CreateVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, CreateVolume),
+      request);
+}
+
+
+Future<DeleteVolumeResponse> Client::DeleteVolume(
+    const DeleteVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, DeleteVolume),
+      request);
+}
+
+
+Future<ControllerPublishVolumeResponse> Client::ControllerPublishVolume(
+    const ControllerPublishVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, ControllerPublishVolume),
+      request);
+}
+
+
+Future<ControllerUnpublishVolumeResponse> Client::ControllerUnpublishVolume(
+    const ControllerUnpublishVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, ControllerUnpublishVolume),
+      request);
+}
+
+
+Future<ValidateVolumeCapabilitiesResponse> Client::ValidateVolumeCapabilities(
+    const ValidateVolumeCapabilitiesRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, ValidateVolumeCapabilities),
+      request);
+}
+
+
+Future<ListVolumesResponse> Client::ListVolumes(
+    const ListVolumesRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, ListVolumes),
+      request);
+}
+
+
+Future<GetCapacityResponse> Client::GetCapacity(
+    const GetCapacityRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, GetCapacity),
+      request);
+}
+
+
+Future<ControllerGetCapabilitiesResponse> Client::ControllerGetCapabilities(
+    const ControllerGetCapabilitiesRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Controller, ControllerGetCapabilities),
+      request);
+}
+
+
+Future<NodePublishVolumeResponse> Client::NodePublishVolume(
+    const NodePublishVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Node, NodePublishVolume),
+      request);
+}
+
+
+Future<NodeUnpublishVolumeResponse> Client::NodeUnpublishVolume(
+    const NodeUnpublishVolumeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Node, NodeUnpublishVolume),
+      request);
+}
+
+
+Future<GetNodeIDResponse> Client::GetNodeID(
+    const GetNodeIDRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Node, GetNodeID),
+      request);
+}
+
+
+Future<ProbeNodeResponse> Client::ProbeNode(
+    const ProbeNodeRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Node, ProbeNode),
+      request);
+}
+
+
+Future<NodeGetCapabilitiesResponse> Client::NodeGetCapabilities(
+    const NodeGetCapabilitiesRequest& request)
+{
+  return runtime.call(
+      channel,
+      GRPC_RPC(Node, NodeGetCapabilities),
+      request);
+}
+
+} // namespace csi {
+} // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/client.hpp
----------------------------------------------------------------------
diff --git a/src/csi/client.hpp b/src/csi/client.hpp
new file mode 100644
index 0000000..df674e1
--- /dev/null
+++ b/src/csi/client.hpp
@@ -0,0 +1,96 @@
+// 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 __CSI_CLIENT_HPP__
+#define __CSI_CLIENT_HPP__
+
+#include <string>
+
+#include <process/grpc.hpp>
+
+#include "csi/spec.hpp"
+
+namespace mesos {
+namespace csi {
+
+using namespace ::csi;
+
+class Client
+{
+public:
+  Client(const std::string& uri,
+         const process::grpc::client::Runtime& _runtime)
+    : channel(uri),
+      runtime(_runtime) {}
+
+  // RPCs for the Identity service.
+  process::Future<GetSupportedVersionsResponse>
+    GetSupportedVersions(const GetSupportedVersionsRequest& request);
+
+  process::Future<GetPluginInfoResponse>
+    GetPluginInfo(const GetPluginInfoRequest& request);
+
+  // RPCs for the Controller service.
+  process::Future<CreateVolumeResponse>
+    CreateVolume(const CreateVolumeRequest& request);
+
+  process::Future<DeleteVolumeResponse>
+    DeleteVolume(const DeleteVolumeRequest& request);
+
+  process::Future<ControllerPublishVolumeResponse>
+    ControllerPublishVolume(const ControllerPublishVolumeRequest& request);
+
+  process::Future<ControllerUnpublishVolumeResponse>
+    ControllerUnpublishVolume(const ControllerUnpublishVolumeRequest& request);
+
+  process::Future<ValidateVolumeCapabilitiesResponse>
+    ValidateVolumeCapabilities(
+        const ValidateVolumeCapabilitiesRequest& request);
+
+  process::Future<ListVolumesResponse>
+    ListVolumes(const ListVolumesRequest& request);
+
+  process::Future<GetCapacityResponse>
+    GetCapacity(const GetCapacityRequest& request);
+
+  process::Future<ControllerGetCapabilitiesResponse>
+    ControllerGetCapabilities(const ControllerGetCapabilitiesRequest& request);
+
+  // RPCs for the Node service.
+  process::Future<NodePublishVolumeResponse>
+    NodePublishVolume(const NodePublishVolumeRequest& request);
+
+  process::Future<NodeUnpublishVolumeResponse>
+    NodeUnpublishVolume(const NodeUnpublishVolumeRequest& request);
+
+  process::Future<GetNodeIDResponse>
+    GetNodeID(const GetNodeIDRequest& request);
+
+  process::Future<ProbeNodeResponse>
+    ProbeNode(const ProbeNodeRequest& request);
+
+  process::Future<NodeGetCapabilitiesResponse>
+    NodeGetCapabilities(const NodeGetCapabilitiesRequest& request);
+
+private:
+  process::grpc::Channel channel;
+  process::grpc::client::Runtime runtime;
+};
+
+} // namespace csi {
+} // namespace mesos {
+
+#endif // __CSI_CLIENT_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/spec.hpp
----------------------------------------------------------------------
diff --git a/src/csi/spec.hpp b/src/csi/spec.hpp
new file mode 100644
index 0000000..60e40e0
--- /dev/null
+++ b/src/csi/spec.hpp
@@ -0,0 +1,23 @@
+// 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 __CSI_SPEC_HPP__
+#define __CSI_SPEC_HPP__
+
+// ONLY USEFUL AFTER RUNNING PROTOC WITH GRPC CPP PLUGIN.
+#include "csi/csi.grpc.pb.h"
+
+#endif // __CSI_SPEC_HPP__