def getSelection(self, selected, deselected): try: row = selected.indexes()[0].row() ioc = self.model.data(self.model.index(row, MyModel.IOCNAME), QtCore.Qt.EditRole).value() host = self.model.data(self.model.index(row, MyModel.HOST), QtCore.Qt.EditRole).value() if ioc == self.currentIOC: return self.disconnectPVs() self.currentIOC = ioc self.ui.IOCname.setText(ioc) base = utils.getBaseName(ioc) self.currentBase = base if base != None: self.dopv(base + ":HEARTBEAT", self.ui.heartbeat, "%d") self.dopv(base + ":TOD", self.ui.tod, "%s") self.dopv(base + ":STARTTOD", self.ui.boottime, "%s") pyca.flush_io() d = utils.netconfig(host) try: self.ui.location.setText(d['location']) except: self.ui.location.setText("") try: self.ui.description.setText(d['description']) except: self.ui.description.setText("") except: pass
def connectIOC(self, index): if isinstance(index, QModelIndex): entry = self.cfglist[index.row()] else: entry = None for l in self.cfglist: if l['id'] == index: entry = l break if entry == None: return # # Sigh. Because we want to do authentication, we have a version of kerberos on our path, # but unfortunately it doesn't play nice with the library that telnet uses! Therefore, # we have to get rid of LD_LIBRARY_PATH here. # try: if entry['hard']: for l in utils.netconfig(entry['id'])['console port dn'].split(','): if l[:7] == 'cn=port': port = 2000 + int(l[7:]) if l[:7] == 'cn=digi': host = l[3:] if l[:5] == 'cn=ts': host = l[3:] else: host = entry['host'] port = entry['port'] self.runCommand(None, entry['id'], "unsetenv LD_LIBRARY_PATH ; telnet %s %s" % (host, port)) except KeyError: print "Dict key error while setting up telnet interface for: %s" % entry except: print "Unspecified error while setting up telnet interface"
def rebootServer(self, index): if isinstance(index, QModelIndex): entry = self.cfglist[index.row()] else: entry = None for l in self.cfglist: if l['id'] == index: entry = l break if entry == None: return if entry['hard']: utils.rebootHIOC(entry['id']) return host = entry['host'] d = QDialog(); d.setWindowTitle("Reboot Server " + host) d.layout = QVBoxLayout(d) ihost = host + '-ipmi' nc = utils.netconfig(ihost) try: nc['name'] except: label = QLabel(d) label.setText("Cannot find IPMI address for host %s!" % host) d.layout.addWidget(label) d.buttonBox = QDialogButtonBox(d) d.buttonBox.setOrientation(Qt.Horizontal) d.buttonBox.setStandardButtons(QDialogButtonBox.Ok) d.layout.addWidget(d.buttonBox) d.buttonBox.accepted.connect(d.accept) d.exec_() return llist = [] label = QLabel(d) label.setText("Rebooting " + host + " will temporarily stop the following IOCs:") d.layout.addWidget(label) llist.append(label) for l in self.cfglist: if l['host'] == host: label = QLabel(d) if l['alias'] != "": label.setText(" " + l['alias'] + " (" + l['id'] + ")"); else: label.setText(" " + l['id']); d.layout.addWidget(label) llist.append(label) label = QLabel(d) label.setText("Proceed?") d.layout.addWidget(label) llist.append(label) d.buttonBox = QDialogButtonBox(d) d.buttonBox.setOrientation(Qt.Horizontal) d.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) d.layout.addWidget(d.buttonBox) d.buttonBox.accepted.connect(d.accept) d.buttonBox.rejected.connect(d.reject) if d.exec_() == QDialog.Accepted: utils.rebootServer(ihost)