+ f.write("%s\n" % json.dumps(logd))
+
+
+class UpbOverprovisioningCloudDcRM(UpbSimpleCloudDcRM):
+ """
+ This will be an example resource model that limits the overall
+ resources that can be deployed per data center.
+ Allows over provisioning. Might result in reducing resources of single
+ containers whenever a data-center is over provisioned.
+ """
+ # TODO add parts for memory
+
+ def __init__(self, *args, **kvargs):
+ super(UpbOverprovisioningCloudDcRM, self).__init__(*args, **kvargs)
+ self.raise_no_cpu_resources_left = False
+
+ def _compute_single_cu(self):
+ """
+ Calculate percentage of CPU time of a singe CU unit.
+ Take scale-down facte for over provisioning into account.
+ :return:
+ """
+ # get cpu time fraction for entire emulation
+ e_cpu = self.registrar.e_cpu
+ # calculate over provisioning scale factor
+ self.cpu_op_factor = float(self.dc_max_cu) / \
+ (max(self.dc_max_cu, self.dc_alloc_cu))
+ # calculate
+ return float(e_cpu) / sum([rm.dc_max_cu for rm in list(
+ self.registrar.resource_models)]) * self.cpu_op_factor
+
+
+class UpbDummyRM(UpbSimpleCloudDcRM):
+ """
+ No limits. But log allocations.
+ """
+
+ def __init__(self, *args, **kvargs):
+ super(UpbDummyRM, self).__init__(*args, **kvargs)
+ self.raise_no_cpu_resources_left = False
+
+ def _apply_limits(self):
+ # do nothing here
+ pass