Loading deploy/tfs.sh +15 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,21 @@ kubectl create secret generic qdb-data --namespace ${TFS_K8S_NAMESPACE} --type=' --from-literal=METRICSDB_PASSWORD=${QDB_PASSWORD} printf "\n" # Check if "dlt" is in the list of components if [[ " ${TFS_COMPONENTS[@]} " =~ " dlt " ]]; then echo "Create secret for HLF keystore" kubectl create secret generic dlt-keystone --namespace ${TFS_K8S_NAMESPACE} --from-file=keystore=${KEY_DIRECTORY_PATH} printf "\n" echo "Create secret for HLF signcerts" kubectl create secret generic dlt-signcerts --namespace ${TFS_K8S_NAMESPACE} --from-file=signcerts.pem=${CERT_DIRECTORY_PATH} printf "\n" echo "Create secret for HLF ca.crt" kubectl create secret generic dlt-ca-crt --namespace ${TFS_K8S_NAMESPACE} --from-file=ca.crt=${TLS_CERT_PATH} printf "\n" fi echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_runtime_env_vars.sh echo "# Environment variables for TeraFlowSDN deployment" > $ENV_VARS_SCRIPT Loading manifests/dltservice.yaml +61 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. apiVersion: v1 kind: ConfigMap metadata: name: dlt-config data: CHANNEL_NAME: "tfs_channel" # Change according to your blockchain configuration CHAINCODE_NAME: "tfs_dlt" # Change according to your blockchain configuration MSP_ID: "ETSI" # Change according to your blockchain configuration PEER_ENDPOINT: "127.0.0.1:7051" # Change according to your blockchain configuration PEER_HOST_ALIAS: "peer0.org1.tfs.etsi.org" # Change according to your blockchain configuration KEY_DIRECTORY_PATH: "/etc/hyperledger/fabric-keystore/keystore" CERT_DIRECTORY_PATH: "/etc/hyperledger/fabric-signcerts/signcerts.pem" TLS_CERT_PATH: "/etc/hyperledger/fabric-ca-crt/ca.crt" --- apiVersion: apps/v1 kind: Deployment metadata: Loading Loading @@ -78,6 +93,52 @@ spec: limits: cpu: 700m memory: 1024Mi volumeMounts: - name: keystore mountPath: /etc/hyperledger/fabric-keystore readOnly: true - name: signcerts mountPath: /etc/hyperledger/fabric-signcerts readOnly: true - name: ca-crt mountPath: /etc/hyperledger/fabric-ca-crt readOnly: true envFrom: - configMapRef: name: dlt-config env: - name: KEY_DIRECTORY_PATH value: "/etc/hyperledger/fabric-keystore/keystore" - name: CERT_DIRECTORY_PATH value: "/etc/hyperledger/fabric-signcerts/signcerts.pem" - name: TLS_CERT_PATH value: "/etc/hyperledger/fabric-ca-crt/ca.crt" volumes: - name: keystore secret: secretName: dlt-keystone - name: signcerts secret: secretName: dlt-signcerts - name: ca-crt secret: secretName: dlt-ca-crt --- apiVersion: v1 kind: Service metadata: name: gatewayservice spec: selector: app: dltservice ports: - protocol: TCP port: 50051 targetPort: 50051 nodePort: 32001 type: NodePort --- apiVersion: v1 kind: Service Loading manifests/interdomainservice.yaml +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ spec: value: "INFO" - name: TOPOLOGY_ABSTRACTOR value: "DISABLE" - name: DLT_INTEGRATION value: "DISABLE" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10010"] Loading my_deploy.sh +8 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,14 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_gene # Uncomment to activate E2E Orchestrator #export TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator" # Uncomment to activate DLT and Interdomain #export TFS_COMPONENTS="${TFS_COMPONENTS} interdomain dlt" #if [[ "$TFS_COMPONENTS" == *"dlt"* ]]; then # export KEY_DIRECTORY_PATH="src/dlt/gateway/keys/priv_sk" # export CERT_DIRECTORY_PATH="src/dlt/gateway/keys/cert.pem" # export TLS_CERT_PATH="src/dlt/gateway/keys/ca.crt" #fi # Set the tag you want to use for your images. export TFS_IMAGE_TAG="dev" Loading src/common/method_wrappers/Decorator.py +32 −0 Original line number Diff line number Diff line Loading @@ -235,3 +235,35 @@ def safe_and_metered_rpc_method(metrics_pool : MetricsPool, logger : logging.Log grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) return inner_wrapper return outer_wrapper def safe_and_metered_rpc_method_async(metrics_pool: MetricsPool, logger: logging.Logger): def outer_wrapper(func): method_name = func.__name__ metrics = metrics_pool.get_metrics(method_name) histogram_duration, counter_started, counter_completed, counter_failed = metrics async def inner_wrapper(self, request, grpc_context: grpc.aio.ServicerContext): counter_started.inc() try: logger.debug('{:s} request: {:s}'.format(method_name, grpc_message_to_json_string(request))) reply = await func(self, request, grpc_context) logger.debug('{:s} reply: {:s}'.format(method_name, grpc_message_to_json_string(reply))) counter_completed.inc() return reply except ServiceException as e: # pragma: no cover (ServiceException not thrown) if e.code not in [grpc.StatusCode.NOT_FOUND, grpc.StatusCode.ALREADY_EXISTS]: # Assume not found or already exists is just a condition, not an error logger.exception('{:s} exception'.format(method_name)) counter_failed.inc() else: counter_completed.inc() await grpc_context.abort(e.code, e.details) except Exception as e: # pragma: no cover, pylint: disable=broad-except logger.exception('{:s} exception'.format(method_name)) counter_failed.inc() await grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) return inner_wrapper return outer_wrapper Loading
deploy/tfs.sh +15 −0 Original line number Diff line number Diff line Loading @@ -229,6 +229,21 @@ kubectl create secret generic qdb-data --namespace ${TFS_K8S_NAMESPACE} --type=' --from-literal=METRICSDB_PASSWORD=${QDB_PASSWORD} printf "\n" # Check if "dlt" is in the list of components if [[ " ${TFS_COMPONENTS[@]} " =~ " dlt " ]]; then echo "Create secret for HLF keystore" kubectl create secret generic dlt-keystone --namespace ${TFS_K8S_NAMESPACE} --from-file=keystore=${KEY_DIRECTORY_PATH} printf "\n" echo "Create secret for HLF signcerts" kubectl create secret generic dlt-signcerts --namespace ${TFS_K8S_NAMESPACE} --from-file=signcerts.pem=${CERT_DIRECTORY_PATH} printf "\n" echo "Create secret for HLF ca.crt" kubectl create secret generic dlt-ca-crt --namespace ${TFS_K8S_NAMESPACE} --from-file=ca.crt=${TLS_CERT_PATH} printf "\n" fi echo "Deploying components and collecting environment variables..." ENV_VARS_SCRIPT=tfs_runtime_env_vars.sh echo "# Environment variables for TeraFlowSDN deployment" > $ENV_VARS_SCRIPT Loading
manifests/dltservice.yaml +61 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. apiVersion: v1 kind: ConfigMap metadata: name: dlt-config data: CHANNEL_NAME: "tfs_channel" # Change according to your blockchain configuration CHAINCODE_NAME: "tfs_dlt" # Change according to your blockchain configuration MSP_ID: "ETSI" # Change according to your blockchain configuration PEER_ENDPOINT: "127.0.0.1:7051" # Change according to your blockchain configuration PEER_HOST_ALIAS: "peer0.org1.tfs.etsi.org" # Change according to your blockchain configuration KEY_DIRECTORY_PATH: "/etc/hyperledger/fabric-keystore/keystore" CERT_DIRECTORY_PATH: "/etc/hyperledger/fabric-signcerts/signcerts.pem" TLS_CERT_PATH: "/etc/hyperledger/fabric-ca-crt/ca.crt" --- apiVersion: apps/v1 kind: Deployment metadata: Loading Loading @@ -78,6 +93,52 @@ spec: limits: cpu: 700m memory: 1024Mi volumeMounts: - name: keystore mountPath: /etc/hyperledger/fabric-keystore readOnly: true - name: signcerts mountPath: /etc/hyperledger/fabric-signcerts readOnly: true - name: ca-crt mountPath: /etc/hyperledger/fabric-ca-crt readOnly: true envFrom: - configMapRef: name: dlt-config env: - name: KEY_DIRECTORY_PATH value: "/etc/hyperledger/fabric-keystore/keystore" - name: CERT_DIRECTORY_PATH value: "/etc/hyperledger/fabric-signcerts/signcerts.pem" - name: TLS_CERT_PATH value: "/etc/hyperledger/fabric-ca-crt/ca.crt" volumes: - name: keystore secret: secretName: dlt-keystone - name: signcerts secret: secretName: dlt-signcerts - name: ca-crt secret: secretName: dlt-ca-crt --- apiVersion: v1 kind: Service metadata: name: gatewayservice spec: selector: app: dltservice ports: - protocol: TCP port: 50051 targetPort: 50051 nodePort: 32001 type: NodePort --- apiVersion: v1 kind: Service Loading
manifests/interdomainservice.yaml +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ spec: value: "INFO" - name: TOPOLOGY_ABSTRACTOR value: "DISABLE" - name: DLT_INTEGRATION value: "DISABLE" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10010"] Loading
my_deploy.sh +8 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,14 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_gene # Uncomment to activate E2E Orchestrator #export TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator" # Uncomment to activate DLT and Interdomain #export TFS_COMPONENTS="${TFS_COMPONENTS} interdomain dlt" #if [[ "$TFS_COMPONENTS" == *"dlt"* ]]; then # export KEY_DIRECTORY_PATH="src/dlt/gateway/keys/priv_sk" # export CERT_DIRECTORY_PATH="src/dlt/gateway/keys/cert.pem" # export TLS_CERT_PATH="src/dlt/gateway/keys/ca.crt" #fi # Set the tag you want to use for your images. export TFS_IMAGE_TAG="dev" Loading
src/common/method_wrappers/Decorator.py +32 −0 Original line number Diff line number Diff line Loading @@ -235,3 +235,35 @@ def safe_and_metered_rpc_method(metrics_pool : MetricsPool, logger : logging.Log grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) return inner_wrapper return outer_wrapper def safe_and_metered_rpc_method_async(metrics_pool: MetricsPool, logger: logging.Logger): def outer_wrapper(func): method_name = func.__name__ metrics = metrics_pool.get_metrics(method_name) histogram_duration, counter_started, counter_completed, counter_failed = metrics async def inner_wrapper(self, request, grpc_context: grpc.aio.ServicerContext): counter_started.inc() try: logger.debug('{:s} request: {:s}'.format(method_name, grpc_message_to_json_string(request))) reply = await func(self, request, grpc_context) logger.debug('{:s} reply: {:s}'.format(method_name, grpc_message_to_json_string(reply))) counter_completed.inc() return reply except ServiceException as e: # pragma: no cover (ServiceException not thrown) if e.code not in [grpc.StatusCode.NOT_FOUND, grpc.StatusCode.ALREADY_EXISTS]: # Assume not found or already exists is just a condition, not an error logger.exception('{:s} exception'.format(method_name)) counter_failed.inc() else: counter_completed.inc() await grpc_context.abort(e.code, e.details) except Exception as e: # pragma: no cover, pylint: disable=broad-except logger.exception('{:s} exception'.format(method_name)) counter_failed.inc() await grpc_context.abort(grpc.StatusCode.INTERNAL, str(e)) return inner_wrapper return outer_wrapper