Commit cd20cba7 authored by George Papathanail's avatar George Papathanail
Browse files

first commit for the refactor codebase

parent d751dadf
Loading
Loading
Loading
Loading

Dockerfile

deleted100644 → 0
+0 −16
Original line number Diff line number Diff line
FROM python:3.12-alpine

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/

RUN pip install --no-cache-dir --trusted-host pypi.org --trusted-host files.pythonhosted.org -r requirements.txt

COPY . /usr/src/app

EXPOSE 8080

ENTRYPOINT ["python"]

CMD ["-m", "edge_cloud_management_api"]

Makefile

0 → 100644
+74 −0
Original line number Diff line number Diff line
.PHONY: install clean lint format precommit type test run

PYTHON := python3.12
PIP := .venv/bin/pip
SRC := open_exposure_gateway/app
TEST := open_exposure_gateway/test
DB ?= base
DEV ?= false

## Database Package Handling
ifeq ($(DB),postgres)
    EXTRA := postgre
else ifeq ($(DB),mongo)
    EXTRA := mongo
else
	EXTRA :=
endif

## Dev tools Packages Handling
ifeq ($(DEV),true)
	ifneq ($(EXTRA),)
		EXTRAS := $(EXTRA),dev
	else
		EXTRAS := dev
	endif
else
	EXTRAS := $(EXTRA)
endif

## Pip install command
ifeq ($(EXTRAS),)
PIP_INSTALL = $(PIP) install -e .
else
PIP_INSTALL = $(PIP) install -e .[$(EXTRAS)]
endif

## Make Commands
install:
	$(PYTHON) -m venv .venv
	$(PIP) install --upgrade pip setuptools wheel
	$(PIP_INSTALL)

clean:
	rm -rf .venv
	rm -rf .cache
	rm -rf open_exposure_gateway/*.egg-info

lint:
	make install DEV=true
	.venv/bin/ruff check --fix $(SRC)

format:
	make install DEV=true
	.venv/bin/ruff format $(SRC)

precommit:
	make install DEV=true
	.venv/bin/pre-commit run --all-files

architecture:
	make install DEV=true
	.venv/bin/lint-imports --cache-dir .cache/import-linter

type:
	make install DEV=true
	.venv/bin/mypy $(SRC) $(TEST)

test:
	make install DEV=true
	.venv/bin/pytest

run:
	make install
	.venv/bin/python3 open_exposure_gateway/app/main.py

deploy/oeg.yaml

deleted100644 → 0
+0 −179
Original line number Diff line number Diff line
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: mongodb-oeg-pv-volume  # Sets PV's name
  labels:
    type: local  # Sets PV's type to local
    app: oegmongo
spec:
  storageClassName: manual
  capacity:
    storage: 50Mi # Sets PV Volume
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data/mongodb_oeg"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: mongo-oeg
  name: mongo-oeg
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Mi
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.26.0 (40646f47)
  creationTimestamp: null
  labels:
    io.kompose.service: oegmongo
  name: oegmongo
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: oegmongo
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert
        kompose.version: 1.26.0 (40646f47)
      creationTimestamp: null
      labels:
        #io.kompose.network/netEMPkub: "true"
        io.kompose.service: oegmongo
    spec:
      containers:
        - image: mongo
          name: oegmongo
          ports:
            - containerPort: 27017
          resources: {}
          volumeMounts:
            - mountPath: /data/db
              name: mongo-db
      restartPolicy: Always
      volumes:
        - name: mongo-db
          persistentVolumeClaim:
            claimName: mongo-oeg
status: {}
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.26.0 (40646f47)
  creationTimestamp: null
  labels:
    io.kompose.service: oegmongo
  name: oegmongo
spec:
  type: ClusterIP
  ports:
    - name: "27017"
      port: 27017
      targetPort: 27017
  selector:
    io.kompose.service: oegmongo
status:
  loadBalancer: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose convert
    kompose.version: 1.26.0 (40646f47)
  creationTimestamp: null
  labels:
    io.kompose.service: oegcontroller
  name: oegcontroller
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: oegcontroller
  strategy: {}
  template:
    metadata:
      annotations:
        kompose.cmd: kompose convert
        kompose.version: 1.26.0 (40646f47)
      creationTimestamp: null
      labels:
        io.kompose.service: oegcontroller
    spec:
      containers:
        - env:
            - name: MONGO_URI
              value: mongodb://oegmongo:27017
            - name: SRM_HOST
              value: http://srm:8080/srm/1.0.0
            - name: FEDERATION_MANAGER_HOST
              value: http://federation-manager.federation-manager.svc.cluster.local:8989/operatorplatform/federation/v1
            - name: PARTNER_API_ROOT
              value: http://10.8.0.1:31002
            - name: TOKEN_ENDPOINT
              value: http://federation-manager.federation-manager.svc.cluster.local:8080/realms/federation/protocol/openid-connect/token
          image: ghcr.io/sunriseopenoperatorplatform/oeg/oeg:1.0.1
          name: oegcontroller
          ports:
            - containerPort: 8080
          resources: {}
          imagePullPolicy: Always
      restartPolicy: Always

status: {}
---
apiVersion: v1
kind: Service
metadata:
  name: oeg
  namespace: sunrise6g
spec:
  type: ClusterIP
  selector:
    io.kompose.service: oegcontroller
  ports:
    - name: http
      port: 80
      targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: oegcontroller-ingress
  namespace: sunrise6g
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: web
    # traefik.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: traefik
  rules:
    - host: isiath.duckdns.org
      http:
        paths:
          - path: /oeg
            pathType: Prefix
            backend:
              service:
                name: oeg
                port:
                  number: 80
 No newline at end of file
+0 −5
Original line number Diff line number Diff line
from edge_cloud_management_api.app import get_app_instance

if __name__ == "__main__":
    app = get_app_instance()
    app.run(host="0.0.0.0", port=8080)

edge_cloud_management_api/app.py

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
from pathlib import Path
from connexion import FlaskApp
from connexion.options import SwaggerUIOptions


def get_app_instance() -> FlaskApp:
    file_path = Path(__file__).resolve().parent
    swagger_options = SwaggerUIOptions(swagger_ui_path="/docs")
    app = FlaskApp(__name__, specification_dir=file_path / "specification")
    app.add_api(
        "openapi.yaml",
        swagger_ui_options=swagger_options,
        strict_validation=True,
    )
    return app


if __name__ == "__main__":
    app = get_app_instance()
    app.run(host="0.0.0.0", port=8080)
Loading