def energy_project(self):
     energy_vm = list()
     for project in self.project_list:
         is_empty = True
         date_query = '{0}-{1}'.format(str(self.year), str(self.month_list[self.month-1]))
         data = VmPower.select().where((VmPower.project == project) & (VmPower.date == date_query))
         for d in data:
             if d.project:
                 is_empty = False
         if not is_empty:
             energy_vm.append(map(lambda m: m, data))
     return energy_vm
    def energy_vm(self):
        """

        :type self: User
        """
        energy_vm = list()
        for project in self.tenant_list:
            date_query = '{0}-{1}'.format(str(self.year), str(self.month_list[self.month-1]))
            data = VmPower.select().where((VmPower.project == project) & (VmPower.date == date_query))
            if data:
                energy_vm.append(map(lambda m: m, data))
        return energy_vm
Beispiel #3
0
    def energy_vm(self):
        """

        :type self: User
        """
        energy_vm = list()
        for project in self.tenant_list:
            date_query = '{0}-{1}'.format(str(self.year),
                                          str(self.month_list[self.month - 1]))
            data = VmPower.select().where((VmPower.project == project)
                                          & (VmPower.date == date_query))
            if data:
                energy_vm.append(map(lambda m: m, data))
        return energy_vm
 def energy_project(self):
     energy_vm = list()
     for project in self.project_list:
         is_empty = True
         date_query = '{0}-{1}'.format(str(self.year),
                                       str(self.month_list[self.month - 1]))
         data = VmPower.select().where((VmPower.project == project)
                                       & (VmPower.date == date_query))
         for d in data:
             if d.project:
                 is_empty = False
         if not is_empty:
             energy_vm.append(map(lambda m: m, data))
     return energy_vm
Beispiel #5
0
    def set_variables(self, y, m, h, d):
        power_meters = self.hosts()
        total_energy, active_instances = 0, 0
        datew, timestamp = '', ''
        instances = list()
        for resources in power_meters:
            query = self.get_query(resources, y, m, h, d)
            energy_samples = self.get_energy_meters(query)
            energy_samples = list(reversed(energy_samples))
            initial_energy = energy_samples[0].counter_volume
            for samples in energy_samples:
                if samples.counter_volume > initial_energy:
                    total_energy += samples.counter_volume - initial_energy
                initial_energy = samples.counter_volume
            datew = str(y) + '-' + self.month_list[m - 1]
            timestamp = datetime(y, m, d, h)
        total_energy *= 3600000
        instance_meters = self.set_instances()
        for instance in instance_meters:
            query = self.get_query(instance, y, m, h, d)
            instance_samples = self.get_instances(query, True)
            for sample in instance_samples:
                if sample:
                    active_instances += 1
                    instances.append(sample)
        if active_instances == 0:
            active_instances = 1
        instance_divided_all = int(total_energy) / active_instances
        instance_divided_load = self.get_energy_load(instances, y, m, h, d)
        total_utilisation = sum(
            map(lambda x: float(x['cpu_util']), instance_divided_load))

        for instance in instance_divided_load:
            energy_per_instance = (int(total_energy) *
                                   instance['cpu_util']) / total_utilisation
            joule = VmPower.create(joulesall=instance_divided_all,
                                   joulesmean=energy_per_instance,
                                   date=datew,
                                   timestamp=timestamp,
                                   name=instance['instance'],
                                   project=instance['project'],
                                   wattsall=instance_divided_all / 3600,
                                   wattsmean=energy_per_instance / 3600)
            joule.save()
    def set_variables(self, y, m, h, d):
        power_meters = self.hosts()
        total_energy, active_instances = 0, 0
        datew, timestamp = "", ""
        instances = list()
        for resources in power_meters:
            query = self.get_query(resources, y, m, h, d)
            energy_samples = self.get_energy_meters(query)
            energy_samples = list(reversed(energy_samples))
            initial_energy = energy_samples[0].counter_volume
            for samples in energy_samples:
                if samples.counter_volume > initial_energy:
                    total_energy += samples.counter_volume - initial_energy
                initial_energy = samples.counter_volume
            datew = str(y) + "-" + self.month_list[m - 1]
            timestamp = datetime(y, m, d, h)
        total_energy *= 3600000
        instance_meters = self.set_instances()
        for instance in instance_meters:
            query = self.get_query(instance, y, m, h, d)
            instance_samples = self.get_instances(query, True)
            for sample in instance_samples:
                if sample:
                    active_instances += 1
                    instances.append(sample)
        if active_instances == 0:
            active_instances = 1
        instance_divided_all = int(total_energy) / active_instances
        instance_divided_load = self.get_energy_load(instances, y, m, h, d)
        total_utilisation = sum(map(lambda x: float(x["cpu_util"]), instance_divided_load))

        for instance in instance_divided_load:
            energy_per_instance = (int(total_energy) * instance["cpu_util"]) / total_utilisation
            joule = VmPower.create(
                joulesall=instance_divided_all,
                joulesmean=energy_per_instance,
                date=datew,
                timestamp=timestamp,
                name=instance["instance"],
                project=instance["project"],
                wattsall=instance_divided_all / 3600,
                wattsmean=energy_per_instance / 3600,
            )
            joule.save()