1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-29 18:50:08 +03:00

F #3951: fix list provisions

Signed-off-by: Jorge Lobo <jlobo@opennebula.io>
This commit is contained in:
Jorge Lobo 2020-12-10 13:42:44 +01:00 committed by Tino Vázquez
parent eaa9417605
commit e948f16b44
2 changed files with 13 additions and 3 deletions

View File

@ -55,6 +55,7 @@ const getListProviders = (res = {}, next = () => undefined, params = {}, userDat
}
const getProvidersDefaults = (res = {}, next = () => undefined, params = {}) => {
const extFiles = 'yml'
let rtn = httpInternalError
let err = false
const files = []
@ -70,7 +71,7 @@ const getProvidersDefaults = (res = {}, next = () => undefined, params = {}) =>
try {
if (params && params.name) {
existsFile(
`${path}/${`${params.name}`.toLowerCase()}.yaml`,
`${path}/${`${params.name}`.toLowerCase()}.${extFiles}`,
fillData,
() => {
err = true
@ -79,7 +80,7 @@ const getProvidersDefaults = (res = {}, next = () => undefined, params = {}) =>
} else {
getFiles(
path,
'yaml'
extFiles
).map(file =>
existsFile(file, fillData)
)

View File

@ -136,7 +136,16 @@ const getListProvisions = (res = {}, next = () => undefined, params = {}, userDa
const executedCommand = executeCommand(command, paramsCommand)
try {
const response = executedCommand.success ? ok : internalServerError
res.locals.httpCode = httpResponse(response, JSON.parse(executedCommand.data))
let data = JSON.parse(executedCommand.data)
if (data && data.DOCUMENT_POOL && data.DOCUMENT_POOL.DOCUMENT && Array.isArray(data.DOCUMENT_POOL.DOCUMENT)) {
data.DOCUMENT_POOL.DOCUMENT = data.DOCUMENT_POOL.DOCUMENT.map(provision => {
if(provision && provision.TEMPLATE && provision.TEMPLATE.BODY){
provision.TEMPLATE.BODY = JSON.parse(provision.TEMPLATE.BODY)
}
return provision
})
}
res.locals.httpCode = httpResponse(response, data)
next()
return
} catch (error) {