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) {
const _namespace = (await this._getNamespaces())[namespace]
if (_namespace === undefined) {
throw new Error(`${namespace} is not available`)
}
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 })

View File

@ -1749,8 +1749,6 @@ const messages = {
contactUs: 'Contact us!',
xosanNoLicense: 'No license.',
xosanUnlockNow: 'Unlock now!',
xosanBetaOverMessage:
'XOSAN Beta is over. You may now delete and recreate previous existing XOSAN SRs.',
selectLicense: 'Select a license',
bindLicense: 'Bind license',
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) =>
_call('xosan.fixHostNotInNetwork', { xosanSr, host })

View File

@ -9,6 +9,7 @@ import SortedTable from 'sorted-table'
import Tooltip from 'tooltip'
import { Container, Col, Row } from 'grid'
import { get } from 'xo-defined'
import { ignoreErrors } from 'promise-toolbox'
import {
every,
filter,
@ -32,6 +33,7 @@ import {
import {
deleteSr,
getLicenses,
registerXosan,
subscribePlugins,
subscribeResourceCatalog,
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 })
_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 () {
const {
hostsNeedRestartByPool,
@ -433,18 +439,11 @@ export default class Xosan extends Component {
</Row>
) : (
[
this._showBetaIsOver() && (
<Row key='beta-is-over'>
<Col>
<em>{_('xosanBetaOverMessage')}</em>
</Col>
</Row>
),
<Row key='new-button' className='mb-1'>
<Col>
<ActionButton
btnStyle='primary'
handler={this.toggleState('showNewXosanForm')}
handler={this._toggleShowNewXosanForm}
icon={this.state.showNewXosanForm ? 'minus' : 'plus'}
>
{_('xosanNew')}
@ -453,18 +452,21 @@ export default class Xosan extends Component {
</Row>,
<Row key='new-form'>
<Col>
{this.state.showNewXosanForm && (
<NewXosan
hostsNeedRestartByPool={hostsNeedRestartByPool}
noPacksByPool={noPacksByPool}
poolPredicate={poolPredicate}
onSrCreationFinished={this._updateLicenses}
onSrCreationStarted={this._onSrCreationStarted}
notRegistered={
get(() => xoaRegistration.state) !== 'registered'
}
/>
)}
{this.state.showNewXosanForm &&
(this._isXosanRegistered() ? (
<NewXosan
hostsNeedRestartByPool={hostsNeedRestartByPool}
noPacksByPool={noPacksByPool}
poolPredicate={poolPredicate}
onSrCreationFinished={this._updateLicenses}
onSrCreationStarted={this._onSrCreationStarted}
notRegistered={
get(() => xoaRegistration.state) !== 'registered'
}
/>
) : (
<em>{_('statusLoading')}</em>
))}
</Col>
</Row>,
<Row key='progress'>