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

F #3629: Add onevnet orphans (#3794)

This commit is contained in:
Christian González 2019-10-01 15:34:49 +02:00 committed by Ruben S. Montero
parent a2757c3c18
commit 1bb4146592
2 changed files with 33 additions and 0 deletions

View File

@ -192,6 +192,29 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
puts template
end
def check_orphans
orphans = []
xpath = '/VMTEMPLATE_POOL/VMTEMPLATE/TEMPLATE/NIC'
pool = factory_pool
tmpl_pool = OpenNebula::TemplatePool.new(@client, -2)
pool.info
tmpl_pool.info
pool.each do |img|
attrs = { :id => img['ID'],
:name => img['NAME'],
:uname => img['UNAME'] }
orphans << img['ID'] if check_orphan(tmpl_pool,
xpath,
'NETWORK', attrs)
end
orphans
end
private
def factory(id=nil)

View File

@ -429,4 +429,14 @@ CommandParser::CmdParser.new(ARGV) do
vnet.unlock
end
end
show_desc = <<-EOT.unindent
Shows orphans vnets (i.e vnets not referenced in any template).
EOT
command :orphans, show_desc do
puts helper.check_orphans
return 0
end
end