fix(xo-web,xo-server#probeIscsiLuns): handle undefined lun size (#5212)

See xoa-support#2815
See https://xcp-ng.org/forum/topic/3409/getting-error-when-trying-to-mount-iscsi-lun
This commit is contained in:
badrAZ 2020-09-09 12:11:50 +02:00 committed by GitHub
parent 846eff4984
commit edaae02892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View File

@ -13,6 +13,8 @@
> Users must be able to say: “I had this issue, happy to know it's fixed” > Users must be able to say: “I had this issue, happy to know it's fixed”
- [New SR] Fix `Cannot read property 'trim' of undefined` error (PR [#5212](https://github.com/vatesfr/xen-orchestra/pull/5212))
### Packages to release ### Packages to release
> Packages will be released in the order they are here, therefore, they should > Packages will be released in the order they are here, therefore, they should
@ -31,3 +33,4 @@
> In case of conflict, the highest (lowest in previous list) `$version` wins. > In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-web minor - xo-web minor
- xo-server patch

View File

@ -719,7 +719,7 @@ export async function probeIscsiLuns({
id: lun.LUNid.trim(), id: lun.LUNid.trim(),
vendor: lun.vendor.trim(), vendor: lun.vendor.trim(),
serial: lun.serial.trim(), serial: lun.serial.trim(),
size: lun.size.trim(), size: lun.size?.trim(),
scsiId: lun.SCSIid.trim(), scsiId: lun.SCSIid.trim(),
}) })
}) })

View File

@ -82,6 +82,7 @@ const messages = {
upgradesAvailable: 'Upgrades available', upgradesAvailable: 'Upgrades available',
advancedSettings: 'Advanced settings', advancedSettings: 'Advanced settings',
txChecksumming: 'TX checksumming', txChecksumming: 'TX checksumming',
unknownSize: 'Unknown size',
// ----- Modals ----- // ----- Modals -----
alertOk: 'OK', alertOk: 'OK',

View File

@ -144,6 +144,7 @@ class SelectIqn extends Component {
} }
} }
@injectIntl
class SelectLun extends Component { class SelectLun extends Component {
static propTypes = { static propTypes = {
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
@ -152,11 +153,14 @@ class SelectLun extends Component {
_getOptions = createSelector( _getOptions = createSelector(
() => this.props.options, () => this.props.options,
options => () => this.props.intl.formatMessage,
(options, formatMessage) =>
map(options, (lun, index) => ({ map(options, (lun, index) => ({
label: `LUN ${lun.id}: ${lun.serial} - ${formatSize(+lun.size)} - (${ label: `LUN ${lun.id}: ${lun.serial} - ${
lun.vendor lun.size !== undefined
})`, ? formatSize(+lun.size)
: formatMessage(messages.unknownSize)
} - (${lun.vendor})`,
value: index, value: index,
})) }))
) )
@ -989,7 +993,11 @@ export default class New extends Component {
{type === 'iscsi' && ( {type === 'iscsi' && (
<dl className='dl-horizontal'> <dl className='dl-horizontal'>
<dt>{_('newSrSize')}</dt> <dt>{_('newSrSize')}</dt>
<dd>{formatSize(+lun.size)}</dd> <dd>
{lun.size !== undefined
? formatSize(+lun.size)
: _('unknownSize')}
</dd>
</dl> </dl>
)} )}
{includes(['nfs', 'hba'], type) && ( {includes(['nfs', 'hba'], type) && (