def calculate_savings()

in docker/services/saving/saving_service.py [0:0]


    def calculate_savings(self, general_actions, current_shape: str,
                          recommended_shapes, schedule,
                          customer, region, os, price_type='on_demand'):
        saving_options: List[AbstractSaving] = []
        general_actions = copy.copy(general_actions)

        # as an alternative for shutdown
        if 'SHUTDOWN' in general_actions:
            general_actions.append('SCALE_DOWN')

        current_monthly_price = self._get_monthly_price(
            instance_type=current_shape, customer=customer,
            region=region, price_type=price_type, os=os)

        if not current_monthly_price:
            _LOG.warning(f'No shape price found for current shape '
                         f'\'{current_shape}\'')
            return {}

        for action in general_actions:
            calculator_func = self.action_calculator_mapping.get(action)
            if not calculator_func:
                continue
            kwargs = {
                'action': action,
                'current_instance_type': current_shape,
                'recommended_shapes': recommended_shapes,
                'schedule': schedule,
                'current_monthly_price': current_monthly_price,
                'customer': customer,
                'region': region,
                'price_type': price_type,
                'os': os
            }
            try:
                result = calculator_func(**kwargs)
                if not result:
                    continue
            except:
                _LOG.error(f'Exception occurred while calculating saving '
                           f'for action \'{action}\'')
                continue

            if isinstance(result, list):
                saving_options.extend(result)
            elif isinstance(result, AbstractSaving):
                saving_options.append(result)

        saving_options.sort(key=lambda k: k.saving_month_usd, reverse=True)

        saving_result = SavingResult(
            current_instance_type=current_shape,
            current_monthly_price_usd=current_monthly_price,
            saving_options=saving_options
        )
        return saving_result.as_dict()