Arjun Roy
2009-Jul-08 18:40 UTC
[Ovirt-devel] [PATCH: host-browser replacement 0/3] replacement of host-browser on ovirt-server
The purpose of this patch is to replace the identify function in host-browser.rb with a new script, host-register.rb. host-register.rb is a qmf ruby console that interfaces with the newly added matahari qmf agent on the ovirt node. While it stores node data in the database with the same behavior as the original host-browser implementation, it acquires the data using the amqp protocol (and specifically, using Apache qmf objects). This patchset goes hand in hand with the patchsets adding support for the matahari qmf agent to ovirt-node and ovirt-node-image. Note that host-browser still performs the kerberos related duties it did before. There is at present a bug in the implementation of qmf - if the node connects to qpidd on the server before host-register does, then the data picked up by host-register will be in an inconsistent state till the node disconnects and reconnects to the broker. See: http://issues.apache.org/jira/browse/QPID-1973 The workaround for the above bug is to restart that matahari service on the node should the data appear incorrect. If the host-register needs to be restarted, the service on each of the nodes needs to be restarted after host-register. See also: http://git.et.redhat.com/?p=matahari.git;a=summary (The matahari qmf agent for the ovirt-node) Arjun Roy (3): Removed host browser identify unit test in preparation of removal of host browser node identify functionality. Removed ovirt node identify functionality from host-browser. Added new host-register script to ovirt server. host-register is a qmf ruby console that replaces the identify node functionality in host-browser, by interfacing with the matahari qmf agent on the node to stat node hardware data. conf/ovirt-host-register | 54 +++ installer/modules/ovirt/manifests/ovirt.pp | 6 + ovirt-server.spec.in | 5 + src/host-browser/host-browser.rb | 255 +--------------- src/host-browser/host-register.rb | 468 +++++++++++++++++++++++++++ src/test/unit/host_browser_identify_test.rb | 310 ------------------ 6 files changed, 534 insertions(+), 564 deletions(-) create mode 100644 conf/ovirt-host-register create mode 100644 src/host-browser/host-register.rb delete mode 100644 src/test/unit/host_browser_identify_test.rb
Arjun Roy
2009-Jul-08 18:40 UTC
[Ovirt-devel] [PATCH: host-browser replacement 1/3] Removed host browser identify unit test in preparation of removal of host browser node identify functionality.
--- src/test/unit/host_browser_identify_test.rb | 310 --------------------------- 1 files changed, 0 insertions(+), 310 deletions(-) delete mode 100644 src/test/unit/host_browser_identify_test.rb diff --git a/src/test/unit/host_browser_identify_test.rb b/src/test/unit/host_browser_identify_test.rb deleted file mode 100644 index 083b364..0000000 --- a/src/test/unit/host_browser_identify_test.rb +++ /dev/null @@ -1,310 +0,0 @@ -#!/usr/bin/ruby -Wall -# -# Copyright (C) 2008 Red Hat, Inc. -# Written by Darryl L. Pierce <dpierce at redhat.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. A copy of the GNU General Public License is -# also available at http://www.gnu.org/copyleft/gpl.html. - -$: << File.join(File.dirname(__FILE__), "../../dutils") -$: << File.join(File.dirname(__FILE__), "../../host-browser") - -require File.dirname(__FILE__) + '/../test_helper' - -require 'test/unit' -require 'flexmock/test_unit' -require 'dutils' - -TESTING=true - -require 'host-browser' - -# +HostBrowserIdentifyTest+ tests the host-browser server to ensure that it -# works correctly during the identify mode of operation. -# -class HostBrowserIdentifyTest < Test::Unit::TestCase - fixtures :boot_types - - def setup - @connection = flexmock('connection') - @connection.should_receive(:peeraddr).at_least.once.returns { [nil,nil,nil,"192.168.2.255"] } - - @browser = HostBrowser.new(@connection) - @browser.logfile = './unit-test.log' - - # default host info - @host_info = {} - @host_info['UUID'] = 'node1' - @host_info['IPADDR'] = '192.168.2.2' - @host_info['HOSTNAME'] = 'prod.corp.com' - @host_info['ARCH'] = 'x86_64' - @host_info['MEMSIZE'] = '16384' - @host_info['DISABLED'] = '0' - - @host_info['NUMCPUS'] = '2' - - @host_info['CPUINFO'] = Array.new - @host_info['CPUINFO'][0] = {} - @host_info['CPUINFO'][0]['CPUNUM'] = '0' - @host_info['CPUINFO'][0]['CORENUM'] = '0' - @host_info['CPUINFO'][0]['NUMCORES'] = '2' - @host_info['CPUINFO'][0]['VENDOR'] = 'GenuineIntel' - @host_info['CPUINFO'][0]['MODEL'] = '15' - @host_info['CPUINFO'][0]['FAMILY'] = '6' - @host_info['CPUINFO'][0]['CPUIDLVL'] = '10' - @host_info['CPUINFO'][0]['SPEED'] = '3' - @host_info['CPUINFO'][0]['CACHE'] = '4096 kb' - @host_info['CPUINFO'][0]['FLAGS'] = 'fpu vme de pse tsc msr pae \ - mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx \ - fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs \ - bts pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm' - - @host_info['CPUINFO'][1] = {} - @host_info['CPUINFO'][1]['CPUNUM'] = '1' - @host_info['CPUINFO'][1]['CORENUM'] = '1' - @host_info['CPUINFO'][1]['NUMCORES'] = '2' - @host_info['CPUINFO'][1]['VENDOR'] = 'GenuineIntel' - @host_info['CPUINFO'][1]['MODEL'] = '15' - @host_info['CPUINFO'][1]['FAMILY'] = '6' - @host_info['CPUINFO'][1]['CPUIDLVL'] = '10' - @host_info['CPUINFO'][1]['SPEED'] = '3' - @host_info['CPUINFO'][1]['CACHE'] = '4096 kb' - @host_info['CPUINFO'][1]['FLAGS'] = 'fpu vme de pse tsc msr pae \ - mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx \ - fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs \ - bts pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr lahf_lm' - - @host_info['NICINFO'] = Array.new - @host_info['NICINFO'] << { - 'MAC' => '00:11:22:33:44:55', - 'BANDWIDTH' => '100', - 'IFACE_NAME' => 'eth0'} - - @host_info['NICINFO'] << { - 'MAC' => '00:77:11:77:19:65', - 'BANDWIDTH' => '100', - 'IFACE_NAME' => 'eth01'} - end - - # Ensures that the server is satisfied if the remote system is - # making a wakeup call. - # - def test_get_mode_with_awaken_request - @connection.should_receive(:write).with("MODE?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "IDENTIFY\n" } - - result = @browser.get_mode() - - assert_equal "IDENTIFY", result, "method did not return the right value" - end - - # Ensures that, if an info field is missing a key, the server raises - # an exception. - # - def test_get_info_with_missing_key - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "=value1\n" } - - assert_raise(Exception) { @browser.get_remote_info } - end - - # Ensures that, if an info field is missing a value, the server raises - # an exception. - # - def test_get_info_with_missing_value - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=\n" } - - assert_raise(Exception) { @browser.get_remote_info } - end - - # Ensures that, if the server gets a poorly formed ending statement, it - # raises an exception. - # - def test_get_info_with_invalid_end - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=value1\n" } - @connection.should_receive(:write).with("ACK key1\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDIFNO\n" } - - assert_raise(Exception) { @browser.get_remote_info } - end - - # Ensures that a well-formed transaction works as expected. - # - def test_get_info - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=value1\n" } - @connection.should_receive(:write).with("ACK key1\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key2=value2\n" } - @connection.should_receive(:write).with("ACK key2\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDINFO\n" } - - info = @browser.get_remote_info - - assert_equal 5,info.keys.size, "Should contain five keys" - assert info.include?("IPADDR") - assert info.include?("HOSTNAME") - assert info.include?("NICINFO") - assert info.include?("key1") - assert info.include?("key2") - end - - # Ensures that the server is fine when no UUID is present. - # - def test_write_host_info_with_missing_uuid - @host_info['UUID'] = nil - - assert_nothing_raised { @browser.write_host_info(@host_info) } - end - - # Ensures that, if the hostname is missing, the server - # raises an exception. - # - def test_write_host_info_with_missing_hostname - @host_info['HOSTNAME'] = nil - - assert_raise(Exception) { @browser.write_host_info(@host_info) } - end - - # Ensures that, if the architecture is missing, the server raises an - # exception. - # - def test_write_host_info_with_missing_arch - @host_info['ARCH'] = nil - - assert_raise(Exception) { @browser.write_host_info(@host_info) } - end - - # Ensures that, if the memory size is missing, the server raises an - # exception. - # - def test_write_host_info_info_with_missing_memsize - @host_info['MEMSIZE'] = nil - - assert_raise(Exception) { @browser.write_host_info(@host_info) } - end - - # Ensures that, if no cpu info was available, the server raises an - # exception. - # - def test_write_host_info_with_missing_cpuinfo - @host_info['CPUINFO'] = nil - - assert_raise(Exception) { @browser.write_host_info(@host_info) } - end - - # Ensures that, if no NIC info was available, the server raises an - # exception. - # - def test_write_host_info_with_missing_nicinfo - @host_info['NICINFO'] = nil - - assert_raise(Exception) { @browser.write_host_info(@host_info) } - end - - # Ensures that, if a NIC is present that was already submitted, it - # doesn't get re-entered. - # - def test_write_host_info_with_duplicate_nic - # Values taken from the nics.yml fixture - @host_info['NICINFO'] << { - 'MAC' => '00:11:22:33:44:55', - 'BANDWIDTH' => '100', - 'IFACE_NAME' => 'eth0' - } - - assert_nothing_raised { @browser.write_host_info(@host_info) } - assert_equal 3, Host.find_by_hostname('prod.corp.com').nics.size, 'Expected three NICs.' - end - - # Ensures the browser can properly parse the CPU details. - # - def test_parse_cpu_info - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "CPU\n" } - @connection.should_receive(:write).with("CPUINFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=value1\n" } - @connection.should_receive(:write).with("ACK key1\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key2=value2\n" } - @connection.should_receive(:write).with("ACK key2\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDCPU\n" } - @connection.should_receive(:write).with("ACK CPU\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDINFO\n" } - - info = @browser.get_remote_info - - assert_equal 4,info.keys.size, "Should contain four keys" - assert info.include?("CPUINFO") - end - - # Ensures the browser can properly parse the CPU details of two CPUs. - # - def test_parse_cpu_info_with_two_entries - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - - # CPU 0 - @connection.should_receive(:readline).once().returns { "CPU\n" } - @connection.should_receive(:write).with("CPUINFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=value1\n" } - @connection.should_receive(:write).with("ACK key1\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key2=value2\n" } - @connection.should_receive(:write).with("ACK key2\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDCPU\n" } - @connection.should_receive(:write).with("ACK CPU\n").once().returns { |request| request.length } - - # CPU 1 - @connection.should_receive(:readline).once().returns { "CPU\n" } - @connection.should_receive(:write).with("CPUINFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key3=value3\n" } - @connection.should_receive(:write).with("ACK key3\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key4=value4\n" } - @connection.should_receive(:write).with("ACK key4\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDCPU\n" } - @connection.should_receive(:write).with("ACK CPU\n").once().returns { |request| request.length } - - @connection.should_receive(:readline).once().returns { "ENDINFO\n" } - - info = @browser.get_remote_info - - assert_equal 4,info.keys.size, "Should contain four keys" - assert info.include?('CPUINFO') - assert_equal 2, info['CPUINFO'].size, "Should contain details for two CPUs" - assert_not_nil info['CPUINFO'][0]['key1'] - assert_not_nil info['CPUINFO'][0]['key2'] - assert_not_nil info['CPUINFO'][1]['key3'] - assert_not_nil info['CPUINFO'][1]['key4'] - end - - # Ensures the browser can properly parse the details for a NIC. - # - def test_parse_nic_info - @connection.should_receive(:write).with("INFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "NIC\n" } - @connection.should_receive(:write).with("NICINFO?\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key1=value1\n" } - @connection.should_receive(:write).with("ACK key1\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "key2=value2\n" } - @connection.should_receive(:write).with("ACK key2\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDNIC\n" } - @connection.should_receive(:write).with("ACK NIC\n").once().returns { |request| request.length } - @connection.should_receive(:readline).once().returns { "ENDINFO\n" } - - info = @browser.get_remote_info - - assert_equal 3,info.keys.size, "Should contain four keys" - assert info.include?("NICINFO") - end -end -- 1.6.2.5