Commit 1a402455 authored by Mohamad Rahhal's avatar Mohamad Rahhal
Browse files

Logical Resources component :

- Added Add Device and GetDatabase methods
- Microservice up runnin and tested using unitary test
parent ee1b4511
Loading
Loading
Loading
Loading
+99 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 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: logical-resourcesservice
spec:
  selector:
    matchLabels:
      app: logical-resourcesservice
  #replicas: 1
  template:
    metadata:
      labels:
        app: logical-resourcesservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: server
          image: labs.etsi.org:5050/tfs/controller/logical_resources:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 30230
            - containerPort: 9192
          env:
            - name: LOG_LEVEL
              value: "INFO"
          startupProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:30230"]
            failureThreshold: 30
            periodSeconds: 1
          readinessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:30230"]
          livenessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:30230"]
          resources:
            requests:
              cpu: 250m
              memory: 128Mi
            limits:
              cpu: 1000m
              memory: 1024Mi
---
apiVersion: v1
kind: Service
metadata:
  name: logical-resourcesservice
  labels:
    app: logical-resourcesservice
spec:
  type: ClusterIP
  selector:
    app: logical-resourcesservice
  ports:
    - name: grpc
      protocol: TCP
      port: 30230
      targetPort: 30230
    - name: metrics
      protocol: TCP
      port: 9192
      targetPort: 9192
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: logical-resourcesservice-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: logical-resourcesservice
  minReplicas: 1
  maxReplicas: 20
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 80
  #behavior:
  #  scaleDown:
  #    stabilizationWindowSeconds: 30
+2 −2
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp service nbi webui"
export TFS_COMPONENTS="context device pathcomp service nbi webui logical_resources"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
@@ -143,7 +143,7 @@ export CRDB_PASSWORD="tfs123"
export CRDB_DEPLOY_MODE="single"

# Disable flag for dropping database, if it exists.
export CRDB_DROP_DATABASE_IF_EXISTS=""
export CRDB_DROP_DATABASE_IF_EXISTS="YES"

# Disable flag for re-deploying CockroachDB from scratch.
export CRDB_REDEPLOY=""
+45 −0
Original line number Diff line number Diff line
// Copyright 2022-2025 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 logical_resources;

service LogicalResources{  
  rpc AddDevice (DeviceConfig) returns (Response) {}
  rpc DeleteDevice (DeviceId) returns (Response) {}
  rpc GetDeviceConfig (DeviceId) returns (DeviceConfig) {} 
  rpc GetDatabase (Empty) returns (Database) {} } 

message Empty {}
message DeviceConfig {
string device_uuid = 1;
string endpoint_uuid = 2;
string ip_address = 3;
uint32 vlan_tag = 4;
string mac_address = 5;
uint32 asn=6;
string router_id = 7; }

message DeviceId {
    string device_uuid = 1;} 

message Response {
    bool success = 1;
    string message = 2;}

message Database {
    map<string, DeviceEndpoints> devices = 1;}

message DeviceEndpoints {
    map<string, DeviceConfig> endpoints = 1;}
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ class ServiceNameEnum(Enum):
    QOSPROFILE             = 'qos-profile'
    OSMCLIENT              = 'osm-client'
    PLUGGABLES             = 'dscm-pluggable'
    LogicalResource        = 'logical-resource'

    # Used for test and debugging only
    DLT_GATEWAY    = 'dltgateway'
@@ -119,6 +120,7 @@ DEFAULT_SERVICE_GRPC_PORTS = {
    ServiceNameEnum.AUTOMATION             .value : 30200,
    ServiceNameEnum.OSMCLIENT              .value : 30210,
    ServiceNameEnum.PLUGGABLES             .value : 30220,
    ServiceNameEnum.LogicalResource        .value : 30230,

    # Used for test and debugging only
    ServiceNameEnum.DLT_GATEWAY   .value : 50051,
+14 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 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