Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update b1_ipam_address_block.py to include creation of tags #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def next_available_address_block(data):
cidr = int(address_data['cidr'])
name = data['name'] if 'name' in data.keys() else ''
comment = data['comment'] if 'comment' in data.keys() else ''
tags = data['tags'] if 'tags' in data.keys() else ''

data['address'] = address_data['parent_block']
address_block = get_address_block(data)
Expand All @@ -271,7 +272,11 @@ def next_available_address_block(data):
elif(name!='' and comment==''):
endpoint = f'/api/ddi/v1/{ref_id}/nextavailableaddressblock?count={count}&cidr={cidr}&name={name}'
else:
endpoint = f'/api/ddi/v1/{ref_id}/nextavailableaddressblock?count={count}&cidr={cidr}'
endpoint = f'/api/ddi/v1/{ref_id}/nextavailableaddressblock?count={count}&cidr={cidr}'
if tags:
# Convert tags list of dictionaries to URL query string
tags_str = '&'.join([f"{k}={v}" for tag in tags for k, v in tag.items()])
endpoint += f'&{tags_str}'
return connector.create(endpoint,body=False)
except:
return(True, False, {'status': '400', 'response': 'Invalid Syntax', 'data':data})
Expand Down