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

F #5422: Add persistent flag in saveas (#1580)

(cherry picked from commit 4463493b121d2df071979c517e7514f3fa0da8d5)
This commit is contained in:
Jorge Miguel Lobo Escalona 2021-11-17 16:50:38 +01:00 committed by Tino Vazquez
parent 5f29eb1487
commit e1f6eb95b0
No known key found for this signature in database
GPG Key ID: 14201E424D02047E
2 changed files with 13 additions and 3 deletions

View File

@ -43,13 +43,19 @@ const regexpSplitLine = /\r|\n/
*/
const saveAsTemplate = (res = {}, next = defaultEmptyFunction, params = {}, userData = {}) => {
let rtn = httpBadRequest
if (params && params.id && params.name) {
const paramsCommand = ['save', `${params.id}`, `${params.name}`]
const { id, name, persistent } = params
if (id && name) {
let message = ''
const paramsCommand = ['save', `${id}`, `${name}`]
if (persistent && persistent === 'true') {
paramsCommand.push('--persistent')
}
const executedCommand = executeCommand(defaultCommandVM, paramsCommand, prependCommand)
const response = executedCommand.success ? ok : internalServerError
let message = ''
if (executedCommand.data) {
message = executedCommand.data.replace(regexpSplitLine, '')
}

View File

@ -30,6 +30,10 @@ const routes = {
name: {
from: fromData.postBody,
name: 'name'
},
persistent: {
from: fromData.postBody,
name: 'persistent'
}
}
}