in table_class_evaluator.py [0:0]
def run(self):
"""Main program entry point"""
table_names = []
try:
if self.args.table_name is not None:
table_names = [self.args.table_name]
else:
table_names = self.table_utility.get_table_names()
table_cost_estimates = self.table_utility.estimate_table_costs_for_region(table_names, self.args.region)
if not table_cost_estimates:
print("No table cost results returned.")
exit(0)
if self.args.estimates_only:
print(json.dumps(table_cost_estimates, cls=DecimalEncoder, indent=2))
exit(0)
recommendations = []
# evaluate tables costs for storage classes
for table_estimate in table_cost_estimates:
table_pricing_data = table_estimate[constants.PRICING_DATA]
# skip on-demand tables
if table_pricing_data[constants.BILLING_MODE] == constants.ON_DEMAND_BILLING:
continue
table_class = table_pricing_data[constants.TABLE_CLASS]
monthly_cost_estimates = table_estimate[constants.ESTIMATED_MONTHLY_COSTS]
ia_cost_differential = (monthly_cost_estimates[constants.IA_MO_TOTAL_COST]
- monthly_cost_estimates[constants.STD_MO_TOTAL_COST])
if ia_cost_differential < 0:
if table_class == constants.STD_TABLE_CLASS:
recommendation = {constants.RECOMMENDATION_TYPE: constants.TABLE_CLASS_CHANGE_RECOMMENDATION,
constants.RECOMMENDED_TABLE_CLASS: constants.IA_TABLE_CLASS,
constants.ESTIMATED_MO_SAVINGS: abs(ia_cost_differential),
constants.ESTIMATE_DETAIL: table_estimate}
recommendations.append(recommendation)
elif ia_cost_differential > 0:
if table_class == constants.IA_TABLE_CLASS:
recommendation = {constants.RECOMMENDATION_TYPE: constants.TABLE_CLASS_CHANGE_RECOMMENDATION,
constants.RECOMMENDED_TABLE_CLASS: constants.STD_TABLE_CLASS,
constants.ESTIMATED_MO_SAVINGS: ia_cost_differential,
constants.ESTIMATE_DETAIL: table_estimate}
recommendations.append(recommendation)
output = json.dumps(recommendations, cls=DecimalEncoder, indent=2)
print(output)
exit(0)
except Exception as e:
print(f"Table evaluation failed: {e}")
import traceback
traceback.print_exc()
exit(0)