some progress on classes
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Torma Kristóf 2021-12-03 20:09:11 +01:00
parent e6569729bb
commit ed4fba74b9
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
7 changed files with 71 additions and 0 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python:3.10
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY ./src .

8
src/apps.py Normal file
View File

@ -0,0 +1,8 @@
class ApplicationModule:
bwRequirement: int = 0
cpuRequirement: int = 0
class Application:
name: str = ""
modules: list[ApplicationModule] = []

28
src/bucketresources.py Normal file
View File

@ -0,0 +1,28 @@
from enum import Enum
class BucketResourceType(Enum):
NetworkLink = 'network_link'
CpuResource = 'cpu_resource'
class BucketResource:
type: BucketResourceType = BucketResourceType.NetworkLink
currentUsage: int = 0
capacity: int = 0
def reserve(self, resource: int) -> bool:
if self.capacity == self.currentUsage or resource > self.capacity - self.currentUsage:
return False
else:
return True
def release(self, resource: int) -> bool:
if self.currentUsage == 0 or self.currentUsage - resource < 0:
return False
else:
return True
def releaseAll(self) -> bool:
self.currentUsage = 0
return True

7
src/clients.py Normal file
View File

@ -0,0 +1,7 @@
from apps import Application
class Client:
startSlices: list[int] = []
lengthOfTransmission: int = 0
application: Application = Application()

6
src/datacentre.py Normal file
View File

@ -0,0 +1,6 @@
from bucketresources import BucketResource
class Datacentre:
processingpower: BucketResource = BucketResource()
uplink: BucketResource = BucketResource()

13
src/scheduler.py Normal file
View File

@ -0,0 +1,13 @@
from clients import Client
from apps import Application, ApplicationModule
from bucketresources import BucketResource, BucketResource
from datacentre import Datacentre
class Scheduler:
clients: list[Client] = []
cloud: Datacentre = Datacentre()
edge: Datacentre = Datacentre()
def createClients(self, numofClients: int = 1):
pass