From: peusterm Date: Tue, 26 Apr 2016 13:35:07 +0000 (+0200) Subject: small refactoring as preparation for overprovisioning RM X-Git-Tag: v3.1~139^2~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=6a6d9a69d088b61d1bf0f2ea631d7d9f052013d3;p=osm%2Fvim-emu.git small refactoring as preparation for overprovisioning RM --- diff --git a/src/emuvim/dcemulator/resourcemodel/upb/simple.py b/src/emuvim/dcemulator/resourcemodel/upb/simple.py index da76b96..181bc97 100644 --- a/src/emuvim/dcemulator/resourcemodel/upb/simple.py +++ b/src/emuvim/dcemulator/resourcemodel/upb/simple.py @@ -126,10 +126,8 @@ class UpbSimpleCloudDcRM(BaseResourceModel): :return: """ number_cu = self._get_flavor(d).get("compute") - # get cpu time fraction for entire emulation - e_cpu = self.registrar.e_cpu # calculate cpu time fraction of a single compute unit - self.single_cu = float(e_cpu) / sum([rm.dc_max_cu for rm in list(self.registrar.resource_models)]) + self.single_cu = self._compute_single_cu() # calculate cpu time fraction for container with given flavor cpu_time_percentage = self.single_cu * number_cu # calculate input values for CFS scheduler bandwidth limitation @@ -140,6 +138,16 @@ class UpbSimpleCloudDcRM(BaseResourceModel): d.name, cpu_period, cpu_time_percentage, cpu_quota)) d.updateCpuLimit(cpu_period=int(cpu_period), cpu_quota=int(cpu_quota)) + def _compute_single_cu(self): + """ + Calculate percentage of CPU time of a singe CU unit. + :return: + """ + # get cpu time fraction for entire emulation + e_cpu = self.registrar.e_cpu + # calculate + return float(e_cpu) / sum([rm.dc_max_cu for rm in list(self.registrar.resource_models)]) + def _calculate_cpu_cfs_values(self, cpu_time_percentage): """ Calculate cpu period and quota for CFS