# HG changeset patch # User Oliver Maurhart # Date 1403725765 -7200 # Node ID be839e4a1370940e64a2fe8d54fd638e1699dc8f # Parent b16c57614eee81513db85cdff18ebc28b8cda1a7# Parent 0c3136908f4f7cfd938650f21bb5613090b08898 merge diff -r b16c57614eee -r be839e4a1370 OpenSecurity/bin/opensecurityd.pyw --- a/OpenSecurity/bin/opensecurityd.pyw Wed Jun 25 21:49:09 2014 +0200 +++ b/OpenSecurity/bin/opensecurityd.pyw Wed Jun 25 21:49:25 2014 +0200 @@ -231,6 +231,7 @@ return json.dumps(json.loads(res), indent = 4) + class os_sdvm: """OpenSecurity '/sdvms/[VM]' handler @@ -241,7 +242,7 @@ def GET(self, name): log_call(web.ctx.environ) global gvm_mgr - return gvm_mgr.getVMInfo(name) + return json.dumps(gvm_mgr.getVMInfo(name), indent = 4) def DELETE(self, name): log_call(web.ctx.environ) @@ -311,7 +312,12 @@ """get the list of SDVMs""" log_call(web.ctx.environ) global gvm_mgr - return gvm_mgr.listSDVM() + + d = {} + for sdvm in gvm_mgr.listSDVM(): + d[sdvm] = gvm_mgr.getHostOnlyIP(sdvm) + + return json.dumps(d, indent = 4) def POST(self): """create a new SDVM""" diff -r b16c57614eee -r be839e4a1370 OpenSecurity/bin/ui/configure_dialog.py --- a/OpenSecurity/bin/ui/configure_dialog.py Wed Jun 25 21:49:09 2014 +0200 +++ b/OpenSecurity/bin/ui/configure_dialog.py Wed Jun 25 21:49:25 2014 +0200 @@ -180,7 +180,6 @@ self.ui.edtStatus.setEnabled(False); self.ui.edtVersion.setEnabled(False); self.ui.tvTemplate.clear() - self.ui.tvMachines.clear() try: @@ -202,15 +201,53 @@ i.setText(2, str(j['initial_template']['size'])) i.setText(3, j['initial_template']['path']) - # get machines - j = json.load(urllib2.urlopen('http://127.0.0.1:8080/vms')) - for m in j: - i = QtGui.QTreeWidgetItem(self.ui.tvMachines) - i.setText(0, m) - except: pass + # trigger machine update + self.update_machines() + + + def update_machines(self): + + """Update the machines view""" + self.ui.tvMachines.clear() + self._icon_machine = QtGui.QIcon() + self._icon_machine.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/cpu.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self._icon_property = QtGui.QIcon() + self._icon_property.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/configure.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self._icon_network = QtGui.QIcon() + self._icon_network.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/network-workgroup.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + + + #try: + + # get machines + machines = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms')) + for m in machines: + i = QtGui.QTreeWidgetItem(self.ui.tvMachines) + i.setIcon(0, self._icon_machine) + i.setText(0, m) + i.setIcon(1, self._icon_network) + i.setText(1, machines[m]) + + + properties = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms/' + m)) + for p in properties: + j = QtGui.QTreeWidgetItem(i) + j.setIcon(0, self._icon_property) + j.setText(0, p) + j.setText(1, properties[p]) + + j.setIcon(0, self._icon_network) + j.setText(0, 'ip') + j.setText(1, machines[m]) + + + #except: + # pass + + def update_progress(self):