Skip to content

Commit

Permalink
F #3629: Add onevnet orphans (#3794)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian González authored and Ruben S. Montero committed Oct 1, 2019
1 parent a2757c3 commit 1bb4146
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/cli/one_helper/onevnet_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,29 @@ def show_ar(vn, ar_id)
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)
Expand Down
10 changes: 10 additions & 0 deletions src/cli/onevnet
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1bb4146

Please sign in to comment.