def get_instance_list(self, identity): from service.monitoring import _core_instances_for # Retrieve the core that could have an impact.. core_instances = _core_instances_for( identity, self.counting_behavior.start_date) # Convert Core Models --> Allocation/core Models alloc_instances = [AllocInstance.from_core( inst, self.counting_behavior.start_date) for inst in core_instances] return alloc_instances
def get_instance_list(self, identity): from service.monitoring import _core_instances_for # Retrieve the core that could have an impact.. core_instances = _core_instances_for(identity, self.counting_behavior.start_date) # Convert Core Models --> Allocation/core Models alloc_instances = [ AllocInstance.from_core(inst, self.counting_behavior.start_date) for inst in core_instances ] return alloc_instances
def get_instance_list(self, identity): from service.monitoring import _core_instances_for # Retrieve the core that could have an impact.. core_instances = _core_instances_for(identity, self.counting_behavior.start_date) # Convert Core Models --> Allocation/core Models alloc_instances = [] for inst in core_instances: try: alloc_instances.append( AllocInstance.from_core(inst, self.counting_behavior.start_date)) except Exception as exc: logger.exception(exc) return alloc_instances
def get_instance_list(self, identity): from service.monitoring import _core_instances_for # Retrieve the core that could have an impact.. core_instances = _core_instances_for( identity, self.counting_behavior.start_date) # Convert Core Models --> Allocation/core Models alloc_instances = [] for inst in core_instances: try: alloc_instances.append( AllocInstance.from_core(inst, self.counting_behavior.start_date) ) except Exception as exc: logger.exception(exc) return alloc_instances
def _create_monthly_window_input(identity, core_allocation, start_date, end_date, interval_delta=None): """ This function is meant to create an allocation input that is identical in functionality to that of the ORIGINAL allocation system. """ if not end_date: end_date = timezone.now() if not start_date: delta_time = get_delta(core_allocation, settings.FIXED_WINDOW, end_date) start_date = end_date - delta_time else: delta_time = end_date - start_date #TODO: I wanted delta_time.. why? #Guaranteed a range (IF BOTH are NONE: Starting @ FIXED_WINDOW until NOW) if core_allocation: initial_recharge = AllocationRecharge( name="%s Assigned allocation" % identity.created_by.username, unit=TimeUnit.minute, amount=core_allocation.threshold, recharge_date=start_date) else: initial_recharge = AllocationUnlimited(start_date) #Retrieve the core that could have an impact.. core_instances = _core_instances_for(identity, start_date) #Noteably MISSING: 'active', 'running' multiply_by_cpu = MultiplySizeCPU(name="Multiply TimeUsed by CPU", multiplier=1) ignore_inactive = IgnoreStatusRule("Ignore Inactive StatusHistory", value=["build", "pending", "hard_reboot", "reboot", "migrating", "rescue", "resize", "verify_resize", "shutoff", "shutting-down", "suspended", "terminated", "deleted", "error", "unknown","N/A", ]) #Convert Core Models --> Allocation/core Models alloc_instances = [AllocInstance.from_core(inst, start_date) for inst in core_instances] return Allocation( credits=[initial_recharge], rules=[multiply_by_cpu, ignore_inactive], instances=alloc_instances, start_date=start_date, end_date=end_date, interval_delta=interval_delta)
def get_instance_list(self, identity, limit_instances=[], limit_history=[]): from service.monitoring import _core_instances_for # Retrieve the core that could have an impact.. core_instances = _core_instances_for( identity, self.counting_behavior.start_date) # Convert Core Models --> Allocation/core Models alloc_instances = [] for inst in core_instances: if limit_instances and inst.provider_alias not in limit_instances: continue try: alloc_instances.append( AllocInstance.from_core( inst, self.counting_behavior.start_date, limit_history=limit_history ) ) except Exception as exc: logger.exception("Instance %s could not be counted: %s" % (inst, exc)) return alloc_instances