#from sfa.util.rspecHelper import RSpec
from sfa.rspecs.rspec_parser import parse_rspec
from sface.config import config
-from sface.sfirenew import SfiRenewer
+from sface.sfirenew import RenewWindow
from sface.sfiprocess import SfiProcess
from sface.screens.sfascreen import SfaScreen
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setToolTip("Double click on a row to change its status. Right click on a host to add a tag.")
+ def keyPressEvent(self, event):
+ if (event.key() == Qt.Key_Space):
+ self.toggleSelection()
+ else:
+ QTreeView.keyPressEvent(self, event)
+
def mouseDoubleClickEvent(self, event):
+ self.toggleSelection()
+
+ def toggleSelection(self):
index = self.currentIndex()
model = index.model()
status_index = model.index(index.row(), MEMBERSHIP_STATUS_COLUMN, index.parent())
tagstring = QString("%s: %s" % (tagname, value))
tagItem = QStandardItem(tagstring)
status = QStandardItem(QString(tag_status['add']))
- nodeItem.appendRow([tagItem, status])
+ nodeItem.appendRow([tagItem, QStandardItem(QString("")), status])
elif status_data in (node_status['out'], node_status['remove']):
QMessageBox.warning(self, "Not selected", "Can only add tags to selected nodes")
self.updateView()
def submitFinished(self):
- self.setStatus("<font color='green'>Slice data submitted.</font>")
- QTimer.singleShot(1000, self.refresh)
+ faultString = self.process.getFaultString()
+ if not faultString:
+ self.setStatus("<font color='green'>Slice data submitted.</font>")
+ else:
+ self.setStatus("<font color='red'>Slice submit failed: %s</font>" % (faultString))
+
+ # no need to do that anymore
+ # QTimer.singleShot(1000, self.refresh)
+ self.updateView()
+ self.parent().signalAll("rspecUpdated")
def refreshFinished(self):
self.setStatus("<font color='green'>Slice data refreshed.</font>", timeout=5000)
def renew(self):
dlg = RenewWindow(parent=self)
- if (dlg.exec_() == QDialog.Accepted):
- self.setStatus("Renewing Slice.")
-
- self.renewProcess = SfiRenewer(config.getSlice(), dlg.get_new_expiration(), self)
- self.connect(self.renewProcess, SIGNAL('finished()'), self.renewFinished)
-
- def renewFinished(self):
- if self.renewProcess.statusMsg:
- self.setStatus("Renew " + self.renewProcess.status + ": " + self.renewProcess.statusMsg)
- else:
- self.setStatus("Renew " + self.renewProcess.status)
- self.disconnect(self.renewProcess, SIGNAL('finished()'), self.renewFinished)
- self.renewProcess = None
+ dlg.exec_()
def refresh(self):
if not config.getSlice():
self.disconnect(self.process, SIGNAL('finished()'), self.submitFinished)
self.connect(self.process, SIGNAL('finished()'), self.refreshFinished)
- self.process.getRSpecFromSM()
+ self.process.retrieveRspec()
self.setStatus("Refreshing slice data. This will take some time...")
def updateView(self):
def nodeSelectionChanged(self, hostname):
self.parent().nodeSelectionChanged(hostname)
-class RenewWindow(QDialog):
- def __init__(self, parent=None):
- super(RenewWindow, self).__init__(parent)
- self.setWindowTitle("Renew Slivers")
-
- self.duration = QComboBox()
-
- self.expirations = []
-
- durations = ( (1, "One Week"), (2, "Two Weeks"), (3, "Three Weeks"), (4, "One Month") )
-
- now = datetime.datetime.utcnow()
- for (weeks, desc) in durations:
- exp = now + datetime.timedelta(days = weeks * 7)
- desc = desc + " " + exp.strftime("%Y-%m-%d %H:%M:%S")
- self.expirations.append(exp)
- self.duration.addItem(desc)
-
- self.duration.setCurrentIndex(0)
-
- buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
- buttonBox.button(QDialogButtonBox.Ok).setDefault(True)
-
- layout = QVBoxLayout()
- layout.addWidget(self.duration)
- layout.addWidget(buttonBox)
- self.setLayout(layout)
-
- self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
- self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
-
- def accept(self):
- QDialog.accept(self)
-
- def get_new_expiration(self):
- index = self.duration.currentIndex()
- return self.expirations[index]
-
class MainScreen(SfaScreen):
def __init__(self, parent):
SfaScreen.__init__(self, parent)