Skip to content

Commit 1c245ac

Browse files
authored
feat(xo-web/network): reconfigure management PIF (#9510)
1 parent 58c2c51 commit 1c245ac

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed

CHANGELOG.unreleased.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
> Users must be able to say: "Nice enhancement, I'm eager to test it"
1313
14+
- **XO 5:**
15+
- [Network] Ability to switch management PIF (PRs [#9369](https://github.com/vatesfr/xen-orchestra/pull/9369) [#9510](https://github.com/vatesfr/xen-orchestra/pull/9510))
16+
1417
### Bug fixes
1518

1619
> Users must be able to say: “I had this issue, happy to know it's fixed”
@@ -31,4 +34,6 @@
3134
3235
<!--packages-start-->
3336

37+
- xo-web minor
38+
3439
<!--packages-end-->

packages/xo-web/src/common/intl/messages.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,11 @@ const messages = {
24352435
pifDisconnected: 'Disconnected',
24362436
pifPhysicallyConnected: 'Physically connected',
24372437
pifPhysicallyDisconnected: 'Physically disconnected',
2438+
setAsManagementPif: 'Set as management PIF',
2439+
setAsManagementPifConfirm: 'Are you sure you want to make this PIF the management interface?',
2440+
setAsManagementPifs: 'Set as management network',
2441+
setAsManagementPifsConfirm:
2442+
'Are you sure you want to make this network the management network? This will make all the PIFs attached to it management PIFs.',
24382443

24392444
// ----- User -----
24402445
authToken: 'Token',

packages/xo-web/src/common/xo/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,24 @@ export const editPif = (pif, { vlan }) => _call('pif.editPif', { pif: resolveId(
26762676

26772677
export const scanHostPifs = hostId => _call('host.scanPifs', { host: hostId })
26782678

2679+
export const setManagementPif = async (host, pif) => {
2680+
await confirm({
2681+
title: _('setAsManagementPif'),
2682+
body: _('setAsManagementPifConfirm'),
2683+
})
2684+
2685+
return _call('host.managementReconfigure', { id: resolveId(host), pif: resolveId(pif) })
2686+
}
2687+
2688+
export const setManagementPifs = async (pool, network) => {
2689+
await confirm({
2690+
title: _('setAsManagementPifs'),
2691+
body: _('setAsManagementPifsConfirm'),
2692+
})
2693+
2694+
return _call('pool.managementReconfigure', { id: resolveId(pool), network: resolveId(network) })
2695+
}
2696+
26792697
// SR ----------------------------------------------------------------
26802698

26812699
export const deleteSr = sr =>

packages/xo-web/src/icons.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,13 @@
755755
}
756756
}
757757

758+
&-pif {
759+
&-management {
760+
@extend .fa;
761+
@extend .fa-star;
762+
}
763+
}
764+
758765
// Host and VM actions
759766
&-host,
760767
&-vm {

packages/xo-web/src/xo-app/host/tab-network.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
getIpv4ConfigModes,
2929
getIpv6ConfigModes,
3030
reconfigurePifIp,
31+
setManagementPif,
3132
scanHostPifs,
3233
} from 'xo'
3334

@@ -327,6 +328,12 @@ const PIF_INDIVIDUAL_ACTIONS = [
327328
icon: 'clipboard',
328329
label: pif => _('copyUuid', { uuid: pif.uuid }),
329330
},
331+
{
332+
handler: pif => setManagementPif(pif.$host, pif.id),
333+
disabled: pif => pif.management || !pif.attached,
334+
icon: 'pif-management',
335+
label: _('setAsManagementPif'),
336+
},
330337
{
331338
handler: deletePif,
332339
icon: 'delete',

packages/xo-web/src/xo-app/pool/tab-network.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { TabButtonLink } from 'tab-button'
1616
import { Text, Number } from 'editable'
1717
import { Select, Toggle } from 'form'
1818
import { createGetObjectsOfType, createSelector } from 'selectors'
19-
import { deleteNetwork, editNetwork, editPif } from 'xo'
19+
import { deleteNetwork, editNetwork, editPif, setManagementPifs } from 'xo'
2020

2121
// =============================================================================
2222

@@ -201,6 +201,11 @@ class NetworkActions extends Component {
201201
icon='clipboard'
202202
tooltip={_('copyUuid', { uuid: network.uuid })}
203203
/>
204+
<ActionRowButton
205+
handler={() => setManagementPifs(network.$pool, network)}
206+
icon='pif-management'
207+
tooltip={_('setAsManagementPifs')}
208+
/>
204209
<ActionRowButton
205210
disabled={disableNetworkDelete}
206211
handler={deleteNetwork}

0 commit comments

Comments
 (0)