fix exp bug

pull/42/head
StarsL.cn 2 years ago
parent fb1b52438e
commit fd3eeeca66

@ -26,6 +26,10 @@ def exp(account,collect_days,notify_days,notify_amount):
config = open_api_models.Config(access_key_id=ak,access_key_secret=sk)
config.endpoint = f'business.aliyuncs.com'
client = BssOpenApi20171214Client(config)
exp_config = consul_kv.get_value('ConsulManager/exp/config')
wecomwh = exp_config.get('wecomwh','')
dingdingwh = exp_config.get('dingdingwh','')
feishuwh = exp_config.get('feishuwh','')
try:
amount_response = client.query_account_balance()
if amount_response.body.success:
@ -50,8 +54,7 @@ def exp(account,collect_days,notify_days,notify_amount):
except Exception as e:
print('==ERROR==',e,flush=True)
raise
query_available_instances_request = bss_open_api_20171214_models.QueryAvailableInstancesRequest(
renew_status='ManualRenewal',end_time_start=now,end_time_end=collect)
query_available_instances_request = bss_open_api_20171214_models.QueryAvailableInstancesRequest(renew_status='ManualRenewal',end_time_start=now,end_time_end=collect)
runtime = util_models.RuntimeOptions()
try:
exp = client.query_available_instances_with_options(query_available_instances_request, runtime)
@ -75,10 +78,6 @@ def exp(account,collect_days,notify_days,notify_amount):
if (endtime - datetime.datetime.now()).days < notify_days and notify_id not in isnotify_list:
notify_dict[i['InstanceID']] = exp_dict[i['InstanceID']]
consul_kv.put_kv(f'ConsulManager/exp/lists/alicloud/{account}/exp', exp_dict)
exp_config = consul_kv.get_value('ConsulManager/exp/config')
wecomwh = exp_config.get('wecomwh','')
dingdingwh = exp_config.get('dingdingwh','')
feishuwh = exp_config.get('feishuwh','')
if notify_dict != {}:
msg = [f'### 阿里云账号 {account}\n### 以下资源到期日小于 {notify_days} 天:']
for k,v in notify_dict.items():

@ -20,7 +20,7 @@
<el-switch v-model="exp_config.switch" /><br>
<font size="3px" color="#ff0000">
<li>开启采集每小时会自动采集一次余额与到期资源信息</li>
<li>开启通知余额或到期资源低于设定时立刻推送通知</li>
<li>开启通知每次采集后检测到余额或到期资源低于设定时推送通知</li>
</font>
</el-form-item>
<el-form-item v-if="exp_config.switch" label="自动采集">
@ -82,7 +82,7 @@
</template>
</el-table-column>
</el-table>
<el-dialog title="查询余额" :visible.sync="amountFormVisible" width="60%">
<el-dialog title="查询余额(非实时,每小时采集一次,可在配置余额页面点击确认手动更新。)" :visible.sync="amountFormVisible" width="60%">
<el-table v-loading="listLoading" :data="amount_list" height="540" :default-sort="{ prop: 'amount', order: 'ascending' }" border fit highlight-current-row style="width: 100%;">
<el-table-column prop="vendor" label="云厂商" sortable align="center" />
<el-table-column prop="account" label="账户" sortable align="center" />

Loading…
Cancel
Save