mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
B #5126: OneFlow now allows updating the Service resource
This commit is contained in:
parent
6afb1ea097
commit
43ef050c88
@ -403,6 +403,34 @@ module OpenNebula
|
||||
return @body['shutdown_action']
|
||||
end
|
||||
|
||||
# Replaces the template contents
|
||||
#
|
||||
# @param template_json [String] New template contents
|
||||
# @param append [true, false] True to append new attributes instead of
|
||||
# replace the whole template
|
||||
#
|
||||
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
||||
# otherwise
|
||||
def update(template_json=nil, append=false)
|
||||
if template_json
|
||||
template = JSON.parse(template_json)
|
||||
|
||||
if append
|
||||
rc = info
|
||||
|
||||
if OpenNebula.is_error? rc
|
||||
return rc
|
||||
end
|
||||
|
||||
template = @body.merge(template)
|
||||
end
|
||||
|
||||
template_json = template.to_json
|
||||
end
|
||||
|
||||
super(template_json, append)
|
||||
end
|
||||
|
||||
# Replaces the raw template contents
|
||||
#
|
||||
# @param template [String] New template contents, in the form KEY = VAL
|
||||
|
@ -209,10 +209,10 @@ module OpenNebula
|
||||
def update(template_json, append=false)
|
||||
template = JSON.parse(template_json)
|
||||
|
||||
if(append)
|
||||
rc = info()
|
||||
if append
|
||||
rc = info
|
||||
|
||||
if(OpenNebula.is_error?(rc))
|
||||
if OpenNebula.is_error? rc
|
||||
return rc
|
||||
end
|
||||
|
||||
|
@ -248,20 +248,24 @@ post '/service/:id/action' do
|
||||
when 'rename'
|
||||
service.rename(opts['name'])
|
||||
when 'update'
|
||||
if opts && opts['template_raw']
|
||||
if (opts['append'] == true)
|
||||
rc = service.update_raw(
|
||||
opts['template_raw'],
|
||||
(opts['append'] == true))
|
||||
|
||||
if opts && opts['append']
|
||||
if opts['template_json']
|
||||
begin
|
||||
rc = service.update(opts['template_json'], true)
|
||||
status 204
|
||||
rescue Validator::ParseException, JSON::ParserError
|
||||
OpenNebula::Error.new($!.message)
|
||||
end
|
||||
elsif opts['template_raw']
|
||||
rc = service.update_raw(opts['template_raw'], true)
|
||||
status 204
|
||||
else
|
||||
OpenNebula::Error.new("Action #{action['perform']}: " <<
|
||||
"Only supported for append")
|
||||
"You have to provide a template")
|
||||
end
|
||||
else
|
||||
OpenNebula::Error.new("Action #{action['perform']}: " <<
|
||||
"You have to provide a raw template")
|
||||
"Only supported for append")
|
||||
end
|
||||
else
|
||||
OpenNebula::Error.new("Action #{action['perform']} not supported")
|
||||
|
Loading…
x
Reference in New Issue
Block a user