-
Notifications
You must be signed in to change notification settings - Fork 1k
[ansible] Adding support for multi vlans #1353
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
Merged
tahmed-dev
merged 9 commits into
sonic-net:master
from
tahmed-dev:taahme/add-vlan-support
Jan 29, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ab78b30
[ansible] Adding support for droplet vlans
tahmed-dev 7a9fdae
Fix bug with IPInterface for new vlans.
tahmed-dev 09b9398
Addressing code comments
tahmed-dev 78ab5d2
PR comments
tahmed-dev 48f23a8
Option 2: making vlan part of topo files
tahmed-dev 6574f1e
PR comments
tahmed-dev 50dd4aa
PR Comments
tahmed-dev 16687cb
Removing separate vlan file
tahmed-dev 8dfaae9
Offline comments
tahmed-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import yaml | ||
| import traceback | ||
|
|
||
| DOCUMENTATION = ''' | ||
| module: vlan_config.py | ||
| Ansible_version_added: 2.0.0.2 | ||
| short_description: Gather all vlan info related to servers' interfaces | ||
| Description: | ||
| When deploy testbed topology with server connected to TOR SONiC, | ||
| gather server vlan interfaces info for generating SONiC minigraph file | ||
| arguments: | ||
| vm_topo_config: Topology file; required: True | ||
| port_alias: Port aliases of TOR SONiC; required: True | ||
| vlan_config: vlan config name to use; required: False | ||
|
|
||
| Ansible_facts: | ||
| 'vlan_configs': all Vlans Configuration | ||
| ''' | ||
|
|
||
| EXAMPLES = ''' | ||
| - name: find all vlan configurations for T0 topology | ||
| vlan_config: | ||
| vm_topo_config: "{{ vm_topo_config }}" | ||
| port_alias: "{{ port_alias }}" | ||
| vlan_config: "{{ vlan_config | default(None) }}" | ||
| ''' | ||
|
|
||
| def main(): | ||
| module = AnsibleModule( | ||
| argument_spec=dict( | ||
| vm_topo_config=dict(required=True), | ||
| port_alias=dict(required=True), | ||
| vlan_config=dict(required=False, type='str', default=None), | ||
| ), | ||
| supports_check_mode=True | ||
| ) | ||
| m_args = module.params | ||
| port_alias = m_args['port_alias'] | ||
| vlan_config = m_args['vlan_config'] | ||
|
|
||
| vlan_configs = {} | ||
| try: | ||
| if vlan_config is None or len(vlan_config) == 0: | ||
| vlan_config = m_args['vm_topo_config']['DUT']['vlan_configs']['default_vlan_config'] | ||
|
|
||
| vlans = m_args['vm_topo_config']['DUT']['vlan_configs'][vlan_config] | ||
| for vlan, vlan_param in vlans.items(): | ||
| vlan_configs.update({vlan : {}}) | ||
| vlan_configs[vlan]['id'] = vlan_param['id'] | ||
| vlan_configs[vlan]['tag'] = vlan_param['tag'] | ||
| vlan_configs[vlan]['prefix'] = vlan_param['prefix'] | ||
| vlan_configs[vlan]['intfs'] = [port_alias[i] for i in vlan_param['intfs']] | ||
| except Exception as e: | ||
| module.fail_json(msg = traceback.format_exc()) | ||
| else: | ||
| module.exit_json(ansible_facts={'vlan_configs' : vlan_configs}) | ||
|
|
||
| from ansible.module_utils.basic import * | ||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.