-
Notifications
You must be signed in to change notification settings - Fork 289
Fix Vpc Network #5385
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
Draft
LAVEEN
wants to merge
9
commits into
GoogleCloudPlatform:develop
Choose a base branch
from
LAVEEN:fixvpcnetwork
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Fix Vpc Network #5385
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
00a8fc9
Fix VPC Name
LAVEEN 41f1d52
Have permanent VPC name
LAVEEN d1f8e15
Apply suggestion from @gemini-code-assist[bot]
LAVEEN 676276a
Apply suggestion from @gemini-code-assist[bot]
LAVEEN bad2f12
Revert "Fix the network name (#5315)"
fe30b0e
Finalize VPC network testing logic via tools/modify_vpc.py
384d88d
Finalize VPC network testing logic via tools/modify_vpc.py
7ac8493
Fix
f652221
Merge branch 'develop' into fixvpcnetwork
LAVEEN 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,29 @@ | ||
| import yaml | ||
| import sys | ||
|
|
||
| def modify_vpcs(blueprint_path): | ||
| with open(blueprint_path, 'r') as f: | ||
| data = yaml.safe_load(f) | ||
|
|
||
| vpc_count = 0 | ||
| # Iterate through all deployment groups and modules | ||
| if 'deployment_groups' in data: | ||
LAVEEN marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for group in data['deployment_groups']: | ||
| for module in group.get('modules', []): | ||
| # Identify VPC modules by their source path | ||
| if 'modules/network/vpc' in module.get('source', ''): | ||
| if 'settings' not in module: | ||
| module['settings'] = {} | ||
| # Set the consecutive name using the $(vars.test_name) variable | ||
| module['settings']['network_name'] = f"$(vars.test_name)-{vpc_count}" | ||
| print(f"Updated module '{module.get('id')}' to: $(vars.test_name)-{vpc_count}") | ||
| vpc_count += 1 | ||
|
|
||
| with open(blueprint_path, 'w') as f: | ||
| yaml.dump(data, f, sort_keys=False) | ||
|
|
||
| if __name__ == "__main__": | ||
| if len(sys.argv) < 2: | ||
| sys.exit(1) | ||
| modify_vpcs(sys.argv[1]) | ||
LAVEEN marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes made by your new script
tools/modify_vpc.pyare being overwritten by a latersedcommand on line 87. Your script correctly assigns unique network names (e.g.,$(vars.test_name)-0,$(vars.test_name)-1) to the VPC modules. However, thesedcommand on line 87 then resets thenetwork_namefor both VPC modules to the same value,$(vars.base_network_name), which will likely cause a resource name collision. You should probably remove thesedcommand on line 87 to allow your script's changes to persist.