def get_volume_capability(volume, read_only): if volume.fs_type == "raw": return pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode(mode=access_mode(volume.mode)), block=pb.VolumeCapability.BlockVolume(), ) mount_flags = ["ro"] if read_only else [] return pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode(mode=access_mode(volume.mode)), mount=pb.VolumeCapability.MountVolume( fs_type=volume.fs_type, mount_flags=mount_flags ), )
def attempt_to_stage_volume_with_missing_mount( get_published_nexus, csi_instance, staging_target_path, io_timeout ): nexus = get_published_nexus with pytest.raises(grpc.RpcError) as error: csi_instance.node.NodeStageVolume( pb.NodeStageVolumeRequest( volume_id=nexus.uuid, publish_context={"uri": nexus.uri, "ioTimeout": io_timeout}, staging_target_path=staging_target_path, volume_capability=pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode( mode=pb.VolumeCapability.AccessMode.Mode.MULTI_NODE_SINGLE_WRITER ), ), secrets={}, volume_context={}, ) ) assert error.value.code() == grpc.StatusCode.INVALID_ARGUMENT
def attempt_to_stage_volume_with_missing_access_mode( get_published_nexus, csi_instance, staging_target_path, io_timeout ): nexus = get_published_nexus with pytest.raises(grpc.RpcError) as error: csi_instance.node.NodeStageVolume( pb.NodeStageVolumeRequest( volume_id=nexus.uuid, publish_context={"uri": nexus.uri, "ioTimeout": io_timeout}, staging_target_path=staging_target_path, volume_capability=pb.VolumeCapability( mount=pb.VolumeCapability.MountVolume( fs_type="ext4", mount_flags=[] ) ), secrets={}, volume_context={}, ) ) assert error.value.code() == grpc.StatusCode.INVALID_ARGUMENT
def publish_mount_volume_capability(access_mode, fs_type, publish_mount_flags): yield pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode(mode=access_mode), mount=pb.VolumeCapability.MountVolume(fs_type=fs_type, mount_flags=publish_mount_flags), )
def stage_mount_volume_capability(access_mode, fs_type): yield pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode(mode=access_mode), mount=pb.VolumeCapability.MountVolume(fs_type=fs_type, mount_flags=[]), )
def block_volume_capability(access_mode): yield pb.VolumeCapability( access_mode=pb.VolumeCapability.AccessMode(mode=access_mode), block=pb.VolumeCapability.BlockVolume(), )