Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import grpc, logging
from prometheus_client import Counter, Histogram
from common.database.api.Database import Database
from common.exceptions.ServiceException import ServiceException
from compute.proto.compute_pb2_grpc import ComputeServiceServicer
from compute.proto.context_pb2 import AuthenticationResult, Empty, TeraFlowController
from compute.proto.service_pb2 import Service, ServiceId, ServiceIdList, ServiceState
LOGGER = logging.getLogger(__name__)
CHECKCREDENTIALS_COUNTER_STARTED = Counter(
'compute_checkcredentials_counter_started',
'Compute:CheckCredentials counter of requests started')
CHECKCREDENTIALS_COUNTER_COMPLETED = Counter(
'compute_checkcredentials_counter_completed',
'Compute:CheckCredentials counter of requests completed')
CHECKCREDENTIALS_COUNTER_FAILED = Counter(
'compute_checkcredentials_counter_failed',
'Compute:CheckCredentials counter of requests failed')
CHECKCREDENTIALS_HISTOGRAM_DURATION = Histogram(
'compute_checkcredentials_histogram_duration',
'Compute:CheckCredentials histogram of request duration')
GETCONNECTIVITYSERVICESTATUS_COUNTER_STARTED = Counter(
'compute_getconnectivityservicestatus_counter_started',
'Compute:GetConnectivityServiceStatus counter of requests started')
GETCONNECTIVITYSERVICESTATUS_COUNTER_COMPLETED = Counter(
'compute_getconnectivityservicestatus_counter_completed',
'Compute:GetConnectivityServiceStatus counter of requests completed')
GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED = Counter(
'compute_getconnectivityservicestatus_counter_failed',
'Compute:GetConnectivityServiceStatus counter of requests failed')
GETCONNECTIVITYSERVICESTATUS_HISTOGRAM_DURATION = Histogram(
'compute_getconnectivityservicestatus_histogram_duration',
'Compute:GetConnectivityServiceStatus histogram of request duration')
CREATECONNECTIVITYSERVICE_COUNTER_STARTED = Counter(
'compute_createconnectivityservice_counter_started',
'Compute:CreateConnectivityService counter of requests started' )
CREATECONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter(
'compute_createconnectivityservice_counter_completed',
'Compute:CreateConnectivityService counter of requests completed')
CREATECONNECTIVITYSERVICE_COUNTER_FAILED = Counter(
'compute_createconnectivityservice_counter_failed',
'Compute:CreateConnectivityService counter of requests failed')
CREATECONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram(
'compute_createconnectivityservice_histogram_duration',
'Compute:CreateConnectivityService histogram of request duration')
EDITCONNECTIVITYSERVICE_COUNTER_STARTED = Counter(
'compute_editconnectivityservice_counter_started',
'Compute:EditConnectivityService counter of requests started')
EDITCONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter(
'compute_editconnectivityservice_counter_completed',
'Compute:EditConnectivityService counter of requests completed')
EDITCONNECTIVITYSERVICE_COUNTER_FAILED = Counter(
'compute_editconnectivityservice_counter_failed',
'Compute:EditConnectivityService counter of requests failed')
EDITCONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram(
'compute_editconnectivityservice_histogram_duration',
'Compute:EditConnectivityService histogram of request duration')
DELETECONNECTIVITYSERVICE_COUNTER_STARTED = Counter(
'compute_deleteconnectivityservice_counter_started',
'Compute:DeleteConnectivityService counter of requests started')
DELETECONNECTIVITYSERVICE_COUNTER_COMPLETED = Counter(
'compute_deleteconnectivityservice_counter_completed',
'Compute:DeleteConnectivityService counter of requests completed')
DELETECONNECTIVITYSERVICE_COUNTER_FAILED = Counter(
'compute_deleteconnectivityservice_counter_failed',
'Compute:DeleteConnectivityService counter of requests failed')
DELETECONNECTIVITYSERVICE_HISTOGRAM_DURATION = Histogram(
'compute_deleteconnectivityservice_histogram_duration',
'Compute:DeleteConnectivityService histogram of request duration')
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_STARTED = Counter(
'compute_getallactiveconnectivityservices_counter_started',
'Compute:GetAllActiveConnectivityServices counter of requests started')
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_COMPLETED = Counter(
'compute_getallactiveconnectivityservices_counter_completed',
'Compute:GetAllActiveConnectivityServices counter of requests completed')
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED = Counter(
'compute_getallactiveconnectivityservices_counter_failed',
'Compute:GetAllActiveConnectivityServices counter of requests failed')
GETALLACTIVECONNECTIVITYSERVICES_HISTOGRAM_DURATION = Histogram(
'compute_getallactiveconnectivityservices_histogram_duration',
'Compute:GetAllActiveConnectivityServices histogram of request duration')
CLEARALLCONNECTIVITYSERVICES_COUNTER_STARTED = Counter(
'compute_clearallconnectivityservices_counter_started',
'Compute:ClearAllConnectivityServices counter of requests started')
CLEARALLCONNECTIVITYSERVICES_COUNTER_COMPLETED = Counter(
'compute_clearallconnectivityservices_counter_completed',
'Compute:ClearAllConnectivityServices counter of requests completed')
CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED = Counter(
'compute_clearallconnectivityservices_counter_failed',
'Compute:ClearAllConnectivityServices counter of requests failed')
CLEARALLCONNECTIVITYSERVICES_HISTOGRAM_DURATION = Histogram(
'compute_clearallconnectivityservices_histogram_duration',
'Compute:ClearAllConnectivityServices histogram of request duration')
class ComputeServiceServicerImpl(ComputeServiceServicer):
def __init__(self):
LOGGER.info('Creating Servicer...')
LOGGER.info('Servicer Created')
@CHECKCREDENTIALS_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def CheckCredentials(
self, request : TeraFlowController, grpc_context : grpc.ServicerContext) -> AuthenticationResult:
CHECKCREDENTIALS_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('CheckCredentials request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = AuthenticationResult()
Lluis Gifre Renom
committed
LOGGER.info('CheckCredentials reply: {}'.format(str(reply)))
CHECKCREDENTIALS_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('CheckCredentials exception')
CHECKCREDENTIALS_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('CheckCredentials exception')
CHECKCREDENTIALS_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@GETCONNECTIVITYSERVICESTATUS_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def GetConnectivityServiceStatus(
self, request : ServiceId, grpc_context : grpc.ServicerContext) -> ServiceState:
GETCONNECTIVITYSERVICESTATUS_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('GetConnectivityServiceStatus request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = ServiceState()
Lluis Gifre Renom
committed
LOGGER.info('GetConnectivityServiceStatus reply: {}'.format(str(reply)))
GETCONNECTIVITYSERVICESTATUS_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('GetConnectivityServiceStatus exception')
GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('GetConnectivityServiceStatus exception')
GETCONNECTIVITYSERVICESTATUS_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@CREATECONNECTIVITYSERVICE_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def CreateConnectivityService(
self, request : Service, grpc_context : grpc.ServicerContext) -> ServiceId:
CREATECONNECTIVITYSERVICE_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('CreateConnectivityService request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = ServiceId()
Lluis Gifre Renom
committed
LOGGER.info('CreateConnectivityService reply: {}'.format(str(reply)))
CREATECONNECTIVITYSERVICE_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('CreateConnectivityService exception')
CREATECONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('CreateConnectivityService exception')
CREATECONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@EDITCONNECTIVITYSERVICE_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def EditConnectivityService(
self, request : Service, grpc_context : grpc.ServicerContext) -> ServiceId:
EDITCONNECTIVITYSERVICE_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('EditConnectivityService request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = ServiceId()
Lluis Gifre Renom
committed
LOGGER.info('EditConnectivityService reply: {}'.format(str(reply)))
EDITCONNECTIVITYSERVICE_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('EditConnectivityService exception')
EDITCONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('EditConnectivityService exception')
EDITCONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@DELETECONNECTIVITYSERVICE_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def DeleteConnectivityService(
self, request : Service, grpc_context : grpc.ServicerContext) -> Empty:
DELETECONNECTIVITYSERVICE_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('DeleteConnectivityService request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = Empty()
Lluis Gifre Renom
committed
LOGGER.info('DeleteConnectivityService reply: {}'.format(str(reply)))
DELETECONNECTIVITYSERVICE_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('DeleteConnectivityService exception')
DELETECONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('DeleteConnectivityService exception')
DELETECONNECTIVITYSERVICE_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@GETALLACTIVECONNECTIVITYSERVICES_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def GetAllActiveConnectivityServices(
self, request : Empty, grpc_context : grpc.ServicerContext) -> ServiceIdList:
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('GetAllActiveConnectivityServices request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = ServiceIdList()
Lluis Gifre Renom
committed
LOGGER.info('GetAllActiveConnectivityServices reply: {}'.format(str(reply)))
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('GetAllActiveConnectivityServices exception')
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('GetAllActiveConnectivityServices exception')
GETALLACTIVECONNECTIVITYSERVICES_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))
@CLEARALLCONNECTIVITYSERVICES_HISTOGRAM_DURATION.time()
Lluis Gifre Renom
committed
def ClearAllConnectivityServices(
self, request : Empty, grpc_context : grpc.ServicerContext) -> Empty:
CLEARALLCONNECTIVITYSERVICES_COUNTER_STARTED.inc()
try:
Lluis Gifre Renom
committed
LOGGER.info('ClearAllConnectivityServices request: {}'.format(str(request)))
LOGGER.warning('NOT IMPLEMENTED')
# ----- Validate request data and pre-conditions -----------------------------------------------------------
# ----- Retrieve data from the database --------------------------------------------------------------------
# ----- Compose reply --------------------------------------------------------------------------------------
reply = Empty()
Lluis Gifre Renom
committed
LOGGER.info('ClearAllConnectivityServices reply: {}'.format(str(reply)))
CLEARALLCONNECTIVITYSERVICES_COUNTER_COMPLETED.inc()
return reply
except ServiceException as e: # pragma: no cover (ServiceException not thrown)
Lluis Gifre Renom
committed
LOGGER.exception('ClearAllConnectivityServices exception')
CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED.inc()
grpc_context.abort(e.code, e.details)
except Exception as e: # pragma: no cover
Lluis Gifre Renom
committed
LOGGER.exception('ClearAllConnectivityServices exception')
CLEARALLCONNECTIVITYSERVICES_COUNTER_FAILED.inc()
grpc_context.abort(grpc.StatusCode.INTERNAL, str(e))