From 7bcde306f12e0ccc76d8500bc00cd86abdba3a22 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Date: Mon, 10 Jun 2019 10:33:01 +0200 Subject: [PATCH] F #3378: add new column to show fed index --- src/cli/one_helper/onezone_helper.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cli/one_helper/onezone_helper.rb b/src/cli/one_helper/onezone_helper.rb index fcf19076c92..3425a0a5c4d 100644 --- a/src/cli/one_helper/onezone_helper.rb +++ b/src/cli/one_helper/onezone_helper.rb @@ -77,12 +77,32 @@ def format_pool(options) d["TEMPLATE"]['ENDPOINT'] end - default :CURRENT, :ID, :NAME, :ENDPOINT + column :FED_INDEX, "Federation index", :left, :size=>10 do |d| + helper.get_fed_index(d["TEMPLATE"]['ENDPOINT']) + end + + default :CURRENT, :ID, :NAME, :ENDPOINT, :FED_INDEX end table end + def get_fed_index(endpoint) + client = OpenNebula::Client.new(nil, endpoint, :timeout => 5) + xml = client.call('zone.raftstatus') + xml = Nokogiri::XML(xml) + + if OpenNebula.is_error?(xml) + '-' + end + + if xml.xpath('RAFT/FEDLOG_INDEX') + xml.xpath('RAFT/FEDLOG_INDEX').text + else + '-' + end + end + def set_zone(zone_id, temporary_zone) zone = factory(zone_id) rc = zone.info