1 # Copyright (c) 2010 Citrix Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from OVEStandard import *
17 from OVEConfig import *
18 from OVEFetch import *
20 from OVEConfigWindow import *
21 from OVEFlowWindow import *
22 from OVELogWindow import *
23 from OVEMainWindow import *
28 self.app.setOrganizationName("Citrix_Systems_Inc")
29 self.app.setOrganizationDomain("citrix.com")
30 self.app.setApplicationName("ovsdbmonitor")
33 self.configWindow = None
36 if len(OVEConfig.Inst().hosts) < 1:
38 QtGui.QMessageBox.information(
39 None, "OVSDB Monitor",
40 "This application browses openvswitch databases on remote hosts. Please add one or more openvswitch hosts to continue")
41 self.loadMainWindows()
42 self.loadFlowWindows()
43 if len(self.mainWindows) == 0 and len(self.flowWindows) == 0:
46 # Reactor must be started after the event loop is running, so use a zero timeout
47 QtCore.QTimer.singleShot(0, OVEFetch.startReactor)
48 OVELog("Application started")
49 retCode = self.app.exec_()
51 for mainWindow in self.mainWindows:
52 if mainWindow.isVisible():
53 mainWindow.saveSettings(index)
54 index += 1 # Indent intentional
55 OVEMainWindow.terminateSettings(index)
57 for flowWindow in self.flowWindows:
58 if flowWindow.isVisible():
59 flowWindow.saveSettings(index)
60 index += 1 # Indent intentional
61 OVEFlowWindow.terminateSettings(index)
62 self.logWindow.saveSettings()
67 def showLog(self, value):
74 def showConfig(self, value):
77 self.configWindow = OVEConfigWindow(self)
78 self.configWindow.show()
80 self.configWindow.hide()
82 def newMainWindow(self, loadIndex = None):
83 self.mainWindows.append(OVEMainWindow(self, loadIndex))
84 self.mainWindows[-1].show()
86 def newFlowWindow(self, loadIndex = None):
87 self.flowWindows.append(OVEFlowWindow(self, loadIndex))
88 self.flowWindows[-1].show()
90 def newLogWindow(self):
91 self.logWindow = OVELogWindow(self)
93 def loadMainWindows(self):
94 for loadIndex in range(0, 100):
95 if OVEMainWindow.isLoadable(loadIndex):
96 self.newMainWindow(loadIndex)
100 def loadFlowWindows(self):
101 for loadIndex in range(0, 100):
102 if OVEFlowWindow.isLoadable(loadIndex):
103 self.newFlowWindow(loadIndex)