Commit d6d55efb authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/context-database-api' into 'develop'

Context service and Database API rework

See merge request teraflow-h2020/controller!25
parents 1d517d1b 0361abec
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -6,5 +6,4 @@ dependencies all:
    - kubectl version
    - kubectl get all
    - kubectl apply -f "manifests/prometheus.yaml"
    - kubectl apply -f "manifests/redis.yaml"
    - kubectl get all
+16 −2
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ spec:
  selector:
    matchLabels:
      app: contextservice
  replicas: 1
  template:
    metadata:
      labels:
@@ -13,6 +14,17 @@ spec:
    spec:
      terminationGracePeriodSeconds: 5
      containers:
      - name: redis
        image: redis:6.2
        ports:
        - containerPort: 6379
        resources:
          requests:
            cpu: 250m
            memory: 512Mi
          limits:
            cpu: 700m
            memory: 1024Mi
      - name: server
        image: registry.gitlab.com/teraflow-h2020/controller/context:latest
        imagePullPolicy: Always
@@ -20,12 +32,14 @@ spec:
        - containerPort: 1010
        - containerPort: 8080
        env:
        - name: DB_ENGINE
        - name: DB_BACKEND
          value: "redis"
        - name: REDIS_DATABASE_ID
          value: "0"
        - name: LOG_LEVEL
          value: "DEBUG"
          value: "INFO"
        - name: POPULATE_FAKE_DATA
          value: "true"
        readinessProbe:
          exec:
            command: ["/bin/grpc_health_probe", "-addr=:1010"]

manifests/redis.yaml

deleted100644 → 0
+0 −54
Original line number Diff line number Diff line
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
spec:
  selector:
    matchLabels:
      app: redis
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
        version: v1
    spec:
      containers:
      - name: redis
        image: redis:6.2
        ports:
        - containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
  name: redis
  labels:
    app: redis
spec:
  type: ClusterIP
  selector:
    app: redis
  ports:
  - name: redis
    protocol: TCP
    port: 6379
    targetPort: 6379
---
apiVersion: v1
kind: Service
metadata:
  name: redis-public
  labels:
    app: redis
spec:
  type: NodePort
  selector:
    app: redis
  ports:
  - name: redis
    protocol: TCP
    port: 6379
    targetPort: 6379
---
+246 −46
Original line number Diff line number Diff line
syntax = "proto3";
package context;


service ContextService {
  rpc GetTopology (Empty) returns (Topology) {}
  rpc ListContextIds   (Empty     ) returns (       ContextIdList ) {}
  rpc ListContexts     (Empty     ) returns (       ContextList   ) {}
  rpc GetContext       (ContextId ) returns (       Context       ) {}
  rpc SetContext       (Context   ) returns (       ContextId     ) {}
  rpc RemoveContext    (ContextId ) returns (       Empty         ) {}
  rpc GetContextEvents (Empty     ) returns (stream ContextEvent  ) {}

  rpc ListTopologyIds  (ContextId ) returns (       TopologyIdList) {}
  rpc ListTopologies   (ContextId ) returns (       TopologyList  ) {}
  rpc GetTopology      (TopologyId) returns (       Topology      ) {}
  rpc SetTopology      (Topology  ) returns (       TopologyId    ) {}
  rpc RemoveTopology   (TopologyId) returns (       Empty         ) {}
  rpc GetTopologyEvents(Empty     ) returns (stream TopologyEvent ) {}

  rpc ListDeviceIds    (Empty     ) returns (       DeviceIdList  ) {}
  rpc ListDevices      (Empty     ) returns (       DeviceList    ) {}
  rpc GetDevice        (DeviceId  ) returns (       Device        ) {}
  rpc SetDevice        (Device    ) returns (       DeviceId      ) {}
  rpc RemoveDevice     (DeviceId  ) returns (       Empty         ) {}
  rpc GetDeviceEvents  (Empty     ) returns (stream DeviceEvent   ) {}

  rpc ListLinkIds      (Empty     ) returns (       LinkIdList    ) {}
  rpc ListLinks        (Empty     ) returns (       LinkList      ) {}
  rpc GetLink          (LinkId    ) returns (       Link          ) {}
  rpc SetLink          (Link      ) returns (       LinkId        ) {}
  rpc RemoveLink       (LinkId    ) returns (       Empty         ) {}
  rpc GetLinkEvents    (Empty     ) returns (stream LinkEvent     ) {}

  rpc AddLink(Link) returns (LinkId) {}
  rpc DeleteLink(LinkId) returns (Empty) {}
  rpc ListServiceIds   (ContextId ) returns (       ServiceIdList ) {}
  rpc ListServices     (ContextId ) returns (       ServiceList   ) {}
  rpc GetService       (ServiceId ) returns (       Service       ) {}
  rpc SetService       (Service   ) returns (       ServiceId     ) {}
  rpc RemoveService    (ServiceId ) returns (       Empty         ) {}
  rpc GetServiceEvents (Empty     ) returns (stream ServiceEvent  ) {}
}

message Empty {
// ----- Generic -------------------------------------------------------------------------------------------------------
message Empty {}

message Uuid {
  string uuid = 1;
}

message Context {
  ContextId contextId= 1;
  Topology topo = 2;
  TeraFlowController ctl = 3;
enum EventTypeEnum {
  EVENTTYPE_UNDEFINED = 0;
  EVENTTYPE_CREATE = 1;
  EVENTTYPE_UPDATE = 2;
  EVENTTYPE_REMOVE = 3;
}

message Event {
  double timestamp = 1;
  EventTypeEnum event_type = 2;
}

// ----- Context -------------------------------------------------------------------------------------------------------
message ContextId {
  Uuid contextUuid = 1;
  Uuid context_uuid = 1;
}

message Topology {
  TopologyId topoId = 2;
  repeated Device device = 3;
  repeated Link link = 4; 
message Context {
  ContextId context_id = 1;
  repeated TopologyId topology_ids = 2;
  repeated ServiceId service_ids = 3;
  TeraFlowController controller = 4;
}

message Link {
  LinkId link_id = 1;
  repeated EndPointId endpointList = 2;
message ContextIdList {
  repeated ContextId context_ids = 1;
}

message ContextList {
  repeated Context contexts = 1;
}

message ContextEvent {
  Event event = 1;
  ContextId context_id = 2;
}


// ----- Topology ------------------------------------------------------------------------------------------------------
message TopologyId {
  ContextId contextId = 1;
  Uuid topoId = 2;
  ContextId context_id = 1;
  Uuid topology_uuid = 2;
}

message Constraint {
  string constraint_type = 1;
  string constraint_value = 2;
message Topology {
  TopologyId topology_id = 1;
  repeated DeviceId device_ids = 2;
  repeated LinkId link_ids = 3;
}

message TopologyIdList {
  repeated TopologyId topology_ids = 1;
}

message TopologyList {
  repeated Topology topologies = 1;
}

message TopologyEvent {
  Event event = 1;
  TopologyId topology_id = 2;
}


// ----- Device --------------------------------------------------------------------------------------------------------
message DeviceId {
  Uuid device_uuid = 1;
}

message Device {
  DeviceId device_id = 1;
  string device_type = 2;
  DeviceConfig device_config = 3;
  DeviceOperationalStatus devOperationalStatus = 4;
  repeated EndPoint endpointList = 5;  
  DeviceOperationalStatusEnum device_operational_status = 4;
  repeated DeviceDriverEnum device_drivers = 5;
  repeated EndPoint device_endpoints = 6;
}

message DeviceConfig {
  string device_config = 1;
  repeated ConfigRule config_rules = 1;
}

message EndPoint {
  EndPointId port_id = 1;
  string port_type = 2;
enum DeviceDriverEnum {
  DEVICEDRIVER_UNDEFINED = 0; // also used for emulated
  DEVICEDRIVER_OPENCONFIG = 1;
  DEVICEDRIVER_TRANSPORT_API = 2;
  DEVICEDRIVER_P4 = 3;
  DEVICEDRIVER_IETF_NETWORK_TOPOLOGY = 4;
  DEVICEDRIVER_ONF_TR_352 = 5;
}

message EndPointId {
  TopologyId topoId = 1;
  DeviceId dev_id = 2;
  Uuid port_id = 3;
enum DeviceOperationalStatusEnum {
  DEVICEOPERATIONALSTATUS_UNDEFINED = 0;
  DEVICEOPERATIONALSTATUS_DISABLED = 1;
  DEVICEOPERATIONALSTATUS_ENABLED = 2;
}

message DeviceId {
  Uuid device_id = 1;
message DeviceIdList {
  repeated DeviceId device_ids = 1;
}

message DeviceList {
  repeated Device devices = 1;
}

message DeviceEvent {
  Event event = 1;
  DeviceId device_id = 2;
}


// ----- Link ----------------------------------------------------------------------------------------------------------
message LinkId {
  Uuid link_id = 1;
  Uuid link_uuid = 1;
}

message Uuid {
  string uuid = 1;
message Link {
  LinkId link_id = 1;
  repeated EndPointId link_endpoint_ids = 2;
}

message LinkIdList {
  repeated LinkId link_ids = 1;
}

enum DeviceOperationalStatus {
  KEEP_STATUS = 0; // Do not change operational status of device (used in configure)
  DISABLED    = -1;
  ENABLED     = 1;
message LinkList {
  repeated Link links = 1;
}

message LinkEvent {
  Event event = 1;
  LinkId link_id = 2;
}


// ----- Service -------------------------------------------------------------------------------------------------------
message ServiceId {
  ContextId context_id = 1;
  Uuid service_uuid = 2;
}

message Service {
  ServiceId service_id = 1;
  ServiceTypeEnum service_type = 2;
  repeated EndPointId service_endpoint_ids = 3;
  repeated Constraint service_constraints = 4;
  ServiceStatus service_status = 5;
  ServiceConfig service_config = 6;
}

enum ServiceTypeEnum {
  SERVICETYPE_UNKNOWN = 0;
  SERVICETYPE_L3NM = 1;
  SERVICETYPE_L2NM = 2;
  SERVICETYPE_TAPI_CONNECTIVITY_SERVICE = 3;
}

enum ServiceStatusEnum {
  SERVICESTATUS_UNDEFINED = 0;
  SERVICESTATUS_PLANNED = 1;
  SERVICESTATUS_ACTIVE =  2;
  SERVICESTATUS_PENDING_REMOVAL = 3;
}

message ServiceStatus {
  ServiceStatusEnum service_status = 1;
}

message ServiceConfig {
  repeated ConfigRule config_rules = 1;
}

message ServiceIdList {
  repeated ServiceId service_ids = 1;
}

message ServiceList {
  repeated Service services = 1;
}

message ServiceEvent {
  Event event = 1;
  ServiceId service_id = 2;
}


// ----- Endpoint ------------------------------------------------------------------------------------------------------
message EndPointId {
  TopologyId topology_id = 1;
  DeviceId device_id = 2;
  Uuid endpoint_uuid = 3;
}

message EndPoint {
  EndPointId endpoint_id = 1;
  string endpoint_type = 2;
}


// ----- Configuration -------------------------------------------------------------------------------------------------
enum ConfigActionEnum {
  CONFIGACTION_UNDEFINED = 0;
  CONFIGACTION_SET = 1;
  CONFIGACTION_DELETE = 2;
}

message ConfigRule {
  ConfigActionEnum action = 1;
  string resource_key = 2;
  string resource_value = 3;
}


// ----- Constraint ----------------------------------------------------------------------------------------------------
message Constraint {
  string constraint_type = 1;
  string constraint_value = 2;
}


// ----- Connection ----------------------------------------------------------------------------------------------------
message ConnectionId {
  Uuid connection_uuid = 1;
}

message Connection {
  ConnectionId connection_id = 1;
  ServiceId related_service_id = 2;
  repeated EndPointId path = 3;
}

message ConnectionIdList {
  repeated ConnectionId connection_ids = 1;
}

message ConnectionList {
  repeated Connection connections = 1;
}


// ----- Miscellaneous -------------------------------------------------------------------------------------------------
message TeraFlowController {
  ContextId ctl_id = 1;
  string ipaddress = 2;
  ContextId context_id = 1;
  string ip_address = 2;
  uint32 port = 3;
}

message AuthenticationResult {
  ContextId ctl_id = 1;
  ContextId context_id = 1;
  bool authenticated = 2;
}

+4 −3
Original line number Diff line number Diff line
@@ -7,4 +7,5 @@ service DeviceService {
  rpc AddDevice       (context.Device  ) returns (context.DeviceId    ) {}
  rpc ConfigureDevice (context.Device  ) returns (context.DeviceId    ) {}
  rpc DeleteDevice    (context.DeviceId) returns (context.Empty       ) {}
  rpc GetInitialConfig(context.DeviceId) returns (context.DeviceConfig) {}
}
Loading