From 371a96c5ed558bae8bb1045e69921c995545e777 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Fri, 21 Aug 2015 13:48:09 +0200 Subject: [PATCH] feature #3028: show pci devices in onehost show --- src/cli/one_helper/onehost_helper.rb | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 44f262daa4..60f8e56be2 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -413,11 +413,22 @@ class OneHostHelper < OpenNebulaHelper::OneHelper wilds = host.wilds + begin + pcis = [host.to_hash['HOST']['HOST_SHARE']['PCI_DEVICES']['PCI']] + pcis = pcis.flatten.compact + rescue + pcis = nil + end + host.delete_element("TEMPLATE/VM") host.delete_element("TEMPLATE_WILDS") puts host.template_str + if pcis && !pcis.empty? + print_pcis(pcis) + end + puts CLIHelper.print_header("WILD VIRTUAL MACHINES", false) puts @@ -457,4 +468,43 @@ class OneHostHelper < OpenNebulaHelper::OneHelper onevm_helper.client=@client onevm_helper.list_pool({:filter=>["HOST=#{host.name}"]}, false) end + + def print_pcis(pcis) + puts + CLIHelper.print_header("PCI DEVICES", false) + puts + + table=CLIHelper::ShowTable.new(nil, self) do + column :VM, "Used by VM", :size => 4, :left => false do |d| + if d["VMID"] == "-1" + "" + else + d["VMID"] + end + end + + column :ADDR, "PCI Address", :size => 7, :left => true do |d| + d["SHORT_ADDRESS"] + end + + column :TYPE, "Type", :size => 14, :left => true do |d| + d["TYPE"] + end + + column :CLASS, "Class", :size => 12, :left => true do |d| + d["CLASS_NAME"] + end + + column :NAME, "Name", :size => 30, :left => true do |d| + d["DEVICE_NAME"] + end + + column :VENDOR, "Vendor", :size => 8, :left => true do |d| + d["VENDOR_NAME"] + end + + end + + table.show(pcis) + end end