From ce0333b0a7271c4e4ccdb032fb9f9a962f8b9d72 Mon Sep 17 00:00:00 2001 From: Olivier Lambert Date: Tue, 1 Mar 2016 17:40:39 +0100 Subject: [PATCH 1/3] prepare user/pass for CIFS ISO share --- src/api/sr.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/sr.js b/src/api/sr.js index 5939ba233..dedaa5832 100644 --- a/src/api/sr.js +++ b/src/api/sr.js @@ -80,7 +80,9 @@ export async function createIso ({ host, nameLabel, nameDescription, - path + path, + user, + password }) { const xapi = this.getXapi(host) @@ -112,7 +114,9 @@ createIso.params = { host: { type: 'string' }, nameLabel: { type: 'string' }, nameDescription: { type: 'string' }, - path: { type: 'string' } + path: { type: 'string' }, + user: { type: 'string', optional: true }, + password: { type: 'string', optional: true } } createIso.resolve = { From eb21a1bfb308dbb9ff5a8cfb6164dffca2417b88 Mon Sep 17 00:00:00 2001 From: Olivier Lambert Date: Thu, 3 Mar 2016 18:25:43 +0100 Subject: [PATCH 2/3] support SMB ISO SR --- src/api/sr.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/api/sr.js b/src/api/sr.js index dedaa5832..eb0dd908f 100644 --- a/src/api/sr.js +++ b/src/api/sr.js @@ -88,11 +88,18 @@ export async function createIso ({ // FIXME: won't work for IPv6 // Detect if NFS or local path for ISO files - const deviceConfig = {location: path} + const deviceConfig = {} if (path.indexOf(':') === -1) { // not NFS share - // TODO: legacy will be removed in XAPI soon by FileSR - deviceConfig.legacy_mode = 'true' + if (path.indexOf('\\') === -1) { // not SMB + deviceConfig.legacy_mode = 'true' + } else { + path = path.replace(/\\/g, '/') + } } + deviceConfig.location = path + deviceConfig.username = user + deviceConfig.cifspassword = password + const srRef = await xapi.call( 'SR.create', host._xapiRef, From 33304eb8d91f32d9fbd726f2e5ed6d38438d7789 Mon Sep 17 00:00:00 2001 From: Olivier Lambert Date: Fri, 4 Mar 2016 12:29:21 +0100 Subject: [PATCH 3/3] add type in the new SR API --- src/api/sr.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/api/sr.js b/src/api/sr.js index eb0dd908f..7a4c5d198 100644 --- a/src/api/sr.js +++ b/src/api/sr.js @@ -81,24 +81,22 @@ export async function createIso ({ nameLabel, nameDescription, path, + type, user, password }) { const xapi = this.getXapi(host) - // FIXME: won't work for IPv6 - // Detect if NFS or local path for ISO files const deviceConfig = {} - if (path.indexOf(':') === -1) { // not NFS share - if (path.indexOf('\\') === -1) { // not SMB - deviceConfig.legacy_mode = 'true' - } else { - path = path.replace(/\\/g, '/') - } + if (type === 'local') { + deviceConfig.legacy_mode = 'true' + } else if (type === 'smb') { + path = path.replace(/\\/g, '/') + deviceConfig.username = user + deviceConfig.cifspassword = password } + deviceConfig.location = path - deviceConfig.username = user - deviceConfig.cifspassword = password const srRef = await xapi.call( 'SR.create', @@ -122,6 +120,7 @@ createIso.params = { nameLabel: { type: 'string' }, nameDescription: { type: 'string' }, path: { type: 'string' }, + type: { type: 'string' }, user: { type: 'string', optional: true }, password: { type: 'string', optional: true } }