]>
git.proxmox.com Git - mirror_ovs.git/blob - ovsdb/ovsdbmonitor/OVEConfig.py
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.
15 from OVEStandard
import *
16 from OVELogger
import *
18 class OVEConfig(QtCore
.QObject
):
21 QtCore
.QObject
.__init
__(self
)
23 self
.logTraffic
= True
24 self
.truncateUuids
= True
29 if cls
.instance
is None:
30 cls
.instance
= OVEConfig()
31 cls
.instance
.loadConfig()
34 def hostFromUuid(self
, uuid
):
35 for host
in self
.hosts
:
36 if host
['uuid'] == uuid
:
38 OVELog("+++ Couldn't find host '"+str(uuid
)+"' in "+str([x
['uuid'] for x
in self
.hosts
]))
42 settings
= QtCore
.QSettings()
43 settings
.setValue('config/hosts', QVariant(json
.JsonWriter().write(self
.hosts
)))
44 settings
.setValue('config/logTraffic', QVariant(self
.logTraffic
))
45 settings
.setValue('config/truncateUuids', QVariant(self
.truncateUuids
))
46 settings
.setValue('config/ssgList', QVariant(json
.JsonWriter().write(self
.ssgList
)))
51 settings
= QtCore
.QSettings()
52 jsonText
= unicode(settings
.value('config/hosts', QVariant('[]')).toString())
53 self
.hosts
= json
.JsonReader().read(str(jsonText
))
54 self
.logTraffic
= settings
.value('config/logTraffic', QVariant(False)).toBool()
55 self
.truncateUuids
= settings
.value('config/truncateUuids', QVariant(False)).toBool()
56 jsonText
= unicode(settings
.value('config/ssgList', QVariant('[]')).toString())
57 self
.ssgList
= json
.JsonReader().read(str(jsonText
))
58 if len(self
.ssgList
) == 0:
71 r
'!ff:ff:ff:ff:ff:ff',
74 r
'255\.255\.255\.255',
75 r
'!255\.255\.255\.255',
84 def emitUpdated(self
):
85 self
.emit(QtCore
.SIGNAL("configUpdated()"))