mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 05:04:56 +09:00
* Add onevcenter list_all command * Add a parameter as opts called filter * Sunstone will not show uplinks nor unmanaged networks.
This commit is contained in:
1 parent
973ff0d4f7
commit
f13f51a62e
4 files changed
+45
-9
No files matched your search
@@ -152,6 +152,7 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
:options => [OBJECT, HOST, DATASTORE, VCENTER, USER, PASS] do
|
||||
begin
|
||||
args = helper.parse_opts(options)
|
||||
args[:filter] = true
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
|
||||
importer = VCenterDriver::VcImporter
|
||||
.new_child(helper.client, vi_client, options[:object])
|
||||
@@ -166,6 +167,36 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
exit 0
|
||||
end
|
||||
|
||||
list_desc = <<-EOT.unindent
|
||||
Show a list with unimported vCenter objects excluding all filters
|
||||
|
||||
Examples:
|
||||
- listing networks including uplinks:
|
||||
|
||||
onevcenter list_all -o networks -h <host_id>
|
||||
|
||||
EOT
|
||||
|
||||
command :list_all,
|
||||
list_desc,
|
||||
:options => [OBJECT, HOST, DATASTORE, VCENTER, USER, PASS] do
|
||||
begin
|
||||
args = helper.parse_opts(options)
|
||||
args[:filter] = false
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(options[:host])
|
||||
importer = VCenterDriver::VcImporter
|
||||
.new_child(helper.client, vi_client, options[:object])
|
||||
|
||||
list = importer.retrieve_resources(args)
|
||||
|
||||
helper.list_object(options, list)
|
||||
rescue StandardError => e
|
||||
puts e.message
|
||||
end
|
||||
|
||||
exit 0
|
||||
end
|
||||
|
||||
import_desc = <<-EOT.unindent
|
||||
Import the the desired vCenter object
|
||||
|
||||
|
||||
@@ -186,8 +186,8 @@ end
|
||||
get '/vcenter/networks' do
|
||||
begin
|
||||
new_vcenter_importer("networks")
|
||||
|
||||
[200, $importer.retrieve_resources.to_json]
|
||||
opts = {:filter => true}
|
||||
[200, $importer.retrieve_resources(opts).to_json]
|
||||
rescue Exception => e
|
||||
logger.error("[vCenter] " + e.message)
|
||||
error = Error.new(e.message)
|
||||
|
||||
@@ -331,7 +331,7 @@ class DatacenterFolder
|
||||
{ vcenter_instance_name => template_objects }
|
||||
end
|
||||
|
||||
def get_unimported_networks(npool,vcenter_instance_name, hpool)
|
||||
def get_unimported_networks(npool,vcenter_instance_name, hpool, args)
|
||||
vcenter_uuid = get_vcenter_instance_uuid
|
||||
pc = @vi_client.vim.serviceContent.propertyCollector
|
||||
|
||||
@@ -373,11 +373,16 @@ class DatacenterFolder
|
||||
|
||||
next if exist
|
||||
|
||||
# Exclude networks without hosts
|
||||
next if r.obj['host'].empty?
|
||||
# Exclude uplinks
|
||||
unless r.obj['tag'].empty?
|
||||
next if r.obj['tag'][0][:key] == 'SYSTEM/DVS.UPLINKPG'
|
||||
if args[:filter]
|
||||
# Exclude networks without hosts
|
||||
next if r.obj['host'].empty?
|
||||
|
||||
# Exclude DVS uplinks
|
||||
unless r.obj['tag'].empty?
|
||||
next if r.obj['tag'][0][:key] == 'SYSTEM/DVS.UPLINKPG'
|
||||
end
|
||||
# Exclude NSX uplinks
|
||||
next if r.obj['name'].match(/^vxw-vmknicPg-dvs-(.*)/)
|
||||
end
|
||||
|
||||
networks[r.obj._ref] = r.to_hash if r.obj.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) || r.obj.is_a?(RbVmomi::VIM::Network) || r.obj.is_a?(RbVmomi::VIM::OpaqueNetwork)
|
||||
|
||||
@@ -367,7 +367,7 @@ class NetImporter < VCenterDriver::VcImporter
|
||||
raise "Could not get OpenNebula HostPool: #{hpool.message}"
|
||||
end
|
||||
|
||||
rs = dc_folder.get_unimported_networks(npool, @vi_client.vc_name,hpool)
|
||||
rs = dc_folder.get_unimported_networks(npool, @vi_client.vc_name,hpool, args)
|
||||
@list = rs
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user