OpenSecurity/bin/ui/configure_dialog.py
changeset 203 0cc33b647a4e
parent 199 26b9a95b0da1
child 204 0c3136908f4f
     1.1 --- a/OpenSecurity/bin/ui/configure_dialog.py	Wed Jun 25 19:21:04 2014 +0200
     1.2 +++ b/OpenSecurity/bin/ui/configure_dialog.py	Wed Jun 25 20:46:31 2014 +0200
     1.3 @@ -180,7 +180,6 @@
     1.4          self.ui.edtStatus.setEnabled(False);
     1.5          self.ui.edtVersion.setEnabled(False);
     1.6          self.ui.tvTemplate.clear()
     1.7 -        self.ui.tvMachines.clear()
     1.8  
     1.9          try:
    1.10  
    1.11 @@ -202,15 +201,52 @@
    1.12              i.setText(2, str(j['initial_template']['size']))
    1.13              i.setText(3, j['initial_template']['path'])
    1.14              
    1.15 -            # get machines
    1.16 -            j = json.load(urllib2.urlopen('http://127.0.0.1:8080/vms'))
    1.17 -            for m in j:
    1.18 -                i = QtGui.QTreeWidgetItem(self.ui.tvMachines)
    1.19 -                i.setText(0, m)
    1.20 -
    1.21          except:
    1.22              pass
    1.23  
    1.24 +        # trigger machine update
    1.25 +        self.update_machines()
    1.26 +
    1.27 +
    1.28 +    def update_machines(self):
    1.29 +
    1.30 +        """Update the machines view"""
    1.31 +        self.ui.tvMachines.clear()
    1.32 +        self._icon_machine = QtGui.QIcon()
    1.33 +        self._icon_machine.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/cpu.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
    1.34 +        self._icon_property = QtGui.QIcon()
    1.35 +        self._icon_property.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/configure.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
    1.36 +        self._icon_network = QtGui.QIcon()
    1.37 +        self._icon_network.addPixmap(QtGui.QPixmap(":/opensecurity/gfx/network-workgroup.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
    1.38 +
    1.39 +
    1.40 +        #try:
    1.41 +
    1.42 +        # get machines
    1.43 +        machines = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms'))
    1.44 +        for m in machines:
    1.45 +            i = QtGui.QTreeWidgetItem(self.ui.tvMachines)
    1.46 +            i.setIcon(0, self._icon_machine)
    1.47 +            i.setText(0, m)
    1.48 +
    1.49 +            properties = json.load(urllib2.urlopen('http://127.0.0.1:8080/sdvms/' + m))
    1.50 +            for p in properties:
    1.51 +                j = QtGui.QTreeWidgetItem(i)
    1.52 +                j.setIcon(0, self._icon_property)
    1.53 +                j.setText(0, p)
    1.54 +                j.setText(1, properties[p])
    1.55 +
    1.56 +            ip = urllib2.urlopen('http://127.0.0.1:8080/sdvms/' + m + '/ip')   
    1.57 +            j = QtGui.QTreeWidgetItem(i)
    1.58 +            j.setIcon(0, self._icon_network)
    1.59 +            j.setText(0, 'ip')
    1.60 +            j.setText(1, ip.read())
    1.61 +
    1.62 +
    1.63 +        #except:
    1.64 +        #    pass
    1.65 +
    1.66 +
    1.67  
    1.68      def update_progress(self):
    1.69