Skip to content

Commit

Permalink
F #5832: Add IPv6 AR no-SLAAC (#2233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Betanzos authored and rsmontero committed Jul 27, 2022
1 parent 7c2e9c9 commit 7ca5e0c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const AddressRangeCard = memo(

return (
<Box
data-cy="ar"
className={classes.root}
sx={{
'&:hover': { bgcolor: 'action.hover' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ import {
OPTION_SORTERS,
arrayToOptions,
REG_V4,
REG_V6,
REG_MAC,
} from 'client/utils'
import { T, INPUT_TYPES } from 'client/constants'

const AR_TYPES = { IP4: 'IP4', IP4_6: 'IP4_6', IP6: 'IP6', ETHER: 'ETHER' }
const AR_TYPES = {
IP4: 'IP4',
IP4_6: 'IP4_6',
IP6: 'IP6',
IP6_STATIC: 'IP6_STATIC',
ETHER: 'ETHER',
}

const AR_TYPES_STR = {
[AR_TYPES.IP4]: 'IPv4',
[AR_TYPES.IP4_6]: 'IPv4/6',
[AR_TYPES.IP6]: 'IPv6',
[AR_TYPES.IP6_STATIC]: 'IPv6 (no-SLAAC)',
[AR_TYPES.IP4_6]: 'IPv4/6',
[AR_TYPES.ETHER]: 'Ethernet',
}

Expand Down Expand Up @@ -58,18 +66,58 @@ const IP_FIELD = {
type: INPUT_TYPES.TEXT,
dependOf: TYPE_FIELD.name,
htmlType: (arType) =>
[AR_TYPES.IP6, AR_TYPES.ETHER].includes(arType) && INPUT_TYPES.HIDDEN,
[AR_TYPES.IP6, AR_TYPES.IP6_STATIC, AR_TYPES.ETHER].includes(arType) &&
INPUT_TYPES.HIDDEN,
validation: string()
.trim()
.default(() => undefined)
.when(TYPE_FIELD.name, {
is: (arType) => [AR_TYPES.IP6, AR_TYPES.ETHER].includes(arType),
is: (arType) =>
[AR_TYPES.IP6, AR_TYPES.IP6_STATIC, AR_TYPES.ETHER].includes(arType),
then: (schema) => schema.strip().notRequired(),
otherwise: (schema) =>
schema.required().matches(REG_V4, { message: T.InvalidIPv4 }),
}),
}

/** @type {Field} IPv6 field */
const IP6_FIELD = {
name: 'IP6',
label: T.FirstIPv6Address,
type: INPUT_TYPES.TEXT,
dependOf: TYPE_FIELD.name,
htmlType: (arType) =>
![AR_TYPES.IP6_STATIC, AR_TYPES.IP4_6].includes(arType) &&
INPUT_TYPES.HIDDEN,
validation: string()
.trim()
.default(() => undefined)
.when(TYPE_FIELD.name, {
is: (arType) => ![AR_TYPES.IP6_STATIC, AR_TYPES.IP4_6].includes(arType),
then: (schema) => schema.strip(),
otherwise: (schema) =>
schema.required().matches(REG_V6, { message: T.InvalidIPv6 }),
}),
}

/** @type {Field} Prefix length field */
const PREFIX_LENGTH_FIELD = {
name: 'PREFIX_LENGTH',
label: T.PrefixLength,
tooltip: T.PrefixLengthConcept,
type: INPUT_TYPES.TEXT,
dependOf: TYPE_FIELD.name,
htmlType: (arType) => AR_TYPES.IP6_STATIC !== arType && INPUT_TYPES.HIDDEN,
validation: string()
.trim()
.default(() => undefined)
.when(TYPE_FIELD.name, {
is: (arType) => AR_TYPES.IP6_STATIC !== arType,
then: (schema) => schema.strip(),
otherwise: (schema) => schema.required(),
}),
}

/** @type {Field} MAC field */
const MAC_FIELD = {
name: 'MAC',
Expand Down Expand Up @@ -137,8 +185,10 @@ const FIELDS = [
TYPE_FIELD,
IP_FIELD,
MAC_FIELD,
IP6_FIELD,
SIZE_FIELD,
GLOBAL_PREFIX_FIELD,
PREFIX_LENGTH_FIELD,
ULA_PREFIX_FIELD,
]

Expand Down
4 changes: 4 additions & 0 deletions src/fireedge/src/client/constants/translates.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,13 +892,17 @@ module.exports = {
Addresses: 'Addresses',
AddressRange: 'Address Range',
FirstIPv4Address: 'First IPv4 address',
FirstIPv6Address: 'First IPv6 address',
FirstMacAddress: 'First MAC address',
PrefixLength: 'Prefix length',
PrefixLengthConcept: 'Length of the prefix to configure VM interfaces',
SLAAC: 'SLAAC',
IPv6GlobalPrefix: 'IPv6 Global prefix',
IPv6ULAPrefix: 'IPv6 ULA prefix',
IPAMDriver: 'IPAM driver',
InvalidAddress: 'Invalid address',
InvalidIPv4: 'Invalid IPv4',
InvalidIPv6: 'Invalid IPv6',
InvalidMAC: 'Invalid MAC',
DisabledAddressRangeInForm:
'Address Ranges need to be managed in the individual Virtual Network panel',
Expand Down

0 comments on commit 7ca5e0c

Please sign in to comment.