Skip to content

Commit

Permalink
Merge pull request #8 from insobi/20240430
Browse files Browse the repository at this point in the history
fixed bug
  • Loading branch information
insobi authored Apr 30, 2024
2 parents 913e930 + 29c595a commit 6f63fda
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions aci-interface-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_l1PhysIf(self, page_size=100, filters={}) -> (bool, dict):
l1PhysIf = []
page = 0
while True:
url = f'{self.base_url}/api/node/class/l1PhysIf.json?page-size={page_size}&page={page}'
url = f'{self.base_url}/api/node/class/l1PhysIf.json?page-size={page_size}&page={page}&order-by=l1PhysIf.dn'
if filters:
filter_items = []
if 'descr_exists' in filters:
Expand All @@ -69,7 +69,7 @@ def get_ethpmPhysIf(self, page_size=100, filters={}) -> (bool, dict):
ethpmPhysIf = []
page = 0
while True:
url = f'{self.base_url}/api/node/class/ethpmPhysIf.json?page-size={page_size}&page={page}'
url = f'{self.base_url}/api/node/class/ethpmPhysIf.json?page-size={page_size}&page={page}&order-by=ethpmPhysIf.dn'
if filters:
filter_items = []
if 'state' in filters:
Expand All @@ -85,17 +85,24 @@ def get_ethpmPhysIf(self, page_size=100, filters={}) -> (bool, dict):
page += 1
return True, {"imdata": ethpmPhysIf}

def get_vpcIf(self, filters) -> (bool, str):
def get_vpcIf(self, page_size=100, filters={}) -> (bool, str):
'''call rest api for get VPC interfaces'''
url = f'{self.base_url}/api/node/class/vpcIf.json?page=0'
if filters:
if filters['descr_exists']:
url += '&query-target-filter=ne(vpcIf.descr,"")'
response = requests.request("GET", url=url, headers=self.headers, verify=self.ssl_verify)
if response.status_code == 200:
return True, response.json()
else:
return False, 'Failed to Execute.'
vpcIf = []
page = 0
while True:
url = f'{self.base_url}/api/node/class/vpcIf.json?page-size={page_size}&page={page}&order-by=vpcIf.dn'
if filters:
if filters['descr_exists']:
url += '&query-target-filter=ne(vpcIf.descr,"")'
res = requests.request("GET", url=url, headers=self.headers, verify=self.ssl_verify)
try:
res.json()['imdata'][0]
for item in res.json()['imdata']:
vpcIf.append(item)
except:
break
page += 1
return True, {"imdata": vpcIf}


@click.group()
Expand Down

0 comments on commit 6f63fda

Please sign in to comment.