M #-: fix minor bug in JSON CLI output (#326)

This commit is contained in:
Alejandro Huertas Herrero authored and GitHub committed 2020-10-19 10:05:30 +02:00
1 parent 7e96cea83f
commit 7366c2d2d3
3 files changed
+22 -19

No files matched your search

+11
View File
@@ -87,6 +87,17 @@ EOT
if options[:xml]
return 0, resource.to_xml(true)
elsif options[:json]
# If body is set, the resource contains a JSON inside
if options[:body]
return 0, check_resource_xsd(resource)
else
return 0, ::JSON.pretty_generate(
check_resource_xsd(resource)
)
end
elsif options[:yaml]
return 0, check_resource_xsd(resource).to_yaml(:indent => 4)
else
format_resource(resource, options)
return 0
-19
View File
@@ -38,25 +38,6 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper
"onevrouter.yaml"
end
def show_resource(id, options)
resource = retrieve_resource(id)
if !options[:extended].nil?
rc = resource.info(options[:extended])
else
rc = resource.info
end
return -1, rc.message if OpenNebula.is_error?(rc)
if options[:xml]
return 0, resource.to_xml(true)
else
format_resource(resource, options)
return 0
end
end
def format_pool(options)
config_file = self.class.table_conf
+11
View File
@@ -470,6 +470,17 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
if options[:xml]
return 0, resource.to_xml(true)
elsif options[:json]
# If body is set, the resource contains a JSON inside
if options[:body]
return 0, check_resource_xsd(resource)
else
return 0, ::JSON.pretty_generate(
check_resource_xsd(resource)
)
end
elsif options[:yaml]
return 0, check_resource_xsd(resource).to_yaml(:indent => 4)
else
format_resource(resource, options)
return 0