feat(xo-web/SR): add possibility to create SMB shared SR (#7330)

Fixes #991
This commit is contained in:
MlssFrncJrg 2024-01-30 17:24:31 +01:00 committed by GitHub
parent 6084db22a9
commit 06d411543a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 62 additions and 10 deletions

View File

@ -7,6 +7,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it” > Users must be able to say: “Nice enhancement, I'm eager to test it”
- [SR] Possibility to create SMB shared SR [#991](https://github.com/vatesfr/xen-orchestra/issues/991) (PR [#7330](https://github.com/vatesfr/xen-orchestra/pull/7330))
### Bug fixes ### Bug fixes
> 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”

View File

@ -277,6 +277,50 @@ createNfs.resolve = {
host: ['host', 'host', 'administrate'], host: ['host', 'host', 'administrate'],
} }
export async function createSmb({ host, nameLabel, nameDescription, server, user, password, srUuid }) {
const xapi = this.getXapi(host)
const deviceConfig = {
server,
user,
password,
}
if (srUuid !== undefined) {
return xapi.reattachSr({
uuid: srUuid,
nameLabel,
nameDescription,
type: 'smb',
deviceConfig,
})
}
const srRef = await xapi.SR_create({
device_config: deviceConfig,
host: host._xapiRef,
name_description: nameDescription,
name_label: nameLabel,
shared: true,
type: 'smb',
})
return xapi.getField('SR', srRef, 'uuid')
}
createSmb.params = {
host: { type: 'string' },
nameLabel: { type: 'string' },
nameDescription: { type: 'string', minLength: 0, default: '' },
server: { type: 'string' },
srUuid: { type: 'string', optional: true },
user: { type: 'string', optional: true },
password: { type: 'string', optional: true },
}
createSmb.resolve = {
host: ['host', 'host', 'administrate'],
}
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// HBA SR // HBA SR

View File

@ -2978,6 +2978,14 @@ export const createSrNfs = (
return _call('sr.createNfs', params) return _call('sr.createNfs', params)
} }
export const createSrSmb = (host, nameLabel, nameDescription, server, user, password, srUuid) => {
const params = { host, nameLabel, nameDescription, server, user, password }
if (srUuid !== undefined) {
params.srUuid = srUuid
}
return _call('sr.createSmb', params)
}
export const createSrIscsi = ( export const createSrIscsi = (
host, host,
nameLabel, nameLabel,

View File

@ -27,6 +27,7 @@ import {
createSrLvm, createSrLvm,
createSrNfs, createSrNfs,
createSrHba, createSrHba,
createSrSmb,
createSrZfs, createSrZfs,
probeSrIscsiExists, probeSrIscsiExists,
probeSrIscsiIqns, probeSrIscsiIqns,
@ -176,6 +177,7 @@ const SR_TYPE_TO_LABEL = {
nfs: 'NFS', nfs: 'NFS',
nfsiso: 'NFS ISO', nfsiso: 'NFS ISO',
smb: 'SMB', smb: 'SMB',
smbiso: 'SMB ISO',
zfs: 'ZFS (local)', zfs: 'ZFS (local)',
} }
@ -187,8 +189,8 @@ const SR_GROUP_TO_LABEL = {
const SR_TYPE_REQUIRE_DISK_FORMATTING = ['ext', 'lvm'] const SR_TYPE_REQUIRE_DISK_FORMATTING = ['ext', 'lvm']
const typeGroups = { const typeGroups = {
vdisr: ['ext', 'hba', 'iscsi', 'lvm', 'nfs', 'zfs'], vdisr: ['ext', 'hba', 'iscsi', 'lvm', 'nfs', 'smb', 'zfs'],
isosr: ['local', 'nfsiso', 'smb'], isosr: ['local', 'nfsiso', 'smbiso'],
} }
const getSrPath = id => (id !== undefined ? `/srs/${id}` : undefined) const getSrPath = id => (id !== undefined ? `/srs/${id}` : undefined)
@ -278,6 +280,7 @@ export default class New extends Component {
nfsOptions, nfsOptions,
srUuid srUuid
), ),
smb: () => createSrSmb(host.id, name.value, description.value, server.value, username.value, password.value),
hba: async () => { hba: async () => {
if (srUuid === undefined) { if (srUuid === undefined) {
const previous = await probeSrHbaExists(host.id, scsiId) const previous = await probeSrHbaExists(host.id, scsiId)
@ -346,7 +349,7 @@ export default class New extends Component {
nfsOptions, nfsOptions,
srUuid srUuid
), ),
smb: () => smbiso: () =>
createSrIso( createSrIso(
host.id, host.id,
name.value, name.value,
@ -803,7 +806,7 @@ export default class New extends Component {
<SelectLun options={luns} onChange={this._handleSrLunSelection} /> <SelectLun options={luns} onChange={this._handleSrLunSelection} />
</fieldset> </fieldset>
)} )}
{type === 'smb' && ( {(type === 'smb' || type === 'smbiso') && (
<fieldset> <fieldset>
<label htmlFor='srServer'>{_('newSrServer')}</label> <label htmlFor='srServer'>{_('newSrServer')}</label>
<input <input
@ -820,15 +823,10 @@ export default class New extends Component {
className='form-control' className='form-control'
placeholder={formatMessage(messages.newSrUsernamePlaceHolder)} placeholder={formatMessage(messages.newSrUsernamePlaceHolder)}
ref='username' ref='username'
required
type='text' type='text'
/> />
<label>{_('newSrPassword')}</label> <label>{_('newSrPassword')}</label>
<Password <Password placeholder={formatMessage(messages.newSrPasswordPlaceHolder)} ref='password' />
placeholder={formatMessage(messages.newSrPasswordPlaceHolder)}
ref='password'
required
/>
</fieldset> </fieldset>
)} )}
{(type === 'lvm' || type === 'ext') && ( {(type === 'lvm' || type === 'ext') && (