some progress on classes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-12-03 20:09:11 +01:00
parent e6569729bb
commit ed4fba74b9
7 changed files with 71 additions and 0 deletions

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()

16
src/main.py Normal file
View File

@@ -0,0 +1,16 @@
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

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