Commit 2a85e17a authored by Manuel Angel Jimenez Quesada's avatar Manuel Angel Jimenez Quesada
Browse files

Add osm_client microservice

	Implement new osm_client.proto
	Create logic to manage request provide by NBI microservice
		Including ServiceServicer implementation

ToDo: Automatic test with HTTP Mock
	Dockerfile
parent c2a65dc4
Loading
Loading
Loading
Loading
+75 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: osm_clientservice
spec:
  selector:
    matchLabels:
      app: osm_clientservice
  #replicas: 1
  template:
    metadata:
      labels:
        app: osm_clientservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: server
          image: labs.etsi.org:5050/tfs/controller/osm_client:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 30210
            - containerPort: 9192
          env:
            - name: OSM_ADDRESS
              value: "127.0.0.1"
            - name: LOG_LEVEL
              value: "INFO"
          readinessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:30210"]
          livenessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:30210"]
          resources:
            requests:
              cpu: 250m
              memory: 128Mi
            limits:
              cpu: 1000m
              memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
  name: osm_clientservice
  labels:
    app: osm_clientservice
spec:
  type: ClusterIP
  selector:
    app: osm_clientservice
  ports:
    - name: grpc
      protocol: TCP
      port: 30210
      targetPort: 30210
    - name: metrics
      protocol: TCP
      port: 9192
      targetPort: 
---
 No newline at end of file

proto/osm_client.proto

0 → 100644
+71 −0
Original line number Diff line number Diff line
// Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package osmClient;

import "context.proto";

service OsmService {
  rpc NsiCreate   (CreateRequest)   returns(CreateResponse) {}
  rpc NsiList     (context.Empty)   returns(NsiListResponse) {}
  rpc NsiGet      (GetRequest)      returns(GetResponse) {}
  rpc NsiDelete   (DeleteRequest)   returns(DeleteResponse) {}
}

message CreateRequest {
  string nst_name = 1;
  string nsi_name = 2;
  string config = 3;
  string ssh_key = 4;
  string account = 5;
}

//OSM library doesn't return nsi ID, just an exception
message CreateResponse {
  bool succeded = 1;
  string errormessage = 2;
}

message NsiListResponse {
  repeated string id = 1;
}

message GetRequest {
  string id = 1;
}

message GetResponse {
  NsiObject nsi = 1;
}

message NsiObject {
  string nst_name = 1;
  string nsi_name = 2;
  string description = 3;
  string VimAccountId = 4;
  string Netslice_Subnet_id = 5;
  string Netslice_vld_ip = 6;
}

message DeleteRequest {
  string id = 1;
}

//OSM library doesn't return nsi ID, just an exception
message DeleteResponse {
  bool succeded = 1;
  string errormessage = 2;
}
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ class ServiceNameEnum(Enum):
    ANALYTICS              = 'analytics'
    ANALYTICSBACKEND       = 'analytics-backend'
    QOSPROFILE             = 'qos-profile'
    OSMCLIENT              = 'osm-client'

    # Used for test and debugging only
    DLT_GATEWAY    = 'dltgateway'
@@ -112,6 +113,7 @@ DEFAULT_SERVICE_GRPC_PORTS = {
    ServiceNameEnum.ANALYTICS              .value : 30080,
    ServiceNameEnum.ANALYTICSBACKEND       .value : 30090,
    ServiceNameEnum.AUTOMATION             .value : 30200,
    ServiceNameEnum.OSMCLIENT              .value : 30210,

    # Used for test and debugging only
    ServiceNameEnum.DLT_GATEWAY   .value : 50051,
+20 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from common.Settings import get_setting

DEFAULT_OSM_ADDRESS = '127.0.0.1'
OSM_ADDRESS = get_setting('OSM_ADDRESS', DEFAULT_OSM_ADDRESS)
 
 
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading