start cadvisor and prometheus docker container at startup
[osm/vim-emu.git] / src / emuvim / dcemulator / resourcemodel / __init__.py
index 3d05b96..c28e226 100644 (file)
@@ -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):
         """
@@ -85,15 +87,15 @@ class BaseResourceModel(object):
         initialize some default flavours (naming/sizes inspired by OpenStack)
         """
         self.addFlavour(ResourceFlavor(
-            "tiny",  {"compute": 1, "memory": 32, "disk": 1}))
+            "tiny",  {"compute": 0.5, "memory": 32, "disk": 1}))
         self.addFlavour(ResourceFlavor(
-            "small",  {"compute": 4, "memory": 128, "disk": 20}))
+            "small",  {"compute": 1.0, "memory": 128, "disk": 20}))
         self.addFlavour(ResourceFlavor(
-            "medium",  {"compute": 8, "memory": 256, "disk": 40}))
+            "medium",  {"compute": 4.0, "memory": 256, "disk": 40}))
         self.addFlavour(ResourceFlavor(
-            "large",  {"compute": 16, "memory": 512, "disk": 80}))
+            "large",  {"compute": 8.0, "memory": 512, "disk": 80}))
         self.addFlavour(ResourceFlavor(
-            "xlarge",  {"compute": 32, "memory": 1024, "disk": 160}))
+            "xlarge",  {"compute": 16.0, "memory": 1024, "disk": 160}))
 
     def addFlavour(self, fl):
         """
@@ -125,3 +127,11 @@ class BaseResourceModel(object):
         LOG.warning("Free in BaseResourceModel: %r" % name)
         del self.allocated_compute_instances[name]
         return True
+
+    def get_state_dict(self):
+        """
+        Return the state of the resource model as simple dict.
+        Helper method for logging functionality.
+        :return:
+        """
+        return dict()