mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-26 18:40:51 +08:00
* feat: add the Kube-OVN BGP page and a BGP option on subnets Add an Overlay Networks > BGP page that edits spec.bgp of the kube-system/kubeovn Configuration: speaker hosts, neighbor IPv4 and IPv6 addresses, neighbor and cluster AS, router ID and next hops. Add a BGP option to the subnet form that sets or removes the ovn.kubernetes.io/bgp annotation. Both need Harvester v1.10.0 or later. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * refactor: move the BGP settings into the kubeovn-operator add-on Every entry under Overlay Networks is a list, and BGP is a single setting for the whole Kube-OVN install, so show it as a BGP tab in the kubeovn-operator add-on's config instead of its own page. The tab saves spec.bgp of the kube-system/kubeovn Configuration before the add-on is saved, only when it changed and the add-on stays enabled. The subnet BGP tooltip now points to it. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: make the BGP tab clearer and check each field as it is typed - Add a BGP Speaker Enabled/Disabled switch. Disabled removes the speaker hosts and keeps the other values. An untouched install opens as disabled, with empty fields instead of the placeholder values. - Neighbors are one list of IPv4 or IPv6 addresses, split by family on save with duplicates dropped. Next hops are two single fields, one per family, under Advanced. - Show the errors under each field as it is typed, and keep the same checks on save. A router ID is rejected when more than one host runs the speaker, because every speaker needs its own. - Only write the Configuration when the form changed. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: save the BGP tab on top of the latest Kube-OVN Configuration The operator rewrites the Configuration's status about every five minutes, so the copy loaded with the form went stale and saving it failed with a conflict when the form had been open for a while. Fetch the latest copy at save time and apply only spec.bgp to it. After a successful save, remember it, so pressing Save again after a failed add-on save doesn't send the Configuration twice. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: warn on the subnet form when no host runs the BGP speaker Turning BGP on for a subnet has no effect until some host runs the BGP speaker. When the subnet's BGP option is Enabled and the Kube-OVN Configuration has no speaker hosts, show a warning that links to the BGP tab of the kubeovn-operator add-on. If the Configuration can't be read, show nothing. The add-on form now shows its tabs once the BGP data is loaded, so a link to its #bgp tab opens that tab: Tabbed only honours the URL hash when the tabs first appear. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * refactor: move the BGP speaker to Overlay Networks > Settings Keep the BGP configuration out of the kubeovn-operator add-on: add an Overlay Networks > Settings page that lists cluster-wide overlay network settings as cards, like Advanced > Settings. The BGP Speaker card shows whether the speaker is off or where it runs and what it peers with, and its Edit action opens the BGP form on its own page. The page owns its Save button, so Save stays disabled while the form has errors. The add-on goes back to its generic form, and the subnet BGP warning links to the new page. The speaker state the card and the warning need is read through a kubeovn.io.configuration model. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: show why Save is disabled on the BGP Speaker page Save stays disabled while the form is invalid, but an empty Speaker Hosts or Neighbor Addresses showed no error anywhere, and the neighbor list had no required mark. Mark Neighbor Addresses as required and flag both fields when they are left empty, like the other required fields. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: show load errors and fix the add-on link on the BGP pages - The BGP Speaker page showed only its title when the Kube-OVN Configuration could not be read, because the error was only shown inside the form. Show it on the page. The Settings card now says Unknown instead of Disabled in that case. - The add-on link on the BGP Speaker page was a relative path, which resolved under /overlay-network-settings/ and opened the fail-whale. Both pages now link to the add-on by route name. - The subnet form shows its BGP warning under the BGP option, like the DHCP banner, instead of in a column of its own. - The BGP page reads hosts, neighbors and next hops through the model's getters instead of parsing them again. - The "requires v1.10.0" message uses the product name token, and the subnet BGP comment and tooltip no longer say that "local" advertises the subnet's CIDR block. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * refactor: keep the Kube-OVN model's parsing helpers private Nothing outside the model uses splitList or the placeholder neighbor addresses since the BGP page reads the model's getters, so stop exporting them. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: tell users to label the external gateway hosts on BGP subnets When BGP is enabled on a subnet, show a note under it: the hosts that carry external traffic need the label ovn.kubernetes.io/external-gw=true. It shows next to the existing warning about the BGP speaker having no hosts. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: separate the IPv4 and IPv6 BGP neighbors - The BGP Speaker page now has one neighbor list per family, like the next hops. Each list only takes addresses of its own family, and one neighbor in either list is enough. - Reject the placeholder neighbors Harvester installs (192.0.2.1 and 2001:db8::1). The page hides them on load, so a saved one disappeared on the next visit and was dropped on the next save. - Only treat the Configuration as never set up when it holds nothing but the installed values. A speaker set up with the private AS numbers 64512/64513 and then disabled used to reopen with both AS fields blank. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: edit the BGP speaker on the Overlay Network Settings page Overlay Network Settings showed one card per setting and opened the BGP speaker on a page of its own. Show the BGP speaker form on the settings page instead, in an RcSection titled BGP Speaker, with Save and no Cancel. Another setting would be another section on the same page, under the same Save. Saving stays on the page and shows what was saved. Inside the section, follow how the shell's own RcSection forms are built: the Enabled/Disabled choice has no label of its own (the section title names it), and the neighbors and the advanced options are nested secondary sections, with the two neighbor lists under column headers instead of their own headings. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: reject IPv4 addresses with leading zeros in the BGP speaker The speaker parses its addresses with Go, which rejects an IPv4 part written with a leading zero, like 192.0.2.010. The form accepted those in the IPv4 neighbors, the router ID and the next hops, and nothing on the backend checks them, so saving one left the speaker unable to start. Reject them on every address field, including an IPv6 address that ends in an IPv4 one, and say how to write the address instead. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * feat: show the BGP speaker as its own entry under Overlay Networks The backend owner asked for BGP to show in the menu by name rather than behind a Settings entry. Replace Overlay Networks > Settings with an Overlay Networks > BGP Speaker entry that opens the form directly, titled BGP Speaker, and point the subnet's BGP warning and tooltip to it. If more parts of the Kube-OVN Configuration get a form later, they can move into a Configuration group under Overlay Networks. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> --------- Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
589 lines
19 KiB
Vue
589 lines
19 KiB
Vue
<script>
|
|
import isEqual from 'lodash/isEqual';
|
|
import ArrayList from '@shell/components/form/ArrayList';
|
|
import CruResource from '@shell/components/CruResource';
|
|
import LabeledSelect from '@shell/components/form/LabeledSelect';
|
|
import Loading from '@shell/components/Loading';
|
|
import MessageLink from '@shell/components/MessageLink';
|
|
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
import { RadioGroup } from '@components/Form/Radio';
|
|
import { Banner } from '@components/Banner';
|
|
import { RcSection } from '@components/RcSection';
|
|
import { RcContentGroup } from '@components/Layout';
|
|
import { NODE } from '@shell/config/types';
|
|
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
import { isIpv4 } from '@shell/utils/string';
|
|
import { exceptionToErrorsArray } from '@shell/utils/error';
|
|
import { allHash } from '@shell/utils/promise';
|
|
import { HCI } from '../../../../types';
|
|
import { ADD_ONS } from '../../../../config/harvester-map';
|
|
import { PRODUCT_NAME } from '../../../../config/harvester';
|
|
import { KUBEOVN_CONFIGURATION_ID, isIpv6, isPlaceholderNeighbor, withoutLeadingZeros } from '../../../../models/kubeovn.io.configuration';
|
|
|
|
const AS_MAX = 4294967294;
|
|
|
|
const cleanList = (list) => [...new Set((list || []).map((item) => `${ item || '' }`.trim()).filter(Boolean))];
|
|
const isAsNumber = (value) => /^\d+$/.test(`${ value ?? '' }`.trim()) && Number(value) >= 1 && Number(value) <= AS_MAX;
|
|
const asText = (value) => `${ value ?? '' }`.trim();
|
|
|
|
// The BGP speaker part of the Kube-OVN Configuration (Overlay Networks > BGP Speaker)
|
|
export default {
|
|
name: 'HarvesterBgpSpeaker',
|
|
|
|
components: {
|
|
ArrayList,
|
|
Banner,
|
|
CruResource,
|
|
LabeledInput,
|
|
LabeledSelect,
|
|
Loading,
|
|
MessageLink,
|
|
RadioGroup,
|
|
RcContentGroup,
|
|
RcSection,
|
|
},
|
|
|
|
async fetch() {
|
|
const inStore = this.$store.getters['currentProduct'].inStore;
|
|
const hash = await allHash({
|
|
addons: this.$store.dispatch(`${ inStore }/findAll`, { type: HCI.ADD_ONS }),
|
|
nodes: this.$store.dispatch(`${ inStore }/findAll`, { type: NODE }),
|
|
});
|
|
|
|
this.addonEnabled = hash.addons.find((addon) => addon.name === ADD_ONS.KUBEOVN_OPERATOR)?.spec?.enabled === true;
|
|
|
|
if (!this.addonEnabled || !this.featureEnabled) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const configuration = await this.$store.dispatch(`${ inStore }/find`, { type: HCI.KUBEOVN_CONFIG, id: KUBEOVN_CONFIGURATION_ID });
|
|
|
|
this.configuration = await this.$store.dispatch(`${ inStore }/clone`, { resource: configuration });
|
|
this.loadBgp(this.configuration);
|
|
} catch (e) {
|
|
this.errors = exceptionToErrorsArray(e);
|
|
}
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
addonEnabled: false,
|
|
configuration: null,
|
|
bgpEnabled: false,
|
|
nodeNames: [],
|
|
neighborsV4: [],
|
|
neighborsV6: [],
|
|
neighborAS: '',
|
|
clusterAS: '',
|
|
routerID: '',
|
|
nextHopV4: '',
|
|
nextHopV6: '',
|
|
loadedState: null,
|
|
// Bumped after a save so the form is drawn again from the saved values, as after a reload
|
|
formKey: 0,
|
|
errors: [],
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
featureEnabled() {
|
|
return this.$store.getters['harvester-common/getFeatureEnabled']('kubeovnBgp');
|
|
},
|
|
|
|
mode() {
|
|
return this.configuration?.canUpdate ? _EDIT : _VIEW;
|
|
},
|
|
|
|
isView() {
|
|
return this.mode === _VIEW;
|
|
},
|
|
|
|
addonLocation() {
|
|
return {
|
|
name: `${ PRODUCT_NAME }-c-cluster-resource-namespace-id`,
|
|
params: {
|
|
resource: HCI.ADD_ONS, namespace: 'kube-system', id: ADD_ONS.KUBEOVN_OPERATOR
|
|
},
|
|
query: { mode: _EDIT },
|
|
};
|
|
},
|
|
|
|
// Save stays disabled until the form is valid; each field shows its own error
|
|
validationPassed() {
|
|
return this.validateBgp().length === 0;
|
|
},
|
|
|
|
nodeOptions() {
|
|
const inStore = this.$store.getters['currentProduct'].inStore;
|
|
const nodes = this.$store.getters[`${ inStore }/all`](NODE) || [];
|
|
|
|
return nodes.map((node) => ({
|
|
label: node.nameDisplay,
|
|
value: node.id,
|
|
}));
|
|
},
|
|
|
|
// Each field shows its own error once touched, so a disabled Save always has a visible reason
|
|
nodeNamesRules() {
|
|
return [(value) => ((value || []).length ? undefined : this.t('harvester.bgp.validation.hostsRequired', null, true))];
|
|
},
|
|
|
|
neighborV4Rules() {
|
|
return [(value) => this.neighborError(value, isIpv4)];
|
|
},
|
|
|
|
neighborV6Rules() {
|
|
return [(value) => this.neighborError(value, isIpv6)];
|
|
},
|
|
|
|
// One neighbor in either list is enough
|
|
hasNeighbor() {
|
|
return cleanList(this.neighborsV4).length + cleanList(this.neighborsV6).length > 0;
|
|
},
|
|
|
|
neighborASRules() {
|
|
return [(value) => this.asError('neighborAS', value)];
|
|
},
|
|
|
|
clusterASRules() {
|
|
return [(value) => this.asError('clusterAS', value)];
|
|
},
|
|
|
|
routerIDRules() {
|
|
return [(value) => this.routerIDError(value)];
|
|
},
|
|
|
|
nextHopV4Rules() {
|
|
return [(value) => this.nextHopError('nextHopV4', value, isIpv4)];
|
|
},
|
|
|
|
nextHopV6Rules() {
|
|
return [(value) => this.nextHopError('nextHopV6', value, isIpv6)];
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
loadBgp(configuration) {
|
|
const bgp = configuration.bgp;
|
|
const untouched = configuration.bgpUntouched;
|
|
|
|
this.nodeNames = configuration.bgpSpeakerHosts;
|
|
this.bgpEnabled = this.nodeNames.length > 0;
|
|
this.neighborsV4 = configuration.bgpNeighborsV4;
|
|
this.neighborsV6 = configuration.bgpNeighborsV6;
|
|
// An untouched install only has placeholder AS numbers: show empty fields instead of values nobody chose
|
|
this.neighborAS = untouched ? '' : bgp.neighborAS ?? '';
|
|
this.clusterAS = untouched ? '' : bgp.clusterAS ?? '';
|
|
this.routerID = bgp.routerID || '';
|
|
// The speaker uses the last next hop of each family
|
|
this.nextHopV4 = configuration.bgpNextHops.filter(isIpv4).pop() || '';
|
|
this.nextHopV6 = configuration.bgpNextHops.filter(isIpv6).pop() || '';
|
|
this.loadedState = this.formState();
|
|
},
|
|
|
|
formState() {
|
|
return {
|
|
enabled: this.bgpEnabled,
|
|
nodeNames: [...this.nodeNames],
|
|
neighborsV4: cleanList(this.neighborsV4),
|
|
neighborsV6: cleanList(this.neighborsV6),
|
|
neighborAS: asText(this.neighborAS),
|
|
clusterAS: asText(this.clusterAS),
|
|
routerID: this.routerID.trim(),
|
|
nextHopV4: this.nextHopV4.trim(),
|
|
nextHopV6: this.nextHopV6.trim(),
|
|
};
|
|
},
|
|
|
|
neighborError(value, isFamily) {
|
|
const ip = `${ value || '' }`.trim();
|
|
|
|
if (!ip) {
|
|
return this.hasNeighbor ? undefined : this.t('harvester.bgp.validation.neighborRequired', null, true);
|
|
}
|
|
|
|
if (withoutLeadingZeros(ip)) {
|
|
return this.leadingZeroError(ip);
|
|
}
|
|
|
|
// Harvester installs these before anyone sets up BGP, and this page hides them, so saving one would lose it
|
|
if (isPlaceholderNeighbor(ip)) {
|
|
return this.t('harvester.bgp.validation.placeholderNeighbor', { ip }, true);
|
|
}
|
|
|
|
const key = isFamily === isIpv4 ? 'neighborV4' : 'neighborV6';
|
|
|
|
return isFamily(ip) ? undefined : this.t(`harvester.bgp.validation.${ key }`, { ip }, true);
|
|
},
|
|
|
|
asError(field, value) {
|
|
return isAsNumber(value) ? undefined : this.t('harvester.bgp.validation.asNumber', { key: this.t(`harvester.bgp.${ field }.label`), max: AS_MAX }, true);
|
|
},
|
|
|
|
// The speaker can't parse these, so it would not start
|
|
leadingZeroError(ip) {
|
|
return this.t('harvester.bgp.validation.leadingZero', { ip, fixed: withoutLeadingZeros(ip) }, true);
|
|
},
|
|
|
|
routerIDError(value) {
|
|
const ip = `${ value || '' }`.trim();
|
|
|
|
if (!ip) {
|
|
return undefined;
|
|
}
|
|
|
|
if (withoutLeadingZeros(ip)) {
|
|
return this.leadingZeroError(ip);
|
|
}
|
|
|
|
if (!isIpv4(ip)) {
|
|
return this.t('harvester.bgp.validation.routerID', null, true);
|
|
}
|
|
|
|
// Every speaker needs its own router ID, and this one would go to every selected host
|
|
return this.nodeNames.length > 1 ? this.t('harvester.bgp.validation.routerIDMultipleHosts', null, true) : undefined;
|
|
},
|
|
|
|
nextHopError(field, value, isFamily) {
|
|
const ip = `${ value || '' }`.trim();
|
|
const key = isFamily === isIpv4 ? 'ipv4' : 'ipv6';
|
|
|
|
if (ip && withoutLeadingZeros(ip)) {
|
|
return this.leadingZeroError(ip);
|
|
}
|
|
|
|
return ip && !isFamily(ip) ? this.t(`harvester.bgp.validation.${ key }`, { key: this.t(`harvester.bgp.${ field }.label`) }, true) : undefined;
|
|
},
|
|
|
|
validateBgp() {
|
|
if (!this.bgpEnabled) {
|
|
return [];
|
|
}
|
|
|
|
const errors = [];
|
|
|
|
if (!this.nodeNames.length) {
|
|
errors.push(this.t('harvester.bgp.validation.hostsRequired', null, true));
|
|
}
|
|
|
|
if (!this.hasNeighbor) {
|
|
errors.push(this.t('harvester.bgp.validation.neighborRequired', null, true));
|
|
} else {
|
|
// The first bad address is enough here: the lists flag each one
|
|
errors.push([
|
|
...cleanList(this.neighborsV4).map((ip) => this.neighborError(ip, isIpv4)),
|
|
...cleanList(this.neighborsV6).map((ip) => this.neighborError(ip, isIpv6)),
|
|
].find(Boolean));
|
|
}
|
|
|
|
errors.push(
|
|
this.asError('neighborAS', this.neighborAS),
|
|
this.asError('clusterAS', this.clusterAS),
|
|
this.routerIDError(this.routerID),
|
|
this.nextHopError('nextHopV4', this.nextHopV4, isIpv4),
|
|
this.nextHopError('nextHopV6', this.nextHopV6, isIpv6),
|
|
);
|
|
|
|
return errors.filter(Boolean);
|
|
},
|
|
|
|
toBgpSpec(current = {}) {
|
|
const bgp = { ...current };
|
|
|
|
// Disabled: no host runs the speaker. Keep the other values for when it is turned back on.
|
|
if (!this.bgpEnabled) {
|
|
delete bgp.nodeNames;
|
|
|
|
return bgp;
|
|
}
|
|
|
|
const state = this.formState();
|
|
|
|
Object.assign(bgp, {
|
|
nodeNames: state.nodeNames.join(','),
|
|
neighborV4Address: state.neighborsV4.join(','),
|
|
neighborV6Address: state.neighborsV6.join(','),
|
|
neighborAS: Number(state.neighborAS),
|
|
clusterAS: Number(state.clusterAS),
|
|
routerID: state.routerID,
|
|
nextHops: [state.nextHopV4, state.nextHopV6].filter(Boolean).join(','),
|
|
});
|
|
|
|
// The CRD omits empty strings, so drop them instead of storing ''
|
|
Object.keys(bgp).forEach((key) => {
|
|
if (bgp[key] === '') {
|
|
delete bgp[key];
|
|
}
|
|
});
|
|
|
|
return bgp;
|
|
},
|
|
|
|
async save(buttonCb) {
|
|
// Save is disabled while the form is invalid; this is the backstop
|
|
const errors = this.validateBgp();
|
|
|
|
if (errors.length) {
|
|
this.errors = errors;
|
|
buttonCb(false);
|
|
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (!isEqual(this.formState(), this.loadedState)) {
|
|
// The operator keeps updating the Configuration's status, so the copy loaded with the page goes stale
|
|
// and saving it fails with a conflict. Save the BGP values on top of the latest copy instead.
|
|
const inStore = this.$store.getters['currentProduct'].inStore;
|
|
const latest = await this.$store.dispatch(`${ inStore }/find`, {
|
|
type: HCI.KUBEOVN_CONFIG, id: KUBEOVN_CONFIGURATION_ID, opt: { force: true }
|
|
});
|
|
const configuration = await this.$store.dispatch(`${ inStore }/clone`, { resource: latest });
|
|
const bgp = this.toBgpSpec(configuration.spec?.bgp);
|
|
|
|
if (!isEqual(bgp, configuration.spec?.bgp || {})) {
|
|
configuration.spec = { ...configuration.spec, bgp };
|
|
await configuration.save();
|
|
}
|
|
|
|
// Stay on the page, showing what was saved
|
|
this.configuration = configuration;
|
|
this.loadBgp(configuration);
|
|
this.formKey++;
|
|
}
|
|
|
|
this.errors = [];
|
|
buttonCb(true);
|
|
} catch (e) {
|
|
this.errors = exceptionToErrorsArray(e);
|
|
buttonCb(false);
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<Loading v-if="$fetchState.pending" />
|
|
<div v-else>
|
|
<h1 class="mb-20">
|
|
{{ t('harvester.bgp.label') }}
|
|
</h1>
|
|
<CruResource
|
|
v-if="featureEnabled && addonEnabled && configuration"
|
|
:resource="configuration"
|
|
:mode="mode"
|
|
:can-yaml="false"
|
|
:show-cancel="false"
|
|
:validation-passed="validationPassed"
|
|
:errors="errors"
|
|
@finish="save"
|
|
@error="e => errors = e"
|
|
>
|
|
<RcSection
|
|
:key="formKey"
|
|
type="primary"
|
|
mode="no-header"
|
|
:expandable="false"
|
|
data-testid="bgp-section"
|
|
>
|
|
<RcContentGroup>
|
|
<Banner
|
|
color="info"
|
|
class="mt-0 mb-0"
|
|
:label="t('harvester.bgp.description')"
|
|
/>
|
|
<!-- The section title names this choice, as in the shell's own sections -->
|
|
<RadioGroup
|
|
v-model:value="bgpEnabled"
|
|
data-testid="bgp-enabled"
|
|
name="bgp-enabled"
|
|
:aria-label="t('harvester.bgp.label')"
|
|
:mode="mode"
|
|
:options="[true, false]"
|
|
:labels="[t('generic.enabled'), t('generic.disabled')]"
|
|
/>
|
|
</RcContentGroup>
|
|
<template v-if="bgpEnabled">
|
|
<RcContentGroup>
|
|
<div class="row">
|
|
<div class="col span-12">
|
|
<LabeledSelect
|
|
v-model:value="nodeNames"
|
|
data-testid="bgp-node-names"
|
|
:mode="mode"
|
|
:multiple="true"
|
|
:required="true"
|
|
:rules="nodeNamesRules"
|
|
:options="nodeOptions"
|
|
:label="t('harvester.bgp.nodeNames.label')"
|
|
:placeholder="t('harvester.bgp.nodeNames.placeholder')"
|
|
:tooltip="t('harvester.bgp.nodeNames.tooltip')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col span-6">
|
|
<LabeledInput
|
|
v-model:value="clusterAS"
|
|
data-testid="bgp-cluster-as"
|
|
type="number"
|
|
min="1"
|
|
:required="true"
|
|
:mode="mode"
|
|
:rules="clusterASRules"
|
|
:label="t('harvester.bgp.clusterAS.label')"
|
|
:placeholder="t('harvester.bgp.clusterAS.placeholder')"
|
|
:tooltip="t('harvester.bgp.clusterAS.tooltip')"
|
|
/>
|
|
</div>
|
|
<div class="col span-6">
|
|
<LabeledInput
|
|
v-model:value="routerID"
|
|
data-testid="bgp-router-id"
|
|
:mode="mode"
|
|
:rules="routerIDRules"
|
|
:label="t('harvester.bgp.routerID.label')"
|
|
:placeholder="t('harvester.bgp.routerID.placeholder', null, true)"
|
|
:tooltip="t('harvester.bgp.routerID.tooltip')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</RcContentGroup>
|
|
<RcSection
|
|
:title="t('harvester.bgp.neighbors.label')"
|
|
type="secondary"
|
|
mode="with-header"
|
|
:expandable="false"
|
|
data-testid="bgp-neighbors-section"
|
|
>
|
|
<!-- One neighbor in either list is enough, so neither list is marked required -->
|
|
<p
|
|
v-if="!isView"
|
|
class="mb-0"
|
|
>
|
|
{{ t('harvester.bgp.neighbors.description') }}
|
|
</p>
|
|
<div class="row">
|
|
<div class="col span-6">
|
|
<ArrayList
|
|
v-model:value="neighborsV4"
|
|
data-testid="bgp-neighbors-v4"
|
|
:mode="mode"
|
|
:initial-empty-row="true"
|
|
:rules="neighborV4Rules"
|
|
:show-header="true"
|
|
:value-label="t('harvester.bgp.neighborsV4.label')"
|
|
:a11y-label="t('harvester.bgp.neighborsV4.label')"
|
|
:value-placeholder="t('harvester.bgp.neighborsV4.placeholder')"
|
|
:add-label="t('harvester.bgp.neighborsV4.add')"
|
|
/>
|
|
</div>
|
|
<div class="col span-6">
|
|
<ArrayList
|
|
v-model:value="neighborsV6"
|
|
data-testid="bgp-neighbors-v6"
|
|
:mode="mode"
|
|
:initial-empty-row="true"
|
|
:rules="neighborV6Rules"
|
|
:show-header="true"
|
|
:value-label="t('harvester.bgp.neighborsV6.label')"
|
|
:a11y-label="t('harvester.bgp.neighborsV6.label')"
|
|
:value-placeholder="t('harvester.bgp.neighborsV6.placeholder')"
|
|
:add-label="t('harvester.bgp.neighborsV6.add')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col span-6">
|
|
<LabeledInput
|
|
v-model:value="neighborAS"
|
|
data-testid="bgp-neighbor-as"
|
|
type="number"
|
|
min="1"
|
|
:required="true"
|
|
:mode="mode"
|
|
:rules="neighborASRules"
|
|
:label="t('harvester.bgp.neighborAS.label')"
|
|
:placeholder="t('harvester.bgp.neighborAS.placeholder')"
|
|
:tooltip="t('harvester.bgp.neighborAS.tooltip')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</RcSection>
|
|
<RcSection
|
|
:title="t('harvester.bgp.sections.advanced')"
|
|
type="secondary"
|
|
mode="with-header"
|
|
:expandable="false"
|
|
data-testid="bgp-advanced-section"
|
|
>
|
|
<div class="row">
|
|
<div class="col span-6">
|
|
<LabeledInput
|
|
v-model:value="nextHopV4"
|
|
data-testid="bgp-next-hop-v4"
|
|
:mode="mode"
|
|
:rules="nextHopV4Rules"
|
|
:label="t('harvester.bgp.nextHopV4.label')"
|
|
:placeholder="t('harvester.bgp.nextHopV4.placeholder', null, true)"
|
|
:tooltip="t('harvester.bgp.nextHopV4.tooltip')"
|
|
/>
|
|
</div>
|
|
<div class="col span-6">
|
|
<LabeledInput
|
|
v-model:value="nextHopV6"
|
|
data-testid="bgp-next-hop-v6"
|
|
:mode="mode"
|
|
:rules="nextHopV6Rules"
|
|
:label="t('harvester.bgp.nextHopV6.label')"
|
|
:placeholder="t('harvester.bgp.nextHopV6.placeholder', null, true)"
|
|
:tooltip="t('harvester.bgp.nextHopV6.tooltip')"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</RcSection>
|
|
</template>
|
|
</RcSection>
|
|
</CruResource>
|
|
<!-- No form: the section says why -->
|
|
<RcSection
|
|
v-else
|
|
type="primary"
|
|
mode="no-header"
|
|
:expandable="false"
|
|
data-testid="bgp-section"
|
|
>
|
|
<Banner
|
|
v-if="!featureEnabled"
|
|
color="warning"
|
|
class="mt-0 mb-0"
|
|
:label="t('harvester.bgp.unsupported')"
|
|
/>
|
|
<Banner
|
|
v-else-if="!addonEnabled"
|
|
color="warning"
|
|
class="mt-0 mb-0"
|
|
>
|
|
<MessageLink
|
|
:to="addonLocation"
|
|
prefix-label="harvester.bgp.noAddonEnabled.prefix"
|
|
middle-label="harvester.bgp.noAddonEnabled.middle"
|
|
suffix-label="harvester.bgp.noAddonEnabled.suffix"
|
|
/>
|
|
</Banner>
|
|
<!-- The Configuration could not be read -->
|
|
<template v-else>
|
|
<Banner
|
|
v-for="(err, i) in errors"
|
|
:key="i"
|
|
color="error"
|
|
class="mt-0 mb-0"
|
|
:label="err"
|
|
/>
|
|
</template>
|
|
</RcSection>
|
|
</div>
|
|
</template>
|