feat(xo-web/vm): rescan ISO SRs available in console view
This commit is contained in:
parent
9139c5e9d6
commit
d7940292d0
@ -8,8 +8,9 @@ import Icon from 'icon'
|
||||
import Tooltip from 'tooltip'
|
||||
import { alert } from 'modal'
|
||||
import { isAdmin } from 'selectors'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { addSubscriptions, connectStore, resolveResourceSet } from './utils'
|
||||
import { ejectCd, insertCd, subscribeResourceSets } from './xo'
|
||||
import { ejectCd, insertCd, rescanSrs, subscribeResourceSets } from './xo'
|
||||
import { createGetObjectsOfType, createFinder, createGetObject, createSelector } from './selectors'
|
||||
import { SelectResourceSetsVdi, SelectVdi as SelectAnyVdi } from './select-objects'
|
||||
|
||||
@ -24,6 +25,12 @@ const vdiPredicate = vdi => !vdi.missing
|
||||
[vbd => vbd.is_cd_drive]
|
||||
)
|
||||
|
||||
const getIsoSrs = createGetObjectsOfType('SR').filter(
|
||||
(_, { vm: { $pool } }) =>
|
||||
sr =>
|
||||
sr.$pool === $pool && sr.SR_type === 'iso'
|
||||
)
|
||||
|
||||
const getMountedIso = createGetObject((state, props) => {
|
||||
const cdDrive = getCdDrive(state, props)
|
||||
if (cdDrive) {
|
||||
@ -34,6 +41,7 @@ const vdiPredicate = vdi => !vdi.missing
|
||||
return {
|
||||
cdDrive: getCdDrive,
|
||||
isAdmin,
|
||||
isoSrs: getIsoSrs,
|
||||
mountedIso: getMountedIso,
|
||||
}
|
||||
})
|
||||
@ -81,10 +89,12 @@ export default class IsoDevice extends Component {
|
||||
|
||||
_handleEject = () => ejectCd(this.props.vm)
|
||||
|
||||
_rescanIsoSrs = () => rescanSrs(this.props.isoSrs)
|
||||
|
||||
_showWarning = () => alert(_('cdDriveNotInstalled'), _('cdDriveInstallation'))
|
||||
|
||||
render() {
|
||||
const { cdDrive, isAdmin, mountedIso } = this.props
|
||||
const { cdDrive, isAdmin, isoSrs, mountedIso } = this.props
|
||||
const resourceSet = this._getResolvedResourceSet()
|
||||
const useResourceSet = !(isAdmin || resourceSet === undefined)
|
||||
const SelectVdi = useResourceSet ? SelectResourceSetsVdi : SelectAnyVdi
|
||||
@ -98,6 +108,14 @@ export default class IsoDevice extends Component {
|
||||
srPredicate={this._getSrPredicate()}
|
||||
value={mountedIso}
|
||||
/>
|
||||
<span className='input-group-btn'>
|
||||
<ActionButton
|
||||
disabled={isEmpty(isoSrs)}
|
||||
handler={this._rescanIsoSrs}
|
||||
icon='refresh'
|
||||
tooltip={_('rescanIsoSrs')}
|
||||
/>
|
||||
</span>
|
||||
<span className='input-group-btn'>
|
||||
<ActionButton disabled={!mountedIso} handler={this._handleEject} icon='vm-eject' />
|
||||
</span>
|
||||
|
@ -11,7 +11,7 @@ import React from 'react'
|
||||
import StateButton from 'state-button'
|
||||
import SortedTable from 'sorted-table'
|
||||
import TabButton from 'tab-button'
|
||||
import { compact, every, filter, find, forEach, get, isEmpty, map, some, sortedUniq, uniq } from 'lodash'
|
||||
import { compact, every, filter, find, forEach, get, map, some, sortedUniq, uniq } from 'lodash'
|
||||
import { Sr } from 'render-xo-item'
|
||||
import { Container, Row, Col } from 'grid'
|
||||
import {
|
||||
@ -54,7 +54,6 @@ import {
|
||||
isSrWritable,
|
||||
isVmRunning,
|
||||
migrateVdi,
|
||||
rescanSrs,
|
||||
setBootableVbd,
|
||||
subscribeResourceSets,
|
||||
} from 'xo'
|
||||
@ -455,17 +454,11 @@ class AttachDisk extends Component {
|
||||
}))
|
||||
@connectStore(() => {
|
||||
const getAllVbds = createGetObjectsOfType('VBD')
|
||||
const getIsoSrs = createGetObjectsOfType('SR').filter(
|
||||
(_, { pool: { $pool } }) =>
|
||||
sr =>
|
||||
sr.$pool === $pool && sr.SR_type === 'iso'
|
||||
)
|
||||
|
||||
return (state, props) => ({
|
||||
allVbds: getAllVbds(state, props),
|
||||
checkPermissions: getCheckPermissions(state, props),
|
||||
isAdmin: isAdmin(state, props),
|
||||
isoSrs: getIsoSrs(state, props),
|
||||
resolvedResourceSet: getResolvedResourceSet(state, props, !props.isAdmin && props.resourceSet !== undefined),
|
||||
})
|
||||
})
|
||||
@ -621,8 +614,6 @@ export default class TabDisks extends Component {
|
||||
)
|
||||
)
|
||||
|
||||
_rescanIsoSrs = () => rescanSrs(this.props.isoSrs)
|
||||
|
||||
actions = [
|
||||
{
|
||||
disabled: selectedVbds => some(selectedVbds, 'attached'),
|
||||
@ -653,7 +644,7 @@ export default class TabDisks extends Component {
|
||||
]
|
||||
|
||||
render() {
|
||||
const { allVbds, isoSrs, resolvedResourceSet, vm } = this.props
|
||||
const { allVbds, resolvedResourceSet, vm } = this.props
|
||||
|
||||
const { attachDisk, newDisk } = this.state
|
||||
|
||||
@ -718,14 +709,6 @@ export default class TabDisks extends Component {
|
||||
<Col mediumSize={5}>
|
||||
<IsoDevice vm={vm} />
|
||||
</Col>
|
||||
<Col mediumSize={1}>
|
||||
<ActionButton
|
||||
disabled={isEmpty(isoSrs)}
|
||||
handler={this._rescanIsoSrs}
|
||||
icon='refresh'
|
||||
tooltip={_('rescanIsoSrs')}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user