blob: 40b1df9ec1c14599e008e4a9193e207c39f8622b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
'''
Implements the rtsadmin root UI.
This file is part of RTSAdmin Community Edition.
Copyright (c) 2011 by RisingTide Systems LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, version 3 (AGPLv3).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from rtslib import RTSRoot
from ui_node import UINode
from ui_target import UIFabricModule
from ui_backstore import UIBackstores
class UIRoot(UINode):
'''
The rtsadmin hierarchy root node.
'''
def __init__(self):
self.loaded = False
UINode.__init__(self)
self.name = '/'
def refresh(self):
'''
Refreshes the tree of target fabric modules.
'''
self._children = set([])
self.add_child(UIBackstores())
if not self.loaded:
self.log.debug("Refreshing in non-loaded mode.")
for fabric_module in RTSRoot().fabric_modules:
if fabric_module:
self.log.info("Using %s fabric module." \
% fabric_module.name)
self.add_child(UIFabricModule(fabric_module))
else:
try:
for step in fabric_module.load(yield_steps=True):
(action, taken, desc) = step
if taken:
self.log.info(desc)
self.log.info("Done loading %s fabric module." \
% fabric_module.name)
except Exception, msg:
self.log.warning("Can't load fabric module %s."
% fabric_module.name)
self.log.debug(msg)
else:
self.add_child(UIFabricModule(fabric_module))
self.loaded = True
else:
self.log.debug("Refreshing in loaded mode.")
for fabric_module in RTSRoot().loaded_fabric_modules:
self.log.debug("Loading %s." % fabric_module.name)
self.add_child(UIFabricModule(fabric_module))
def ui_command_version(self):
'''
Displays the rtsadmin and support libraries versions.
'''
from rtslib import __version__ as rtslib_version
from rtsadmin import __version__ as rtsadmin_version
from configshell import __version__ as configshell_version
self.log.info("Running rtsadmin version %s" % rtsadmin_version)
self.log.info("Using rtslib version %s" % rtslib_version)
self.log.info("Using configshell version %s" % configshell_version)
|