NFS version and options (#2841)

Add NFS version & NFS options. Fixes #2706
This commit is contained in:
Pierre Donias
2018-04-06 17:46:18 +02:00
committed by Olivier Lambert
parent a251f8ca75
commit 55b35ac0cf
4 changed files with 76 additions and 48 deletions

View File

@@ -189,6 +189,7 @@ export async function createNfs ({
server,
serverPath,
nfsVersion,
nfsOptions,
}) {
const xapi = this.getXapi(host)
@@ -202,6 +203,11 @@ export async function createNfs ({
deviceConfig.nfsversion = nfsVersion
}
// if NFS options given
if (nfsVersion) {
deviceConfig.options = nfsVersion
}
const srRef = await xapi.call(
'SR.create',
host._xapiRef,
@@ -226,6 +232,7 @@ createNfs.params = {
server: { type: 'string' },
serverPath: { type: 'string' },
nfsVersion: { type: 'string', optional: true },
nfsOptions: { type: 'string', optional: true },
}
createNfs.resolve = {

View File

@@ -447,6 +447,8 @@ const messages = {
newSrPasswordPlaceHolder: 'Password',
newSrLvmDevicePlaceHolder: 'Device, e.g /dev/sda…',
newSrLocalPathPlaceHolder: '/path/to/directory',
newSrUseNfs4: 'Use NFSv4',
newSrNfsOptions: 'Comma delimited NFS options',
// ----- Acls, Users, Groups ------
subjectName: 'Users/Groups',

View File

@@ -917,26 +917,26 @@ export const copyVm = (vm, sr, name, compress) => {
const vmId = resolveId(vm)
return sr !== undefined
? confirm({
title: _('copyVm'),
body: _('copyVmConfirm', { SR: sr.name_label }),
}).then(() =>
_call('vm.copy', {
vm: vmId,
sr: sr.id,
name: name || vm.name_label + '_COPY',
compress,
})
)
title: _('copyVm'),
body: _('copyVmConfirm', { SR: sr.name_label }),
}).then(() =>
_call('vm.copy', {
vm: vmId,
sr: sr.id,
name: name || vm.name_label + '_COPY',
compress,
})
)
: confirm({
title: _('copyVm'),
body: <CopyVmModalBody vm={vm} />,
}).then(params => {
if (!params.sr) {
error('copyVmsNoTargetSr', 'copyVmsNoTargetSrMessage')
return
}
return _call('vm.copy', { vm: vmId, ...params })
}, noop)
title: _('copyVm'),
body: <CopyVmModalBody vm={vm} />,
}).then(params => {
if (!params.sr) {
error('copyVmsNoTargetSr', 'copyVmsNoTargetSrMessage')
return
}
return _call('vm.copy', { vm: vmId, ...params })
}, noop)
}
import CopyVmsModalBody from './copy-vms-modal' // eslint-disable-line import/first
@@ -1001,28 +1001,28 @@ export const deleteTemplates = templates =>
return nDefaultTemplates === 0
? showError()
: confirm({
title: _('deleteDefaultTemplatesTitle', { nDefaultTemplates }),
body: _('deleteDefaultTemplatesMessage', { nDefaultTemplates }),
})
.then(
() =>
Promise.all(
map(defaultTemplates, id =>
_call('vm.delete', {
id,
forceDeleteDefaultTemplate: true,
}).catch(() => {
nErrors++
})
)
),
noop
)
.then(() => {
if (nErrors !== 0) {
showError()
}
}, noop)
title: _('deleteDefaultTemplatesTitle', { nDefaultTemplates }),
body: _('deleteDefaultTemplatesMessage', { nDefaultTemplates }),
})
.then(
() =>
Promise.all(
map(defaultTemplates, id =>
_call('vm.delete', {
id,
forceDeleteDefaultTemplate: true,
}).catch(() => {
nErrors++
})
)
),
noop
)
.then(() => {
if (nErrors !== 0) {
showError()
}
}, noop)
}, noop)
export const snapshotVm = vm => _call('vm.snapshot', { id: resolveId(vm) })
@@ -1977,10 +1977,12 @@ export const createSrNfs = (
nameDescription,
server,
serverPath,
nfsVersion = undefined
nfsVersion = undefined,
nfsOptions
) => {
const params = { host, nameLabel, nameDescription, server, serverPath }
nfsVersion && (params.nfsVersion = nfsVersion)
nfsOptions && (params.nfsOptions = nfsOptions)
return _call('sr.createNfs', params)
}

View File

@@ -18,7 +18,7 @@ import { connectStore, formatSize } from 'utils'
import { Container, Row, Col } from 'grid'
import { ignoreErrors } from 'promise-toolbox'
import { injectIntl } from 'react-intl'
import { Password, Select } from 'form'
import { Password, Select, Toggle } from 'form'
import { SelectHost } from 'select-objects'
import {
createFilter,
@@ -262,7 +262,7 @@ export default class New extends Component {
server,
username,
} = this.refs
const { host, iqn, lun, path, type, scsiId } = this.state
const { host, iqn, lun, path, type, scsiId, nfs4, nfsOptions } = this.state
const createMethodFactories = {
nfs: async () => {
@@ -282,7 +282,9 @@ export default class New extends Component {
name.value,
description.value,
server.value,
path
path,
nfs4 ? '4' : undefined,
nfsOptions
)
},
hba: async () => {
@@ -637,7 +639,7 @@ export default class New extends Component {
<Section icon='settings' title='newSrSettings'>
{host && (
<fieldset>
{(type === 'nfs' || type === 'nfsiso') && (
{(type === 'nfs' || type === 'nfsiso') && [
<fieldset>
<label htmlFor='srServer'>{_('newSrServer')}</label>
<div className='input-group'>
@@ -658,8 +660,23 @@ export default class New extends Component {
/>
</span>
</div>
</fieldset>
)}
</fieldset>,
<fieldset>
<label>{_('newSrUseNfs4')}</label>
<div>
<Toggle onChange={this.toggleState('nfs4')} />
</div>
</fieldset>,
<fieldset>
<label>{_('newSrNfsOptions')}</label>
<input
className='form-control'
onChange={this.linkState('nfsOptions')}
type='text'
value={this.state.nfsOptions}
/>
</fieldset>,
]}
{type === 'hba' && (
<fieldset>
<label>{_('newSrLun')}</label>