|
@@ -1,9 +1,11 @@
|
|
|
+import json
|
|
|
from concurrent import futures
|
|
|
|
|
|
import grpc
|
|
|
+import pydash
|
|
|
|
|
|
-from ll_sdk.config_api import ConfigApiClient
|
|
|
import llnw_pb2_grpc
|
|
|
+from ll_sdk.config_api import ConfigApiClient
|
|
|
from llnw_pb2 import *
|
|
|
|
|
|
|
|
@@ -13,23 +15,23 @@ def get_cl(base):
|
|
|
|
|
|
def delivery_to_grpc(delivery):
|
|
|
return DeliveryEntity(
|
|
|
- uuid=delivery['uuid'],
|
|
|
- isEnabled=delivery['isEnabled'],
|
|
|
- shortname=delivery['shortname'],
|
|
|
- status=delivery['status']['state'],
|
|
|
- sourceHostname=delivery['body']['sourceHostname'],
|
|
|
- publishedHostname=delivery['body']['publishedHostname'],
|
|
|
- sourceUrlPath=delivery['body']['sourceUrlPath'],
|
|
|
- publishedUrlPath=delivery['body']['publishedUrlPath'],
|
|
|
+ uuid=delivery.get('uuid', None),
|
|
|
+ isEnabled=delivery.get('isEnabled', None),
|
|
|
+ shortname=delivery.get('shortname', None),
|
|
|
+ status=pydash.objects.get(delivery, "status.state"),
|
|
|
+ sourceHostname=pydash.objects.get(delivery, "body.sourceHostname"),
|
|
|
+ publishedHostname=pydash.objects.get(delivery, "body.publishedHostname"),
|
|
|
+ sourceUrlPath=pydash.objects.get(delivery, "body.sourceUrlPath"),
|
|
|
+ publishedUrlPath=pydash.objects.get(delivery, "body.publishedUrlPath"),
|
|
|
protocolSets=[ProtocolSet(
|
|
|
- sourceProtocol=protocolSets['sourceProtocol'],
|
|
|
- publishedProtocol=protocolSets['publishedProtocol'],
|
|
|
+ sourceProtocol=protocolSets.get('sourceProtocol', None),
|
|
|
+ publishedProtocol=protocolSets.get('publishedProtocol', None),
|
|
|
options=[ProtocolSetOptions(
|
|
|
- name=options['name'],
|
|
|
- parameters=options['parameters'],
|
|
|
- source=options['source'],
|
|
|
- ) for options in protocolSets['options']]
|
|
|
- ) for protocolSets in delivery['body']['protocolSets']]
|
|
|
+ name=options.get('name', None),
|
|
|
+ parameters=[str(param) for param in options.get('parameters', None)],
|
|
|
+ source=options.get('source', None),
|
|
|
+ ) for options in protocolSets.get('options', [])]
|
|
|
+ ) for protocolSets in pydash.objects.get(delivery, 'body.protocolSets', [])]
|
|
|
)
|
|
|
|
|
|
|
|
@@ -48,7 +50,9 @@ def delivery_from_grpc(delivery_entity: DeliveryEntity):
|
|
|
"options": [
|
|
|
{
|
|
|
"name": po.name,
|
|
|
- "parameters": po.parameters,
|
|
|
+ "parameters": [
|
|
|
+ para if po.name != "refresh_absmin" and po.name != "refresh_absmax" else int(para)
|
|
|
+ for para in po.parameters],
|
|
|
"source": po.source
|
|
|
} for po in protocol.options
|
|
|
],
|
|
@@ -80,11 +84,13 @@ class DeliveryServiceServicer(llnw_pb2_grpc.DeliveryServiceServicer):
|
|
|
|
|
|
def ValidateDelivery(self, request, context):
|
|
|
delivery_config = delivery_from_grpc(request.delivery)
|
|
|
+ del delivery_config['uuid']
|
|
|
res = get_cl(request.base).validate_delivery_service_instance(delivery_config).json()
|
|
|
return delivery_to_grpc(res)
|
|
|
|
|
|
def CreateDelivery(self, request, context):
|
|
|
delivery_config = delivery_from_grpc(request.delivery)
|
|
|
+ del delivery_config['uuid']
|
|
|
res = get_cl(request.base).create_delivery_service_instance(delivery_config).json()
|
|
|
return delivery_to_grpc(res)
|
|
|
|
|
@@ -94,7 +100,7 @@ class DeliveryServiceServicer(llnw_pb2_grpc.DeliveryServiceServicer):
|
|
|
|
|
|
def UpdateDelivery(self, request, context):
|
|
|
delivery_config = delivery_from_grpc(request.delivery)
|
|
|
- res = get_cl(request.base).update_delivery_service_instance(delivery_config.uuid. delivery_config).json()
|
|
|
+ res = get_cl(request.base).update_delivery_service_instance(delivery_config['uuid'], delivery_config).json()
|
|
|
return delivery_to_grpc(res)
|
|
|
|
|
|
def DeleteDelivery(self, request, context):
|