F #3629: Add onevnet orphans (#3794)

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

No files matched your search

+23
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)
+10
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