支持阿里华为腾讯云采集ECS外网IP

pull/72/head
starsliao 1 year ago
parent 6356edbea8
commit e7a5b922fe

@ -155,6 +155,17 @@ def ecs(account,region,isextip=False):
'mem':f"{str(round(int(i['flavor']['ram'])/1024,1)).rstrip('.0')}GB",
'exp': '-'
} for i in info}
if isextip:
for i in info:
try:
pubip_list = [x.addr for x in i['addresses'][i['metadata']['vpc_id']] if 'floating' in str(x)]
if pubip_list:
ecs_dict[i['id']]['ip'] = pubip_list[0]
else:
pass
except:
pass
count = len(ecs_dict)
off,on = sync_ecs.w2consul('huaweicloud',account,region,ecs_dict)
data = {'count':count,'update':now,'status':20000,'on':on,'off':off,'msg':f'ECS同步成功总数{count},开机:{on},关机:{off}'}

@ -131,11 +131,13 @@ def ecs(account,region,isextip=False):
offset = 0
total = 0
ecs_dict = {}
ecs_list_temp = []
while offset <= total:
params = {"Offset": offset, "Limit": 100}
req.from_json_string(json.dumps(params))
resp = client.DescribeInstances(req)
ecs_list = resp.InstanceSet
ecs_list_temp.extend(ecs_list)
total = resp.TotalCount
ecs_dict_temp = {i.InstanceId:{'name':i.InstanceName,'group':group_dict.get(str(i.Placement.ProjectId),''),
'ostype': 'windows' if 'win' in i.OsName.lower() else 'linux',
@ -146,6 +148,16 @@ def ecs(account,region,isextip=False):
offset = offset + 100
ecs_dict.update(ecs_dict_temp)
if isextip:
for i in ecs_list_temp:
try:
if i.PublicIpAddresses:
ecs_dict[i.InstanceId]['ip'] = i.PublicIpAddresses[0]
else:
pass
except:
pass
count = len(ecs_dict)
off,on = sync_ecs.w2consul('tencent_cloud',account,region,ecs_dict)
data = {'count':count,'update':now,'status':20000,'on':on,'off':off,'msg':f'ECS同步成功总数{count},开机:{on},关机:{off}'}

@ -127,8 +127,8 @@
<el-checkbox label="redis">REDIS</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item v-if="restype.includes('ecs') && ecsJob.vendor === 'alicloud'" label="优先获取外网IP" prop="isextip">
<el-checkbox v-model="ecsJob.isextip">(ECS)</el-checkbox>
<el-form-item v-if="restype.includes('ecs')" label="优先获取外网IP" prop="isextip">
<el-checkbox v-model="ecsJob.isextip">(ECS)</el-checkbox>
</el-form-item>
<el-form-item prop="proj_interval">
<span slot="label">
@ -202,8 +202,8 @@
<el-checkbox label="redis">REDIS</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item v-if="editJob.restype.includes('ecs') && editJob.vendor === 'alicloud'" label="优先获取外网IP" prop="isextip">
<el-checkbox v-model="editJob.isextip">(ECS)</el-checkbox>
<el-form-item v-if="editJob.restype.includes('ecs')" label="优先获取外网IP" prop="isextip">
<el-checkbox v-model="editJob.isextip">(ECS)</el-checkbox>
</el-form-item>
<el-form-item prop="proj_interval">
<span slot="label">

Loading…
Cancel
Save