2020-04-23 13:52:01 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
|
|
from concurrent import futures
|
|
|
|
|
|
|
|
import click
|
|
|
|
import grpc
|
|
|
|
|
|
|
|
import rawfile_servicer
|
2020-05-29 14:50:03 +00:00
|
|
|
from consts import CONFIG
|
2020-04-23 13:52:01 +00:00
|
|
|
from csi import csi_pb2_grpc
|
2020-04-25 19:39:16 +00:00
|
|
|
from metrics import expose_metrics
|
2020-07-16 15:24:04 +00:00
|
|
|
from rawfile_util import migrate_all_volume_schemas
|
2020-04-23 13:52:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
@click.group()
|
2020-05-29 14:50:03 +00:00
|
|
|
@click.option("--image-repository", envvar="IMAGE_REPOSITORY")
|
|
|
|
@click.option("--image-tag", envvar="IMAGE_TAG")
|
|
|
|
def cli(image_repository, image_tag):
|
|
|
|
CONFIG["image_repository"] = image_repository
|
|
|
|
CONFIG["image_tag"] = image_tag
|
2020-04-23 13:52:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
@click.option("--endpoint", envvar="CSI_ENDPOINT", default="0.0.0.0:5000")
|
|
|
|
@click.option("--nodeid", envvar="NODE_ID")
|
2020-04-25 19:39:16 +00:00
|
|
|
@click.option("--enable-metrics/--disable-metrics", default=True)
|
|
|
|
def csi_driver(endpoint, nodeid, enable_metrics):
|
2020-07-16 15:24:04 +00:00
|
|
|
migrate_all_volume_schemas()
|
2020-04-25 19:39:16 +00:00
|
|
|
if enable_metrics:
|
|
|
|
expose_metrics()
|
2020-04-23 13:52:01 +00:00
|
|
|
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
|
|
|
|
csi_pb2_grpc.add_IdentityServicer_to_server(
|
|
|
|
rawfile_servicer.RawFileIdentityServicer(), server
|
|
|
|
)
|
|
|
|
csi_pb2_grpc.add_NodeServicer_to_server(
|
|
|
|
rawfile_servicer.RawFileNodeServicer(node_name=nodeid), server
|
|
|
|
)
|
|
|
|
csi_pb2_grpc.add_ControllerServicer_to_server(
|
|
|
|
rawfile_servicer.RawFileControllerServicer(), server
|
|
|
|
)
|
|
|
|
server.add_insecure_port(endpoint)
|
|
|
|
server.start()
|
|
|
|
server.wait_for_termination()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
logging.basicConfig()
|
|
|
|
cli()
|