Пример #1
0
 def partialBillingInterval(instance):
     """
     Returns a floating point value between 0 and 1.0 representing how far we are into the
     current billing cycle for the given instance. If the return value is .25, we are one
     quarter into the billing cycle, with three quarters remaining before we will be charged
     again for that instance.
     """
     launch_time = parse_iso_utc(instance.launchTime)
     now = datetime.datetime.utcnow()
     delta = now - launch_time
     return delta.total_seconds() / 3600.0 % 1.0
Пример #2
0
 def partialBillingInterval(instance):
     """
     Returns a floating point value between 0 and 1.0 representing how far we are into the
     current billing cycle for the given instance. If the return value is .25, we are one
     quarter into the billing cycle, with three quarters remaining before we will be charged
     again for that instance.
     """
     launch_time = parse_iso_utc(instance.launchTime)
     now = datetime.datetime.utcnow()
     delta = now - launch_time
     return delta.total_seconds() / 3600.0 % 1.0
Пример #3
0
    def remainingBillingInterval(self):
        """
        If the node has a launch time, this function returns a floating point value
        between 0 and 1.0 representing how far we are into the
        current billing cycle for the given instance. If the return value is .25, we are one
        quarter into the billing cycle, with three quarters remaining before we will be charged
        again for that instance.

        Assumes a billing cycle of one hour.

        :return: Float from 0 -> 1.0 representing percentage of pre-paid time left in cycle.
        """
        if self.launchTime:
            now = datetime.datetime.utcnow()
            delta = now - parse_iso_utc(self.launchTime)
            return 1 - delta.total_seconds() / 3600.0 % 1.0
        else:
            return 1