feat(xo-web/pool/advanced, xen-api/{get,put}Resource): introduce backup network (#5957)

This commit is contained in:
Rajaa.BARHTAOUI 2021-10-28 10:21:48 +02:00 committed by GitHub
parent 2412f8b1e2
commit eb238bf107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 11 deletions

View File

@ -12,6 +12,7 @@
- [Host/advanced] Add button to enable/disable the host (PR [#5952](https://github.com/vatesfr/xen-orchestra/pull/5952))
- [VM/export] Ability to copy the export URL (PR [#5948](https://github.com/vatesfr/xen-orchestra/pull/5948))
- [Servers] Ability to use an HTTP proxy between XO and a server
- [Pool/advanced] Ability to define network for importing/exporting VMs/VDIs (PR [#5957](https://github.com/vatesfr/xen-orchestra/pull/5957))
### Bug fixes
@ -48,5 +49,5 @@
- @xen-orchestra/proxy minor
- vhd-cli minor
- xapi-explore-sr minor
- xo-server patch
- xo-server minor
- xo-web minor

View File

@ -807,9 +807,9 @@ export class Xapi extends EventEmitter {
async _setHostAddressInUrl(url, host) {
const pool = this._pool
const poolMigrationNetwork = pool.other_config['xo:migrationNetwork']
const poolBackupNetwork = pool.other_config['xo:backupNetwork']
if (host === undefined) {
if (poolMigrationNetwork === undefined) {
if (poolBackupNetwork === undefined) {
const xapiUrl = this._url
url.hostname = xapiUrl.hostname
url.port = xapiUrl.port
@ -820,16 +820,16 @@ export class Xapi extends EventEmitter {
}
let { address } = host
if (poolMigrationNetwork !== undefined) {
if (poolBackupNetwork !== undefined) {
const hostPifs = new Set(host.PIFs)
try {
const networkRef = await this._roCall('network.get_by_uuid', [poolMigrationNetwork])
const networkRef = await this._roCall('network.get_by_uuid', [poolBackupNetwork])
const networkPifs = await this.getField('network', networkRef, 'PIFs')
const migrationNetworkPifRef = networkPifs.find(hostPifs.has, hostPifs)
address = await this.getField('PIF', migrationNetworkPifRef, 'IP')
const backupNetworkPifRef = networkPifs.find(hostPifs.has, hostPifs)
address = await this.getField('PIF', backupNetworkPifRef, 'IP')
} catch (error) {
console.warn('unable to get the host address linked to the pool migration network', poolMigrationNetwork, error)
console.warn('unable to get the host address linked to the pool backup network', poolBackupNetwork, error)
}
}

View File

@ -7,6 +7,7 @@ export async function set({
name_description: nameDescription,
name_label: nameLabel,
backupNetwork,
migrationNetwork,
}) {
pool = this.getXapiObject(pool)
@ -15,6 +16,7 @@ export async function set({
nameDescription !== undefined && pool.set_name_description(nameDescription),
nameLabel !== undefined && pool.set_name_label(nameLabel),
migrationNetwork !== undefined && pool.update_other_config('xo:migrationNetwork', migrationNetwork),
backupNetwork !== undefined && pool.update_other_config('xo:backupNetwork', backupNetwork),
])
}
@ -30,6 +32,10 @@ set.params = {
type: 'string',
optional: true,
},
backupNetwork: {
type: ['string', 'null'],
optional: true,
},
migrationNetwork: {
type: ['string', 'null'],
optional: true,

View File

@ -795,6 +795,7 @@ const messages = {
vmsTabName: 'VMs',
srsTabName: 'SRs',
// ----- Pool advanced tab -----
backupNetwork: 'Backup network',
poolEditAll: 'Edit all',
poolHaStatus: 'High Availability',
poolHaEnabled: 'Enabled',

View File

@ -60,6 +60,7 @@ class PoolMaster extends Component {
.filter((_, { pool }) => ({ $pool: pool.id }))
.sort()
return {
backupNetwork: createGetObject((_, { pool }) => pool.otherConfig['xo:backupNetwork']),
hosts: getHosts,
hostsByMultipathing: createGroupBy(
getHosts,
@ -77,7 +78,7 @@ class PoolMaster extends Component {
plugins: subscribePlugins,
})
export default class TabAdvanced extends Component {
_getMigrationNetworkPredicate = createSelector(
_getNetworkPredicate = createSelector(
createCollectionWrapper(
createSelector(
() => this.props.pifs,
@ -100,6 +101,10 @@ export default class TabAdvanced extends Component {
plugins => plugins !== undefined && plugins.some(plugin => plugin.name === 'netbox' && plugin.loaded)
)
_onChangeBackupNetwork = backupNetwork => editPool(this.props.pool, { backupNetwork: backupNetwork.id })
_removeBackupNetwork = () => editPool(this.props.pool, { backupNetwork: null })
_onChangeMigrationNetwork = migrationNetwork => editPool(this.props.pool, { migrationNetwork: migrationNetwork.id })
_removeMigrationNetwork = () => editPool(this.props.pool, { migrationNetwork: null })
@ -110,7 +115,7 @@ export default class TabAdvanced extends Component {
)
render() {
const { hosts, gpuGroups, pool, hostsByMultipathing, migrationNetwork } = this.props
const { backupNetwork, hosts, gpuGroups, pool, hostsByMultipathing, migrationNetwork } = this.props
const { state } = this
const { editRemoteSyslog } = state
const { enabled: hostsEnabledMultipathing, disabled: hostsDisabledMultipathing } = hostsByMultipathing
@ -254,7 +259,7 @@ export default class TabAdvanced extends Component {
<td>
<XoSelect
onChange={this._onChangeMigrationNetwork}
predicate={this._getMigrationNetworkPredicate()}
predicate={this._getNetworkPredicate()}
value={migrationNetwork}
xoType='network'
>
@ -267,6 +272,24 @@ export default class TabAdvanced extends Component {
)}
</td>
</tr>
<tr>
<th>{_('backupNetwork')}</th>
<td>
<XoSelect
onChange={this._onChangeBackupNetwork}
predicate={this._getNetworkPredicate()}
value={backupNetwork}
xoType='network'
>
{backupNetwork !== undefined ? <Network id={backupNetwork.id} /> : _('noValue')}
</XoSelect>{' '}
{backupNetwork !== undefined && (
<a role='button' onClick={this._removeBackupNetwork}>
<Icon icon='remove' />
</a>
)}
</td>
</tr>
</tbody>
</table>
</Col>