54
58
err_dial.set_parent(parent)
55
59
err_dial = err_dial
61
############################################################
62
# Helpers for shared storage UI between create/addhardware #
63
############################################################
65
def set_sparse_tooltip(widget):
66
sparse_str = _("Fully allocating storage will take longer now, "
67
"but the OS install phase will be quicker. \n\n"
68
"Skipping allocation can also cause space issues on "
69
"the host machine, if the maximum image size exceeds "
70
"available storage space.")
71
util.tooltip_wrapper(widget, sparse_str)
73
def host_disk_space(conn, config):
74
pool = util.get_default_pool(conn)
75
path = util.get_default_dir(conn, config)
79
# FIXME: make sure not inactive?
80
# FIXME: use a conn specific function after we send pool-added
81
pool = virtinst.util.lookup_pool_by_path(conn.vmm, path)
84
avail = int(virtinst.util.get_xml_path(pool.XMLDesc(0),
87
elif not conn.is_remote():
88
vfs = os.statvfs(os.path.dirname(path))
89
avail = vfs[statvfs.F_FRSIZE] * vfs[statvfs.F_BAVAIL]
91
return float(avail / 1024.0 / 1024.0 / 1024.0)
93
def host_space_tick(conn, config, widget):
94
max_storage = host_disk_space(conn, config)
96
def pretty_storage(size):
97
return "%.1f Gb" % float(size)
99
hd_label = ("%s available in the default location" %
100
pretty_storage(max_storage))
101
hd_label = ("<span color='#484848'>%s</span>" % hd_label)
102
widget.set_markup(hd_label)
106
#####################################################
107
# Hardware model list building (for details, addhw) #
108
#####################################################
109
def build_video_combo(vm, video_dev, no_default=False):
110
video_dev_model = gtk.ListStore(str)
111
video_dev.set_model(video_dev_model)
112
text = gtk.CellRendererText()
113
video_dev.pack_start(text, True)
114
video_dev.add_attribute(text, 'text', 0)
115
video_dev_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
117
tmpdev = virtinst.VirtualVideoDevice(vm.get_connection().vmm)
118
for m in tmpdev.model_types:
119
if m == tmpdev.MODEL_DEFAULT and no_default:
121
video_dev_model.append([m])
122
if len(video_dev_model) > 0:
123
video_dev.set_active(0)
125
def build_sound_combo(vm, combo, no_default=False):
126
dev_model = gtk.ListStore(str)
127
combo.set_model(dev_model)
128
text = gtk.CellRendererText()
129
combo.pack_start(text, True)
130
combo.add_attribute(text, 'text', 0)
131
dev_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
133
for m in virtinst.VirtualAudio.MODELS:
134
if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
136
dev_model.append([m])
137
if len(dev_model) > 0:
140
def build_watchdogmodel_combo(vm, combo, no_default=False):
141
dev_model = gtk.ListStore(str)
142
combo.set_model(dev_model)
143
text = gtk.CellRendererText()
144
combo.pack_start(text, True)
145
combo.add_attribute(text, 'text', 0)
146
dev_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
148
for m in virtinst.VirtualWatchdog.MODELS:
149
if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
151
dev_model.append([m])
152
if len(dev_model) > 0:
155
def build_watchdogaction_combo(vm, combo, no_default=False):
156
dev_model = gtk.ListStore(str, str)
157
combo.set_model(dev_model)
158
text = gtk.CellRendererText()
159
combo.pack_start(text, True)
160
combo.add_attribute(text, 'text', 1)
161
dev_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
163
for m in virtinst.VirtualWatchdog.ACTIONS:
164
if m == virtinst.VirtualWatchdog.ACTION_DEFAULT and no_default:
166
dev_model.append([m, virtinst.VirtualWatchdog.get_action_desc(m)])
167
if len(dev_model) > 0:
170
def build_netmodel_combo(vm, combo):
171
dev_model = gtk.ListStore(str, str)
172
combo.set_model(dev_model)
173
text = gtk.CellRendererText()
174
combo.pack_start(text, True)
175
combo.add_attribute(text, 'text', 1)
176
dev_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
178
populate_netmodel_combo(vm, combo)
181
def populate_netmodel_combo(vm, combo):
182
model = combo.get_model()
186
model.append([None, _("Hypervisor default")])
188
mod_list = [ "rtl8139", "ne2k_pci", "pcnet" ]
189
if vm.get_hv_type() == "kvm":
190
mod_list.append("e1000")
191
mod_list.append("virtio")
58
198
#######################################################################
59
199
# Widgets for listing network device options (in create, addhardware) #
83
def init_network_list(net_list):
84
# [ network type, source name, label, sensitive? ]
85
net_model = gtk.ListStore(str, str, str, bool)
223
def init_network_list(net_list, bridge_box):
224
# [ network type, source name, label, sensitive?, net is active,
226
net_model = gtk.ListStore(str, str, str, bool, bool, bool)
86
227
net_list.set_model(net_model)
88
if isinstance(net_list, gtk.ComboBox):
91
net_col = gtk.TreeViewColumn()
92
net_list.append_column(net_col)
229
net_list.connect("changed", net_list_changed, bridge_box)
94
231
text = gtk.CellRendererText()
95
net_col.pack_start(text, True)
96
net_col.add_attribute(text, 'text', 2)
97
net_col.add_attribute(text, 'sensitive', 3)
232
net_list.pack_start(text, True)
233
net_list.add_attribute(text, 'text', 2)
234
net_list.add_attribute(text, 'sensitive', 3)
236
def net_list_changed(net_list, bridge_box):
237
active = net_list.get_active()
241
row = net_list.get_model()[active]
244
bridge_box.set_property("visible", show_bridge)
246
def get_network_selection(net_list, bridge_entry):
247
row = net_list.get_model()[net_list.get_active()]
250
net_check_bridge = row[5]
253
net_type = VirtualNetworkInterface.TYPE_BRIDGE
254
net_src = bridge_entry.get_text()
256
return net_type, net_src
99
258
def populate_network_list(net_list, conn):
100
259
model = net_list.get_model()
195
361
# If not, use 'default' network
196
362
# If not present, use first list entry
197
363
# If list empty, use no network devices
198
365
label = brIdxLabel or netIdxLabel
199
367
for idx in range(len(model)):
369
is_inactive = not row[4]
202
371
if row[2] == label:
373
return_warn = is_inactive
206
376
if row[3] == True:
378
return_warn = is_inactive
210
model.insert(0, [None, None, _("No networking."), True])
382
row = build_row(None, None, _("No networking."), True, False)
386
# After all is said and done, add a manual bridge option
387
manual_row = build_row(None, None, _("Specify shared device name"),
388
True, False, manual_bridge=True)
389
model.append(manual_row)
213
391
set_active(default)
215
394
def validate_network(parent, conn, nettype, devname, macaddr, model=None):
216
395
set_error_parent(parent)
289
468
# Populate media widget (choosecd, create) #
290
469
############################################
292
def init_mediadev_combo(widget, empty_sensitive=False):
471
def init_mediadev_combo(widget):
293
472
# [Device path, pretty label, has_media?, device key, media key,
295
model = gtk.ListStore(str, str, bool, str, str)
473
# vmmMediaDevice, is valid device]
474
model = gtk.ListStore(str, str, bool, str, str, bool)
296
475
widget.set_model(model)
299
478
text = gtk.CellRendererText()
300
479
widget.pack_start(text, True)
301
widget.add_attribute(text, 'text', 1)
302
if not empty_sensitive:
303
widget.add_attribute(text, 'sensitive', 2)
480
widget.add_attribute(text, 'text', OPTICAL_LABEL)
481
widget.add_attribute(text, 'sensitive', OPTICAL_IS_VALID)
305
483
def populate_mediadev_combo(conn, widget, devtype):
308
widget.get_model().clear()
486
model = widget.get_model()
488
set_mediadev_default(model)
310
490
sigs.append(conn.connect("mediadev-added", mediadev_added, widget, devtype))
311
491
sigs.append(conn.connect("mediadev-removed", mediadev_removed, widget))