Merge "feat: show instance name in member selection table during load balancer creation"

This commit is contained in:
Zuul
2025-11-29 13:54:12 +00:00
committed by Gerrit Code Review
4 changed files with 31 additions and 4 deletions

View File

@@ -66,6 +66,10 @@ const MemberAllocator = ({ componentProps, formItemProps }) => {
title: t('Binding Instance'),
dataIndex: 'server_name',
},
{
title: t('Instance Name'),
dataIndex: 'instance_name',
},
{
title: t('IP'),
dataIndex: 'fixed_ips',

View File

@@ -55,7 +55,7 @@ export class CreateAction extends ModalAction {
})
.then((lb) => {
this.lbDetail = lb;
return this.store.fetchList();
return this.store.fetchList({ withInstanceName: true });
})
.then((ports) => {
this.setState({

View File

@@ -23,7 +23,7 @@ export class MemberStep extends Base {
this.state = {
ports: [],
};
this.store.fetchList().then((ports) => {
this.store.fetchList({ withInstanceName: true }).then((ports) => {
this.setState({
ports: ports.filter(
(port) =>

View File

@@ -183,7 +183,7 @@ export class PortStore extends Base {
if (!items.length) {
return items;
}
const { subnetId } = filters;
const { subnetId, withInstanceName } = filters;
if (subnetId) {
const newItems = [];
items.forEach((it) => {
@@ -208,7 +208,7 @@ export class PortStore extends Base {
return newItems;
}
const fips = (await globalFloatingIpsStore.pureFetchList()) || [];
const newItems = items.map((it) => {
let newItems = items.map((it) => {
it.associatedDetail = fips.filter(
(f) =>
f.port_id === it.id &&
@@ -216,6 +216,29 @@ export class PortStore extends Base {
);
return it;
});
if (withInstanceName) {
try {
const computePorts = newItems.filter(
(port) => port.device_owner?.startsWith('compute:') && port.device_id
);
if (computePorts.length > 0) {
const serverList = await client.nova.servers.list();
const serverMap = new Map(
serverList.servers?.map((s) => [s.id, s.name]) || []
);
newItems = newItems.map((port) => {
if (port.device_owner?.startsWith('compute:') && port.device_id) {
port.instance_name = serverMap.get(port.device_id) || '';
}
return port;
});
}
} catch (error) {
// eslint-disable-next-line no-console
console.warn('Failed to fetch instance names:', error);
}
}
return newItems;
}
}