mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-22 20:54:49 +09:00
M #-: fix minor bug in JSON CLI output (#326)
This commit is contained in:
1 parent
7e96cea83f
commit
7366c2d2d3
3 files changed
+22
-19
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user