支持阿里华为腾讯云采集ECS外网IP
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",
|
'mem':f"{str(round(int(i['flavor']['ram'])/1024,1)).rstrip('.0')}GB",
|
||||||
'exp': '-'
|
'exp': '-'
|
||||||
} for i in info}
|
} 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)
|
count = len(ecs_dict)
|
||||||
off,on = sync_ecs.w2consul('huaweicloud',account,region,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}'}
|
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
|
offset = 0
|
||||||
total = 0
|
total = 0
|
||||||
ecs_dict = {}
|
ecs_dict = {}
|
||||||
|
ecs_list_temp = []
|
||||||
while offset <= total:
|
while offset <= total:
|
||||||
params = {"Offset": offset, "Limit": 100}
|
params = {"Offset": offset, "Limit": 100}
|
||||||
req.from_json_string(json.dumps(params))
|
req.from_json_string(json.dumps(params))
|
||||||
resp = client.DescribeInstances(req)
|
resp = client.DescribeInstances(req)
|
||||||
ecs_list = resp.InstanceSet
|
ecs_list = resp.InstanceSet
|
||||||
|
ecs_list_temp.extend(ecs_list)
|
||||||
total = resp.TotalCount
|
total = resp.TotalCount
|
||||||
ecs_dict_temp = {i.InstanceId:{'name':i.InstanceName,'group':group_dict.get(str(i.Placement.ProjectId),'无'),
|
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',
|
'ostype': 'windows' if 'win' in i.OsName.lower() else 'linux',
|
||||||
|
@ -146,6 +148,16 @@ def ecs(account,region,isextip=False):
|
||||||
offset = offset + 100
|
offset = offset + 100
|
||||||
ecs_dict.update(ecs_dict_temp)
|
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)
|
count = len(ecs_dict)
|
||||||
off,on = sync_ecs.w2consul('tencent_cloud',account,region,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}'}
|
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 label="redis">REDIS</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="restype.includes('ecs') && ecsJob.vendor === 'alicloud'" label="优先获取外网IP" prop="isextip">
|
<el-form-item v-if="restype.includes('ecs')" label="优先获取外网IP" prop="isextip">
|
||||||
<el-checkbox v-model="ecsJob.isextip">(仅支持阿里云ECS)</el-checkbox>
|
<el-checkbox v-model="ecsJob.isextip">(仅支持ECS)</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="proj_interval">
|
<el-form-item prop="proj_interval">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
|
@ -202,8 +202,8 @@
|
||||||
<el-checkbox label="redis">REDIS</el-checkbox>
|
<el-checkbox label="redis">REDIS</el-checkbox>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="editJob.restype.includes('ecs') && editJob.vendor === 'alicloud'" label="优先获取外网IP" prop="isextip">
|
<el-form-item v-if="editJob.restype.includes('ecs')" label="优先获取外网IP" prop="isextip">
|
||||||
<el-checkbox v-model="editJob.isextip">(仅支持阿里云ECS)</el-checkbox>
|
<el-checkbox v-model="editJob.isextip">(仅支持ECS)</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="proj_interval">
|
<el-form-item prop="proj_interval">
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
|
|
Loading…
Reference in New Issue