Module VirtP2V::UI::Convert
In: lib/virt-p2v/ui/convert.rb
lib/virt-p2v/ui/convert.rb

Methods

Included Modules

GetText GetText

Classes and Modules

Class VirtP2V::UI::Convert::InvalidUIState

Constants

CONVERT_PROFILE_NAME = 0
CONVERT_NETWORK_CONVERT = 0
CONVERT_NETWORK_DEVICE = 1
CONVERT_FIXED_CONVERT = 0
CONVERT_FIXED_DEVICE = 1
CONVERT_FIXED_PROGRESS = 2
CONVERT_REMOVABLE_CONVERT = 0
CONVERT_REMOVABLE_DEVICE = 1
CONVERT_REMOVABLE_TYPE = 2
UI_STATE_INVALID = 0
UI_STATE_VALID = 1
UI_STATE_CONNECTING = 2
UI_STATE_CONVERTING = 3
UI_STATE_COMPLETE = 4
EV_VALID = 0
EV_BUTTON = 1
EV_CONNECTION = 2
EV_CONVERTED = 3
CONVERT_PROFILE_NAME = 0
CONVERT_NETWORK_CONVERT = 0
CONVERT_NETWORK_DEVICE = 1
CONVERT_FIXED_CONVERT = 0
CONVERT_FIXED_DEVICE = 1
CONVERT_FIXED_PROGRESS = 2
CONVERT_REMOVABLE_CONVERT = 0
CONVERT_REMOVABLE_DEVICE = 1
CONVERT_REMOVABLE_TYPE = 2
UI_STATE_INVALID = 0
UI_STATE_VALID = 1
UI_STATE_CONNECTING = 2
UI_STATE_CONVERTING = 3
UI_STATE_COMPLETE = 4
EV_VALID = 0
EV_BUTTON = 1
EV_CONNECTION = 2
EV_CONVERTED = 3

Public Class methods

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 384
384:     def self.check_numeric(widget)
385:         value = widget.text
386:         if value.nil? ? false : begin
387:             value = Integer(value)
388:             value > 0
389:         rescue
390:             false
391:         end
392:         then
393:             widget.secondary_icon_name = nil
394:         else
395:             widget.secondary_icon_name = 'gtk-dialog-warning'
396:             widget.secondary_icon_tooltip_text =
397:                 _('Value must be an integer greater than 0')
398:         end
399: 
400:         update_values
401:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 384
384:     def self.check_numeric(widget)
385:         value = widget.text
386:         if value.nil? ? false : begin
387:             value = Integer(value)
388:             value > 0
389:         rescue
390:             false
391:         end
392:         then
393:             widget.secondary_icon_name = nil
394:         else
395:             widget.secondary_icon_name = 'gtk-dialog-warning'
396:             widget.secondary_icon_tooltip_text =
397:                 _('Value must be an integer greater than 0')
398:         end
399: 
400:         update_values
401:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 236
236:     def self.convert
237:         @converter.convert(
238:             # status
239:             lambda { |msg|
240:                 @status.text = msg
241:             },
242:             # progress
243:             lambda { |dev, progress|
244:                 @fixeds.each { |model, path, iter|
245:                     next unless iter[CONVERT_FIXED_DEVICE] == dev
246: 
247:                     iter[CONVERT_FIXED_PROGRESS] = progress
248:                     break
249:                 }
250:             }
251:         ) { |result|
252:             # N.B. Explicit test against true is required here, as result may be
253:             # an Exception, which would also return true if evaluated alone
254:             if result == true then
255:                 @status.text = ''
256:                 event(EV_CONVERTED, true)
257:             else
258:                 @status.text = result.message
259:                 event(EV_CONVERTED, false)
260:             end
261:         }
262:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 236
236:     def self.convert
237:         @converter.convert(
238:             # status
239:             lambda { |msg|
240:                 @status.text = msg
241:             },
242:             # progress
243:             lambda { |dev, progress|
244:                 @fixeds.each { |model, path, iter|
245:                     next unless iter[CONVERT_FIXED_DEVICE] == dev
246: 
247:                     iter[CONVERT_FIXED_PROGRESS] = progress
248:                     break
249:                 }
250:             }
251:         ) { |result|
252:             # N.B. Explicit test against true is required here, as result may be
253:             # an Exception, which would also return true if evaluated alone
254:             if result == true then
255:                 @status.text = ''
256:                 event(EV_CONVERTED, true)
257:             else
258:                 @status.text = result.message
259:                 event(EV_CONVERTED, false)
260:             end
261:         }
262:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 418
418:     def self.convert_button_clicked
419:         event(EV_BUTTON, true)
420:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 418
418:     def self.convert_button_clicked
419:         event(EV_BUTTON, true)
420:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 376
376:     def self.convert_cpus_changed
377:         check_numeric(@cpus)
378:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 376
376:     def self.convert_cpus_changed
377:         check_numeric(@cpus)
378:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 277
277:     def self.convert_fixed_list_row_changed(model, path, iter)
278:         update_values
279:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 277
277:     def self.convert_fixed_list_row_changed(model, path, iter)
278:         update_values
279:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 403
403:     def self.convert_fixed_select_toggled(widget, path)
404:         iter = @fixeds.get_iter(path)
405:         iter[CONVERT_FIXED_CONVERT] = !iter[CONVERT_FIXED_CONVERT]
406:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 403
403:     def self.convert_fixed_select_toggled(widget, path)
404:         iter = @fixeds.get_iter(path)
405:         iter[CONVERT_FIXED_CONVERT] = !iter[CONVERT_FIXED_CONVERT]
406:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 380
380:     def self.convert_memory_changed
381:         check_numeric(@memory)
382:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 380
380:     def self.convert_memory_changed
381:         check_numeric(@memory)
382:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 413
413:     def self.convert_network_select_toggled(widget, path)
414:         iter = @nics.get_iter(path)
415:         iter[CONVERT_NETWORK_CONVERT] = !iter[CONVERT_NETWORK_CONVERT]
416:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 413
413:     def self.convert_network_select_toggled(widget, path)
414:         iter = @nics.get_iter(path)
415:         iter[CONVERT_NETWORK_CONVERT] = !iter[CONVERT_NETWORK_CONVERT]
416:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 408
408:     def self.convert_removable_select_toggled(widget, path)
409:         iter = @removables.get_iter(path)
410:         iter[CONVERT_REMOVABLE_CONVERT] = !iter[CONVERT_REMOVABLE_CONVERT]
411:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 408
408:     def self.convert_removable_select_toggled(widget, path)
409:         iter = @removables.get_iter(path)
410:         iter[CONVERT_REMOVABLE_CONVERT] = !iter[CONVERT_REMOVABLE_CONVERT]
411:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 148
148:     def self.event(event, status)
149:         case @state
150:         when UI_STATE_INVALID
151:             case event
152:             when EV_VALID
153:                 set_state(UI_STATE_VALID) if status
154:             else
155:                 raise "Unexpected event: #{@state} #{event}"
156:             end
157:         when UI_STATE_VALID
158:             case event
159:             when EV_VALID
160:                 set_state(UI_STATE_INVALID) if !status
161:             when EV_BUTTON
162:                 if @converter.connection.connected then
163:                     set_state(UI_STATE_CONVERTING)
164:                     convert
165:                 else
166:                     set_state(UI_STATE_CONNECTING)
167:                     reconnect
168:                 end
169:             else
170:                 raise "Unexpected event: #{@state} #{event}"
171:             end
172:         when UI_STATE_CONNECTING
173:             case event
174:             when EV_CONNECTION
175:                 if status then
176:                     set_state(UI_STATE_CONVERTING)
177:                     convert
178:                 else
179:                     set_state(UI_STATE_VALID)
180:                 end
181:             when EV_VALID
182:                 # update_values will be called when the profile list is cleared
183:                 # and repopulated during connection. Untidy, but ignore it.
184:             else
185:                 raise "Unexpected event: #{@state} #{event}" \
186:                     unless event == EV_CONNECTION
187:             end
188:         when UI_STATE_CONVERTING
189:             case event
190:             when EV_CONVERTED
191:                 if status then
192:                     set_state(UI_STATE_COMPLETE)
193:                 else
194:                     set_state(UI_STATE_VALID)
195:                 end
196:             when EV_VALID
197:                 # update_values will be called when the list stores are updated.
198:                 # Untidy, but ignore it
199:             else
200:                 raise "Unexpected event: #{@state} #{event}"
201:             end
202:         else
203:             raise "Unexpected UI state: #{@state}"
204:         end
205:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 148
148:     def self.event(event, status)
149:         case @state
150:         when UI_STATE_INVALID
151:             case event
152:             when EV_VALID
153:                 set_state(UI_STATE_VALID) if status
154:             else
155:                 raise "Unexpected event: #{@state} #{event}"
156:             end
157:         when UI_STATE_VALID
158:             case event
159:             when EV_VALID
160:                 set_state(UI_STATE_INVALID) if !status
161:             when EV_BUTTON
162:                 if @converter.connection.connected then
163:                     set_state(UI_STATE_CONVERTING)
164:                     convert
165:                 else
166:                     set_state(UI_STATE_CONNECTING)
167:                     reconnect
168:                 end
169:             else
170:                 raise "Unexpected event: #{@state} #{event}"
171:             end
172:         when UI_STATE_CONNECTING
173:             case event
174:             when EV_CONNECTION
175:                 if status then
176:                     set_state(UI_STATE_CONVERTING)
177:                     convert
178:                 else
179:                     set_state(UI_STATE_VALID)
180:                 end
181:             when EV_VALID
182:                 # update_values will be called when the profile list is cleared
183:                 # and repopulated during connection. Untidy, but ignore it.
184:             else
185:                 raise "Unexpected event: #{@state} #{event}" \
186:                     unless event == EV_CONNECTION
187:             end
188:         when UI_STATE_CONVERTING
189:             case event
190:             when EV_CONVERTED
191:                 if status then
192:                     set_state(UI_STATE_COMPLETE)
193:                 else
194:                     set_state(UI_STATE_VALID)
195:                 end
196:             when EV_VALID
197:                 # update_values will be called when the list stores are updated.
198:                 # Untidy, but ignore it
199:             else
200:                 raise "Unexpected event: #{@state} #{event}"
201:             end
202:         else
203:             raise "Unexpected UI state: #{@state}"
204:         end
205:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 50
 50:     def self.init(ui, converter)
 51:         # ListStores
 52:         @profiles   = ui.get_object('convert_profile_list')
 53:         @nics       = ui.get_object('convert_network_list')
 54:         @fixeds     = ui.get_object('convert_fixed_list')
 55:         @removables = ui.get_object('convert_removable_list')
 56: 
 57:         # Widgets
 58:         @profile    = ui.get_object('convert_profile')
 59:         @name       = ui.get_object('convert_name')
 60:         @cpus       = ui.get_object('convert_cpus')
 61:         @memory     = ui.get_object('convert_memory')
 62:         @editable   = ui.get_object('convert_editable')
 63:         @button     = ui.get_object('convert_button')
 64:         @status     = ui.get_object('convert_status')
 65: 
 66:         # Get initial values from converter
 67:         @name.text = converter.name
 68:         @cpus.text = converter.cpus.to_s
 69:         @memory.text = (converter.memory / 1024 / 1024).to_s
 70: 
 71:         # Populate profiles on connection
 72:         converter.on_connection { |conn|
 73:             conn.on_connect { |cb|
 74:                 conn.list_profiles { |profiles|
 75:                     cb.call(RuntimeError.new(_('Remote server does not ' +
 76:                                                'define any profiles in ' +
 77:                                                '/etc/virt-v2v.conf'))) \
 78:                         if profiles.kind_of?(Exception) or profiles.empty?
 79: 
 80:                     selected = @profile.active_iter
 81:                     selected = selected[CONVERT_PROFILE_NAME] \
 82:                         unless selected.nil?
 83: 
 84:                     @profiles.clear
 85:                     profiles.each { |i|
 86:                         profile = @profiles.append
 87:                         profile[CONVERT_PROFILE_NAME] = i
 88:                         @profile.active_iter = profile if i == selected
 89:                     }
 90: 
 91:                     cb.call(true)
 92:                 }
 93:             }
 94:         }
 95: 
 96:         VirtP2V::FixedBlockDevice.all_devices.each { |dev|
 97:             fixed = @fixeds.append
 98:             fixed[CONVERT_FIXED_CONVERT]    = true
 99:             fixed[CONVERT_FIXED_DEVICE]     = dev.device
100:             fixed[CONVERT_FIXED_PROGRESS]   = 0
101:         }
102: 
103:         VirtP2V::RemovableBlockDevice.all_devices.each { |dev|
104:             rem = @removables.append
105:             rem[CONVERT_REMOVABLE_CONVERT]  = true
106:             rem[CONVERT_REMOVABLE_DEVICE]   = dev.device
107:             rem[CONVERT_REMOVABLE_TYPE]     = dev.type
108:         }
109: 
110:         VirtP2V::NetworkDevice.all_devices.each { |dev|
111:             nic = @nics.append
112:             nic[CONVERT_NETWORK_CONVERT]    = dev.connected
113:             nic[CONVERT_NETWORK_DEVICE]     = dev.name
114:         }
115: 
116:         # Event handlers
117:         ui.register_handler('convert_profile_changed',
118:                             method(:update_values))
119:         ui.register_handler('convert_name_changed',
120:                             method(:update_values))
121:         ui.register_handler('convert_cpus_changed',
122:                             method(:convert_cpus_changed))
123:         ui.register_handler('convert_memory_changed',
124:                             method(:convert_memory_changed))
125:         ui.register_handler('convert_fixed_list_row_changed',
126:                             method(:convert_fixed_list_row_changed))
127:         ui.register_handler('convert_removable_list_row_changed',
128:                             method(:update_values))
129:         ui.register_handler('convert_network_list_row_changed',
130:                             method(:update_values))
131:         ui.register_handler('convert_fixed_select_toggled',
132:                             method(:convert_fixed_select_toggled))
133:         ui.register_handler('convert_removable_select_toggled',
134:                             method(:convert_removable_select_toggled))
135:         ui.register_handler('convert_network_select_toggled',
136:                             method(:convert_network_select_toggled))
137:         ui.register_handler('convert_button_clicked',
138:                             method(:convert_button_clicked))
139: 
140:         @state = nil
141:         set_state(UI_STATE_INVALID)
142:         update_values
143: 
144:         @ui = ui
145:         @converter = converter
146:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 50
 50:     def self.init(ui, converter)
 51:         # ListStores
 52:         @profiles   = ui.get_object('convert_profile_list')
 53:         @nics       = ui.get_object('convert_network_list')
 54:         @fixeds     = ui.get_object('convert_fixed_list')
 55:         @removables = ui.get_object('convert_removable_list')
 56: 
 57:         # Widgets
 58:         @profile    = ui.get_object('convert_profile')
 59:         @name       = ui.get_object('convert_name')
 60:         @cpus       = ui.get_object('convert_cpus')
 61:         @memory     = ui.get_object('convert_memory')
 62:         @editable   = ui.get_object('convert_editable')
 63:         @button     = ui.get_object('convert_button')
 64:         @status     = ui.get_object('convert_status')
 65: 
 66:         # Get initial values from converter
 67:         @name.text = converter.name
 68:         @cpus.text = converter.cpus.to_s
 69:         @memory.text = (converter.memory / 1024 / 1024).to_s
 70: 
 71:         # Populate profiles on connection
 72:         converter.on_connection { |conn|
 73:             conn.on_connect { |cb|
 74:                 conn.list_profiles { |profiles|
 75:                     cb.call(RuntimeError.new(_('Remote server does not ' +
 76:                                                'define any profiles in ' +
 77:                                                '/etc/virt-v2v.conf'))) \
 78:                         if profiles.kind_of?(Exception) or profiles.empty?
 79: 
 80:                     selected = @profile.active_iter
 81:                     selected = selected[CONVERT_PROFILE_NAME] \
 82:                         unless selected.nil?
 83: 
 84:                     @profiles.clear
 85:                     profiles.each { |i|
 86:                         profile = @profiles.append
 87:                         profile[CONVERT_PROFILE_NAME] = i
 88:                         @profile.active_iter = profile if i == selected
 89:                     }
 90: 
 91:                     cb.call(true)
 92:                 }
 93:             }
 94:         }
 95: 
 96:         VirtP2V::FixedBlockDevice.all_devices.each { |dev|
 97:             fixed = @fixeds.append
 98:             fixed[CONVERT_FIXED_CONVERT]    = true
 99:             fixed[CONVERT_FIXED_DEVICE]     = dev.device
100:             fixed[CONVERT_FIXED_PROGRESS]   = 0
101:         }
102: 
103:         VirtP2V::RemovableBlockDevice.all_devices.each { |dev|
104:             rem = @removables.append
105:             rem[CONVERT_REMOVABLE_CONVERT]  = true
106:             rem[CONVERT_REMOVABLE_DEVICE]   = dev.device
107:             rem[CONVERT_REMOVABLE_TYPE]     = dev.type
108:         }
109: 
110:         VirtP2V::NetworkDevice.all_devices.each { |dev|
111:             nic = @nics.append
112:             nic[CONVERT_NETWORK_CONVERT]    = dev.connected
113:             nic[CONVERT_NETWORK_DEVICE]     = dev.name
114:         }
115: 
116:         # Event handlers
117:         ui.register_handler('convert_profile_changed',
118:                             method(:update_values))
119:         ui.register_handler('convert_name_changed',
120:                             method(:update_values))
121:         ui.register_handler('convert_cpus_changed',
122:                             method(:convert_cpus_changed))
123:         ui.register_handler('convert_memory_changed',
124:                             method(:convert_memory_changed))
125:         ui.register_handler('convert_fixed_list_row_changed',
126:                             method(:convert_fixed_list_row_changed))
127:         ui.register_handler('convert_removable_list_row_changed',
128:                             method(:update_values))
129:         ui.register_handler('convert_network_list_row_changed',
130:                             method(:update_values))
131:         ui.register_handler('convert_fixed_select_toggled',
132:                             method(:convert_fixed_select_toggled))
133:         ui.register_handler('convert_removable_select_toggled',
134:                             method(:convert_removable_select_toggled))
135:         ui.register_handler('convert_network_select_toggled',
136:                             method(:convert_network_select_toggled))
137:         ui.register_handler('convert_button_clicked',
138:                             method(:convert_button_clicked))
139: 
140:         @state = nil
141:         set_state(UI_STATE_INVALID)
142:         update_values
143: 
144:         @ui = ui
145:         @converter = converter
146:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 264
264:     def self.reconnect
265:         @status.text = _('Reconnecting')
266:         @converter.connection.connect { |result|
267:             if result == true then
268:                 event(EV_CONNECTION, true)
269:             else
270:                 @status.text =
271:                     _'Failed to start virt-p2v-server on remote server'
272:                 event(EV_CONNECTION, false)
273:             end
274:         }
275:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 264
264:     def self.reconnect
265:         @status.text = _('Reconnecting')
266:         @converter.connection.connect { |result|
267:             if result == true then
268:                 event(EV_CONNECTION, true)
269:             else
270:                 @status.text =
271:                     _'Failed to start virt-p2v-server on remote server'
272:                 event(EV_CONNECTION, false)
273:             end
274:         }
275:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 207
207:     def self.set_state(state)
208:         # Don't do anything if state hasn't changed
209:         return if state == @state
210:         @state = state
211: 
212:         case @state
213:         when UI_STATE_INVALID
214:             @editable.sensitive = true
215:             @button.sensitive = false
216:         when UI_STATE_VALID
217:             @editable.sensitive = true
218:             @button.sensitive = true
219:         when UI_STATE_CONNECTING
220:             @status.text = _'Failed to start virt-p2v-server on remote server'
221:             @editable.sensitive = false
222:             @button.sensitive = false
223:         when UI_STATE_CONVERTING
224:             @editable.sensitive = false
225:             @button.sensitive = false
226:         when UI_STATE_COMPLETE
227:             @ui.active_page = 'success_win'
228: 
229:             # ... then leave this one as we hope to find it if we come back here
230:             set_state(UI_STATE_VALID)
231:         else
232:             raise "Attempt to set unexpected UI state: #{@state}"
233:         end
234:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 207
207:     def self.set_state(state)
208:         # Don't do anything if state hasn't changed
209:         return if state == @state
210:         @state = state
211: 
212:         case @state
213:         when UI_STATE_INVALID
214:             @editable.sensitive = true
215:             @button.sensitive = false
216:         when UI_STATE_VALID
217:             @editable.sensitive = true
218:             @button.sensitive = true
219:         when UI_STATE_CONNECTING
220:             @status.text = _'Failed to start virt-p2v-server on remote server'
221:             @editable.sensitive = false
222:             @button.sensitive = false
223:         when UI_STATE_CONVERTING
224:             @editable.sensitive = false
225:             @button.sensitive = false
226:         when UI_STATE_COMPLETE
227:             @ui.active_page = 'success_win'
228: 
229:             # ... then leave this one as we hope to find it if we come back here
230:             set_state(UI_STATE_VALID)
231:         else
232:             raise "Attempt to set unexpected UI state: #{@state}"
233:         end
234:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 283
283:     def self.update_values
284:         valid = nil
285:         begin
286:             # Check there's a profile selected
287:             profile = @profile.active_iter
288:             raise InvalidUIState if profile.nil?
289:             @converter.profile = profile[CONVERT_PROFILE_NAME]
290: 
291:             # Check there's a name set
292:             name = @name.text
293:             raise InvalidUIState if name.nil? || name.strip.length == 0
294:             @converter.name = name
295: 
296:             # Check cpus and memory are set and numeric
297:             cpus = @cpus.text
298:             raise InvalidUIState if cpus.nil?
299:             cpus = Integer(cpus) rescue nil
300:             raise InvalidUIState if cpus.nil?
301:             @converter.cpus = cpus
302: 
303:             memory = @memory.text
304:             raise InvalidUIState if memory.nil?
305:             memory = Integer(memory) rescue nil
306:             raise InvalidUIState if memory.nil?
307:             @converter.memory = memory * 1024 * 1024
308: 
309:             # Check that at least 1 fixed storage device is selected
310:             fixed = false
311:             @converter.disks.clear
312:             @fixeds.each { |model, path, iter|
313:                 if iter[CONVERT_FIXED_CONVERT] then
314:                     fixed = true
315:                     @converter.disks << iter[CONVERT_FIXED_DEVICE]
316:                 end
317:             }
318:             raise InvalidUIState unless fixed
319: 
320:             # Populate removables and nics, although these aren't required to be
321:             # selected for the ui state to be valid
322:             @converter.removables.clear
323:             @removables.each { |model, path, iter|
324:                 if iter[CONVERT_REMOVABLE_CONVERT] then
325:                     @converter.removables << iter[CONVERT_REMOVABLE_DEVICE]
326:                 end
327:             }
328:             @converter.nics.clear
329:             @nics.each { |model, path, iter|
330:                 if iter[CONVERT_NETWORK_CONVERT] then
331:                     @converter.nics << iter[CONVERT_NETWORK_DEVICE]
332:                 end
333:             }
334:         rescue InvalidUIState
335:             valid = false
336:         end
337:         valid = true if valid.nil?
338: 
339:         event(EV_VALID, valid)
340:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 283
283:     def self.update_values
284:         valid = nil
285:         begin
286:             # Check there's a profile selected
287:             profile = @profile.active_iter
288:             raise InvalidUIState if profile.nil?
289:             @converter.profile = profile[CONVERT_PROFILE_NAME]
290: 
291:             # Check there's a name set
292:             name = @name.text
293:             raise InvalidUIState if name.nil? || name.strip.length == 0
294:             @converter.name = name
295: 
296:             # Check cpus and memory are set and numeric
297:             cpus = @cpus.text
298:             raise InvalidUIState if cpus.nil?
299:             cpus = Integer(cpus) rescue nil
300:             raise InvalidUIState if cpus.nil?
301:             @converter.cpus = cpus
302: 
303:             memory = @memory.text
304:             raise InvalidUIState if memory.nil?
305:             memory = Integer(memory) rescue nil
306:             raise InvalidUIState if memory.nil?
307:             @converter.memory = memory * 1024 * 1024
308: 
309:             # Check that at least 1 fixed storage device is selected
310:             fixed = false
311:             @converter.disks.clear
312:             @fixeds.each { |model, path, iter|
313:                 if iter[CONVERT_FIXED_CONVERT] then
314:                     fixed = true
315:                     @converter.disks << iter[CONVERT_FIXED_DEVICE]
316:                 end
317:             }
318:             raise InvalidUIState unless fixed
319: 
320:             # Populate removables and nics, although these aren't required to be
321:             # selected for the ui state to be valid
322:             @converter.removables.clear
323:             @removables.each { |model, path, iter|
324:                 if iter[CONVERT_REMOVABLE_CONVERT] then
325:                     @converter.removables << iter[CONVERT_REMOVABLE_DEVICE]
326:                 end
327:             }
328:             @converter.nics.clear
329:             @nics.each { |model, path, iter|
330:                 if iter[CONVERT_NETWORK_CONVERT] then
331:                     @converter.nics << iter[CONVERT_NETWORK_DEVICE]
332:                 end
333:             }
334:         rescue InvalidUIState
335:             valid = false
336:         end
337:         valid = true if valid.nil?
338: 
339:         event(EV_VALID, valid)
340:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 342
342:     def self.valid?
343:         # Check there's a profile selected
344:         profile = @profile.active_iter
345:         return false if profile.nil?
346: 
347:         # Check there's a name set
348:         name = @name.text
349:         return false if name.nil?
350:         return false unless name.strip.length > 0
351: 
352:         # Check cpus and memory are set and numeric
353:         cpus = @cpus.text
354:         return false if cpus.nil?
355:         cpus = Integer(cpus) rescue nil
356:         return false if cpus.nil?
357: 
358:         memory = @memory.text
359:         return false if memory.nil?
360:         memory = Integer(memory) rescue nil
361:         return false if memory.nil?
362: 
363:         # Check that at least 1 fixed storage device is selected
364:         fixed = false
365:         @fixeds.each { |model, path, iter|
366:             if iter[CONVERT_FIXED_CONVERT] then
367:                 fixed = true
368:                 break
369:             end
370:         }
371:         return false unless fixed
372: 
373:         return true
374:     end

[Source]

     # File lib/virt-p2v/ui/convert.rb, line 342
342:     def self.valid?
343:         # Check there's a profile selected
344:         profile = @profile.active_iter
345:         return false if profile.nil?
346: 
347:         # Check there's a name set
348:         name = @name.text
349:         return false if name.nil?
350:         return false unless name.strip.length > 0
351: 
352:         # Check cpus and memory are set and numeric
353:         cpus = @cpus.text
354:         return false if cpus.nil?
355:         cpus = Integer(cpus) rescue nil
356:         return false if cpus.nil?
357: 
358:         memory = @memory.text
359:         return false if memory.nil?
360:         memory = Integer(memory) rescue nil
361:         return false if memory.nil?
362: 
363:         # Check that at least 1 fixed storage device is selected
364:         fixed = false
365:         @fixeds.each { |model, path, iter|
366:             if iter[CONVERT_FIXED_CONVERT] then
367:                 fixed = true
368:                 break
369:             end
370:         }
371:         return false unless fixed
372: 
373:         return true
374:     end

[Validate]