Skip to content

Commit

Permalink
feat(xo-server,xo-web): display bond mode of a network (#8010)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaFrncJrg authored Sep 27, 2024
1 parent eb39e14 commit cdfe0b0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `rest post` and `rest put` now accept `--input $file` to upload a file and display progress information
- [Backup] Detect invalid VDI exports that are incorrectly reported as successful by XAPI
- [Backup] Backup job sequences: configure lists of backup jobs to run in order one after the other (PRs [#7985](https://github.com/vatesfr/xen-orchestra/pull/7985), [#8014](https://github.com/vatesfr/xen-orchestra/pull/8014))
- [Pool/Network] Display the bond mode of a network [#7802](https://github.com/vatesfr/xen-orchestra/issues/7802) (PR [#8010](https://github.com/vatesfr/xen-orchestra/pull/8010))

### Bug fixes

Expand Down
10 changes: 10 additions & 0 deletions packages/xo-server/src/xapi-object-to-xo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,16 @@ const TRANSFORMS = {
VUSBs: link(obj, 'VUSBs'),
}
},

// -----------------------------------------------------------------

bond(obj) {
return {
type: 'bond',
master: link(obj, 'master'),
mode: obj.mode,
}
},
}

// ===================================================================
Expand Down
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ const messages = {
noHost: 'No hosts',
memoryLeftTooltip: '{used}% used ({free} free)',
// ----- Pool network tab -----
bondMode: 'Bond Mode',
pif: 'PIF',
poolNetworkAutomatic: 'Automatic',
poolNetworkNameLabel: 'Name',
Expand Down
11 changes: 8 additions & 3 deletions packages/xo-web/src/common/sorted-table/pifs-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import map from 'lodash/map'
import React, { Component } from 'react'
import Tooltip from 'tooltip'
import { connectStore } from 'utils'
import { createGetObject, createSelector } from 'selectors'
import { createGetObject, createGetObjectsOfType, createSelector } from 'selectors'
import { connectPif, disconnectPif } from 'xo'

@connectStore(() => {
Expand All @@ -19,18 +19,22 @@ import { connectPif, disconnectPif } from 'xo'
pif => pif?.attached && !pif?.isBondMaster && (pif?.management || pif?.disallowUnplug)
)

return { host, pif, disableUnplug }
const bonds = createGetObjectsOfType('bond')
const bond = createSelector(pif, bonds, (pif, bonds) => Object.values(bonds).find(bond => bond.master === pif.id))

return { host, pif, disableUnplug, bond }
})
class PifItem extends Component {
render() {
const { pif, host, disableUnplug } = this.props
const { pif, host, disableUnplug, bond } = this.props

return (
<tr>
<td>{pif?.device ?? _('unknown')}</td>
<td>{host?.name_label ?? _('unknown')}</td>
<td>{pif?.ip ?? _('unknown')}</td>
<td>{pif?.mac ?? _('unknown')}</td>
<td>{bond?.mode ?? '-'}</td>
<td>
{pif?.carrier === undefined ? (
<span className='tag tag-warning'>{_('unknown')}</span>
Expand Down Expand Up @@ -78,6 +82,7 @@ export default class PifsColumn extends BaseComponent {
<th>{_('homeTypeHost')}</th>
<th>{_('pifAddressLabel')}</th>
<th>{_('pifMacLabel')}</th>
<th>{_('bondMode')}</th>
<th>{_('pifStatusLabel')}</th>
<th />
</tr>
Expand Down

0 comments on commit cdfe0b0

Please sign in to comment.