From a4d8479f913ed45b18199d70c4b524fca73a0a21 Mon Sep 17 00:00:00 2001 From: peusterm Date: Fri, 25 Mar 2016 12:27:07 +0100 Subject: [PATCH] Added emulation max memory property to network and RM registrar --- src/emuvim/dcemulator/net.py | 8 ++++++-- src/emuvim/dcemulator/resourcemodel/__init__.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/emuvim/dcemulator/net.py b/src/emuvim/dcemulator/net.py index d91ef4a..80fb2f8 100755 --- a/src/emuvim/dcemulator/net.py +++ b/src/emuvim/dcemulator/net.py @@ -27,7 +27,10 @@ class DCNetwork(Dockernet): This class is used by topology definition scripts. """ - def __init__(self, controller=RemoteController, dc_emulation_max_cpu=1.0, **kwargs): + def __init__(self, controller=RemoteController, + dc_emulation_max_cpu=1.0, # fraction of overall CPU time for emulation + dc_emulation_max_mem=512, # emulation max mem in MB + **kwargs): """ Create an extended version of a Dockernet network :param dc_emulation_max_cpu: max. CPU time used by containers in data centers @@ -56,7 +59,8 @@ class DCNetwork(Dockernet): self.monitor_agent = DCNetworkMonitor(self) # initialize resource model registrar - self.rm_registrar = ResourceModelRegistrar(dc_emulation_max_cpu) + self.rm_registrar = ResourceModelRegistrar( + dc_emulation_max_cpu, dc_emulation_max_mem) def addDatacenter(self, label, metadata={}): """ diff --git a/src/emuvim/dcemulator/resourcemodel/__init__.py b/src/emuvim/dcemulator/resourcemodel/__init__.py index 3d05b96..e35da25 100644 --- a/src/emuvim/dcemulator/resourcemodel/__init__.py +++ b/src/emuvim/dcemulator/resourcemodel/__init__.py @@ -12,11 +12,13 @@ class ResourceModelRegistrar(object): Global registry to keep track of all existing resource models. """ - def __init__(self, dc_emulation_max_cpu): + def __init__(self, dc_emulation_max_cpu, dc_emulation_max_mem): self.e_cpu = dc_emulation_max_cpu + self.e_mem = dc_emulation_max_mem # pointer to all resource models assigned to DCs self._resource_models = dict() - LOG.info("Resource model registrar created with dc_emulation_max_cpu=%r" % dc_emulation_max_cpu) + LOG.info("Resource model registrar created with dc_emulation_max_cpu=%r and dc_emulation_max_mem=%r" + % (dc_emulation_max_cpu, dc_emulation_max_mem)) def register(self, dc, rm): """ -- 2.25.1