- def allocate(self, name, flavor_name):
- LOG.info("RM-ALLOCATE: %r with flavor: %r" % (name, flavor_name))
- return 0.0, 0.0, 0.0
-
- def free(self, name):
- LOG.info("RM-FREE: %r" % name)
-
+ def allocate(self, d):
+ """
+ This method has to be overwritten by a real resource model.
+ :param d: Container object
+ """
+ LOG.warning("Allocating in BaseResourceModel: %r with flavor: %r" % (d.name, d.flavor_name))
+ self._allocated_compute_instances[d.name] = d.flavor_name
+
+ def free(self, d):
+ """
+ This method has to be overwritten by a real resource model.
+ :param d: Container object
+ """
+ LOG.warning("Free in BaseResourceModel: %r" % d.name)
+ del self._allocated_compute_instances[d.name]
+
+ def get_state_dict(self):
+ """
+ Return the state of the resource model as simple dict.
+ Helper method for logging functionality.
+ :return:
+ """
+ return dict()
+
+ def write_allocation_log(self, d, path):
+ """
+ Helper to log RM info for experiments.
+ :param d: container
+ :param path: log path
+ :return:
+ """
+ self._write_log(d, path, "allocate")
+
+ def write_free_log(self, d, path):
+ """
+ Helper to log RM info for experiments.
+ :param d: container
+ :param path: log path
+ :return:
+ """
+ self._write_log(d, path, "free")
+
+ def _write_log(self, d, path, action):
+ """
+ Helper to log RM info for experiments.
+ :param d: container
+ :param path: log path
+ :param action: allocate or free
+ :return:
+ """
+ pass
+
+
+class NotEnoughResourcesAvailable(BaseException):
+ pass