-
Notifications
You must be signed in to change notification settings - Fork 5
Use number of fip also for internal network #428
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
jose-caballero
wants to merge
2
commits into
main
Choose a base branch
from
use_number_of_fip_also_for_internal_network
base: main
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,12 +102,14 @@ def create_project( | |
| refresh_security_groups(conn, project["id"]) | ||
|
|
||
| network_type = Networks.from_string(network) | ||
|
|
||
| set_floating_ips(conn, project, network_type, number_of_floating_ips) | ||
|
|
||
| if network_type in (Networks.EXTERNAL, Networks.JASMIN): | ||
| setup_external_networking( | ||
| conn, | ||
| project, | ||
| network_type, | ||
| number_of_floating_ips, | ||
| number_of_security_group_rules, | ||
| ) | ||
| elif network_type == Networks.INTERNAL: | ||
|
|
@@ -148,7 +150,6 @@ def setup_external_networking( | |
| conn: Connection, | ||
| project: Project, | ||
| external_network: Networks, | ||
| number_of_floating_ips: int, | ||
| number_of_security_group_rules: int, | ||
| ): | ||
| """ | ||
|
|
@@ -159,8 +160,6 @@ def setup_external_networking( | |
| :type project: Project | ||
| :param external_network: External Cloud network | ||
| :type external_network: Networks | ||
| :param number_of_floating_ips: Floating IP quota for project | ||
| :type number_of_floating_ips: int | ||
| :param number_of_security_group_rules: Security group quota for project | ||
| :type number_of_security_group_rules: int | ||
| """ | ||
|
|
@@ -234,7 +233,6 @@ def setup_external_networking( | |
| conn, | ||
| QuotaDetails( | ||
| project_identifier=project.id, | ||
| floating_ips=number_of_floating_ips, | ||
| security_group_rules=number_of_security_group_rules, | ||
| ), | ||
| ) | ||
|
|
@@ -253,15 +251,6 @@ def setup_external_networking( | |
|
|
||
| logger.info("Created default security group") | ||
|
|
||
| allocate_floating_ips( | ||
| conn, | ||
| network_identifier=external_network.value, | ||
| project_identifier=project.id, | ||
| number_to_create=number_of_floating_ips, | ||
| ) | ||
|
|
||
| logger.info("Allocated %s floating ips", number_of_floating_ips) | ||
|
|
||
|
|
||
| def setup_internal_networking(conn: Connection, project: Project): | ||
| """ | ||
|
|
@@ -282,3 +271,37 @@ def setup_internal_networking(conn: Connection, project: Project): | |
|
|
||
| # create default security group rules | ||
| create_internal_security_group_rules(conn, project["id"], "default") | ||
|
|
||
|
|
||
| def set_floating_ips( | ||
| conn: Connection, | ||
| project: Project, | ||
| network: Networks, | ||
| number_of_floating_ips: int, | ||
| ): | ||
| """ | ||
| Set the Floating IPs | ||
|
|
||
| :param conn: OpenStack connection object | ||
| :type conn: Connection | ||
| :param project: OpenStack project object | ||
| :type project: Project | ||
| :param network: type of network | ||
| :type network: Networks | ||
| :param number_of_floating_ips: Floating IP quota for project | ||
| :type number_of_floating_ips: int | ||
| """ | ||
| set_quota( | ||
| conn, | ||
| QuotaDetails( | ||
| project_identifier=project.id, | ||
| floating_ips=number_of_floating_ips, | ||
| ), | ||
| ) | ||
| allocate_floating_ips( | ||
| conn, | ||
| network_identifier=network.value, | ||
| project_identifier=project.id, | ||
| number_to_create=number_of_floating_ips, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will max out their quota when the project is created?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we should not do this. Let users allocate their own FIPs. Otherwise we are wasting FIPs |
||
| ) | ||
| logger.info("Allocated %s floating ips", number_of_floating_ips) | ||
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.
I think this will attempt to allocate floating IPs from the Internal network which we don't want, only from External or Jasmin