From 2a292e2e3a1d7bca53f85c7e6cfa40ae58ce2401 Mon Sep 17 00:00:00 2001 From: matancarmeli7 Date: Tue, 4 Jul 2023 10:13:21 +0300 Subject: [PATCH] add vg to csi addons Signed-off-by: matancarmeli7 --- controllers/scripts/csi_general/csi_pb2.sh | 6 ++--- .../volume_group_server.py | 0 .../identity_controller_servicer.py | 23 ++++++++++++++++++- controllers/servers/csi/main.py | 4 +++- .../volume_group_server_test.py | 4 ++-- 5 files changed, 30 insertions(+), 7 deletions(-) rename controllers/servers/csi/{controller_server => common_servers}/volume_group_server.py (100%) diff --git a/controllers/scripts/csi_general/csi_pb2.sh b/controllers/scripts/csi_general/csi_pb2.sh index e5a0bce7e..73d0f99d4 100755 --- a/controllers/scripts/csi_general/csi_pb2.sh +++ b/controllers/scripts/csi_general/csi_pb2.sh @@ -3,18 +3,18 @@ set -x CSI_VERSION="v1.5.0" ADDONS_VERSION="v0.1.1" -VG_VERSION="v0.9.0" PB2_DIR="csi_general" mkdir -p ./proto/${PB2_DIR} cd ./proto/${PB2_DIR} curl -O https://raw.githubusercontent.com/container-storage-interface/spec/${CSI_VERSION}/csi.proto -curl -O https://raw.githubusercontent.com/IBM/csi-volume-group/${VG_VERSION}/volumegroup/volumegroup.proto +curl -O https://raw.githubusercontent.com/matancarmeli7/spec/add_volume_group_spec/volumegroup/volumegroup.proto curl -O https://raw.githubusercontent.com/csi-addons/spec/v0.2.0/replication/replication.proto curl -O https://raw.githubusercontent.com/csi-addons/spec/v0.2.0/fence/fence.proto -curl -O https://raw.githubusercontent.com/csi-addons/spec/main/identity/identity.proto +curl -O https://raw.githubusercontent.com/matancarmeli7/spec/add_volume_group_spec/identity/identity.proto sed -i 's|github.com/container-storage-interface/spec/lib/go/csi/csi.proto|csi_general/csi.proto|g' replication.proto +sed -i 's|github.com/container-storage-interface/spec/lib/go/csi/csi.proto|csi_general/csi.proto|g' volumegroup.proto sed -i 's|github.com/container-storage-interface/spec/lib/go/csi/csi.proto|csi_general/csi.proto|g' fence.proto cd - diff --git a/controllers/servers/csi/controller_server/volume_group_server.py b/controllers/servers/csi/common_servers/volume_group_server.py similarity index 100% rename from controllers/servers/csi/controller_server/volume_group_server.py rename to controllers/servers/csi/common_servers/volume_group_server.py diff --git a/controllers/servers/csi/csi_addons_server/identity_controller_servicer.py b/controllers/servers/csi/csi_addons_server/identity_controller_servicer.py index 460ffd943..41d6125d7 100644 --- a/controllers/servers/csi/csi_addons_server/identity_controller_servicer.py +++ b/controllers/servers/csi/csi_addons_server/identity_controller_servicer.py @@ -29,7 +29,10 @@ def GetCapabilities(self, request, context): response = pb2.GetCapabilitiesResponse( capabilities=[self._get_replication_capability(), self._get_controller_capability(), - self._get_network_fence_capability()]) + self._get_network_fence_capability(), + self._get_volume_group_capability(), + self._get_vg_limit_volume_to_one_vg_capability(), + self._get_vg_disable_deleting_volumes_when_vg_deleted_capability()]) logger.info("finished GetCapabilities") return response @@ -52,6 +55,24 @@ def _get_network_fence_capability(self): return pb2.Capability( network_fence=pb2.Capability.NetworkFence(type=capability_enum_value)) + def _get_volume_group_capability(self): + types = pb2.Capability.VolumeGroup.Type + capability_enum_value = types.Value("VOLUME_GROUP") + return pb2.Capability( + volume_group=pb2.Capability.VolumeGroup(type=capability_enum_value)) + + def _get_vg_limit_volume_to_one_vg_capability(self): + types = pb2.Capability.VolumeGroup.Type + capability_enum_value = types.Value("LIMIT_VOLUME_TO_ONE_VG") + return pb2.Capability( + volume_group=pb2.Capability.VolumeGroup(type=capability_enum_value)) + + def _get_vg_disable_deleting_volumes_when_vg_deleted_capability(self): + types = pb2.Capability.VolumeGroup.Type + capability_enum_value = types.Value("DO_NOT_ALLOW_VG_TO_DELETE_VOLUMES") + return pb2.Capability( + volume_group=pb2.Capability.VolumeGroup(type=capability_enum_value)) + def Probe(self, request, context): context.set_code(grpc.StatusCode.OK) return pb2.ProbeResponse() diff --git a/controllers/servers/csi/main.py b/controllers/servers/csi/main.py index 8d0bced8d..30e2b0935 100644 --- a/controllers/servers/csi/main.py +++ b/controllers/servers/csi/main.py @@ -9,7 +9,7 @@ from controllers.common.csi_logger import set_log_level from controllers.common.settings import CSI_CONTROLLER_SERVER_WORKERS from controllers.servers.csi.controller_server.csi_controller_server import CSIControllerServicer -from controllers.servers.csi.controller_server.volume_group_server import VolumeGroupControllerServicer +from controllers.servers.csi.common_servers.volume_group_server import VolumeGroupControllerServicer from controllers.servers.csi.csi_addons_server.fence_controller_servicer import FenceControllerServicer from controllers.servers.csi.csi_addons_server.identity_controller_servicer import IdentityControllerServicer from controllers.servers.csi.csi_addons_server.replication_controller_servicer import ReplicationControllerServicer @@ -57,9 +57,11 @@ def _add_csi_addons_servicers(csi_addons_server): replication_servicer = ReplicationControllerServicer() identity_servicer = IdentityControllerServicer() fence_servicer = FenceControllerServicer() + volume_group_servicer = VolumeGroupControllerServicer() replication_pb2_grpc.add_ControllerServicer_to_server(replication_servicer, csi_addons_server) identity_pb2_grpc.add_IdentityServicer_to_server(identity_servicer, csi_addons_server) fence_pb2_grpc.add_FenceControllerServicer_to_server(fence_servicer, csi_addons_server) + volumegroup_pb2_grpc.add_ControllerServicer_to_server(volume_group_servicer, csi_addons_server) return csi_addons_server diff --git a/controllers/tests/controller_server/controller_server/volume_group_server_test.py b/controllers/tests/controller_server/controller_server/volume_group_server_test.py index 16351425e..925ee4019 100644 --- a/controllers/tests/controller_server/controller_server/volume_group_server_test.py +++ b/controllers/tests/controller_server/controller_server/volume_group_server_test.py @@ -7,7 +7,7 @@ from controllers.array_action import errors as array_errors from controllers.servers import settings as servers_settings -from controllers.servers.csi.controller_server.volume_group_server import VolumeGroupControllerServicer +from controllers.servers.csi.common_servers.volume_group_server import VolumeGroupControllerServicer from controllers.tests import utils from controllers.tests.common.test_settings import SECRET, VOLUME_GROUP_NAME, NAME_PREFIX, REQUEST_VOLUME_GROUP_ID, \ VOLUME_GROUP_UID, REQUEST_VOLUME_ID, VOLUME_UID, REQUEST_REAL_VOLUME_ID, REAL_NGUID @@ -15,7 +15,7 @@ from controllers.tests.controller_server.controller_server.csi_controller_server_test import CommonControllerTest from controllers.tests.utils import ProtoBufMock -VG_CONTROLLER_SERVER_PATH = "controllers.servers.csi.controller_server.volume_group_server" +VG_CONTROLLER_SERVER_PATH = "controllers.servers.csi.common_servers.volume_group_server" class BaseVgControllerSetUp(unittest.TestCase):