1.1 --- a/OpenSecurity/bin/opensecurityd.pyw Wed Jun 25 21:49:09 2014 +0200
1.2 +++ b/OpenSecurity/bin/opensecurityd.pyw Wed Jun 25 21:49:25 2014 +0200
1.3 @@ -231,6 +231,7 @@
1.4 return json.dumps(json.loads(res), indent = 4)
1.5
1.6
1.7 +
1.8 class os_sdvm:
1.9 """OpenSecurity '/sdvms/[VM]' handler
1.10
1.11 @@ -241,7 +242,7 @@
1.12 def GET(self, name):
1.13 log_call(web.ctx.environ)
1.14 global gvm_mgr
1.15 - return gvm_mgr.getVMInfo(name)
1.16 + return json.dumps(gvm_mgr.getVMInfo(name), indent = 4)
1.17
1.18 def DELETE(self, name):
1.19 log_call(web.ctx.environ)
1.20 @@ -311,7 +312,12 @@
1.21 """get the list of SDVMs"""
1.22 log_call(web.ctx.environ)
1.23 global gvm_mgr
1.24 - return gvm_mgr.listSDVM()
1.25 +
1.26 + d = {}
1.27 + for sdvm in gvm_mgr.listSDVM():
1.28 + d[sdvm] = gvm_mgr.getHostOnlyIP(sdvm)
1.29 +
1.30 + return json.dumps(d, indent = 4)
1.31
1.32 def POST(self):
1.33 """create a new SDVM"""
2.1 --- a/OpenSecurity/bin/ui/configure_dialog.py Wed Jun 25 21:49:09 2014 +0200
2.2 +++ b/OpenSecurity/bin/ui/configure_dialog.py Wed Jun 25 21:49:25 2014 +0200
2.3 @@ -180,7 +180,6 @@
2.4 self.ui.edtStatus.setEnabled(False);
2.5 self.ui.edtVersion.setEnabled(False);
2.6 self.ui.tvTemplate.clear()
2.7 - self.ui.tvMachines.clear()
2.8
2.9 try:
2.10
2.11 @@ -202,15 +201,53 @@
2.12 i.setText(2, str(j['initial_template']['size']))
2.13 i.setText(3, j['initial_template']['path'])
2.14
2.15 - # get machines
2.16 - j = json.load(urllib2.urlopen('http://127.0.0.1:8080/vms'))
2.17 - for m in j:
2.18 - i = QtGui.QTreeWidgetItem(self.ui.tvMachines)
2.19 - i.setText(0, m)
2.20 -
2.21 except:
2.22 pass
2.23
2.24 + # trigger machine update
2.25 + self.update_machines()
2.26 +
2.27 +
2.28 + def update_machines(self):
2.29 +
2.30 + """Update the machines view"""
2.31 + self.ui.tvMachines.clear()
2.32 + self._icon_machine = QtGui.QIcon()
2.33 + self._icon_machine.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/cpu.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
2.34 + self._icon_property = QtGui.QIcon()
2.35 + self._icon_property.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/configure.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
2.36 + self._icon_network = QtGui.QIcon()
2.37 + self._icon_network.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/network-workgroup.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
2.38 +
2.39 +
2.40 + #try:
2.41 +
2.42 + # get machines
2.43 + machines = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms'))
2.44 + for m in machines:
2.45 + i = QtGui.QTreeWidgetItem(self.ui.tvMachines)
2.46 + i.setIcon(0, self._icon_machine)
2.47 + i.setText(0, m)
2.48 + i.setIcon(1, self._icon_network)
2.49 + i.setText(1, machines[m])
2.50 +
2.51 +
2.52 + properties = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms/' + m))
2.53 + for p in properties:
2.54 + j = QtGui.QTreeWidgetItem(i)
2.55 + j.setIcon(0, self._icon_property)
2.56 + j.setText(0, p)
2.57 + j.setText(1, properties[p])
2.58 +
2.59 + j.setIcon(0, self._icon_network)
2.60 + j.setText(0, 'ip')
2.61 + j.setText(1, machines[m])
2.62 +
2.63 +
2.64 + #except:
2.65 + # pass
2.66 +
2.67 +
2.68
2.69 def update_progress(self):
2.70