45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
async def describe_eip(ns={}):
|
|
import aiohttp
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
ucloud_user_li = await sor.R('ucloud_users', {'orgid': 'main_user', 'del_flg': '0'})
|
|
if ucloud_user_li:
|
|
uc_client = U_Client({
|
|
"project_id": ucloud_user_li[0]['projectid'],
|
|
"public_key": ucloud_user_li[0]['accesskey'],
|
|
"private_key": ucloud_user_li[0]['accesskeysecret'],
|
|
})
|
|
else:
|
|
return {
|
|
'status': False,
|
|
'msg': 'can not find u cloud user'
|
|
}
|
|
try:
|
|
resp = uc_client.unet().describe_eip({
|
|
"Region": ns.get('Region'),
|
|
"Offset": 0,
|
|
"Limit": 10000
|
|
})
|
|
print(resp)
|
|
if resp['TotalCount'] > 0:
|
|
new_eip_li = []
|
|
for eip in resp['EIPSet']:
|
|
if ns.get('orgid') in eip['Name']:
|
|
eip['Name'] = eip['Name'].split('0_____0')[-1]
|
|
new_eip_li.append(eip)
|
|
resp['EIPSet'] = new_eip_li
|
|
# resp['TotalCount'] = len(new_eip_li)
|
|
|
|
return {
|
|
'status': True,
|
|
'msg': 'bind eip success',
|
|
'data': resp['EIPSet']
|
|
}
|
|
except exc.UCloudException as e:
|
|
return {
|
|
'status': False,
|
|
'msg': 'bind eip failed, %s' % str(e)
|
|
}
|
|
|
|
ret = await describe_eip(params_kw)
|
|
return ret |