-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfowindow.py
131 lines (94 loc) · 3.33 KB
/
infowindow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
from gi.repository import Gtk, GLib, Gio
import json
import params
class InfoWindow(Gtk.Window):
def __init__(self, instance_name):
info = params.machines[instance_name]
Gtk.Window.__init__(self, title="Machine info: " + instance_name)
self.instance_name = instance_name
self.set_border_width(10)
self.set_position(Gtk.WindowPosition.CENTER)
hbox = Gtk.Box(spacing=6)
self.add(hbox)
listbox = Gtk.ListBox()
listbox.set_selection_mode(Gtk.SelectionMode.NONE)
hbox.pack_start(listbox, True, True, 0)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("Primary Node:")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(info['pnode'])
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("Secondary Nodes:")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(','.join(info['snodes']))
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("Bridges:")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(','.join(info['nic.bridges']))
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("Memory (Mb):")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(str(info['beparams']['memory']))
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
disks = info['disk.sizes']
i = 0
for disk in disks:
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("Disk Size #"+str(i)+" (Mb):")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(str(info['disk.sizes'][i]))
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
i=i+1
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
label = Gtk.Label("vcpus:")
hbox.pack_start(label, True, True, 0)
self.input_ip = Gtk.Entry()
self.input_ip.set_text(str(info['beparams']['vcpus']))
hbox.pack_start(self.input_ip, False, True, 0)
listbox.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
self.reboot_button = Gtk.Button(label="Reboot")
self.reboot_button.connect("clicked", self.reboot)
hbox.pack_start(self.reboot_button, True, True, 0)
if info['status']!="running":
self.reboot_button.set_sensitive(False)
listbox.add(row)
row = Gtk.ListBoxRow()
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
row.add(hbox)
self.ok_button = Gtk.Button(label="Ok")
self.ok_button.connect("clicked", self.close)
hbox.pack_start(self.ok_button, True, True, 0)
listbox.add(row)
def close(self, widget):
self.hide()
def reboot(self, widget):
params.conn.reboot(self.instance_name)
self.hide()