diff --git a/manifests/computeservice.yaml b/manifests/computeservice.yaml index 7e40ef988bc7dcb77960b224dfe5626ee95cfdfb..378e34b9b4345a3a65f848dbd7a3b3e3753b8a05 100644 --- a/manifests/computeservice.yaml +++ b/manifests/computeservice.yaml @@ -20,6 +20,7 @@ spec: selector: matchLabels: app: computeservice + replicas: 1 template: metadata: labels: @@ -44,16 +45,18 @@ spec: command: ["/bin/grpc_health_probe", "-addr=:9090"] resources: requests: - cpu: 250m - memory: 512Mi + cpu: 50m + memory: 64Mi limits: - cpu: 700m - memory: 1024Mi + cpu: 500m + memory: 512Mi --- apiVersion: v1 kind: Service metadata: name: computeservice + labels: + app: computeservice spec: type: ClusterIP selector: diff --git a/manifests/webuiservice.yaml b/manifests/webuiservice.yaml index f25dbf6e501775d56f266699b1474429b42b2015..234075f738abd880a7c269cb07b72ad6c635d4c6 100644 --- a/manifests/webuiservice.yaml +++ b/manifests/webuiservice.yaml @@ -20,6 +20,7 @@ spec: selector: matchLabels: app: webuiservice + replicas: 1 template: metadata: labels: @@ -55,11 +56,11 @@ spec: timeoutSeconds: 1 resources: requests: - cpu: 100m - memory: 512Mi + cpu: 50m + memory: 64Mi limits: - cpu: 700m - memory: 1024Mi + cpu: 500m + memory: 512Mi - name: grafana image: grafana/grafana:8.5.11 imagePullPolicy: IfNotPresent @@ -92,16 +93,18 @@ spec: timeoutSeconds: 1 resources: requests: - cpu: 250m - memory: 750Mi + cpu: 150m + memory: 512Mi limits: - cpu: 700m + cpu: 500m memory: 1024Mi --- apiVersion: v1 kind: Service metadata: name: webuiservice + labels: + app: webuiservice spec: type: ClusterIP selector: diff --git a/src/context/service/database/Link.py b/src/context/service/database/Link.py index 8d195cb1d548368c4b1d55f70a3d728ee6fd052e..299827dbdde6f9961d55be5f69f4e359f4e876a7 100644 --- a/src/context/service/database/Link.py +++ b/src/context/service/database/Link.py @@ -64,13 +64,14 @@ def link_set(db_engine : Engine, request : Link) -> Tuple[Dict, bool]: topology_uuids : Set[str] = set() related_topologies : List[Dict] = list() link_endpoints_data : List[Dict] = list() - for endpoint_id in request.link_endpoint_ids: + for i,endpoint_id in enumerate(request.link_endpoint_ids): endpoint_topology_uuid, _, endpoint_uuid = endpoint_get_uuid( endpoint_id, allow_random=False) link_endpoints_data.append({ 'link_uuid' : link_uuid, 'endpoint_uuid': endpoint_uuid, + 'position' : i, }) if endpoint_topology_uuid not in topology_uuids: diff --git a/src/context/service/database/Service.py b/src/context/service/database/Service.py index a81a80c3c2398fed16842bcc3d8aa16342edb72b..fe12eaf8a011e2ae4861c64cdfac8c4b9c388731 100644 --- a/src/context/service/database/Service.py +++ b/src/context/service/database/Service.py @@ -91,6 +91,7 @@ def service_set(db_engine : Engine, request : Service) -> Tuple[Dict, bool]: service_endpoints_data.append({ 'service_uuid' : service_uuid, 'endpoint_uuid': endpoint_uuid, + 'position' : i, }) constraints = compose_constraints_data(request.service_constraints, now, service_uuid=service_uuid) diff --git a/src/context/service/database/Slice.py b/src/context/service/database/Slice.py index 1d6781d53f7c85d8cb878b1b38b0de65b4ef5726..724046bfae16ea8e75ba84b83ff52c1050242003 100644 --- a/src/context/service/database/Slice.py +++ b/src/context/service/database/Slice.py @@ -91,6 +91,7 @@ def slice_set(db_engine : Engine, request : Slice) -> Tuple[Dict, bool]: slice_endpoints_data.append({ 'slice_uuid' : slice_uuid, 'endpoint_uuid': endpoint_uuid, + 'position' : i, }) slice_services_data : List[Dict] = list() diff --git a/src/context/service/database/models/LinkModel.py b/src/context/service/database/models/LinkModel.py index ee591f5c8404cd7f0f6c97651b5f731a51c43303..e9fd9bc8742222e0934a76b6e0ffa4acb1b71f40 100644 --- a/src/context/service/database/models/LinkModel.py +++ b/src/context/service/database/models/LinkModel.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from sqlalchemy import Column, DateTime, ForeignKey, String +import operator +from sqlalchemy import CheckConstraint, Column, DateTime, ForeignKey, Integer, String from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from typing import Dict @@ -38,7 +39,7 @@ class LinkModel(_Base): 'name' : self.link_name, 'link_endpoint_ids': [ link_endpoint.endpoint.dump_id() - for link_endpoint in self.link_endpoints + for link_endpoint in sorted(self.link_endpoints, key=operator.attrgetter('position')) ], } @@ -47,6 +48,11 @@ class LinkEndPointModel(_Base): link_uuid = Column(ForeignKey('link.link_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) + position = Column(Integer, nullable=False) link = relationship('LinkModel', back_populates='link_endpoints', lazy='joined') endpoint = relationship('EndPointModel', lazy='joined') # back_populates='link_endpoints' + + __table_args__ = ( + CheckConstraint(position >= 0, name='check_position_value'), + ) diff --git a/src/context/service/database/models/PolicyRuleModel.py b/src/context/service/database/models/PolicyRuleModel.py index 2f0c8a326a57a05ab1fd623a968dea0bc39d9e76..663a9a39a30903b3dd41ccfee56da19528325af0 100644 --- a/src/context/service/database/models/PolicyRuleModel.py +++ b/src/context/service/database/models/PolicyRuleModel.py @@ -64,7 +64,7 @@ class PolicyRuleModel(_Base): 'deviceList': [{'device_uuid': {'uuid': pr_d.device_uuid}} for pr_d in self.policyrule_devices], } if self.policyrule_kind == PolicyRuleKindEnum.SERVICE: - result['serviceId'] = self.policyrule_service.dump_id(), + result['serviceId'] = self.policyrule_service.dump_id() return {self.policyrule_kind.value: result} class PolicyRuleDeviceModel(_Base): diff --git a/src/context/service/database/models/ServiceModel.py b/src/context/service/database/models/ServiceModel.py index 09ff381b5eb374ea752590bba5403fe816319036..f1781c4f86fa25e8d9f3e42da46451e112ef779e 100644 --- a/src/context/service/database/models/ServiceModel.py +++ b/src/context/service/database/models/ServiceModel.py @@ -13,7 +13,7 @@ # limitations under the License. import operator -from sqlalchemy import Column, DateTime, Enum, ForeignKey, String +from sqlalchemy import CheckConstraint, Column, DateTime, Enum, ForeignKey, Integer, String from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from typing import Dict @@ -51,7 +51,7 @@ class ServiceModel(_Base): 'service_status' : {'service_status': self.service_status.value}, 'service_endpoint_ids': [ service_endpoint.endpoint.dump_id() - for service_endpoint in self.service_endpoints + for service_endpoint in sorted(self.service_endpoints, key=operator.attrgetter('position')) ], 'service_constraints' : [ constraint.dump() @@ -68,6 +68,11 @@ class ServiceEndPointModel(_Base): service_uuid = Column(ForeignKey('service.service_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) + position = Column(Integer, nullable=False) service = relationship('ServiceModel', back_populates='service_endpoints', lazy='joined') endpoint = relationship('EndPointModel', lazy='joined') # back_populates='service_endpoints' + + __table_args__ = ( + CheckConstraint(position >= 0, name='check_position_value'), + ) diff --git a/src/context/service/database/models/SliceModel.py b/src/context/service/database/models/SliceModel.py index 2d6c884169154fee8d44c26464416c6708c650b1..7f1550eb2ebb80962bac94374112d43785184374 100644 --- a/src/context/service/database/models/SliceModel.py +++ b/src/context/service/database/models/SliceModel.py @@ -13,7 +13,7 @@ # limitations under the License. import operator -from sqlalchemy import Column, DateTime, Enum, ForeignKey, String +from sqlalchemy import CheckConstraint, Column, DateTime, Enum, ForeignKey, Integer, String from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from typing import Dict @@ -53,7 +53,7 @@ class SliceModel(_Base): 'slice_status' : {'slice_status': self.slice_status.value}, 'slice_endpoint_ids': [ slice_endpoint.endpoint.dump_id() - for slice_endpoint in self.slice_endpoints + for slice_endpoint in sorted(self.slice_endpoints, key=operator.attrgetter('position')) ], 'slice_constraints' : [ constraint.dump() @@ -82,10 +82,15 @@ class SliceEndPointModel(_Base): slice_uuid = Column(ForeignKey('slice.slice_uuid', ondelete='CASCADE' ), primary_key=True) endpoint_uuid = Column(ForeignKey('endpoint.endpoint_uuid', ondelete='RESTRICT'), primary_key=True, index=True) + position = Column(Integer, nullable=False) slice = relationship('SliceModel', back_populates='slice_endpoints', lazy='joined') endpoint = relationship('EndPointModel', lazy='joined') # back_populates='slice_endpoints' + __table_args__ = ( + CheckConstraint(position >= 0, name='check_position_value'), + ) + class SliceServiceModel(_Base): __tablename__ = 'slice_service'