Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xo-web/pool/advanced): ability to set a crash dump SR #6973

Merged
merged 4 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- [Netbox] Synchronize VM tags [#5899](https://github.com/vatesfr/xen-orchestra/issues/5899) [Forum#6902](https://xcp-ng.org/forum/topic/6902) (PR [#6957](https://github.com/vatesfr/xen-orchestra/pull/6957))
- [REST API] Add support for `filter` and `limit` parameters to `backups/logs` and `restore/logs` collections [Forum#64789](https://xcp-ng.org/forum/post/64789)
- [Pool/Advanced] Ability to set a crash dump SR [#5060](https://github.com/vatesfr/xen-orchestra/issues/5060) (PR [#6973](https://github.com/vatesfr/xen-orchestra/pull/6973))

### Bug fixes

Expand Down Expand Up @@ -44,6 +45,6 @@
- xo-server minor
- xo-server-auth-ldap patch
- xo-server-netbox minor
- xo-web patch
- xo-web minor

<!--packages-end-->
8 changes: 8 additions & 0 deletions packages/xo-server/src/api/pool.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function set({
backupNetwork,
migrationNetwork,
suspendSr,
crashDumpSr,
}) {
pool = this.getXapiObject(pool)

Expand All @@ -29,6 +30,8 @@ export async function set({
migrationNetwork !== undefined && pool.update_other_config('xo:migrationNetwork', migrationNetwork),
backupNetwork !== undefined && pool.update_other_config('xo:backupNetwork', backupNetwork),
suspendSr !== undefined && pool.$call('set_suspend_image_SR', suspendSr === null ? Ref.EMPTY : suspendSr._xapiRef),
crashDumpSr !== undefined &&
pool.$call('set_crash_dump_SR', crashDumpSr === null ? Ref.EMPTY : crashDumpSr._xapiRef),
])
}

Expand Down Expand Up @@ -57,11 +60,16 @@ set.params = {
type: ['string', 'null'],
optional: true,
},
crashDumpSr: {
type: ['string', 'null'],
optional: true,
},
}

set.resolve = {
pool: ['id', 'pool', 'administrate'],
suspendSr: ['suspendSr', 'SR', 'administrate'],
crashDumpSr: ['crashDumpSr', 'SR', 'administrate'],
}

// -------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions packages/xo-server/src/xapi-object-to-xo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const TRANSFORMS = {
pool(obj) {
const cpuInfo = obj.cpu_info
return {
crashDumpSr: link(obj, 'crash_dump_SR'),
current_operations: obj.current_operations,
default_SR: link(obj, 'default_SR'),
HA_enabled: Boolean(obj.ha_enabled),
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 @@ -873,6 +873,7 @@ const messages = {
srsTabName: 'SRs',
// ----- Pool advanced tab -----
backupNetwork: 'Backup network',
crashDumpSr: 'Crash dump SR',
poolEditAll: 'Edit all',
poolHaStatus: 'High Availability',
poolHaEnabled: 'Enabled',
Expand Down
32 changes: 31 additions & 1 deletion packages/xo-web/src/xo-app/pool/tab-advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ActionButton from 'action-button'
import ActionRowButton from 'action-row-button'
import Component from 'base-component'
import Icon from 'icon'
import renderXoItem, { Network } from 'render-xo-item'
import renderXoItem, { Network, Sr } from 'render-xo-item'
import SelectFiles from 'select-files'
import TabButton from 'tab-button'
import Upgrade from 'xoa-upgrade'
Expand All @@ -25,6 +25,7 @@ import {
import {
editPool,
installSupplementalPackOnAllHosts,
isSrWritable,
setHostsMultipathing,
setPoolMaster,
setRemoteSyslogHost,
Expand Down Expand Up @@ -244,16 +245,27 @@ export default class TabAdvanced extends Component {

_removeMigrationNetwork = () => editPool(this.props.pool, { migrationNetwork: null })

_onChangeCrashDumpSr = sr => editPool(this.props.pool, { crashDumpSr: sr.id })

_onRemoveCrashDumpSr = () => editPool(this.props.pool, { crashDumpSr: null })

_setRemoteSyslogHosts = () =>
setRemoteSyslogHosts(this.props.hosts, this.state.syslogDestination).then(() =>
this.setState({ editRemoteSyslog: false, syslogDestination: '' })
)

_getCrashDumpSrPredicate = createSelector(
() => this.props.pool,
pool => sr => isSrWritable(sr) && sr.$pool === pool.id
)

render() {
const { backupNetwork, hosts, isAdmin, gpuGroups, pool, hostsByMultipathing, migrationNetwork } = this.props
const { state } = this
const { editRemoteSyslog } = state
const { enabled: hostsEnabledMultipathing, disabled: hostsDisabledMultipathing } = hostsByMultipathing
const { crashDumpSr } = pool
const crashDumpSrPredicate = this._getCrashDumpSrPredicate()
return (
<div>
<Container>
Expand Down Expand Up @@ -343,6 +355,24 @@ export default class TabAdvanced extends Component {
<SelectSuspendSr pool={pool} />
</td>
</tr>
<tr>
<th>{_('crashDumpSr')}</th>
<td>
<XoSelect
onChange={this._onChangeCrashDumpSr}
predicate={crashDumpSrPredicate}
value={crashDumpSr}
xoType='SR'
>
{crashDumpSr !== undefined ? <Sr id={crashDumpSr} /> : _('noValue')}
</XoSelect>{' '}
{crashDumpSr !== undefined && (
<a onClick={this._onRemoveCrashDumpSr} role='button'>
<Icon icon='remove' />
</a>
)}
</td>
</tr>
</tbody>
</table>
</Col>
Expand Down