コード例 #1
0
ファイル: group.py プロジェクト: j143-zz/atmosphere
    def get_allocation_dict(self):
        if not self.allocation:
            return {}
        # Don't move it up. Circular reference.
        from django.conf import settings
        from service.monitoring import get_delta, _get_allocation_result
        delta = get_delta(self, time_period=settings.FIXED_WINDOW)
        allocation_result = _get_allocation_result(self.identity)
        over_allocation, diff_amount = allocation_result.total_difference()
        burn_time = allocation_result.get_burn_rate()
        # Moving from seconds to hours
        hourly_credit = int(allocation_result
                            .total_credit().total_seconds() / 3600.0)
        hourly_runtime = int(allocation_result
                             .total_runtime().total_seconds() / 3600.0)
        hourly_difference = int(diff_amount.total_seconds() / 3600.0)
        zero_time = allocation_result.time_to_zero()

        allocation_dict = {
            "threshold": hourly_credit,
            "current": hourly_runtime,
            "delta": ceil(delta.total_seconds() / 60),
            "burn": hourly_difference,
            "ttz": zero_time,
        }
        return allocation_dict
コード例 #2
0
ファイル: group.py プロジェクト: xuhang57/atmosphere
    def get_allocation_dict(self):
        if not self.allocation:
            return {}
        # Don't move it up. Circular reference.
        from django.conf import settings
        from service.monitoring import get_delta, _get_allocation_result
        delta = get_delta(self, time_period=settings.FIXED_WINDOW)
        allocation_result = _get_allocation_result(self.identity)
        over_allocation, diff_amount = allocation_result.total_difference()
        burn_time = allocation_result.get_burn_rate()
        # Moving from seconds to hours
        hourly_credit = int(allocation_result
                            .total_credit().total_seconds() / 3600.0)
        hourly_runtime = int(allocation_result
                             .total_runtime().total_seconds() / 3600.0)
        hourly_difference = int(diff_amount.total_seconds() / 3600.0)
        zero_time = allocation_result.time_to_zero()

        allocation_dict = {
            "threshold": hourly_credit,
            "current": hourly_runtime,
            "delta": ceil(delta.total_seconds() / 60),
            "burn": hourly_difference,
            "ttz": zero_time,
        }
        return allocation_dict
コード例 #3
0
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     limit_instances = self.instance_set.all().values_list(
         'provider_alias', flat=True).distinct()
     result = _get_allocation_result(self, limit_instances=limit_instances)
     total_hours = result.total_runtime().total_seconds() / 3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #4
0
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     identity = self.created_by_identity
     limit_instances = [self.provider_alias]
     result = _get_allocation_result(identity,
                                     limit_instances=limit_instances)
     total_hours = result.total_runtime().total_seconds() / 3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #5
0
ファイル: identity.py プロジェクト: jmlowe/atmosphere
 def total_usage(self, start_date, end_date):
     # Undoubtedly will cause circular dependencies
     from service.monitoring import _get_allocation_result
     allocation_result = _get_allocation_result(self, start_date, end_date)
     if not allocation_result:
         # Flag to the plugin you have an error in counting.
         return -1
     total_au = allocation_result.total_runtime().total_seconds() / 3600.0
     return total_au
コード例 #6
0
ファイル: identity.py プロジェクト: xuhang57/atmosphere
 def total_usage(self, start_date, end_date):
     # Undoubtedly will cause circular dependencies
     from service.monitoring import _get_allocation_result
     allocation_result = _get_allocation_result(self, start_date, end_date)
     if not allocation_result:
         # Flag to the plugin you have an error in counting.
         return -1
     total_au = allocation_result.total_runtime().total_seconds() / 3600.0
     return total_au
コード例 #7
0
ファイル: instance.py プロジェクト: xuhang57/atmosphere
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     identity = self.created_by_identity
     limit_instances = [self.provider_alias]
     result = _get_allocation_result(
         identity,
         limit_instances=limit_instances)
     total_hours = result.total_runtime().total_seconds()/3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #8
0
ファイル: identity.py プロジェクト: Duke-GCB/atmosphere
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     limit_instances = self.instance_set.all().values_list(
             'provider_alias', flat=True
         ).distinct()
     result = _get_allocation_result(
         self,
         limit_instances=limit_instances)
     total_hours = result.total_runtime().total_seconds()/3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #9
0
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     identity = self.instance.created_by_identity
     history_list = self._base_manager.filter(id=self.id)
     limit_history = [hist.id for hist in history_list]
     limit_instances = [self.instance.provider_alias]
     result = _get_allocation_result(identity,
                                     limit_instances=limit_instances,
                                     limit_history=limit_history)
     total_hours = result.total_runtime().total_seconds() / 3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #10
0
 def get_total_hours(self):
     from service.monitoring import _get_allocation_result
     identity = self.instance.created_by_identity
     history_list = self.__class__.objects.filter(id=self.id)
     limit_history = [hist.id for hist in history_list]
     limit_instances = [self.instance.provider_alias]
     result = _get_allocation_result(
         identity,
         limit_instances=limit_instances,
         limit_history=limit_history)
     total_hours = result.total_runtime().total_seconds()/3600.0
     hours = round(total_hours, 2)
     return hours
コード例 #11
0
def _get_results(idents):
    results = []
    total = len(idents)
    for idx,ident in enumerate(idents):
        try:
            result = _get_allocation_result(ident)
            results.append((ident, result))
        except Exception as exc:
            print "Error calculating for identity: %s" % ident
            print exc

        if total > 10 and idx % int(total / 10) == 0:
            print "Calculating %s/%s.." % (idx, total)
    return results
コード例 #12
0
ファイル: identity.py プロジェクト: jmlowe/atmosphere
 def get_allocation_usage(self):
     # Undoubtedly will cause circular dependencies
     from service.monitoring import _get_allocation_result
     allocation_result = _get_allocation_result(self)
     over_allocation, diff_amount = allocation_result.total_difference()
     burn_time = allocation_result.get_burn_rate()
     # Moving from seconds to hours
     hourly_credit = int(allocation_result
                         .total_credit().total_seconds() / 3600.0)
     hourly_runtime = int(allocation_result
                          .total_runtime().total_seconds() / 3600.0)
     hourly_difference = int(diff_amount.total_seconds() / 3600.0)
     zero_time = allocation_result.time_to_zero()
     return {
         "threshold": hourly_credit,  # Total amount
         "current": hourly_runtime,  # Total used
         "remaining": hourly_difference,
         "ttz": zero_time,  # Time Til Zero
     }
コード例 #13
0
ファイル: identity.py プロジェクト: catdewey/atmosphere
 def get_allocation_usage(self):
     # Undoubtedly will cause circular dependencies
     from service.monitoring import _get_allocation_result
     allocation_result = _get_allocation_result(self)
     over_allocation, diff_amount = allocation_result.total_difference()
     burn_time = allocation_result.get_burn_rate()
     # Moving from seconds to hours
     hourly_credit = int(allocation_result
                         .total_credit().total_seconds() / 3600.0)
     hourly_runtime = int(allocation_result
                          .total_runtime().total_seconds() / 3600.0)
     hourly_difference = int(diff_amount.total_seconds() / 3600.0)
     zero_time = allocation_result.time_to_zero()
     return {
         "threshold": hourly_credit,  # Total amount
         "current": hourly_runtime,  # Total used
         "remaining": hourly_difference,
         "ttz": zero_time,  # Time Til Zero
     }