This introduces support to run P2V without X server. Runtime parameters are specified via kernel command line making it hopefully suitable for automated migration with a little help of PXE boot. Patchset is not squashed and represents dev. history.
--- NOTES.txt | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 NOTES.txt diff --git a/NOTES.txt b/NOTES.txt new file mode 100644 index 0000000..f9f0f91 --- /dev/null +++ b/NOTES.txt @@ -0,0 +1,49 @@ +UI duck screen: + .get_object/1 :: string -> gtk obj + .register_handler/2 :: event string -> method/1 volanie -> () + +network_device_list_view.selection Duck screen: + .mode :: setter na selection type + .set_select_function &block + +device_list: + .append() :: () -> Hash + + +gtk_obj: + .sensitive :: setter na bool + .selection + +SIGNALS: +main_window: destroy:gtk_main_quit + +network_win (gtkwindow): + ip_auto (GtkCheckButton): toggled:ip_auto_toggled + ip_gateway (GtkEntry): changed:ip_gateway_changed + ip_dns (GtkEntry): changed:ip_dns_changed + ip_address (GtkEntry): changed:ip_address_changed + ip_prefix (GtkEntry): changed:ip_prefix_changed + network_button (GtkButton): clicked:network_button_clicked + +server_win (gtkwindow): + server_hostname (GtkEntry): changed:server_hostname_changed + server_password (gtkentry): changed:server_password_changed + server_username (GtkEntry): changed:server_username_changed + connect_button (GtkButton): clicked:connect_button_clicked + +success_win (GtkWindow): + poweroff_button (GtkButton): clicked:poweroff_button_clicked + +conversion_win: + convert_profile (gtkcomboxbox): changed:convert_profile_changed + convert_memory (gtkentry): changed:convert_memory_changed + convert_name (gtkentry): changed:convert_name_changed + convert_cpus (gtkentry): changed:convert_cpus_changed + convert_fixed_select (gtkcellrederertoggle): toggled:convert_fixed_select_toggled + convert_removable_select (GtkCellRendererToggle): toggled:convert_removable_select_toggled + convert_network_select (GtkCellRendererToggle): toggled:convert_network_select_toggled + convert_button (GtkButton): clicked:convert_button_clicked + + convert_fixed_list (GtkListStore): row-changed:convert_fixed_list_row_changed + convert_network_list (GtkListStore): row-changed:convert_network_list_row_changed + convert_removable_list (GtkListStore): row-changed:convert_removable_list_row_changed -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 02/61] basic cmdline parser tests for P2V clients NewMain
---
p2v/client/test/cmdline_default | 1 +
p2v/client/test/cmdline_test | 1 +
p2v/client/test/test_newmain.rb | 49 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+)
create mode 100644 p2v/client/test/cmdline_default
create mode 100644 p2v/client/test/cmdline_test
create mode 100644 p2v/client/test/test_newmain.rb
diff --git a/p2v/client/test/cmdline_default b/p2v/client/test/cmdline_default
new file mode 100644
index 0000000..7766d17
--- /dev/null
+++ b/p2v/client/test/cmdline_default
@@ -0,0 +1 @@
+BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro
rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us
rd.lvm.lv=vg_jelly/lv_swap
rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 rhgb
quiet
diff --git a/p2v/client/test/cmdline_test b/p2v/client/test/cmdline_test
new file mode 100644
index 0000000..6d84e8e
--- /dev/null
+++ b/p2v/client/test/cmdline_test
@@ -0,0 +1 @@
+BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro
rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us
rd.lvm.lv=vg_jelly/lv_swap
rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8
p2v_test=foo rhgb quiet
diff --git a/p2v/client/test/test_newmain.rb b/p2v/client/test/test_newmain.rb
new file mode 100644
index 0000000..26a15a6
--- /dev/null
+++ b/p2v/client/test/test_newmain.rb
@@ -0,0 +1,49 @@
+require 'minitest/autorun'
+require 'virt-p2v/ui/main'
+
+WD = File.expand_path File.dirname(__FILE__)
+CMDLINE_TEST = File.join(WD, "cmdline_test")
+CMDLINE_DEFAULT = File.join(WD, "cmdline_default")
+
+class TestNewMainDry < MiniTest::Unit::TestCase
+ def setup
+ @nm = VirtP2V::UI::NewMain.new dry=true
+ end
+
+ def test_cmdline_parse_d
+ params = @nm.parse_cmdline(CMDLINE_DEFAULT)
+ assert_equal params, {}
+ end
+
+ def test_cmdline_parse_t
+ params = @nm.parse_cmdline(CMDLINE_TEST)
+ assert_equal params, {"test" => "foo"}
+ end
+
+ def test_cmdline_parse_noval
+ params = @nm.parse_cmdline
+ assert_equal params, {}
+ end
+end
+
+
+class TestNewMain < MiniTest::Unit::TestCase
+ def setup
+ @nm = VirtP2V::UI::NewMain.new
+ end
+
+ def test_cmdline_parse_d
+ params = @nm.parse_cmdline(CMDLINE_DEFAULT)
+ assert_equal params, {}
+ end
+
+ def test_cmdline_parse_t
+ params = @nm.parse_cmdline(CMDLINE_TEST)
+ assert_equal params, {"test" => "foo"}
+ end
+
+ def test_cmdline_parse_noval
+ params = @nm.parse_cmdline
+ assert_equal params, {}
+ end
+end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 03/61] P2V client NewMain class with initial GTK2 mocks
---
p2v/client/lib/virt-p2v/ui/main.rb | 76 +++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 2 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 6960183..55cc9f0 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -14,8 +14,37 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-require 'gtk2'
-require 'virt-p2v/gtk-queue'
+#require 'gtk2'
+#require 'virt-p2v/gtk-queue'
+
+module VirtP2V
+module UI
+ class NeverMind
+ def method_missing(m, *args, &block)
+ puts "Never mind call '#{m} #{args}'. ON
#{self.inspect}"
+ self
+ end
+
+ def self.method_missing(m, *args, &block)
+ puts "Never mind class call '#{m} #{args}'. ON
#{self.inspect}"
+ self
+ end
+
+ def initialize
+ puts "Hi, I'm #{self.inspect}"
+ end
+ end
+end
+end
+
+module Gtk
+ Builder = VirtP2V::UI::NeverMind
+ STATE_NORMAL = 0
+end
+
+module Gdk
+ Color = VirtP2V::UI::NeverMind
+end
module VirtP2V
module UI
@@ -111,5 +140,48 @@ class Main
end
end
+
+class NewMain < Main
+ def parse_cmdline(filename = nil)
+ filename ||= '/proc/cmdline'
+ cmdline = open(filename) do |f|
+ f.read.strip.split
+ end
+ params = {}
+ cmdline.each do |c|
+ /p2v_([a-zA-Z0-9_]*)=([a-zA-Z0-9_]*)/ =~ c
+ params.merge! $1 => $2 if $1
+ end
+ params
+ end
+
+ def get_object(name)
+ # this is the entry point for returning our mocked
+ # versions of gtk2 objects, very similar to what we'd
+ # need to write tests
+ puts "GET_OBJ #{name}"
+ if name == "network_win" then
+ n = NeverMind.new
+ n.define_method : do
+
+ end
+ else
+ NeverMind.new
+ end
+ end
+
+ def main_loop
+ # and this is the program flow entry point,
+ # basic idea is to 'proceed with actions
+ # as would user do' based on parameters passed
+ # through kernel command line
+ end
+
+ def initialize dry=nil
+ super() unless dry
+ @builder = NeverMind.new
+ end
+end
+
end # UI
end # VirtP2V
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 04/61] p2v client: shrink TestNewMain class
---
p2v/client/test/test_newmain.rb | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/p2v/client/test/test_newmain.rb b/p2v/client/test/test_newmain.rb
index 26a15a6..cc07f9a 100644
--- a/p2v/client/test/test_newmain.rb
+++ b/p2v/client/test/test_newmain.rb
@@ -27,23 +27,8 @@ class TestNewMainDry < MiniTest::Unit::TestCase
end
-class TestNewMain < MiniTest::Unit::TestCase
+class TestNewMain < TestNewMainDry
def setup
@nm = VirtP2V::UI::NewMain.new
end
-
- def test_cmdline_parse_d
- params = @nm.parse_cmdline(CMDLINE_DEFAULT)
- assert_equal params, {}
- end
-
- def test_cmdline_parse_t
- params = @nm.parse_cmdline(CMDLINE_TEST)
- assert_equal params, {"test" => "foo"}
- end
-
- def test_cmdline_parse_noval
- params = @nm.parse_cmdline
- assert_equal params, {}
- end
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 05/61] p2v client: newmain - give mock obj a name, more gtk and gdk mocks
---
p2v/client/lib/virt-p2v/ui/main.rb | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 55cc9f0..93b2663 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -21,17 +21,18 @@ module VirtP2V
module UI
class NeverMind
def method_missing(m, *args, &block)
- puts "Never mind call '#{m} #{args}'. ON
#{self.inspect}"
+ puts "Never mind call '#{m} #{args}'. ON #{@name ||
self.inspect}"
self
end
def self.method_missing(m, *args, &block)
- puts "Never mind class call '#{m} #{args}'. ON
#{self.inspect}"
+ puts "Never mind class call '#{m} #{args}'. ON #{@name ||
self.inspect}"
self
end
- def initialize
- puts "Hi, I'm #{self.inspect}"
+ def initialize(name=nil, *args)
+ @name = name
+ puts "Hi, I'm #{@name || self.inspect}"
end
end
end
@@ -40,10 +41,16 @@ end
module Gtk
Builder = VirtP2V::UI::NeverMind
STATE_NORMAL = 0
+ SELECTION_SINGLE = 1
+ TreeRowReference = VirtP2V::UI::NeverMind
+
end
module Gdk
Color = VirtP2V::UI::NeverMind
+ Cursor = VirtP2V::UI::NeverMind
+ Cursor::Type = VirtP2V::UI::NeverMind
+ Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
end
module VirtP2V
@@ -161,12 +168,12 @@ class NewMain < Main
# need to write tests
puts "GET_OBJ #{name}"
if name == "network_win" then
- n = NeverMind.new
- n.define_method : do
-
- end
+ n = NeverMind.new name
+# n.define_method : do
+#
+# end
else
- NeverMind.new
+ NeverMind.new name
end
end
@@ -175,6 +182,12 @@ class NewMain < Main
# basic idea is to 'proceed with actions
# as would user do' based on parameters passed
# through kernel command line
+ puts "this is the main loop"
+ end
+
+ def register_handler(signal, handler)
+ super(signal, handler)
+ puts "#{handler} for #{signal} action registered"
end
def initialize dry=nil
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 06/61] p2v: convert - set converter before updating values
---
p2v/client/lib/virt-p2v/ui/convert.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/p2v/client/lib/virt-p2v/ui/convert.rb
b/p2v/client/lib/virt-p2v/ui/convert.rb
index 244125e..74d201f 100644
--- a/p2v/client/lib/virt-p2v/ui/convert.rb
+++ b/p2v/client/lib/virt-p2v/ui/convert.rb
@@ -145,10 +145,11 @@ module VirtP2V::UI::Convert
@state = nil
set_state(UI_STATE_INVALID)
- update_values
@ui = ui
@converter = converter
+
+ update_values
end
def self.event(event, status)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 07/61] p2v: very basic intergration test
--- p2v/client/test/test_newmain_integration.rb | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 p2v/client/test/test_newmain_integration.rb diff --git a/p2v/client/test/test_newmain_integration.rb b/p2v/client/test/test_newmain_integration.rb new file mode 100644 index 0000000..6d6504f --- /dev/null +++ b/p2v/client/test/test_newmain_integration.rb @@ -0,0 +1,45 @@ +require 'minitest/autorun' + +require 'virt-p2v/ui/main' +require 'virt-p2v/ui/network' +require 'virt-p2v/ui/connect' +require 'virt-p2v/ui/convert' +require 'virt-p2v/ui/success' + +require 'virt-p2v/converter' +require 'virt-p2v/netdevice' + +class TestNewMainIntegration < MiniTest::Unit::TestCase + def setup + end + + def make_converter + VirtP2V::UI::NeverMind.new + end + + def test_toothlees_launch + # lets try to start up thing in a similar + # way as usual + converter = make_converter + # Initialise the wizard UI + ui = VirtP2V::UI::NewMain.new + + # Initialize wizard pages + VirtP2V::UI::Network.init(ui) + VirtP2V::UI::Connect.init(ui, converter) + VirtP2V::UI::Convert.init(ui, converter) + VirtP2V::UI::Success.init(ui) + + ui.show + ui.main_loop + end +end + +class TestWithConverterNewMainIntegration < TestNewMainIntegration + def setup + end + + def make_converter + VirtP2V::Converter.new + end +end -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 08/61] p2v: disarm gtk2 dependency (with empty gtk2 file)
--- p2v/client/lib/gtk2.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 p2v/client/lib/gtk2.rb diff --git a/p2v/client/lib/gtk2.rb b/p2v/client/lib/gtk2.rb new file mode 100644 index 0000000..e69de29 -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 09/61] P2V: early test for block device lookup
---
p2v/client/test/test_newmain_integration.rb | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/p2v/client/test/test_newmain_integration.rb
b/p2v/client/test/test_newmain_integration.rb
index 6d6504f..9e96987 100644
--- a/p2v/client/test/test_newmain_integration.rb
+++ b/p2v/client/test/test_newmain_integration.rb
@@ -42,4 +42,9 @@ class TestWithConverterNewMainIntegration <
TestNewMainIntegration
def make_converter
VirtP2V::Converter.new
end
+
+ def test_blockdevice_lookup
+ devs = VirtP2V::FixedBlockDevice.all_devices
+ refute_empty devs
+ end
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 10/61] p2v: fake append and assign for network_device_list
---
p2v/client/lib/virt-p2v/ui/main.rb | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 93b2663..f65ff15 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -167,14 +167,26 @@ class NewMain < Main
# versions of gtk2 objects, very similar to what we'd
# need to write tests
puts "GET_OBJ #{name}"
- if name == "network_win" then
+ @gui_objects ||= {}
+ @gui_objects[name] ||= if name == "network_device_list" then
n = NeverMind.new name
-# n.define_method : do
-#
-# end
+ n.class.send(:define_method, :append) do |*args|
+ @items ||= []
+ @items << []
+ self
+ end
+ n.class.send(:define_method, :"[]=") do |idx, item|
+ p "called []= on #{name} with #{args}"
+ @items.last[idx] = item
+ p @items
+ self
+ end
+ n
else
NeverMind.new name
end
+
+ @gui_objects[name]
end
def main_loop
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 11/61] p2v: fake text setters and getters, selection on netdevview, add reference to instance of main class to mock instance
---
p2v/client/lib/virt-p2v/ui/main.rb | 46 +++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index f65ff15..ccd11b1 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -30,8 +30,9 @@ module UI
self
end
- def initialize(name=nil, *args)
+ def initialize(main = nil, name=nil, *args)
@name = name
+ @main = main
puts "Hi, I'm #{@name || self.inspect}"
end
end
@@ -169,21 +170,53 @@ class NewMain < Main
puts "GET_OBJ #{name}"
@gui_objects ||= {}
@gui_objects[name] ||= if name == "network_device_list" then
- n = NeverMind.new name
+ n = NeverMind.new self, name
n.class.send(:define_method, :append) do |*args|
@items ||= []
@items << []
self
end
+ n.class.send(:define_method, :_items) do
+ #p @items
+ @items
+ end
n.class.send(:define_method, :"[]=") do |idx, item|
- p "called []= on #{name} with #{args}"
+ #p "called []= on #{name} with #{args}"
@items.last[idx] = item
- p @items
+ #p @items
+ self
+ end
+ n
+ elsif name == "network_device_list_view"
+ n = NeverMind.new self, name
+ n.class.send(:define_method, :selection) do
self
end
+ n.class.send(:define_method, :selected) do
+ # TODO: this needs a proper selection
+ # now it's only for a testing purpouse
+ # but later we need to reflect reality
+ # and not blindly return first device
+ nejm = @main.get_object("network_device_list")._items.first
+ p nejm
+ end
+ n
+ elsif ["server_hostname", "server_username",
"server_password",
+ "convert_name", "convert_cpus",
"convert_memory"].any?{|n| n==name}
+ # N.B. some of these are set by user
+ n = NeverMind.new self, name
+ n.class.send(:define_method, :text) do
+# p "called text on #{name}"
+ @text || ""
+ end
+ n.class.send(:define_method, :"text=") do |str|
+ @text = str
+ p "called text= #{str} on #{name}"
+ end
+# p n
n
else
- NeverMind.new name
+ NeverMind.new self, name
end
@gui_objects[name]
@@ -195,6 +228,7 @@ class NewMain < Main
# as would user do' based on parameters passed
# through kernel command line
puts "this is the main loop"
+ @signal_handlers["network_button_clicked"].call
end
def register_handler(signal, handler)
@@ -204,7 +238,7 @@ class NewMain < Main
def initialize dry=nil
super() unless dry
- @builder = NeverMind.new
+ @builder = NeverMind.new self
end
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 12/61] P2V: light debug output cleanup, more fake text fields, initial main loop - fill in data, trigger updates and click
---
p2v/client/lib/virt-p2v/ui/main.rb | 48 +++++++++++++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index ccd11b1..aa6f005 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -21,12 +21,19 @@ module VirtP2V
module UI
class NeverMind
def method_missing(m, *args, &block)
- puts "Never mind call '#{m} #{args}'. ON #{@name ||
self.inspect}"
+ _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
+ self.__id__.to_s : _a}
+ puts "Never mind call '#{m} #{_args}'. ON #{@name ||
+ ("NeverMind:"+self.__id__.to_s)}"
self
end
def self.method_missing(m, *args, &block)
- puts "Never mind class call '#{m} #{args}'. ON #{@name ||
self.inspect}"
+ _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
+ self.__id__.to_s : _a}
+ #puts "Never mind class call '#{m} #{_args}'. ON #{@name ||
self.inspect}"
+ puts "Never mind call '#{m} #{_args}'. ON #{@name ||
+ ("NeverMind:"+self.__id__.to_s)}"
self
end
@@ -95,6 +102,7 @@ class Main
raise "Attempt to activate non-existent page #{name}" \
unless @pages.has_key?(name)
+ p "trying to activate page #{name}"
page = @pages[name]
@page_vbox = self.get_object('page_vbox') unless defined?
@page_vbox
@@ -202,8 +210,12 @@ class NewMain < Main
end
n
elsif ["server_hostname", "server_username",
"server_password",
- "convert_name", "convert_cpus",
"convert_memory"].any?{|n| n==name}
+ "convert_name", "convert_cpus",
"convert_memory",
+ "ip_manual", "ip_address",
"ip_prefix", "ip_gateway",
+ "ip_dns", "server_hostname",
"server_username",
+ "server_password"].any?{|m| m==name}
# N.B. some of these are set by user
+ p "GOTCHA, YOU'D LOVE TO GET #{name}"
n = NeverMind.new self, name
n.class.send(:define_method, :text) do
# p "called text on #{name}"
@@ -219,6 +231,7 @@ class NewMain < Main
NeverMind.new self, name
end
+ p "I'LL RETURN YOU
#{@gui_objects[name].class}:#{@gui_objects[name].__id__} for #{name}"
@gui_objects[name]
end
@@ -228,7 +241,36 @@ class NewMain < Main
# as would user do' based on parameters passed
# through kernel command line
puts "this is the main loop"
+
+ get_object("ip_manual").text=true
+ get_object("ip_address").text="10.0.0.1"
+ get_object("ip_prefix").text="24"
+ get_object("ip_gateway").text="10.0.0.254"
+ get_object("ip_dns").text="10.0.0.253"
+ p "SO, THE IP IS #{get_object("ip_address").text}"
+ @signal_handlers["ip_address_changed"].call
+ @signal_handlers["ip_prefix_changed"].call
+ @signal_handlers["ip_gateway_changed"].call
+ @signal_handlers["ip_dns_changed"].call
+ # aaaand CLICK!
@signal_handlers["network_button_clicked"].call
+
+ # TODO: this activation in NOT neccessary
+ # since it's done automatically in network module
+ # but well, not in "testing"
+ self.active_page='server_win'
+ get_object("server_hostname").text='localhost'
+ get_object("server_username").text='tak'
+ get_object("server_password").text='urcite'
+ @signal_handlers["server_hostname_changed"].call
+ @signal_handlers["server_username_changed"].call
+ @signal_handlers["server_password_changed"].call
+ @signal_handlers["connect_button_clicked"].call
+
+ # TODO: again, stupidly switch page and don't care about truth!
+ self.active_page='conversion_win'
+ p VirtP2V::UI::Connect.instance_variable_get(:@converter).connection.class
+
end
def register_handler(signal, handler)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 13/61] P2V: main.rb - convince network page we made a selection, add dbus main loop
---
p2v/client/lib/virt-p2v/ui/main.rb | 49 ++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index aa6f005..814533c 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -248,28 +248,47 @@ class NewMain < Main
get_object("ip_gateway").text="10.0.0.254"
get_object("ip_dns").text="10.0.0.253"
p "SO, THE IP IS #{get_object("ip_address").text}"
+ @signal_handlers["ip_auto_toggled"].call
@signal_handlers["ip_address_changed"].call
@signal_handlers["ip_prefix_changed"].call
@signal_handlers["ip_gateway_changed"].call
@signal_handlers["ip_dns_changed"].call
+ # send a synthetic event, UI would think that we made a selection
+ VirtP2V::UI::Network.event(VirtP2V::UI::Network::EV_SELECTION, true)
# aaaand CLICK!
@signal_handlers["network_button_clicked"].call
- # TODO: this activation in NOT neccessary
- # since it's done automatically in network module
- # but well, not in "testing"
- self.active_page='server_win'
- get_object("server_hostname").text='localhost'
- get_object("server_username").text='tak'
- get_object("server_password").text='urcite'
- @signal_handlers["server_hostname_changed"].call
- @signal_handlers["server_username_changed"].call
- @signal_handlers["server_password_changed"].call
- @signal_handlers["connect_button_clicked"].call
-
- # TODO: again, stupidly switch page and don't care about truth!
- self.active_page='conversion_win'
- p VirtP2V::UI::Connect.instance_variable_get(:@converter).connection.class
+ # register ourselves as listener on activated connection
+ # as VirtP2V::UI:Netowork does
+ VirtP2V::NetworkDevice.add_listener( lambda { |dev|
+ p dev
+ if dev.connected && dev.activated then
+ p "we should now continue"
+ end
+ })
+
+ # let's try to recieve some more of NMs signals
+ session_bus = DBus::SystemBus.instance
+
+ db_main = DBus::Main.new
+ db_main << session_bus
+ db_main.run
+
+# # TODO: this activation in NOT neccessary
+# # since it's done automatically in network module
+# # but well, not in "testing"
+# self.active_page='server_win'
+# get_object("server_hostname").text='localhost'
+# get_object("server_username").text='tak'
+# get_object("server_password").text='urcite'
+# @signal_handlers["server_hostname_changed"].call
+# @signal_handlers["server_username_changed"].call
+# @signal_handlers["server_password_changed"].call
+# @signal_handlers["connect_button_clicked"].call
+#
+# # TODO: again, stupidly switch page and don't care about truth!
+# self.active_page='conversion_win'
+# p VirtP2V::UI::Connect.instance_variable_get(:@converter).connection.class
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 14/61] P2V: swap hwloc-info with hwloc-ls
---
p2v/client/lib/virt-p2v/converter.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/p2v/client/lib/virt-p2v/converter.rb
b/p2v/client/lib/virt-p2v/converter.rb
index 7cb4e33..eccc436 100644
--- a/p2v/client/lib/virt-p2v/converter.rb
+++ b/p2v/client/lib/virt-p2v/converter.rb
@@ -113,7 +113,7 @@ class Converter
end
# Get the total number of cpu threads from hwloc-info
- hwloc = Document.new `hwloc-info --of xml`
+ hwloc = Document.new `hwloc-ls --of xml`
@cpus = XPath.match(hwloc,
"//object[@type='PU']").length
# Get cpu architecture and features from the first flags entry in
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 15/61] P2V: main - fake Gtk.timeout_add
--- p2v/client/lib/virt-p2v/ui/main.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/p2v/client/lib/virt-p2v/ui/main.rb b/p2v/client/lib/virt-p2v/ui/main.rb index 814533c..0544a8e 100644 --- a/p2v/client/lib/virt-p2v/ui/main.rb +++ b/p2v/client/lib/virt-p2v/ui/main.rb @@ -52,6 +52,12 @@ module Gtk SELECTION_SINGLE = 1 TreeRowReference = VirtP2V::UI::NeverMind + def Gtk.timeout_add(timeout, &block) + while true + sleep(timeout/1000.0) + block.call + end + end end module Gdk -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 16/61] P2V: enter data into server window and click
---
p2v/client/lib/virt-p2v/ui/main.rb | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 0544a8e..5717c5d 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -270,6 +270,15 @@ class NewMain < Main
p dev
if dev.connected && dev.activated then
p "we should now continue"
+ get_object("server_hostname").text='convertserver'
+ get_object("server_username").text='root'
+ get_object("server_password").text='roflkopter'
+ p "let's notify server window that we entered data"
+ @signal_handlers["server_hostname_changed"].call
+ @signal_handlers["server_username_changed"].call
+ @signal_handlers["server_password_changed"].call
+ p "and do a fake click"
+ @signal_handlers["connect_button_clicked"].call
end
})
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 17/61] P2V: main - add DBus thread, fake Gtk main loop and timed thread with exit
---
p2v/client/lib/virt-p2v/ui/main.rb | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 5717c5d..10dd2d7 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -283,11 +283,22 @@ class NewMain < Main
})
# let's try to recieve some more of NMs signals
- session_bus = DBus::SystemBus.instance
-
- db_main = DBus::Main.new
- db_main << session_bus
- db_main.run
+ Thread.new {
+ session_bus = DBus::SystemBus.instance
+
+ db_main = DBus::Main.new
+ db_main << session_bus
+ db_main.run
+ }
+
+ Thread.new {
+ (0..200).each {
+ sleep 0.1
+ }
+ exit(0)
+ }
+
+ Gtk.main_with_queue 100
# # TODO: this activation in NOT neccessary
# # since it's done automatically in network module
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 18/61] P2V: test launch with converter
---
p2v/client/test/test_newmain_integration.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/p2v/client/test/test_newmain_integration.rb
b/p2v/client/test/test_newmain_integration.rb
index 9e96987..ee39a09 100644
--- a/p2v/client/test/test_newmain_integration.rb
+++ b/p2v/client/test/test_newmain_integration.rb
@@ -47,4 +47,8 @@ class TestWithConverterNewMainIntegration <
TestNewMainIntegration
devs = VirtP2V::FixedBlockDevice.all_devices
refute_empty devs
end
+
+ def test_launch_with_converter
+ test_toothlees_launch
+ end
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 19/61] very simple script to install missing dependencies
--- deps.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 deps.sh diff --git a/deps.sh b/deps.sh new file mode 100644 index 0000000..9631655 --- /dev/null +++ b/deps.sh @@ -0,0 +1,41 @@ +yum -y install git-all + +echo 'THESE ARE MISSING IN SPEC' +yum -y install 'perl(Archive::Extract)' +yum -y install 'perl(Digest::SHA1)' +yum -y install 'perl(Archive::Tar)' + +#exit 0 +echo 'THESE ARE FROM SPEC' +yum -y install 'gettext' +yum -y install 'perl' +yum -y install 'perl(Module::Build)' +yum -y install 'perl(ExtUtils::Manifest)' +yum -y install 'perl(Test::More)' +yum -y install 'perl(Test::Pod)' +yum -y install 'perl(Test::Pod::Coverage)' +yum -y install 'perl(Module::Find)' +yum -y install 'perl(DateTime)' +yum -y install 'perl(IO::String)' +yum -y install 'perl(Locale::TextDomain)' +yum -y install 'perl(Module::Pluggable)' +yum -y install 'perl(Net::HTTPS)' +yum -y install 'perl(Net::SSL)' +yum -y install 'perl(Sys::Guestfs)' +yum -y install 'perl(Sys::Virt)' +yum -y install 'perl(Term::ProgressBar)' +yum -y install 'perl(URI)' +yum -y install 'perl(XML::DOM)' +yum -y install 'perl(XML::DOM::XPath)' +yum -y install 'perl(XML::Writer)' +yum -y install 'perl-Sys-Guestfs' +yum -y install 'perl-hivex' + +echo 'THESE ARE FOR TESTING' + +yum -y install 'rake' +yum -y install 'rubygem-minitest' +yum -y install 'rubygem-rake-compiler' +yum -y install 'rubygem-ruby-dbus' +yum -y install 'rubygem-glib2' +yum -y install 'hwloc' -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 20/61] P2V: debug - correct IPs used in testing
---
p2v/client/lib/virt-p2v/ui/main.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 10dd2d7..61df5cd 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -249,10 +249,10 @@ class NewMain < Main
puts "this is the main loop"
get_object("ip_manual").text=true
- get_object("ip_address").text="10.0.0.1"
+ get_object("ip_address").text="192.168.122.110"
get_object("ip_prefix").text="24"
- get_object("ip_gateway").text="10.0.0.254"
- get_object("ip_dns").text="10.0.0.253"
+ get_object("ip_gateway").text="192.168.122.1"
+ get_object("ip_dns").text="192.168.122.1"
p "SO, THE IP IS #{get_object("ip_address").text}"
@signal_handlers["ip_auto_toggled"].call
@signal_handlers["ip_address_changed"].call
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 21/61] P2V: main - Create fake methods on eigen class
---
p2v/client/lib/virt-p2v/ui/main.rb | 79 ++++++++++++++++++++++++++++++--------
1 file changed, 64 insertions(+), 15 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 61df5cd..a19520b 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -37,6 +37,12 @@ module UI
self
end
+ def eigen
+ class << self
+ self
+ end
+ end
+
def initialize(main = nil, name=nil, *args)
@name = name
@main = main
@@ -185,53 +191,96 @@ class NewMain < Main
@gui_objects ||= {}
@gui_objects[name] ||= if name == "network_device_list" then
n = NeverMind.new self, name
- n.class.send(:define_method, :append) do |*args|
+ n.eigen.send(:define_method, :append) do |*args|
+# p "append on #{self.name} #{args.inspect}"
@items ||= []
@items << []
self
end
- n.class.send(:define_method, :_items) do
- #p @items
+ n.eigen.send(:define_method, :_items) do
+ @items ||= []
@items
end
- n.class.send(:define_method, :"[]=") do |idx, item|
- #p "called []= on #{name} with #{args}"
+ n.eigen.send(:define_method, :_select) do |idx|
+ @idx = idx
+ end
+ n.eigen.send(:define_method, :_selection) do
+ @idx ||= 0
+ @idx
+ end
+ n.eigen.send(:define_method, :"[]=") do |idx, item|
+# p "called []= on #{name} with #{args}"
@items.last[idx] = item
#p @items
self
end
+ n.eigen.send(:define_method, :clear) do
+ @items.clear
+ end
+ n.eigen.send(:define_method, :each) do |&block|
+ @items.each do |item|
+ # block accepts three params:
+ # model, path, iter
+ # since we know nothing about model and path
+ # we'll fill only item as iter
+ block.call(nil, nil, item)
+ end
+ end
+ n
+ elsif name == "convert_profile"
+ n = NeverMind.new self, name
+ n.eigen.send(:define_method, :active_iter) do |*args|
+# p "convert_profile.active_iter"
+ cpl = @main.get_object("convert_profile_list")
+ _items = cpl._items
+ _sel = _items[cpl._selection]
+# p _sel
+
+ end
n
elsif name == "network_device_list_view"
n = NeverMind.new self, name
- n.class.send(:define_method, :selection) do
+ n.eigen.send(:define_method, :selection) do
self
end
- n.class.send(:define_method, :selected) do
+ n.eigen.send(:define_method, :selected) do
# TODO: this needs a proper selection
# now it's only for a testing purpouse
# but later we need to reflect reality
# and not blindly return first device
nejm = @main.get_object("network_device_list")._items.first
- p nejm
+# p nejm
+ end
+ n
+ elsif name == 'connect_error'
+ n = NeverMind.new self, name
+ n.eigen.send(:define_method, :text) do
+ p "called text on #{@name}"
+ @text || ""
+ end
+ n.eigen.send(:define_method, :"text=") do |str|
+ @text = str
+# p "called text= '#{str}' on #{@name}"
+ puts "Error connecting: '#{str}'"
+ puts "Giving up."
+ exit(3)
end
n
elsif ["server_hostname", "server_username",
"server_password",
"convert_name", "convert_cpus",
"convert_memory",
"ip_manual", "ip_address",
"ip_prefix", "ip_gateway",
"ip_dns", "server_hostname",
"server_username",
- "server_password"].any?{|m| m==name}
+ "server_password"].any?{|_m| _m==name}
# N.B. some of these are set by user
- p "GOTCHA, YOU'D LOVE TO GET #{name}"
n = NeverMind.new self, name
- n.class.send(:define_method, :text) do
-# p "called text on #{name}"
+ n.eigen.send(:define_method, :text) do
+# p "called text on #{@name}"
@text || ""
end
- n.class.send(:define_method, :"text=") do |str|
+ n.eigen.send(:define_method, :"text=") do |str|
@text = str
- p "called text= #{str} on #{name}"
+# p "called text= #{str} on #{@name}"
end
-# p n
n
else
NeverMind.new self, name
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 22/61] P2V: main - add fake Gtk.main_quit
---
p2v/client/lib/virt-p2v/ui/main.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index a19520b..361f6ed 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -64,6 +64,10 @@ module Gtk
block.call
end
end
+
+ def Gtk.main_quit
+ exit(0)
+ end
end
module Gdk
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 23/61] P2V: main - support dot and comma in cmdline parser
---
p2v/client/lib/virt-p2v/ui/main.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 361f6ed..87724da 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -181,7 +181,7 @@ class NewMain < Main
end
params = {}
cmdline.each do |c|
- /p2v_([a-zA-Z0-9_]*)=([a-zA-Z0-9_]*)/ =~ c
+ /p2v_([a-zA-Z0-9_]*)=([a-zA-Z0-9_\.\,]*)/ =~ c
params.merge! $1 => $2 if $1
end
params
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 24/61] P2V: main - more fake GTK list stores
---
p2v/client/lib/virt-p2v/ui/main.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 87724da..f2fbc65 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -193,7 +193,9 @@ class NewMain < Main
# need to write tests
puts "GET_OBJ #{name}"
@gui_objects ||= {}
- @gui_objects[name] ||= if name == "network_device_list" then
+ @gui_objects[name] ||= if ["network_device_list",
+ "convert_profile_list", "convert_network_list",
+ "convert_fixed_list",
"convert_removable_list"].any?{|m| m==name}
n = NeverMind.new self, name
n.eigen.send(:define_method, :append) do |*args|
# p "append on #{self.name} #{args.inspect}"
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 25/61] P2V: main - cleanup data filling mess and support loading data from file
---
p2v/client/lib/virt-p2v/ui/main.rb | 137 ++++++++++++++++++++++++++-----------
1 file changed, 96 insertions(+), 41 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index f2fbc65..15f29c1 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -296,28 +296,31 @@ class NewMain < Main
@gui_objects[name]
end
+ def cmdline_filename
+ '/proc/cmdline'
+ end
+
def main_loop
# and this is the program flow entry point,
# basic idea is to 'proceed with actions
# as would user do' based on parameters passed
# through kernel command line
- puts "this is the main loop"
-
- get_object("ip_manual").text=true
- get_object("ip_address").text="192.168.122.110"
- get_object("ip_prefix").text="24"
- get_object("ip_gateway").text="192.168.122.1"
- get_object("ip_dns").text="192.168.122.1"
- p "SO, THE IP IS #{get_object("ip_address").text}"
- @signal_handlers["ip_auto_toggled"].call
- @signal_handlers["ip_address_changed"].call
- @signal_handlers["ip_prefix_changed"].call
- @signal_handlers["ip_gateway_changed"].call
- @signal_handlers["ip_dns_changed"].call
- # send a synthetic event, UI would think that we made a selection
- VirtP2V::UI::Network.event(VirtP2V::UI::Network::EV_SELECTION, true)
- # aaaand CLICK!
- @signal_handlers["network_button_clicked"].call
+
+ params = parse_cmdline(cmdline_filename)
+ unless validate_params(params)
+ if params.has_key?('server_password')
+ params['server_password'] = '*' *
params['server_password'].length
+ end
+ puts "Not enough command line parameters or some not entered.
Exitting."
+ puts "Params are: #{params.map {|k,v|
"p2v_#{k}=#{v}"}.join(' ') }, " +
+ "read from #{cmdline_filename}"
+ puts "Expected params are: #{expected_param_keys.map{|p|
"p2v_#{p}"}.
+ join(', ')}."
+ exit(1)
+ end
+ @cmd_params = params
+
+ fill_and_click_network
# register ourselves as listener on activated connection
# as VirtP2V::UI:Netowork does
@@ -325,15 +328,7 @@ class NewMain < Main
p dev
if dev.connected && dev.activated then
p "we should now continue"
- get_object("server_hostname").text='convertserver'
- get_object("server_username").text='root'
- get_object("server_password").text='roflkopter'
- p "let's notify server window that we entered data"
- @signal_handlers["server_hostname_changed"].call
- @signal_handlers["server_username_changed"].call
- @signal_handlers["server_password_changed"].call
- p "and do a fake click"
- @signal_handlers["connect_button_clicked"].call
+ fill_and_click_connect
end
})
@@ -354,23 +349,83 @@ class NewMain < Main
}
Gtk.main_with_queue 100
+ end
-# # TODO: this activation in NOT neccessary
-# # since it's done automatically in network module
-# # but well, not in "testing"
-# self.active_page='server_win'
-# get_object("server_hostname").text='localhost'
-# get_object("server_username").text='tak'
-# get_object("server_password").text='urcite'
-# @signal_handlers["server_hostname_changed"].call
-# @signal_handlers["server_username_changed"].call
-# @signal_handlers["server_password_changed"].call
-# @signal_handlers["connect_button_clicked"].call
-#
-# # TODO: again, stupidly switch page and don't care about truth!
-# self.active_page='conversion_win'
-# p VirtP2V::UI::Connect.instance_variable_get(:@converter).connection.class
+ def expected_param_keys
+ ['ip_manual', 'ip_address', 'ip_prefix',
'ip_gateway', 'ip_dns',
+ 'server_hostname', 'server_username',
'server_password',
+ 'convert_name']
+ end
+
+ def is_param_optional?(name)
+ ['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns'].include?(name)
+ end
+
+ def validate_params(params)
+ expected_param_keys.each do |k|
+# p "validate_params: '#{k}', '#{params[k]}'"
+ if (!is_param_optional?(k)) &&
+ ((!params.has_key?(k)) || params[k].nil?)
+ return false
+ end
+ end
+ if params['ip_manual'] == 'true'
+ params['ip_manual'] = true
+ else
+ params['ip_manual'] = false
+ end
+ true
+ end
+ def fill_widgets_from_params(names)
+ names.each do |p|
+ get_object(p).text = @cmd_params[p]
+ end
+ end
+
+ def call_actions_by_name(names)
+ names.each do |n|
+ @signal_handlers[n].call
+ end
+ end
+
+ def fill_and_click_network
+ fill_widgets_from_params(["ip_manual", "ip_address",
"ip_prefix",
+ "ip_gateway", "ip_dns"])
+
+ p "SO, THE IP IS #{get_object("ip_address").text}"
+ call_actions_by_name(["ip_auto_toggled",
"ip_address_changed",
+ "ip_prefix_changed", "ip_gateway_changed",
"ip_dns_changed"])
+
+ # send a synthetic event, UI would think that we made a selection
+ VirtP2V::UI::Network.event(VirtP2V::UI::Network::EV_SELECTION, true)
+ # aaaand CLICK!
+ call_actions_by_name(["network_button_clicked"])
+ end
+
+ def fill_and_click_connect
+ fill_widgets_from_params(["server_hostname",
"server_username",
+ "server_password"])
+
+ call_actions_by_name(["server_hostname_changed",
+ "server_username_changed",
"server_password_changed",
+ "connect_button_clicked"])
+ end
+
+ def fill_and_click_convert
+ fill_widgets_from_params(['convert_name'])
+ call_actions_by_name(['convert_name_changed',
'convert_cpus_changed',
+ 'convert_memory_changed',
'convert_profile_changed',
+ 'convert_button_clicked'])
+ end
+
+ def active_page=(name)
+ super(name)
+ if name == 'conversion_win'
+ fill_and_click_convert
+ elsif name == 'success_win'
+ call_actions_by_name(['poweroff_button_clicked'])
+ end
end
def register_handler(signal, handler)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 26/61] P2V: main - throw away quit-after-20sec thread
---
p2v/client/lib/virt-p2v/ui/main.rb | 7 -------
1 file changed, 7 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 15f29c1..55db619 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -341,13 +341,6 @@ class NewMain < Main
db_main.run
}
- Thread.new {
- (0..200).each {
- sleep 0.1
- }
- exit(0)
- }
-
Gtk.main_with_queue 100
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 27/61] P2V: move gtk2.rb to ui/gtk.rb
--- p2v/client/lib/gtk2.rb | 0 p2v/client/lib/virt-p2v/ui/gtk.rb | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 p2v/client/lib/gtk2.rb create mode 100644 p2v/client/lib/virt-p2v/ui/gtk.rb diff --git a/p2v/client/lib/gtk2.rb b/p2v/client/lib/gtk2.rb deleted file mode 100644 index e69de29..0000000 diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb b/p2v/client/lib/virt-p2v/ui/gtk.rb new file mode 100644 index 0000000..e69de29 -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 28/61] virt-p2v-launcher: add text box with p2v log
---
p2v/client/bin/virt-p2v-launcher | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/p2v/client/bin/virt-p2v-launcher b/p2v/client/bin/virt-p2v-launcher
index 8b7d9d9..f9bd910 100755
--- a/p2v/client/bin/virt-p2v-launcher
+++ b/p2v/client/bin/virt-p2v-launcher
@@ -28,7 +28,7 @@ LOG = '/tmp/virt-p2v.log'
# Touching this file lets the X wrapper know we ran
FileUtils.touch('/tmp/virt-p2v-launcher')
-def choose
+def choose log
option = nil
window = Gtk::Window.new
@@ -67,7 +67,13 @@ virt-p2v has shutdown unexpectedly. You may:
* Power the machine off
MSG
+ swin = Gtk::ScrolledWindow.new()
+ txt = Gtk::TextView.new()
+ txt.buffer.text = log
+
vbox.border_width = 10
+ swin.add_with_viewport(txt)
+ vbox.add(swin)
vbox.add(l)
vbox.add(hbox)
window.add(vbox)
@@ -83,7 +89,9 @@ loop {
status = $?
break if status.success?
- o = choose
+ open(LOG) do |log|
+ o = choose log.read
+ end
break if o == POWER_OFF
next if o == TRY_AGAIN
system('/usr/bin/openvt', '-sw', '--',
'/bin/sh', '-c', <<DEBUG)
--
1.8.3.1
---
p2v/client/lib/virt-p2v/gtk-queue.rb | 2 +-
p2v/client/lib/virt-p2v/ui/connect.rb | 2 +-
p2v/client/lib/virt-p2v/ui/convert.rb | 2 +-
p2v/client/lib/virt-p2v/ui/gtk.rb | 1 +
p2v/client/lib/virt-p2v/ui/network.rb | 2 +-
5 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/gtk-queue.rb
b/p2v/client/lib/virt-p2v/gtk-queue.rb
index 0ce0a97..22a92b4 100644
--- a/p2v/client/lib/virt-p2v/gtk-queue.rb
+++ b/p2v/client/lib/virt-p2v/gtk-queue.rb
@@ -20,7 +20,7 @@
# The above page is distributed under the terms of the GNU FDL, although I
# consider this code to be too trivial to be copyrightable
-require 'gtk2'
+require 'virt-p2v/ui/gtk'
require 'thread'
module Gtk
diff --git a/p2v/client/lib/virt-p2v/ui/connect.rb
b/p2v/client/lib/virt-p2v/ui/connect.rb
index d2a2ce8..15c3d9c 100644
--- a/p2v/client/lib/virt-p2v/ui/connect.rb
+++ b/p2v/client/lib/virt-p2v/ui/connect.rb
@@ -14,7 +14,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-require 'gtk2'
+require 'virt-p2v/ui/gtk'
require 'virt-p2v/connection'
diff --git a/p2v/client/lib/virt-p2v/ui/convert.rb
b/p2v/client/lib/virt-p2v/ui/convert.rb
index 74d201f..405794f 100644
--- a/p2v/client/lib/virt-p2v/ui/convert.rb
+++ b/p2v/client/lib/virt-p2v/ui/convert.rb
@@ -14,7 +14,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-require 'gtk2'
+require 'virt-p2v/ui/gtk'
require 'virt-p2v/blockdevice'
require 'virt-p2v/netdevice'
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index e69de29..501c9ad 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -0,0 +1 @@
+require('gtk2') if !(Kernel.const_defined?(:NOGUI) && NOGUI ==
true)
diff --git a/p2v/client/lib/virt-p2v/ui/network.rb
b/p2v/client/lib/virt-p2v/ui/network.rb
index 5b2ec19..3ade7ed 100644
--- a/p2v/client/lib/virt-p2v/ui/network.rb
+++ b/p2v/client/lib/virt-p2v/ui/network.rb
@@ -14,7 +14,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-require 'gtk2'
+require 'virt-p2v/ui/gtk'
require 'ipaddr'
require 'virt-p2v/netdevice'
--
1.8.3.1
---
p2v/client/lib/virt-p2v/ui/main.rb | 102 +++++++++++++++++++------------------
1 file changed, 53 insertions(+), 49 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 55db619..67dd1b1 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -14,69 +14,73 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#require 'gtk2'
-#require 'virt-p2v/gtk-queue'
-
-module VirtP2V
-module UI
- class NeverMind
- def method_missing(m, *args, &block)
- _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
- self.__id__.to_s : _a}
- puts "Never mind call '#{m} #{_args}'. ON #{@name ||
- ("NeverMind:"+self.__id__.to_s)}"
- self
- end
-
- def self.method_missing(m, *args, &block)
- _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
- self.__id__.to_s : _a}
- #puts "Never mind class call '#{m} #{_args}'. ON #{@name ||
self.inspect}"
- puts "Never mind call '#{m} #{_args}'. ON #{@name ||
- ("NeverMind:"+self.__id__.to_s)}"
- self
- end
+require 'virt-p2v/ui/gtk'
+require 'virt-p2v/gtk-queue'
+
+if Kernel.const_defined?(:NOGUI) && NOGUI == true
+ module VirtP2V
+ module UI
+ class NeverMind
+ def method_missing(m, *args, &block)
+ _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
+ self.__id__.to_s : _a}
+ puts "Never mind call '#{m} #{_args}'. ON #{@name ||
+ ("NeverMind:"+self.__id__.to_s)}"
+ self
+ end
- def eigen
- class << self
+ def self.method_missing(m, *args, &block)
+ _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
+ self.__id__.to_s : _a}
+ #puts "Never mind class call '#{m} #{_args}'. ON #{@name
|| self.inspect}"
+ puts "Never mind call '#{m} #{_args}'. ON #{@name ||
+ ("NeverMind:"+self.__id__.to_s)}"
self
end
- end
- def initialize(main = nil, name=nil, *args)
- @name = name
- @main = main
- puts "Hi, I'm #{@name || self.inspect}"
+ def eigen
+ class << self
+ self
+ end
+ end
+
+ def initialize(main = nil, name=nil, *args)
+ @name = name
+ @main = main
+ #puts "Hi, I'm #{@name || self.inspect}"
+ end
end
end
-end
-end
+ end
-module Gtk
- Builder = VirtP2V::UI::NeverMind
- STATE_NORMAL = 0
- SELECTION_SINGLE = 1
- TreeRowReference = VirtP2V::UI::NeverMind
+ module Gtk
+ Builder = VirtP2V::UI::NeverMind
+ STATE_NORMAL = 0
+ SELECTION_SINGLE = 1
+ TreeRowReference = VirtP2V::UI::NeverMind
+
+ def Gtk.timeout_add(timeout, &block)
+ p "Gtk.timeout_add"
+ while true
+ sleep(timeout/1000.0)
+ # p "trying to call block #{block.inspect}"
+ block.call
+ end
+ end
- def Gtk.timeout_add(timeout, &block)
- while true
- sleep(timeout/1000.0)
- block.call
+ def Gtk.main_quit
+ exit(0)
end
end
- def Gtk.main_quit
- exit(0)
+ module Gdk
+ Color = VirtP2V::UI::NeverMind
+ Cursor = VirtP2V::UI::NeverMind
+ Cursor::Type = VirtP2V::UI::NeverMind
+ Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
end
end
-module Gdk
- Color = VirtP2V::UI::NeverMind
- Cursor = VirtP2V::UI::NeverMind
- Cursor::Type = VirtP2V::UI::NeverMind
- Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
-end
-
module VirtP2V
module UI
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 31/61] p2v: main - cli error reporting hook from gui
---
p2v/client/lib/virt-p2v/ui/main.rb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 67dd1b1..b91225c 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -291,6 +291,9 @@ class NewMain < Main
@text = str
# p "called text= #{str} on #{@name}"
end
+ n.eigen.send(:define_method, :"secondary_icon_tooltip_text=")
do |str|
+ puts "Error in '#{@name}': '#{str}'"
+ end
n
else
NeverMind.new self, name
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 32/61] p2v: main - dont quit on empty error
---
p2v/client/lib/virt-p2v/ui/main.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index b91225c..2d36028 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -265,15 +265,15 @@ class NewMain < Main
elsif name == 'connect_error'
n = NeverMind.new self, name
n.eigen.send(:define_method, :text) do
- p "called text on #{@name}"
@text || ""
end
n.eigen.send(:define_method, :"text=") do |str|
@text = str
-# p "called text= '#{str}' on #{@name}"
- puts "Error connecting: '#{str}'"
- puts "Giving up."
- exit(3)
+ unless str == ''
+ puts "Error connecting: '#{str}'"
+ puts "Giving up."
+ exit(3)
+ end
end
n
elsif ["server_hostname", "server_username",
"server_password",
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 33/61] p2v: newmain - show fake widgets helper
---
p2v/client/lib/virt-p2v/ui/main.rb | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 2d36028..75815e0 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -383,6 +383,13 @@ class NewMain < Main
end
end
+ def show_widgets_from_params(names)
+ # a little debug helper
+ names.each do |p|
+ puts "#{p} is '#{get_object(p).text}'"
+ end
+ end
+
def call_actions_by_name(names)
names.each do |n|
@signal_handlers[n].call
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 34/61] p2v: newmain - fix dhcp support
---
p2v/client/lib/virt-p2v/ui/main.rb | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 75815e0..ecc2ace 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -400,9 +400,13 @@ class NewMain < Main
fill_widgets_from_params(["ip_manual", "ip_address",
"ip_prefix",
"ip_gateway", "ip_dns"])
- p "SO, THE IP IS #{get_object("ip_address").text}"
- call_actions_by_name(["ip_auto_toggled",
"ip_address_changed",
- "ip_prefix_changed", "ip_gateway_changed",
"ip_dns_changed"])
+ if get_object("ip_manual").text == true ||
+ get_object("ip_manual").text == "true"
+ call_actions_by_name(["ip_auto_toggled"])
+ else
+ call_actions_by_name(["ip_address_changed",
+ "ip_prefix_changed", "ip_gateway_changed",
"ip_dns_changed"])
+ end
# send a synthetic event, UI would think that we made a selection
VirtP2V::UI::Network.event(VirtP2V::UI::Network::EV_SELECTION, true)
--
1.8.3.1
---
p2v/client/bin/virt-p2v | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/p2v/client/bin/virt-p2v b/p2v/client/bin/virt-p2v
index 9bc0965..5373cfb 100755
--- a/p2v/client/bin/virt-p2v
+++ b/p2v/client/bin/virt-p2v
@@ -16,6 +16,11 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Let's check if we should run headless
+NOGUI = open('/proc/cmdline') do |f|
+ f.read =~ /p2v_nogui/
+end || ARGV.include?('-nogui') ? true : false
+
require 'virt-p2v/ui/main'
require 'virt-p2v/ui/network'
require 'virt-p2v/ui/connect'
@@ -34,8 +39,12 @@ end
converter = VirtP2V::Converter.new
-# Initialise the wizard UI
-ui = VirtP2V::UI::Main.new
+ui = if NOGUI
+ VirtP2V::UI::NewMain.new
+else
+ # Initialise the wizard UI
+ VirtP2V::UI::Main.new
+end
# Initialize wizard pages
VirtP2V::UI::Network.init(ui)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 36/61] add ui/gtk.rb to manifests and gemspec
---
MANIFEST | 1 +
p2v/client/Manifest | 1 +
p2v/client/virt-p2v.gemspec | 4 +++-
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/MANIFEST b/MANIFEST
index 6b6c694..3fea7f1 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -47,6 +47,7 @@ p2v/client/lib/virt-p2v/ui/convert.rb
p2v/client/lib/virt-p2v/ui/main.rb
p2v/client/lib/virt-p2v/ui/network.rb
p2v/client/lib/virt-p2v/ui/p2v.ui
+p2v/client/lib/virt-p2v/ui/gtk.rb
p2v/client/lib/virt-p2v/ui/success.rb
p2v/client/Manifest
p2v/client/Rakefile
diff --git a/p2v/client/Manifest b/p2v/client/Manifest
index 29c1817..0f47975 100644
--- a/p2v/client/Manifest
+++ b/p2v/client/Manifest
@@ -12,5 +12,6 @@ lib/virt-p2v/ui/main.rb
lib/virt-p2v/ui/network.rb
lib/virt-p2v/ui/p2v.ui
lib/virt-p2v/ui/success.rb
+lib/virt-p2v/ui/gtk.rb
virt-p2v.gemspec
Manifest
diff --git a/p2v/client/virt-p2v.gemspec b/p2v/client/virt-p2v.gemspec
index 2aced78..18614d1 100644
--- a/p2v/client/virt-p2v.gemspec
+++ b/p2v/client/virt-p2v.gemspec
@@ -53,6 +53,7 @@ GEMSPEC = Gem::Specification.new do |s|
"lib/virt-p2v/ui/network.rb",
"lib/virt-p2v/ui/p2v.ui",
"lib/virt-p2v/ui/success.rb",
+ "lib/virt-p2v/ui/gtk.rb",
"virt-p2v.gemspec",
"Manifest"
]
@@ -85,7 +86,8 @@ GEMSPEC = Gem::Specification.new do |s|
"lib/virt-p2v/ui/main.rb",
"lib/virt-p2v/ui/network.rb",
"lib/virt-p2v/ui/p2v.ui",
- "lib/virt-p2v/ui/success.rb"
+ "lib/virt-p2v/ui/success.rb",
+ "lib/virt-p2v/ui/gtk.rb"
]
s.rdoc_options = [
"--line-numbers",
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 37/61] p2v: tests: validate cmdline params test
--- p2v/client/test/cmdline_test_params | 1 + p2v/client/test/cmdline_test_params_bad | 1 + p2v/client/test/cmdline_test_params_optional | 1 + p2v/client/test/test_newmain.rb | 23 +++++++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 p2v/client/test/cmdline_test_params create mode 100644 p2v/client/test/cmdline_test_params_bad create mode 100644 p2v/client/test/cmdline_test_params_optional diff --git a/p2v/client/test/cmdline_test_params b/p2v/client/test/cmdline_test_params new file mode 100644 index 0000000..b48f9d2 --- /dev/null +++ b/p2v/client/test/cmdline_test_params @@ -0,0 +1 @@ +BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.lvm.lv=vg_jelly/lv_swap rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 p2v_test=foo rhgb quiet p2v_ip_manual=true p2v_ip_address=192.168.122.233 p2v_ip_prefix=24 p2v_ip_gateway=192.168.122.1 p2v_ip_dns=192.168.122.1 p2v_server_hostname=convertserver p2v_server_username=root p2v_server_password=lalala p2v_convert_name=bar diff --git a/p2v/client/test/cmdline_test_params_bad b/p2v/client/test/cmdline_test_params_bad new file mode 100644 index 0000000..f2e6d7f --- /dev/null +++ b/p2v/client/test/cmdline_test_params_bad @@ -0,0 +1 @@ +BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.lvm.lv=vg_jelly/lv_swap rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 p2v_test=foo rhgb quiet p2v_ip_manual=true p2v_ip_address=192.168.122.233 p2v_ip_gateway= p2v_ip_dns=192.168.122.1 p2v_server_hostname=convertserver p2v_server_username=root p2v_convert_namediff --git a/p2v/client/test/cmdline_test_params_optional b/p2v/client/test/cmdline_test_params_optional new file mode 100644 index 0000000..840aa14 --- /dev/null +++ b/p2v/client/test/cmdline_test_params_optional @@ -0,0 +1 @@ +BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.lvm.lv=vg_jelly/lv_swap rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 p2v_test=foo rhgb quiet p2v_ip_manual=true p2v_ip_address=192.168.122.233 p2v_ip_gateway= p2v_ip_dns=192.168.122.1 p2v_server_hostname=convertserver p2v_server_username=root p2v_server_password=lalala p2v_convert_name=bar diff --git a/p2v/client/test/test_newmain.rb b/p2v/client/test/test_newmain.rb index cc07f9a..d4f6905 100644 --- a/p2v/client/test/test_newmain.rb +++ b/p2v/client/test/test_newmain.rb @@ -4,6 +4,9 @@ require 'virt-p2v/ui/main' WD = File.expand_path File.dirname(__FILE__) CMDLINE_TEST = File.join(WD, "cmdline_test") CMDLINE_DEFAULT = File.join(WD, "cmdline_default") +CMDLINE_TEST_PARAMS = File.join(WD, "cmdline_test_params") +CMDLINE_TEST_PARAMS_BAD = File.join(WD, "cmdline_test_params_bad") +CMDLINE_TEST_PARAMS_OPTIONAL = File.join(WD, "cmdline_test_params_optional") class TestNewMainDry < MiniTest::Unit::TestCase def setup @@ -26,6 +29,26 @@ class TestNewMainDry < MiniTest::Unit::TestCase end end +class TestNewMainValidateParams < MiniTest::Unit::TestCase + def setup + @nm = VirtP2V::UI::NewMain.new dry=true + end + + def test_validate_params_ok + params = @nm.parse_cmdline(CMDLINE_TEST_PARAMS) + assert @nm.validate_params(params) + end + + def test_validate_params_opt + params = @nm.parse_cmdline(CMDLINE_TEST_PARAMS_OPTIONAL) + assert @nm.validate_params(params) + end + + def test_validate_params_bad + params = @nm.parse_cmdline(CMDLINE_TEST_PARAMS_BAD) + refute @nm.validate_params(params) + end +end class TestNewMain < TestNewMainDry def setup -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 38/61] p2v: tests: newmain integration mock essential converter methods
---
p2v/client/test/test_newmain_integration.rb | 105 +++++++++++++++++++++++-----
1 file changed, 86 insertions(+), 19 deletions(-)
diff --git a/p2v/client/test/test_newmain_integration.rb
b/p2v/client/test/test_newmain_integration.rb
index ee39a09..f7c59a8 100644
--- a/p2v/client/test/test_newmain_integration.rb
+++ b/p2v/client/test/test_newmain_integration.rb
@@ -9,12 +9,73 @@ require 'virt-p2v/ui/success'
require 'virt-p2v/converter'
require 'virt-p2v/netdevice'
+WD = File.expand_path File.dirname(__FILE__)
+CMDLINE_TEST_PARAMS = File.join(WD, "cmdline_test_params")
+CMDLINE_DEFAULT = File.join(WD, "cmdline_default")
+
class TestNewMainIntegration < MiniTest::Unit::TestCase
def setup
end
def make_converter
- VirtP2V::UI::NeverMind.new
+ cvt = VirtP2V::UI::NeverMind.new
+ con = VirtP2V::UI::NeverMind.new
+ VirtP2V::Connection.send(:define_method, :connect) do |&block|
+ p 'connect called'
+ block.call(true)
+ p 'lala'
+ cvt.run_on_connection
+ end
+ con.eigen.send(:define_method, :connected?) do
+ p ':connected?'
+ true
+ end
+ con.eigen.send(:define_method, :on_connect) do |&block|
+ p ':on_connect'
+ # block takes 'cb' as argument
+ block.call(VirtP2V::UI::NeverMind.new)
+ end
+ con.eigen.send(:define_method, :list_profiles) do |&block|
+ p ':list_profiles'
+ block.call(['fakeprofile'])
+ end
+ cvt.eigen.send(:define_method, :name) do
+ 'name'
+ end
+ cvt.eigen.send(:define_method, :cpus) do
+ '3'
+ end
+ cvt.eigen.send(:define_method, :memory) do
+ 1
+ end
+ cvt.eigen.send(:define_method, :connection) do
+ p ':connection'
+ con
+ end
+ cvt.eigen.send(:define_method, :convert) do |status, progress, &block|
+ p 'called convert on fake converter'
+ # block takes one argument - result
+ # call it and pretend successful conversion
+ block.call(true)
+ end
+ cvt.eigen.send(:define_method, :on_connection) do |&block|
+ p ":on_connection" # #{caller.class.to_s}"
+ # block takes one argument - conn
+ @on_con = block
+ run_on_connection
+ end
+ cvt.eigen.send(:define_method, :run_on_connection) do
+ p ':run_on_connection'
+ # block takes one argument - conn
+ @on_con.call(con)
+ end
+
+ con.eigen.send(:define_method, :connect) do |&block|
+ p ':connect'
+ # block takes 'result' as argument
+ block.call(true)
+ end
+ cvt
end
def test_toothlees_launch
@@ -23,6 +84,9 @@ class TestNewMainIntegration < MiniTest::Unit::TestCase
converter = make_converter
# Initialise the wizard UI
ui = VirtP2V::UI::NewMain.new
+ ui.class.send(:define_method, :cmdline_filename) do
+ CMDLINE_TEST_PARAMS
+ end
# Initialize wizard pages
VirtP2V::UI::Network.init(ui)
@@ -31,24 +95,27 @@ class TestNewMainIntegration < MiniTest::Unit::TestCase
VirtP2V::UI::Success.init(ui)
ui.show
- ui.main_loop
+ begin
+ ui.main_loop
+ rescue SystemExit
+ end
end
end
-class TestWithConverterNewMainIntegration < TestNewMainIntegration
- def setup
- end
-
- def make_converter
- VirtP2V::Converter.new
- end
-
- def test_blockdevice_lookup
- devs = VirtP2V::FixedBlockDevice.all_devices
- refute_empty devs
- end
-
- def test_launch_with_converter
- test_toothlees_launch
- end
-end
+#class TestWithConverterNewMainIntegration < TestNewMainIntegration
+# def setup
+# end
+#
+# def make_converter
+# VirtP2V::Converter.new
+# end
+#
+# def test_blockdevice_lookup
+# devs = VirtP2V::FixedBlockDevice.all_devices
+# refute_empty devs
+# end
+#
+# def test_launch_with_converter
+# test_toothlees_launch
+# end
+#end
--
1.8.3.1
---
p2v/client/bin/virt-p2v | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/p2v/client/bin/virt-p2v b/p2v/client/bin/virt-p2v
index 5373cfb..5b294a7 100755
--- a/p2v/client/bin/virt-p2v
+++ b/p2v/client/bin/virt-p2v
@@ -18,7 +18,8 @@
# Let's check if we should run headless
NOGUI = open('/proc/cmdline') do |f|
- f.read =~ /p2v_nogui/
+ val = f.read.scan(/p2v_nogui=([a-zA-Z0-9_=-]*)/)
+ val.first && val.first.first =~ /true/i
end || ARGV.include?('-nogui') ? true : false
require 'virt-p2v/ui/main'
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 40/61] virt-p2v-launcher: nogui fixes - gtk2 requirement, tee output to log, tempfile remove
---
p2v/client/bin/virt-p2v-launcher | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/p2v/client/bin/virt-p2v-launcher b/p2v/client/bin/virt-p2v-launcher
index f9bd910..3c4e328 100755
--- a/p2v/client/bin/virt-p2v-launcher
+++ b/p2v/client/bin/virt-p2v-launcher
@@ -16,7 +16,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-require 'gtk2'
+require 'gtk2' unless ARGV.include?('-nogui')
require 'fileutils'
TRY_AGAIN = 0
@@ -84,22 +84,31 @@ MSG
return option
end
+def debug_shell
+ system('/usr/bin/openvt', '-sw', '--',
'/bin/sh', '-c', <<DEBUG)
+clear
+echo Output was written to #{LOG}
+echo Any core files will have been written to /tmp
+echo Exit this shell to run virt-p2v again.
+bash -l
+clear
+DEBUG
+end
+
loop {
- system('/bin/sh', '-c', "exec /usr/bin/virt-p2v >
#{LOG} 2>&1")
+ system('/bin/sh', '-c', "exec /usr/bin/virt-p2v
2>&1 | tee -a #{LOG} ; ( exit ${PIPESTATUS[0]} )")
status = $?
break if status.success?
+ if ARGV.include?('-nogui')
+ FileUtils.remove_file('/tmp/virt-p2v-launcher')
+ break
+ end
+
open(LOG) do |log|
o = choose log.read
end
break if o == POWER_OFF
next if o == TRY_AGAIN
- system('/usr/bin/openvt', '-sw', '--',
'/bin/sh', '-c', <<DEBUG)
-clear
-echo Output was written to #{LOG}
-echo Any core files will have been written to /tmp
-echo Exit this shell to run virt-p2v again.
-bash -l
-clear
-DEBUG
+ debug_shell
}
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 41/61] p2v: nogui - flush stdout after puts
---
p2v/client/lib/virt-p2v/ui/convert.rb | 2 ++
p2v/client/lib/virt-p2v/ui/main.rb | 2 ++
2 files changed, 4 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/convert.rb
b/p2v/client/lib/virt-p2v/ui/convert.rb
index 405794f..b737c1b 100644
--- a/p2v/client/lib/virt-p2v/ui/convert.rb
+++ b/p2v/client/lib/virt-p2v/ui/convert.rb
@@ -248,6 +248,8 @@ module VirtP2V::UI::Convert
},
# progress
lambda { |dev, progress|
+ puts "dev #{dev.to_s} progress #{progress.to_s}"
+ STDOUT.flush
@fixeds.each { |model, path, iter|
next unless iter[CONVERT_FIXED_DEVICE] == dev
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index ecc2ace..e49be35 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -431,6 +431,8 @@ class NewMain < Main
end
def active_page=(name)
+ puts "#{name}"
+ STDOUT.flush
super(name)
if name == 'conversion_win'
fill_and_click_convert
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 42/61] p2v: move GTK definitions from main to gtk.rb
---
p2v/client/lib/virt-p2v/ui/gtk.rb | 52 +++++++++++++++++++++++++++++++
p2v/client/lib/virt-p2v/ui/main.rb | 64 --------------------------------------
2 files changed, 52 insertions(+), 64 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index 501c9ad..3984b7f 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -1 +1,53 @@
require('gtk2') if !(Kernel.const_defined?(:NOGUI) && NOGUI ==
true)
+
+if Kernel.const_defined?(:NOGUI) && NOGUI == true
+ module VirtP2V
+ module UI
+ class NeverMind
+ def method_missing(m, *args, &block)
+ self
+ end
+
+ def self.method_missing(m, *args, &block)
+ self
+ end
+
+ def eigen
+ class << self
+ self
+ end
+ end
+
+ def initialize(main = nil, name=nil, *args)
+ @name = name
+ @main = main
+ end
+ end
+ end
+ end
+
+ module Gtk
+ Builder = VirtP2V::UI::NeverMind
+ STATE_NORMAL = 0
+ SELECTION_SINGLE = 1
+ TreeRowReference = VirtP2V::UI::NeverMind
+
+ def Gtk.timeout_add(timeout, &block)
+ while true
+ sleep(timeout/1000.0)
+ block.call
+ end
+ end
+
+ def Gtk.main_quit
+ exit(0)
+ end
+ end
+
+ module Gdk
+ Color = VirtP2V::UI::NeverMind
+ Cursor = VirtP2V::UI::NeverMind
+ Cursor::Type = VirtP2V::UI::NeverMind
+ Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
+ end
+end
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index e49be35..891fe99 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -17,70 +17,6 @@
require 'virt-p2v/ui/gtk'
require 'virt-p2v/gtk-queue'
-if Kernel.const_defined?(:NOGUI) && NOGUI == true
- module VirtP2V
- module UI
- class NeverMind
- def method_missing(m, *args, &block)
- _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
- self.__id__.to_s : _a}
- puts "Never mind call '#{m} #{_args}'. ON #{@name ||
- ("NeverMind:"+self.__id__.to_s)}"
- self
- end
-
- def self.method_missing(m, *args, &block)
- _args = args.map {|_a| _a.class == NeverMind ? "NeverMind:"+
- self.__id__.to_s : _a}
- #puts "Never mind class call '#{m} #{_args}'. ON #{@name
|| self.inspect}"
- puts "Never mind call '#{m} #{_args}'. ON #{@name ||
- ("NeverMind:"+self.__id__.to_s)}"
- self
- end
-
- def eigen
- class << self
- self
- end
- end
-
- def initialize(main = nil, name=nil, *args)
- @name = name
- @main = main
- #puts "Hi, I'm #{@name || self.inspect}"
- end
- end
- end
- end
-
- module Gtk
- Builder = VirtP2V::UI::NeverMind
- STATE_NORMAL = 0
- SELECTION_SINGLE = 1
- TreeRowReference = VirtP2V::UI::NeverMind
-
- def Gtk.timeout_add(timeout, &block)
- p "Gtk.timeout_add"
- while true
- sleep(timeout/1000.0)
- # p "trying to call block #{block.inspect}"
- block.call
- end
- end
-
- def Gtk.main_quit
- exit(0)
- end
- end
-
- module Gdk
- Color = VirtP2V::UI::NeverMind
- Cursor = VirtP2V::UI::NeverMind
- Cursor::Type = VirtP2V::UI::NeverMind
- Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
- end
-end
-
module VirtP2V
module UI
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 43/61] p2v: newmain - exit on error or failure in conversion status
---
p2v/client/lib/virt-p2v/ui/main.rb | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 891fe99..0d27c08 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -198,6 +198,22 @@ class NewMain < Main
# p nejm
end
n
+ elsif name == 'convert_status'
+ n = NeverMind.new self, name
+ n.eigen.send(:define_method, :text) do
+ @text || ""
+ end
+ n.eigen.send(:define_method, :"text=") do |str|
+ @text = str
+ puts "conversion status changed to: '#{str}'"
+ STDOUT.flush
+ if str =~ /failure|error/i
+ #puts "Error connecting: '#{str}'"
+ puts "Giving up."
+ exit(4)
+ end
+ end
+ n
elsif name == 'connect_error'
n = NeverMind.new self, name
n.eigen.send(:define_method, :text) do
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 44/61] p2v: test newmain - tell main we don't want gtk2
--- p2v/client/test/test_newmain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/p2v/client/test/test_newmain.rb b/p2v/client/test/test_newmain.rb index d4f6905..e093303 100644 --- a/p2v/client/test/test_newmain.rb +++ b/p2v/client/test/test_newmain.rb @@ -1,4 +1,5 @@ require 'minitest/autorun' +NOGUI = true require 'virt-p2v/ui/main' WD = File.expand_path File.dirname(__FILE__) -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 45/61] test: add nogui=true to cmdline_test_params fixture
--- p2v/client/test/cmdline_test_params | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/p2v/client/test/cmdline_test_params b/p2v/client/test/cmdline_test_params index b48f9d2..0c81b58 100644 --- a/p2v/client/test/cmdline_test_params +++ b/p2v/client/test/cmdline_test_params @@ -1 +1 @@ -BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.lvm.lv=vg_jelly/lv_swap rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 p2v_test=foo rhgb quiet p2v_ip_manual=true p2v_ip_address=192.168.122.233 p2v_ip_prefix=24 p2v_ip_gateway=192.168.122.1 p2v_ip_dns=192.168.122.1 p2v_server_hostname=convertserver p2v_server_username=root p2v_server_password=lalala p2v_convert_name=bar +BOOT_IMAGE=/vmlinuz-3.9.9-301.fc19.x86_64 root=/dev/mapper/vg_jelly-lv_root ro rd.lvm.lv=vg_jelly/lv_root rd.md=0 rd.dm=0 SYSFONT=True KEYTABLE=us rd.lvm.lv=vg_jelly/lv_swap rd.luks.uuid=luks-2a7c6825-76a4-4b85-9eca-ec35bd682553 LANG=en_US.UTF-8 p2v_test=foo rhgb quiet p2v_nogui=true p2v_ip_manual=true p2v_ip_address=192.168.122.233 p2v_ip_prefix=24 p2v_ip_gateway=192.168.122.1 p2v_ip_dns=192.168.122.1 p2v_server_hostname=convertserver p2v_server_username=root p2v_server_password=lalala p2v_convert_name=bar -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 46/61] p2v: newmain - remove unccessary puts
---
p2v/client/lib/virt-p2v/ui/main.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 0d27c08..af96c4a 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -395,7 +395,6 @@ class NewMain < Main
def register_handler(signal, handler)
super(signal, handler)
- puts "#{handler} for #{signal} action registered"
end
def initialize dry=nil
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:30 UTC
[Libguestfs] [PATCH 47/61] p2v-post.ks: nogui startup condition
---
p2v/image-builder/p2v-sysv.ks | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/p2v/image-builder/p2v-sysv.ks b/p2v/image-builder/p2v-sysv.ks
index 31fa8e3..75baff2 100644
--- a/p2v/image-builder/p2v-sysv.ks
+++ b/p2v/image-builder/p2v-sysv.ks
@@ -21,9 +21,14 @@ again=$(mktemp)
# Launch a getty on tty2 to allow debugging while the program runs
/usr/bin/setsid mingetty --autologin root /dev/tty2 &
+/usr/bin/chvt 1
while [ -f "$again" ]; do
- /usr/bin/xinit /usr/bin/virt-p2v-launcher > $Xlog 2>&1
+ if [[ $(cat /proc/cmdline) =~ "p2v_nogui=true" ]] ; then
+ /usr/bin/openvt -c 1 /usr/bin/virt-p2v-launcher 2>&1 | tee -a
$Xlog
+ else
+ /usr/bin/xinit /usr/bin/virt-p2v-launcher > $Xlog 2>&1
+ fi
# virt-p2v-launcher will have touched this file if it ran
if [ -f /tmp/virt-p2v-launcher ]; then
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 48/61] p2v-systemd: nogui startup, View log option on fail
---
p2v/image-builder/p2v-systemd.ks | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/p2v/image-builder/p2v-systemd.ks b/p2v/image-builder/p2v-systemd.ks
index 33b4716..0ff6ab9 100644
--- a/p2v/image-builder/p2v-systemd.ks
+++ b/p2v/image-builder/p2v-systemd.ks
@@ -18,7 +18,13 @@ Xlog=/tmp/X.log
again=$(mktemp)
while [ -f "$again" ]; do
- /usr/bin/xinit /usr/bin/virt-p2v-launcher > $Xlog 2>&1
+ if [[ $(cat /proc/cmdline) =~ "p2v_nogui=true" ]] ; then
+ /usr/bin/openvt -sw -c 7 -f -- bash -c "
+/usr/bin/virt-p2v-launcher -nogui 2>&1 | tee -a $Xlog
+"
+ else
+ /usr/bin/xinit /usr/bin/virt-p2v-launcher > $Xlog 2>&1
+ fi
# virt-p2v-launcher will have touched this file if it ran
if [ -f /tmp/virt-p2v-launcher ]; then
@@ -26,12 +32,13 @@ while [ -f "$again" ]; do
break
fi
- /usr/bin/openvt -sw -- /bin/bash -c "
+ /usr/bin/openvt -sw -c 7 -f -- /bin/bash -c "
echo virt-p2v-launcher failed
select c in \
\"Try again\" \
\"Debug\" \
- \"Power off\"
+ \"Power off\" \
+ \"View log\"
do
if [ \"\$c\" == Debug ]; then
echo Output was written to $Xlog
@@ -40,6 +47,9 @@ do
bash -l
elif [ \"\$c\" == \"Power off\" ]; then
rm $again
+ elif [ \"\$c\" == \"View log\" ]; then
+ TERM=xterm less /tmp/X.log
+ continue
fi
break
done
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 49/61] p2v: refactor get_object from NewMain to gtk.rb
---
p2v/client/lib/virt-p2v/ui/gtk.rb | 139 +++++++++++++++++++++++++++++++++++++
p2v/client/lib/virt-p2v/ui/main.rb | 122 +-------------------------------
2 files changed, 141 insertions(+), 120 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index 3984b7f..a321c3f 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -50,4 +50,143 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
Cursor::Type = VirtP2V::UI::NeverMind
Cursor::Type::X_CURSOR = VirtP2V::UI::NeverMind
end
+
+ module VirtP2V
+ module UI
+ class SomeListW < NeverMind
+ def append(*args)
+ @items ||= []
+ @items << []
+ self
+ end
+
+ def _items
+ @items ||= []
+ @items
+ end
+
+ def _select(idx)
+ @idx = idx
+ end
+
+ def _selection
+ @idx ||= 0
+ @idx
+ end
+
+ def []=(idx, item)
+ @items.last[idx] = item
+ self
+ end
+
+ def clear
+ @items.clear
+ end
+
+ def each(&block)
+ @items.each do |item|
+ # block accepts three params:
+ # model, path, iter
+ # since we know nothing about model and path
+ # we'll fill only item as iter
+ block.call(nil, nil, item)
+ end
+ end
+ end
+
+ class ConvertProfileW < NeverMind
+ def active_iter
+ cpl = @main.get_object("convert_profile_list")
+ cpl._items[cpl._selection]
+ end
+ end
+
+ class NetworkDeviceListViewW < NeverMind
+ def selection
+ self
+ end
+
+ def selected
+ # TODO: this needs a proper selection
+ # now it's only for a testing purpouse
+ # but later we need to reflect reality
+ # and not blindly return first device
+ @main.get_object("network_device_list")._items.first
+ end
+ end
+
+ class ConnectErrorW < NeverMind
+ def text
+ @text || ''
+ end
+
+ def text=(str)
+ @text = str
+ unless str == ''
+ puts "Error connecting: '#{str}'"
+ puts "Giving up."
+ exit(3)
+ end
+ end
+ end
+
+ class ConvertStatusW < NeverMind
+ def text
+ @text || ''
+ end
+
+ def text=(str)
+ @text = str
+ puts "conversion status changed to: '#{str}'"
+ STDOUT.flush
+ if str =~ /failure|error/i
+ puts "Giving up."
+ exit(4)
+ end
+ end
+ end
+
+ class SomeTextFieldW < NeverMind
+ def text
+ @text || ""
+ end
+
+ def text=(str)
+ @text = str
+ end
+
+ def secondary_icon_tooltip_text=(str)
+ puts "Error in '#{@name}': '#{str}'"
+ end
+ end
+
+ def self.widget_class_factory(widget_name)
+ widgets = Hash[ *(["network_device_list",
+ "convert_profile_list", "convert_network_list",
+ "convert_fixed_list",
"convert_removable_list"].flat_map do |_l|
+ [_l, SomeListW]
+ end) ]
+ .merge(
+ Hash[ *(["server_hostname", "server_username",
"server_password",
+ "convert_name", "convert_cpus",
"convert_memory",
+ "ip_manual", "ip_address",
"ip_prefix", "ip_gateway",
+ "ip_dns", "server_hostname",
"server_username",
+ "server_password"].flat_map do |_l|
+ [_l, SomeTextFieldW]
+ end) ]
+ ).merge({
+ "convert_profile" => ConvertProfileW,
+ "network_device_list_view" => NetworkDeviceListViewW,
+ "convert_status" => ConvertStatusW,
+ "connect_error" => ConnectErrorW
+ })
+
+ if widgets.has_key? widget_name
+ widgets[widget_name]
+ else
+ NeverMind
+ end
+ end
+ end
+ end
end
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index af96c4a..ac2ef27 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -131,127 +131,9 @@ class NewMain < Main
# this is the entry point for returning our mocked
# versions of gtk2 objects, very similar to what we'd
# need to write tests
- puts "GET_OBJ #{name}"
- @gui_objects ||= {}
- @gui_objects[name] ||= if ["network_device_list",
- "convert_profile_list", "convert_network_list",
- "convert_fixed_list",
"convert_removable_list"].any?{|m| m==name}
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :append) do |*args|
-# p "append on #{self.name} #{args.inspect}"
- @items ||= []
- @items << []
- self
- end
- n.eigen.send(:define_method, :_items) do
- @items ||= []
- @items
- end
- n.eigen.send(:define_method, :_select) do |idx|
- @idx = idx
- end
- n.eigen.send(:define_method, :_selection) do
- @idx ||= 0
- @idx
- end
- n.eigen.send(:define_method, :"[]=") do |idx, item|
-# p "called []= on #{name} with #{args}"
- @items.last[idx] = item
- #p @items
- self
- end
- n.eigen.send(:define_method, :clear) do
- @items.clear
- end
- n.eigen.send(:define_method, :each) do |&block|
- @items.each do |item|
- # block accepts three params:
- # model, path, iter
- # since we know nothing about model and path
- # we'll fill only item as iter
- block.call(nil, nil, item)
- end
- end
- n
- elsif name == "convert_profile"
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :active_iter) do |*args|
-# p "convert_profile.active_iter"
- cpl = @main.get_object("convert_profile_list")
- _items = cpl._items
- _sel = _items[cpl._selection]
-# p _sel
-
- end
- n
- elsif name == "network_device_list_view"
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :selection) do
- self
- end
- n.eigen.send(:define_method, :selected) do
- # TODO: this needs a proper selection
- # now it's only for a testing purpouse
- # but later we need to reflect reality
- # and not blindly return first device
- nejm = @main.get_object("network_device_list")._items.first
-# p nejm
- end
- n
- elsif name == 'convert_status'
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :text) do
- @text || ""
- end
- n.eigen.send(:define_method, :"text=") do |str|
- @text = str
- puts "conversion status changed to: '#{str}'"
- STDOUT.flush
- if str =~ /failure|error/i
- #puts "Error connecting: '#{str}'"
- puts "Giving up."
- exit(4)
- end
- end
- n
- elsif name == 'connect_error'
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :text) do
- @text || ""
- end
- n.eigen.send(:define_method, :"text=") do |str|
- @text = str
- unless str == ''
- puts "Error connecting: '#{str}'"
- puts "Giving up."
- exit(3)
- end
- end
- n
- elsif ["server_hostname", "server_username",
"server_password",
- "convert_name", "convert_cpus",
"convert_memory",
- "ip_manual", "ip_address",
"ip_prefix", "ip_gateway",
- "ip_dns", "server_hostname",
"server_username",
- "server_password"].any?{|_m| _m==name}
- # N.B. some of these are set by user
- n = NeverMind.new self, name
- n.eigen.send(:define_method, :text) do
-# p "called text on #{@name}"
- @text || ""
- end
- n.eigen.send(:define_method, :"text=") do |str|
- @text = str
-# p "called text= #{str} on #{@name}"
- end
- n.eigen.send(:define_method, :"secondary_icon_tooltip_text=")
do |str|
- puts "Error in '#{@name}': '#{str}'"
- end
- n
- else
- NeverMind.new self, name
- end
- p "I'LL RETURN YOU
#{@gui_objects[name].class}:#{@gui_objects[name].__id__} for #{name}"
+ @gui_objects ||= {}
+ @gui_objects[name] ||= VirtP2V::UI::widget_class_factory(name).new self,
name
@gui_objects[name]
end
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 50/61] image-builder: keep rblibssh2.so in ISO
--- p2v/image-builder/common-minimizer.ks | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p2v/image-builder/common-minimizer.ks b/p2v/image-builder/common-minimizer.ks index 9215666..08aac34 100644 --- a/p2v/image-builder/common-minimizer.ks +++ b/p2v/image-builder/common-minimizer.ks @@ -24,7 +24,6 @@ droprpm setools-libs droprpm gamin droprpm pm-utils -droprpm kbd droprpm usermode droprpm vbetool droprpm ConsoleKit @@ -165,6 +164,8 @@ drop /usr/etc drop /usr/games drop /usr/include drop /usr/local +keep /usr/local/lib64/ruby/site_ruby/rblibssh2.so +keep /usr/local/lib/ruby/site_ruby/rblibssh2.so drop /usr/sbin/dell* keep /usr/sbin/build-locale-archive drop /usr/sbin/glibc_post_upgrade.* -- 1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 51/61] p2v.spec.PL: use ruby(release) since F17 and EL7
---
rubygem-virt-p2v.spec.PL | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/rubygem-virt-p2v.spec.PL b/rubygem-virt-p2v.spec.PL
index 81157c7..65d0486 100644
--- a/rubygem-virt-p2v.spec.PL
+++ b/rubygem-virt-p2v.spec.PL
@@ -89,7 +89,12 @@ BuildRequires: ruby-devel
# rblibssh2 dependencies
BuildRequires: libssh2-devel
-Requires: ruby(abi) = %{rubyabi}
+%if %{?fedora:0%{fedora} >= 17}%{?rhel:0%{rhel} >= 7}
+Requires: ruby(release) >= %{rubyabi}
+%else
+Requires: ruby(abi) >= %{rubyabi}
+%endif
+
Requires: rubygems
Requires: rubygem(gtk2)
Requires: ruby(dbus)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 52/61] p2v: main.rb - polish text output
---
p2v/client/lib/virt-p2v/ui/main.rb | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index ac2ef27..e46c70f 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -58,7 +58,6 @@ class Main
raise "Attempt to activate non-existent page #{name}" \
unless @pages.has_key?(name)
- p "trying to activate page #{name}"
page = @pages[name]
@page_vbox = self.get_object('page_vbox') unless defined?
@page_vbox
@@ -166,9 +165,9 @@ class NewMain < Main
# register ourselves as listener on activated connection
# as VirtP2V::UI:Netowork does
VirtP2V::NetworkDevice.add_listener( lambda { |dev|
- p dev
+ puts "interface #{dev.name} #{dev.mac}: #{dev.state}"
if dev.connected && dev.activated then
- p "we should now continue"
+ puts "connection ready, connecting to p2v server"
fill_and_click_connect
end
})
@@ -265,7 +264,7 @@ class NewMain < Main
end
def active_page=(name)
- puts "#{name}"
+ puts "setting active page to #{name}"
STDOUT.flush
super(name)
if name == 'conversion_win'
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 53/61] p2v-sysv.ks: nogui startup, View log option on fail
---
p2v/image-builder/p2v-sysv.ks | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/p2v/image-builder/p2v-sysv.ks b/p2v/image-builder/p2v-sysv.ks
index 75baff2..294a36d 100644
--- a/p2v/image-builder/p2v-sysv.ks
+++ b/p2v/image-builder/p2v-sysv.ks
@@ -25,7 +25,9 @@ again=$(mktemp)
while [ -f "$again" ]; do
if [[ $(cat /proc/cmdline) =~ "p2v_nogui=true" ]] ; then
- /usr/bin/openvt -c 1 /usr/bin/virt-p2v-launcher 2>&1 | tee -a
$Xlog
+ /usr/bin/openvt -c 1 -f -- bash -c "
+/usr/bin/virt-p2v-launcher -nogui 2>&1 | tee -a $Xlog
+"
else
/usr/bin/xinit /usr/bin/virt-p2v-launcher > $Xlog 2>&1
fi
@@ -41,7 +43,8 @@ echo virt-p2v-launcher failed
select c in \
\"Try again\" \
\"Debug\" \
- \"Power off\"
+ \"Power off\" \
+ \"View log\"
do
if [ \"\$c\" == Debug ]; then
echo Output was written to $Xlog
@@ -50,6 +53,9 @@ do
bash -l
elif [ \"\$c\" == \"Power off\" ]; then
rm $again
+ elif [ \"\$c\" == \"View log\" ]; then
+ TERM=xterm less /tmp/X.log
+ continue
fi
break
done
--
1.8.3.1
---
p2v/client/Rakefile | 2 +-
p2v/client/bin/virt-p2v | 2 +-
p2v/client/bin/virt-p2v-launcher | 2 +-
p2v/client/lib/virt-p2v/converter.rb | 2 +-
p2v/client/lib/virt-p2v/gtk-queue.rb | 2 +-
p2v/client/lib/virt-p2v/ui/connect.rb | 2 +-
p2v/client/lib/virt-p2v/ui/convert.rb | 2 +-
p2v/client/lib/virt-p2v/ui/gtk.rb | 16 ++++++++++++++++
p2v/client/lib/virt-p2v/ui/main.rb | 2 +-
p2v/client/lib/virt-p2v/ui/network.rb | 2 +-
p2v/client/test/test_newmain.rb | 16 ++++++++++++++++
p2v/client/test/test_newmain_integration.rb | 16 ++++++++++++++++
p2v/client/virt-p2v.gemspec | 2 +-
rubygem-virt-p2v.spec.PL | 1 +
14 files changed, 59 insertions(+), 10 deletions(-)
diff --git a/p2v/client/Rakefile b/p2v/client/Rakefile
index b7059a0..78ddd98 100644
--- a/p2v/client/Rakefile
+++ b/p2v/client/Rakefile
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
#
# 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
diff --git a/p2v/client/bin/virt-p2v b/p2v/client/bin/virt-p2v
index 5b294a7..c1894fa 100755
--- a/p2v/client/bin/virt-p2v
+++ b/p2v/client/bin/virt-p2v
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/bin/virt-p2v-launcher b/p2v/client/bin/virt-p2v-launcher
index 3c4e328..92e68bd 100755
--- a/p2v/client/bin/virt-p2v-launcher
+++ b/p2v/client/bin/virt-p2v-launcher
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
#
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/converter.rb
b/p2v/client/lib/virt-p2v/converter.rb
index eccc436..2c70c0b 100644
--- a/p2v/client/lib/virt-p2v/converter.rb
+++ b/p2v/client/lib/virt-p2v/converter.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2012 Red Hat Inc.
+# Copyright (C) 2011-2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/gtk-queue.rb
b/p2v/client/lib/virt-p2v/gtk-queue.rb
index 22a92b4..2222fa4 100644
--- a/p2v/client/lib/virt-p2v/gtk-queue.rb
+++ b/p2v/client/lib/virt-p2v/gtk-queue.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/ui/connect.rb
b/p2v/client/lib/virt-p2v/ui/connect.rb
index 15c3d9c..df7659c 100644
--- a/p2v/client/lib/virt-p2v/ui/connect.rb
+++ b/p2v/client/lib/virt-p2v/ui/connect.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/ui/convert.rb
b/p2v/client/lib/virt-p2v/ui/convert.rb
index b737c1b..5068078 100644
--- a/p2v/client/lib/virt-p2v/ui/convert.rb
+++ b/p2v/client/lib/virt-p2v/ui/convert.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2012 Red Hat Inc.
+# Copyright (C) 2011-2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index a321c3f..c52eb11 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -1,3 +1,19 @@
+# Copyright (C) 2013-2014 Red Hat Inc.
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
require('gtk2') if !(Kernel.const_defined?(:NOGUI) && NOGUI ==
true)
if Kernel.const_defined?(:NOGUI) && NOGUI == true
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index e46c70f..b445c9e 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013, 2014 Red Hat Inc.
#
# 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
diff --git a/p2v/client/lib/virt-p2v/ui/network.rb
b/p2v/client/lib/virt-p2v/ui/network.rb
index 3ade7ed..fd0adad 100644
--- a/p2v/client/lib/virt-p2v/ui/network.rb
+++ b/p2v/client/lib/virt-p2v/ui/network.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 Red Hat Inc.
+# Copyright (C) 2011, 2013 Red Hat Inc.
#
# 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
diff --git a/p2v/client/test/test_newmain.rb b/p2v/client/test/test_newmain.rb
index e093303..40e0c68 100644
--- a/p2v/client/test/test_newmain.rb
+++ b/p2v/client/test/test_newmain.rb
@@ -1,3 +1,19 @@
+# Copyright (C) 2013, 2014 Red Hat Inc.
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
require 'minitest/autorun'
NOGUI = true
require 'virt-p2v/ui/main'
diff --git a/p2v/client/test/test_newmain_integration.rb
b/p2v/client/test/test_newmain_integration.rb
index f7c59a8..9026d99 100644
--- a/p2v/client/test/test_newmain_integration.rb
+++ b/p2v/client/test/test_newmain_integration.rb
@@ -1,3 +1,19 @@
+# Copyright (C) 2013 Red Hat Inc.
+#
+# 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# 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.
+
require 'minitest/autorun'
require 'virt-p2v/ui/main'
diff --git a/p2v/client/virt-p2v.gemspec b/p2v/client/virt-p2v.gemspec
index 18614d1..db2441a 100644
--- a/p2v/client/virt-p2v.gemspec
+++ b/p2v/client/virt-p2v.gemspec
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Red Hat Inc.
+# Copyright (C) 2012-2014 Red Hat Inc.
#
# 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
diff --git a/rubygem-virt-p2v.spec.PL b/rubygem-virt-p2v.spec.PL
index 65d0486..ccd6256 100644
--- a/rubygem-virt-p2v.spec.PL
+++ b/rubygem-virt-p2v.spec.PL
@@ -1,5 +1,6 @@
# -*- rpm-spec -*-
# Copyright (C) 2006 Daniel Berrange <dan@berrange.com>
+# Copyright (C) 2014 Red Hat Inc. <mzatko@redhat.com>
#
use strict;
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 55/61] p2v: on failure, display log before user input
---
p2v/image-builder/p2v-systemd.ks | 2 ++
p2v/image-builder/p2v-sysv.ks | 2 ++
2 files changed, 4 insertions(+)
diff --git a/p2v/image-builder/p2v-systemd.ks b/p2v/image-builder/p2v-systemd.ks
index 0ff6ab9..a1117b4 100644
--- a/p2v/image-builder/p2v-systemd.ks
+++ b/p2v/image-builder/p2v-systemd.ks
@@ -33,6 +33,8 @@ while [ -f "$again" ]; do
fi
/usr/bin/openvt -sw -c 7 -f -- /bin/bash -c "
+cat $Xlog
+echo
echo virt-p2v-launcher failed
select c in \
\"Try again\" \
diff --git a/p2v/image-builder/p2v-sysv.ks b/p2v/image-builder/p2v-sysv.ks
index 294a36d..a71dbb7 100644
--- a/p2v/image-builder/p2v-sysv.ks
+++ b/p2v/image-builder/p2v-sysv.ks
@@ -39,6 +39,8 @@ while [ -f "$again" ]; do
fi
/usr/bin/openvt -sw -- /bin/bash -c "
+cat $Xlog
+echo
echo virt-p2v-launcher failed
select c in \
\"Try again\" \
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 56/61] p2v: support disk selection when no gui
---
p2v/client/lib/virt-p2v/ui/gtk.rb | 20 +++++++++++++++++++-
p2v/client/lib/virt-p2v/ui/main.rb | 8 +++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index c52eb11..38b9184 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -99,6 +99,20 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
@items.clear
end
+ def _set_checked(dev_name, check)
+ @items.each do |item|
+ if item[VirtP2V::UI::Convert::CONVERT_FIXED_DEVICE] == dev_name then
+ item[VirtP2V::UI::Convert::CONVERT_FIXED_CONVERT] = check
+ end
+ end
+ end
+
+ def _uncheck_all
+ @items.each do |item|
+ item[VirtP2V::UI::Convert::CONVERT_FIXED_CONVERT] = false
+ end
+ end
+
def each(&block)
@items.each do |item|
# block accepts three params:
@@ -108,6 +122,10 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
block.call(nil, nil, item)
end
end
+
+ def get_iter(path)
+ self
+ end
end
class ConvertProfileW < NeverMind
@@ -155,7 +173,7 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
@text = str
puts "conversion status changed to: '#{str}'"
STDOUT.flush
- if str =~ /failure|error/i
+ if str =~ /failure|error|no\ root/i
puts "Giving up."
exit(4)
end
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index b445c9e..42716d2 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -187,7 +187,7 @@ class NewMain < Main
def expected_param_keys
['ip_manual', 'ip_address', 'ip_prefix',
'ip_gateway', 'ip_dns',
'server_hostname', 'server_username',
'server_password',
- 'convert_name']
+ 'convert_name', 'disks']
end
def is_param_optional?(name)
@@ -258,6 +258,12 @@ class NewMain < Main
def fill_and_click_convert
fill_widgets_from_params(['convert_name'])
+
+ get_object('convert_fixed_list')._uncheck_all
+ @cmd_params['disks'].split(',').each do |_dev|
+ get_object('convert_fixed_list')._set_checked(_dev, true)
+ end
+
call_actions_by_name(['convert_name_changed',
'convert_cpus_changed',
'convert_memory_changed',
'convert_profile_changed',
'convert_button_clicked'])
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 57/61] p2v: make no gui p2v_disks param optional
---
p2v/client/lib/virt-p2v/ui/main.rb | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index 42716d2..a3e07ab 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -191,7 +191,8 @@ class NewMain < Main
end
def is_param_optional?(name)
- ['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns'].include?(name)
+ ['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns',
+ 'disks'].include?(name)
end
def validate_params(params)
@@ -207,6 +208,12 @@ class NewMain < Main
else
params['ip_manual'] = false
end
+
+ if params['disks'] &&
params['disks'].split(',') == [] then
+ puts "Explicit p2v_disks can't be empty. Implicit p2v_disks
selects all disks."
+ return false
+ end
+
true
end
@@ -259,9 +266,11 @@ class NewMain < Main
def fill_and_click_convert
fill_widgets_from_params(['convert_name'])
- get_object('convert_fixed_list')._uncheck_all
- @cmd_params['disks'].split(',').each do |_dev|
- get_object('convert_fixed_list')._set_checked(_dev, true)
+ if @cmd_params['disks'] then
+ get_object('convert_fixed_list')._uncheck_all
+ @cmd_params['disks'].split(',').each do |_dev|
+ get_object('convert_fixed_list')._set_checked(_dev, true)
+ end
end
call_actions_by_name(['convert_name_changed',
'convert_cpus_changed',
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 58/61] p2v: nogui selection of NICs and removables
---
p2v/client/lib/virt-p2v/ui/main.rb | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index a3e07ab..bd0a0f8 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -187,12 +187,12 @@ class NewMain < Main
def expected_param_keys
['ip_manual', 'ip_address', 'ip_prefix',
'ip_gateway', 'ip_dns',
'server_hostname', 'server_username',
'server_password',
- 'convert_name', 'disks']
+ 'convert_name', 'disks', 'nics',
'rems']
end
def is_param_optional?(name)
['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns',
- 'disks'].include?(name)
+ 'disks', 'nics', 'rems'].include?(name)
end
def validate_params(params)
@@ -214,6 +214,11 @@ class NewMain < Main
return false
end
+ if params['nics'] &&
params['nics'].split(',') == [] then
+ puts "Explicit p2v_nics can't be empty. Implicit p2v_nics
selects all NICs."
+ return false
+ end
+
true
end
@@ -263,19 +268,26 @@ class NewMain < Main
"connect_button_clicked"])
end
+ def split_and_set_checked(what, where)
+ widget = get_object(where.to_s) # "convert_#{where}_list")
+ widget._uncheck_all
+ @cmd_params[what].split(',').each do |_dev|
+ widget._set_checked(_dev, true)
+ end
+ end
+
def fill_and_click_convert
- fill_widgets_from_params(['convert_name'])
+ fill_widgets_from_params(['convert_name'])
- if @cmd_params['disks'] then
- get_object('convert_fixed_list')._uncheck_all
- @cmd_params['disks'].split(',').each do |_dev|
- get_object('convert_fixed_list')._set_checked(_dev, true)
- end
- end
+ {'disks' => 'convert_fixed_list',
+ 'nics' => 'convert_network_list',
+ 'rems' => 'convert_removable_list'}.each do |p,w|
+ split_and_set_checked(p,w) if @cmd_params[p]
+ end
- call_actions_by_name(['convert_name_changed',
'convert_cpus_changed',
- 'convert_memory_changed',
'convert_profile_changed',
- 'convert_button_clicked'])
+ call_actions_by_name(['convert_name_changed',
'convert_cpus_changed',
+ 'convert_memory_changed',
'convert_profile_changed',
+ 'convert_button_clicked'])
end
def active_page=(name)
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 59/61] p2v: v2v profile selection support in nogui mode
---
p2v/client/lib/virt-p2v/ui/gtk.rb | 7 +++++++
p2v/client/lib/virt-p2v/ui/main.rb | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index 38b9184..daa9ad8 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -113,6 +113,12 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
end
end
+ def _set_selected_name(name)
+ @idx = @items.index([name]) ||
+ (@main.get_object('connect_error').text="Cannot select
'#{name}' \
+on '#{@name}'. Available items are: #{@items.join(',
')}.")
+ end
+
def each(&block)
@items.each do |item|
# block accepts three params:
@@ -159,6 +165,7 @@ if Kernel.const_defined?(:NOGUI) && NOGUI == true
unless str == ''
puts "Error connecting: '#{str}'"
puts "Giving up."
+ STDOUT.flush
exit(3)
end
end
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index bd0a0f8..bdfbd69 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -187,12 +187,12 @@ class NewMain < Main
def expected_param_keys
['ip_manual', 'ip_address', 'ip_prefix',
'ip_gateway', 'ip_dns',
'server_hostname', 'server_username',
'server_password',
- 'convert_name', 'disks', 'nics',
'rems']
+ 'convert_name', 'disks', 'nics',
'rems', 'profile']
end
def is_param_optional?(name)
['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns',
- 'disks', 'nics', 'rems'].include?(name)
+ 'disks', 'nics', 'rems',
'profile'].include?(name)
end
def validate_params(params)
@@ -279,6 +279,9 @@ class NewMain < Main
def fill_and_click_convert
fill_widgets_from_params(['convert_name'])
+ get_object('convert_profile_list').
+ _set_selected_name(@cmd_params['profile']) if
@cmd_params['profile']
+
{'disks' => 'convert_fixed_list',
'nics' => 'convert_network_list',
'rems' => 'convert_removable_list'}.each do |p,w|
--
1.8.3.1
Maros Zatko
2014-Feb-12 14:31 UTC
[Libguestfs] [PATCH 60/61] p2v: memory, cpu and debug options in nogui mode
---
p2v/client/lib/virt-p2v/ui/gtk.rb | 2 +-
p2v/client/lib/virt-p2v/ui/main.rb | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/p2v/client/lib/virt-p2v/ui/gtk.rb
b/p2v/client/lib/virt-p2v/ui/gtk.rb
index daa9ad8..98adca8 100644
--- a/p2v/client/lib/virt-p2v/ui/gtk.rb
+++ b/p2v/client/lib/virt-p2v/ui/gtk.rb
@@ -212,7 +212,7 @@ on '#{@name}'. Available items are:
#{@items.join(', ')}.")
"convert_name", "convert_cpus",
"convert_memory",
"ip_manual", "ip_address",
"ip_prefix", "ip_gateway",
"ip_dns", "server_hostname",
"server_username",
- "server_password"].flat_map do |_l|
+ "server_password", "convert_debug"].flat_map
do |_l|
[_l, SomeTextFieldW]
end) ]
).merge({
diff --git a/p2v/client/lib/virt-p2v/ui/main.rb
b/p2v/client/lib/virt-p2v/ui/main.rb
index bdfbd69..57c762f 100644
--- a/p2v/client/lib/virt-p2v/ui/main.rb
+++ b/p2v/client/lib/virt-p2v/ui/main.rb
@@ -187,12 +187,14 @@ class NewMain < Main
def expected_param_keys
['ip_manual', 'ip_address', 'ip_prefix',
'ip_gateway', 'ip_dns',
'server_hostname', 'server_username',
'server_password',
- 'convert_name', 'disks', 'nics',
'rems', 'profile']
+ 'convert_name', 'disks', 'nics',
'rems', 'profile',
+ 'convert_memory', 'convert_cpus',
'convert_debug']
end
def is_param_optional?(name)
['ip_address', 'ip_prefix', 'ip_gateway',
'ip_dns',
- 'disks', 'nics', 'rems',
'profile'].include?(name)
+ 'disks', 'nics', 'rems', 'profile',
'convert_memory', 'convert_cpus',
+ 'convert_debug'].include?(name)
end
def validate_params(params)
@@ -277,7 +279,13 @@ class NewMain < Main
end
def fill_and_click_convert
- fill_widgets_from_params(['convert_name'])
+ fill_widgets_from_params(['convert_name', 'convert_cpus',
+ 'convert_memory',
'convert_debug'])
+
+ if get_object('convert_debug').text =~ /true|1/ then
+ call_actions_by_name(['convert_debug_toggled'])
+ puts "Conversion debug enabled."
+ end
get_object('convert_profile_list').
_set_selected_name(@cmd_params['profile']) if
@cmd_params['profile']
--
1.8.3.1
--- README-NOGUI | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 README-NOGUI diff --git a/README-NOGUI b/README-NOGUI new file mode 100644 index 0000000..66216ec --- /dev/null +++ b/README-NOGUI @@ -0,0 +1,35 @@ +P2V can run "headless" without any need to manually fill in GTK2 dialogues. + +To specify parameters otherwise entered via GUI you need to pass them through +kernel command line. You could achieve this for example with PXE boot. + +Possible paramters are [M - mandatory, O - optional]: +M p2v_ip_manual=true - use manual IP address, specified via option below +O p2v_ip_address=SOME_IP_ADDRESS +O p2v_ip_prefix=NETMASK_BITS +O p2v_ip_gateway=GW_IP +O p2v_ip_dns=DNS_IP +M p2v_server_hostname=HOSTNAME - Convert server hostname +M p2v_server_username=USER - Connect/run virt-p2v-server as this user +M p2v_server_password=PWD - Password for above +M p2v_convert_name=MACHINE_NAME - Newly created VM will have this name +O p2v_disks=vda,vdc,... - Select which disks to transfer. When p2v_disks is not + present all disks are selected. +O p2v_nics=eth0,p0p2,... - Same as above but for network adapters +O p2v_rems=sr0,fd1,... - Same as above but for removable devices +O p2v_profile=libvirt - One of the profiles specified in /etc/virt-v2v.conf +O p2v_convert_memory=1024 - How much memory should new VM have. If option is + not present, new VM will have same amount. +O p2v_convert_cpus=3 - Same as above but for CPUs +O p2v_convert_debug=true - Can be true or 1, when set, debug option is enabled + in virt-p2v-server + +P2V needs operator's attendance at console in case of some sort of failure. +Operator is then provided with output from P2V and four options: +1 - Try again - re-runs P2V, useful when some missing resource is available again +2 - Debug - runs shell +3 - Power off +4 - View log - shows output from P2V in less + +Example kernel arguments from virt-manager: +initrd=initrd0.img root=live:CDLABEL=Virt-P2V rootfstype=auto ro rd.live.image quiet rd.luks=0 rd.md=0 rd.dm=0 selinux=0 p2v_nogui=true p2v_ip_manual=false p2v_server_hostname=192.168.122.1 p2v_server_username=root p2v_server_password=SUCHPASSWORD p2v_convert_name=newone p2v_disks=vda,vdb p2v_nics=eth0,ens9 p2v_rems=sr1,sr2,fd0 p2v_profile=libvirt p2v_convert_memory=512 p2v_convert_cpus=2 p2v_convert_debug=true -- 1.8.3.1
Seemingly Similar Threads
- remotely mounting client disks in p2v server
- support remotely mounting disk images in p2v
- How to make array of regression objects
- [PATCH node-image] add livecd-iso-to-iscsi script to support iscsi root booting setup
- [Bug 145] sshd fails to increment AIX login failed counter