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”
- [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
> 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'],
}
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

View File

@ -2978,6 +2978,14 @@ export const createSrNfs = (
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 = (
host,
nameLabel,

View File

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