fix(XOSAN): ask for registration (#2628)

Fixes #2625
This commit is contained in:
Pierre Donias 2018-02-09 13:36:30 +01:00 committed by Julien Fontanet
parent edd57f7205
commit 9fc73e03a2
4 changed files with 44 additions and 35 deletions

View File

@ -94,8 +94,12 @@ class XoServerCloud {
async _registerResource (namespace) { async _registerResource (namespace) {
const _namespace = (await this._getNamespaces())[namespace] const _namespace = (await this._getNamespaces())[namespace]
if (_namespace === undefined) {
throw new Error(`${namespace} is not available`)
}
if (_namespace.registered || _namespace.pending) { if (_namespace.registered || _namespace.pending) {
return new Error(`already registered for ${namespace}`) throw new Error(`already registered for ${namespace}`)
} }
return this._updater.call('registerResource', { namespace }) return this._updater.call('registerResource', { namespace })

View File

@ -1749,8 +1749,6 @@ const messages = {
contactUs: 'Contact us!', contactUs: 'Contact us!',
xosanNoLicense: 'No license.', xosanNoLicense: 'No license.',
xosanUnlockNow: 'Unlock now!', xosanUnlockNow: 'Unlock now!',
xosanBetaOverMessage:
'XOSAN Beta is over. You may now delete and recreate previous existing XOSAN SRs.',
selectLicense: 'Select a license', selectLicense: 'Select a license',
bindLicense: 'Bind license', bindLicense: 'Bind license',
expiresOn: 'expires on {date}', expiresOn: 'expires on {date}',

View File

@ -2179,6 +2179,11 @@ export const downloadAndInstallXosanPack = pool =>
}) })
) )
export const registerXosan = () =>
_call('cloud.registerResource', { namespace: 'xosan' })::tap(
subscribeResourceCatalog.forceRefresh
)
export const fixHostNotInXosanNetwork = (xosanSr, host) => export const fixHostNotInXosanNetwork = (xosanSr, host) =>
_call('xosan.fixHostNotInNetwork', { xosanSr, host }) _call('xosan.fixHostNotInNetwork', { xosanSr, host })

View File

@ -9,6 +9,7 @@ import SortedTable from 'sorted-table'
import Tooltip from 'tooltip' import Tooltip from 'tooltip'
import { Container, Col, Row } from 'grid' import { Container, Col, Row } from 'grid'
import { get } from 'xo-defined' import { get } from 'xo-defined'
import { ignoreErrors } from 'promise-toolbox'
import { import {
every, every,
filter, filter,
@ -32,6 +33,7 @@ import {
import { import {
deleteSr, deleteSr,
getLicenses, getLicenses,
registerXosan,
subscribePlugins, subscribePlugins,
subscribeResourceCatalog, subscribeResourceCatalog,
subscribeVolumeInfo, subscribeVolumeInfo,
@ -395,20 +397,24 @@ export default class Xosan extends Component {
} }
) )
_showBetaIsOver = createSelector(
() => this.props.catalog,
() => this.state.xosanLicenses,
() => this.state.xosanTrialLicenses,
() => this.state.licenseError,
(catalog, xosanLicenses, xosanTrialLicenses, licenseError) =>
licenseError === undefined &&
get(() => catalog._namespaces.xosan) !== undefined &&
isEmpty(xosanLicenses) &&
isEmpty(xosanTrialLicenses)
)
_onSrCreationStarted = () => this.setState({ showNewXosanForm: false }) _onSrCreationStarted = () => this.setState({ showNewXosanForm: false })
_isXosanRegistered = () =>
get(() => this.props.catalog._namespaces.xosan.registered)
_toggleShowNewXosanForm = () => {
if (this.state.showNewXosanForm) {
this.setState({ showNewXosanForm: false })
return
}
if (!this._isXosanRegistered()) {
;registerXosan()::ignoreErrors()
}
this.setState({ showNewXosanForm: true })
}
render () { render () {
const { const {
hostsNeedRestartByPool, hostsNeedRestartByPool,
@ -433,18 +439,11 @@ export default class Xosan extends Component {
</Row> </Row>
) : ( ) : (
[ [
this._showBetaIsOver() && (
<Row key='beta-is-over'>
<Col>
<em>{_('xosanBetaOverMessage')}</em>
</Col>
</Row>
),
<Row key='new-button' className='mb-1'> <Row key='new-button' className='mb-1'>
<Col> <Col>
<ActionButton <ActionButton
btnStyle='primary' btnStyle='primary'
handler={this.toggleState('showNewXosanForm')} handler={this._toggleShowNewXosanForm}
icon={this.state.showNewXosanForm ? 'minus' : 'plus'} icon={this.state.showNewXosanForm ? 'minus' : 'plus'}
> >
{_('xosanNew')} {_('xosanNew')}
@ -453,7 +452,8 @@ export default class Xosan extends Component {
</Row>, </Row>,
<Row key='new-form'> <Row key='new-form'>
<Col> <Col>
{this.state.showNewXosanForm && ( {this.state.showNewXosanForm &&
(this._isXosanRegistered() ? (
<NewXosan <NewXosan
hostsNeedRestartByPool={hostsNeedRestartByPool} hostsNeedRestartByPool={hostsNeedRestartByPool}
noPacksByPool={noPacksByPool} noPacksByPool={noPacksByPool}
@ -464,7 +464,9 @@ export default class Xosan extends Component {
get(() => xoaRegistration.state) !== 'registered' get(() => xoaRegistration.state) !== 'registered'
} }
/> />
)} ) : (
<em>{_('statusLoading')}</em>
))}
</Col> </Col>
</Row>, </Row>,
<Row key='progress'> <Row key='progress'>