-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enhance VPC Network Tier form to auto-populate Gateway, and Netmask #10617
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
Changes from 3 commits
6aa691c
1d7fc2a
217789e
873aaa3
d4b11ef
6cd108e
60acacf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,18 +223,18 @@ | |
| </a-form-item> | ||
| <a-form-item ref="gateway" name="gateway" :colon="false"> | ||
| <template #label> | ||
| <tooltip-label :title="$t('label.gateway')" :tooltip="$t('label.create.tier.gateway.description')"/> | ||
| <tooltip-label :title="$t('label.gateway')" :tooltip="gatewayPlaceholder"/> | ||
| </template> | ||
| <a-input | ||
| :placeholder="$t('label.create.tier.gateway.description')" | ||
| :placeholder="gatewayPlaceholder" | ||
| v-model:value="form.gateway"></a-input> | ||
| </a-form-item> | ||
| <a-form-item ref="netmask" name="netmask" :colon="false"> | ||
| <template #label> | ||
| <tooltip-label :title="$t('label.netmask')" :tooltip="$t('label.create.tier.netmask.description')"/> | ||
| <tooltip-label :title="$t('label.netmask')" :tooltip="netmaskPlaceholder"/> | ||
| </template> | ||
| <a-input | ||
| :placeholder="$t('label.create.tier.netmask.description')" | ||
| :placeholder="netmaskPlaceholder" | ||
| v-model:value="form.netmask"></a-input> | ||
| </a-form-item> | ||
| <a-form-item ref="externalId" name="externalId" :colon="false"> | ||
|
|
@@ -381,6 +381,8 @@ export default { | |
| selectedNetworkOffering: {}, | ||
| privateMtuMax: 1500, | ||
| errorPrivateMtu: '', | ||
| gatewayPlaceholder: '', | ||
| netmaskPlaceholder: '', | ||
| algorithms: { | ||
| Source: 'source', | ||
| 'Round-robin': 'roundrobin', | ||
|
|
@@ -617,6 +619,46 @@ export default { | |
| this.initForm() | ||
| this.fetchNetworkAclList() | ||
| this.fetchNetworkOfferings() | ||
| const cidr = this.resource.cidr | ||
| if (cidr && cidr.includes('/')) { | ||
|
Imvedansh marked this conversation as resolved.
Outdated
|
||
| const [address, maskBits] = cidr.split('/') | ||
| const prefix = Number(maskBits) | ||
|
|
||
| const subnetMasks = { | ||
| 8: '255.0.0.0', | ||
| 9: '255.128.0.0', | ||
| 10: '255.192.0.0', | ||
| 11: '255.224.0.0', | ||
| 12: '255.240.0.0', | ||
| 13: '255.248.0.0', | ||
| 14: '255.252.0.0', | ||
| 15: '255.254.0.0', | ||
| 16: '255.255.0.0', | ||
| 17: '255.255.128.0', | ||
| 18: '255.255.192.0', | ||
| 19: '255.255.224.0', | ||
| 20: '255.255.240.0', | ||
| 21: '255.255.248.0', | ||
| 22: '255.255.252.0', | ||
| 23: '255.255.254.0', | ||
| 24: '255.255.255.0', | ||
| 25: '255.255.255.128', | ||
| 26: '255.255.255.192', | ||
| 27: '255.255.255.224', | ||
| 28: '255.255.255.240', | ||
| 29: '255.255.255.248', | ||
| 30: '255.255.255.252', | ||
| 31: '255.255.255.254', | ||
| 32: '255.255.255.255' | ||
| } | ||
|
|
||
| const cidrValue = `${address}/${maskBits}` | ||
|
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. Is it necessary to define this
Collaborator
Author
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. Previously, I was automating the input of the Gateway and Netmask fields. In that case, the Gateway needed to be the network address, and the Subnet Mask had to be derived from the prefix. |
||
| const netmask = subnetMasks[prefix] || '255.255.255.0' | ||
|
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. What do you think about abstracting this process of retrieving a CIDR's netmask into an utility function? Maybe, we could place it inside the
Collaborator
Author
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. I had considered abstracting this logic, as the use of subnetMask list felt out of place in that context. |
||
|
|
||
| this.gatewayPlaceholder = this.$t('label.create.tier.gateway.description', { value: cidrValue }) | ||
| this.netmaskPlaceholder = this.$t('label.create.tier.netmask.description', { value: netmask }) | ||
| } | ||
|
|
||
| this.showCreateNetworkModal = true | ||
| this.rules = { | ||
| name: [{ required: true, message: this.$t('label.required') }], | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.