Merge lp:~blake-rouse/maas/add-version-to-ui into lp:~maas-committers/maas/trunk
- add-version-to-ui
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Blake Rouse |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3597 |
Proposed branch: | lp:~blake-rouse/maas/add-version-to-ui |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
392 lines (+332/-2) 6 files modified
required-packages/base (+1/-0) src/maasserver/context_processors.py (+6/-0) src/maasserver/templates/maasserver/base.html (+1/-1) src/maasserver/templates/maasserver/index.html (+1/-1) src/maasserver/utils/tests/test_version.py (+194/-0) src/maasserver/utils/version.py (+129/-0) |
To merge this branch: | bzr merge lp:~blake-rouse/maas/add-version-to-ui |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raphaël Badin (community) | Approve | ||
Review via email:
|
Commit message
Show the installed version of MAAS on the WebUI.
This will show the installed version of the maas-region-
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Christian Reis (kiko) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raphaël Badin (rvb) wrote : | # |
Feel free to disagree but I feel the caching is done at the wrong level in this branch. The result is that apt will be called a lot when running from a branch.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Blake Rouse (blake-rouse) wrote : | # |
Okay I made the required fixes and now have the documentation link working based on the version. More work then I wanted to do for this branch, but your welcome! :-)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gavin Panella (allenap) wrote : | # |
A few comments (not a review):
- Instead of searching for a particular package name, how about
searching for the package that owns the current file? That's more
likely to be correct *and* it reduces the coupling between upstream
and the package. For example:
import inspect
from os.path import realpath
import apt
def find_package_
# This is quicker than you might think.
for pkg in cache:
if pkg.is_installed:
if filename in pkg.installed_
cache = apt.Cache()
source = inspect.
package = find_package_
if package is None:
pass # Check for branch info.
else:
installed = package.installed
# Use the *source* package name and version.
desc = "%s %s" % (installed.
- When reporting the branch version, also include the branch's location,
or its name. This is less important to the developer, but could be
very useful in screen-grabs, for example.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Blake Rouse (blake-rouse) wrote : | # |
Those are all great suggestions but I don't want to spend anymore time on this branch. There are many more important things that need to be completed and spending more time on this branch would be a waste of the time I have available to complete more important features.
I just did this quickly to fix a annoying bug, that will help the UI.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raphaël Badin (rvb) wrote : | # |
> Those are all great suggestions but I don't want to spend anymore time on this branch.
All right then… I would have liked to see the caching problem fixed but it isn't critical.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Blake Rouse (blake-rouse) wrote : | # |
The caching problem is fixed. It will set the MAAS_VERSION to "", causing it not to be reloaded after the first call.
Preview Diff
1 | === modified file 'required-packages/base' | |||
2 | --- required-packages/base 2015-01-20 15:56:10 +0000 | |||
3 | +++ required-packages/base 2015-03-03 16:09:28 +0000 | |||
4 | @@ -13,6 +13,7 @@ | |||
5 | 13 | libjs-angularjs | 13 | libjs-angularjs |
6 | 14 | libpq-dev | 14 | libpq-dev |
7 | 15 | postgresql | 15 | postgresql |
8 | 16 | python-apt | ||
9 | 16 | python-bson | 17 | python-bson |
10 | 17 | python-bzrlib | 18 | python-bzrlib |
11 | 18 | python-convoy | 19 | python-convoy |
12 | 19 | 20 | ||
13 | === modified file 'src/maasserver/context_processors.py' | |||
14 | --- src/maasserver/context_processors.py 2015-02-26 18:34:40 +0000 | |||
15 | +++ src/maasserver/context_processors.py 2015-03-03 16:09:28 +0000 | |||
16 | @@ -23,6 +23,10 @@ | |||
17 | 23 | from maasserver.components import get_persistent_errors | 23 | from maasserver.components import get_persistent_errors |
18 | 24 | from maasserver.forms import get_node_edit_form | 24 | from maasserver.forms import get_node_edit_form |
19 | 25 | from maasserver.models import Config | 25 | from maasserver.models import Config |
20 | 26 | from maasserver.utils.version import ( | ||
21 | 27 | get_maas_doc_version, | ||
22 | 28 | get_maas_version, | ||
23 | 29 | ) | ||
24 | 26 | 30 | ||
25 | 27 | 31 | ||
26 | 28 | def yui(context): | 32 | def yui(context): |
27 | @@ -86,4 +90,6 @@ | |||
28 | 86 | 'site_name': Config.objects.get_config('maas_name'), | 90 | 'site_name': Config.objects.get_config('maas_name'), |
29 | 87 | }, | 91 | }, |
30 | 88 | 'debug': settings.DEBUG, | 92 | 'debug': settings.DEBUG, |
31 | 93 | 'version': get_maas_version(), | ||
32 | 94 | 'doc_version': get_maas_doc_version(), | ||
33 | 89 | } | 95 | } |
34 | 90 | 96 | ||
35 | === modified file 'src/maasserver/templates/maasserver/base.html' | |||
36 | --- src/maasserver/templates/maasserver/base.html 2015-02-20 17:00:30 +0000 | |||
37 | +++ src/maasserver/templates/maasserver/base.html 2015-03-03 16:09:28 +0000 | |||
38 | @@ -123,7 +123,7 @@ | |||
39 | 123 | <div class="legal-inner"> | 123 | <div class="legal-inner"> |
40 | 124 | {% block footer-copyright %} | 124 | {% block footer-copyright %} |
41 | 125 | <p class="twelve-col"> | 125 | <p class="twelve-col"> |
43 | 126 | <span class="version">MAAS</span> <a href="http://maas.ubuntu.com/docs1.7/changelog.html#id1">View release notes</a>|<a href="https://maas.ubuntu.com/documentation/">View documentation</a> | 126 | <span class="version">MAAS Version {{version}}</span> <a href="http://maas.ubuntu.com/{{doc_version}}/changelog.html#id1">View release notes</a>|<a href="https://maas.ubuntu.com/{{doc_version}}/">View documentation</a> |
44 | 127 | </p> | 127 | </p> |
45 | 128 | <p class="twelve-col copy">© 2015 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p> | 128 | <p class="twelve-col copy">© 2015 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p> |
46 | 129 | {% endblock %} | 129 | {% endblock %} |
47 | 130 | 130 | ||
48 | === modified file 'src/maasserver/templates/maasserver/index.html' | |||
49 | --- src/maasserver/templates/maasserver/index.html 2015-02-20 17:00:30 +0000 | |||
50 | +++ src/maasserver/templates/maasserver/index.html 2015-03-03 16:09:28 +0000 | |||
51 | @@ -102,7 +102,7 @@ | |||
52 | 102 | <div class="legal clearfix"> | 102 | <div class="legal clearfix"> |
53 | 103 | <div class="legal-inner"> | 103 | <div class="legal-inner"> |
54 | 104 | <p class="twelve-col"> | 104 | <p class="twelve-col"> |
56 | 105 | <span class="version">MAAS</span> <a href="http://maas.ubuntu.com/docs1.7/changelog.html#id1">View release notes</a>|<a href="https://maas.ubuntu.com/documentation/">View documentation</a> | 105 | <span class="version">MAAS Version {{version}}</span> <a href="http://maas.ubuntu.com/{{doc_version}}/changelog.html#id1">View release notes</a>|<a href="https://maas.ubuntu.com/{{doc_version}}/">View documentation</a> |
57 | 106 | </p> | 106 | </p> |
58 | 107 | <p class="twelve-col copy">© 2015 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p> | 107 | <p class="twelve-col copy">© 2015 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.</p> |
59 | 108 | </div> | 108 | </div> |
60 | 109 | 109 | ||
61 | === added file 'src/maasserver/utils/tests/test_version.py' | |||
62 | --- src/maasserver/utils/tests/test_version.py 1970-01-01 00:00:00 +0000 | |||
63 | +++ src/maasserver/utils/tests/test_version.py 2015-03-03 16:09:28 +0000 | |||
64 | @@ -0,0 +1,194 @@ | |||
65 | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the | ||
66 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
67 | 3 | |||
68 | 4 | """Test version utilities.""" | ||
69 | 5 | |||
70 | 6 | from __future__ import ( | ||
71 | 7 | absolute_import, | ||
72 | 8 | print_function, | ||
73 | 9 | unicode_literals, | ||
74 | 10 | ) | ||
75 | 11 | |||
76 | 12 | str = None | ||
77 | 13 | |||
78 | 14 | __metaclass__ = type | ||
79 | 15 | __all__ = [] | ||
80 | 16 | |||
81 | 17 | import random | ||
82 | 18 | |||
83 | 19 | from bzrlib.errors import NotBranchError | ||
84 | 20 | from maasserver.utils import version | ||
85 | 21 | from maastesting.matchers import MockCalledOnceWith | ||
86 | 22 | from maastesting.testcase import MAASTestCase | ||
87 | 23 | from mock import ( | ||
88 | 24 | MagicMock, | ||
89 | 25 | sentinel, | ||
90 | 26 | ) | ||
91 | 27 | from testtools.matchers import Is | ||
92 | 28 | |||
93 | 29 | |||
94 | 30 | class TestGetVersionFromAPT(MAASTestCase): | ||
95 | 31 | |||
96 | 32 | def test__returns_empty_string_if_package_not_in_cache(self): | ||
97 | 33 | self.patch(version.apt_pkg, "Cache") | ||
98 | 34 | self.assertEquals( | ||
99 | 35 | "", | ||
100 | 36 | version.get_version_from_apt(version.REGION_PACKAGE_NAME)) | ||
101 | 37 | |||
102 | 38 | def test__returns_empty_string_if_not_current_ver_from_package(self): | ||
103 | 39 | package = MagicMock() | ||
104 | 40 | package.current_ver = None | ||
105 | 41 | mock_cache = { | ||
106 | 42 | version.REGION_PACKAGE_NAME: package, | ||
107 | 43 | } | ||
108 | 44 | self.patch(version.apt_pkg, "Cache").return_value = mock_cache | ||
109 | 45 | self.assertEquals( | ||
110 | 46 | "", | ||
111 | 47 | version.get_version_from_apt(version.REGION_PACKAGE_NAME)) | ||
112 | 48 | |||
113 | 49 | def test__returns_ver_str_from_package(self): | ||
114 | 50 | package = MagicMock() | ||
115 | 51 | package.current_ver.ver_str = sentinel.ver_str | ||
116 | 52 | mock_cache = { | ||
117 | 53 | version.REGION_PACKAGE_NAME: package, | ||
118 | 54 | } | ||
119 | 55 | self.patch(version.apt_pkg, "Cache").return_value = mock_cache | ||
120 | 56 | self.assertIs( | ||
121 | 57 | sentinel.ver_str, | ||
122 | 58 | version.get_version_from_apt(version.REGION_PACKAGE_NAME)) | ||
123 | 59 | |||
124 | 60 | |||
125 | 61 | class TestFormatVersion(MAASTestCase): | ||
126 | 62 | |||
127 | 63 | scenarios = [ | ||
128 | 64 | ("with ~", { | ||
129 | 65 | "version": "1.8.0~alpha4+bzr356-0ubuntu1", | ||
130 | 66 | "output": "1.8.0 (alpha4+bzr356)", | ||
131 | 67 | }), | ||
132 | 68 | ("without ~", { | ||
133 | 69 | "version": "1.8.0+bzr356-0ubuntu1", | ||
134 | 70 | "output": "1.8.0 (+bzr356)", | ||
135 | 71 | }), | ||
136 | 72 | ("without ~ or +", { | ||
137 | 73 | "version": "1.8.0-0ubuntu1", | ||
138 | 74 | "output": "1.8.0", | ||
139 | 75 | }), | ||
140 | 76 | ] | ||
141 | 77 | |||
142 | 78 | def test__returns_formatted_version(self): | ||
143 | 79 | self.assertEquals(self.output, version.format_version(self.version)) | ||
144 | 80 | |||
145 | 81 | |||
146 | 82 | class TestGetMAASRegionPackageVersion(MAASTestCase): | ||
147 | 83 | |||
148 | 84 | def test__returns_value_from_global(self): | ||
149 | 85 | self.patch(version, "MAAS_VERSION", sentinel.maas_version) | ||
150 | 86 | self.assertIs( | ||
151 | 87 | sentinel.maas_version, version.get_maas_region_package_version()) | ||
152 | 88 | |||
153 | 89 | def test__calls_get_version_from_apt_if_global_not_set(self): | ||
154 | 90 | self.patch(version, "MAAS_VERSION", None) | ||
155 | 91 | mock_apt = self.patch(version, "get_version_from_apt") | ||
156 | 92 | version.get_maas_region_package_version() | ||
157 | 93 | self.assertThat( | ||
158 | 94 | mock_apt, MockCalledOnceWith(version.REGION_PACKAGE_NAME)) | ||
159 | 95 | |||
160 | 96 | def test__calls_format_version_with_version_from_apt(self): | ||
161 | 97 | self.patch(version, "MAAS_VERSION", None) | ||
162 | 98 | current_ver = "1.8.0~alpha4+bzr356-0ubuntu1" | ||
163 | 99 | mock_apt = self.patch(version, "get_version_from_apt") | ||
164 | 100 | mock_apt.return_value = current_ver | ||
165 | 101 | mock_format = self.patch(version, "format_version") | ||
166 | 102 | mock_format.return_value = sentinel.format | ||
167 | 103 | self.expectThat( | ||
168 | 104 | version.get_maas_region_package_version(), Is(sentinel.format)) | ||
169 | 105 | self.expectThat( | ||
170 | 106 | mock_format, MockCalledOnceWith(current_ver)) | ||
171 | 107 | |||
172 | 108 | def test__sets_global_value(self): | ||
173 | 109 | self.patch(version, "MAAS_VERSION", None) | ||
174 | 110 | current_ver = "1.8.0~alpha4+bzr356-0ubuntu1" | ||
175 | 111 | mock_apt = self.patch(version, "get_version_from_apt") | ||
176 | 112 | mock_apt.return_value = current_ver | ||
177 | 113 | mock_format = self.patch(version, "format_version") | ||
178 | 114 | mock_format.return_value = sentinel.format | ||
179 | 115 | version.get_maas_region_package_version() | ||
180 | 116 | self.assertIs(sentinel.format, version.MAAS_VERSION) | ||
181 | 117 | |||
182 | 118 | |||
183 | 119 | class TestGetMAASBranch(MAASTestCase): | ||
184 | 120 | |||
185 | 121 | def test__returns_None_if_Branch_is_None(self): | ||
186 | 122 | self.patch(version, "Branch", None) | ||
187 | 123 | self.assertIsNone(version.get_maas_branch()) | ||
188 | 124 | |||
189 | 125 | def test__calls_Branch_open_with_current_dir(self): | ||
190 | 126 | mock_open = self.patch(version.Branch, "open") | ||
191 | 127 | mock_open.return_value = sentinel.branch | ||
192 | 128 | self.expectThat(version.get_maas_branch(), Is(sentinel.branch)) | ||
193 | 129 | self.expectThat(mock_open, MockCalledOnceWith(".")) | ||
194 | 130 | |||
195 | 131 | def test__returns_None_on_NotBranchError(self): | ||
196 | 132 | mock_open = self.patch(version.Branch, "open") | ||
197 | 133 | mock_open.side_effect = NotBranchError("") | ||
198 | 134 | self.assertIsNone(version.get_maas_branch()) | ||
199 | 135 | |||
200 | 136 | |||
201 | 137 | class TestGetMAASVersion(MAASTestCase): | ||
202 | 138 | |||
203 | 139 | def test__returns_version_from_get_maas_region_package_version(self): | ||
204 | 140 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
205 | 141 | mock_version.return_value = sentinel.version | ||
206 | 142 | self.assertIs(sentinel.version, version.get_maas_version()) | ||
207 | 143 | |||
208 | 144 | def test__returns_unknown_if_version_is_empty_and_not_bzr_branch(self): | ||
209 | 145 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
210 | 146 | mock_version.return_value = "" | ||
211 | 147 | mock_branch = self.patch(version, "get_maas_branch") | ||
212 | 148 | mock_branch.return_value = None | ||
213 | 149 | self.assertEquals("unknown", version.get_maas_version()) | ||
214 | 150 | |||
215 | 151 | def test__returns_from_source_and_revno_from_branch(self): | ||
216 | 152 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
217 | 153 | mock_version.return_value = "" | ||
218 | 154 | revno = random.randint(1, 5000) | ||
219 | 155 | mock_branch = self.patch(version, "get_maas_branch") | ||
220 | 156 | mock_branch.return_value.revno.return_value = revno | ||
221 | 157 | self.assertEquals( | ||
222 | 158 | "from source (+bzr%s)" % revno, version.get_maas_version()) | ||
223 | 159 | |||
224 | 160 | |||
225 | 161 | class TestGetMAASMainVersion(MAASTestCase): | ||
226 | 162 | |||
227 | 163 | def test__returns_main_version_from_package_version_with_space(self): | ||
228 | 164 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
229 | 165 | mock_version.return_value = "1.8.0 (alpha4+bzr356)" | ||
230 | 166 | self.assertEquals("1.8.0", version.get_maas_main_version()) | ||
231 | 167 | |||
232 | 168 | def test__returns_main_version_from_package_version_without_space(self): | ||
233 | 169 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
234 | 170 | mock_version.return_value = "1.8.0" | ||
235 | 171 | self.assertEquals("1.8.0", version.get_maas_main_version()) | ||
236 | 172 | |||
237 | 173 | def test__returns_empty_if_version_is_empty(self): | ||
238 | 174 | mock_version = self.patch(version, "get_maas_region_package_version") | ||
239 | 175 | mock_version.return_value = "" | ||
240 | 176 | self.assertEquals("", version.get_maas_main_version()) | ||
241 | 177 | |||
242 | 178 | |||
243 | 179 | class TestGetMAASDocVersion(MAASTestCase): | ||
244 | 180 | |||
245 | 181 | def test__returns_doc_version_with_greater_than_1_decimals(self): | ||
246 | 182 | mock_version = self.patch(version, "get_maas_main_version") | ||
247 | 183 | mock_version.return_value = "1.8.0" | ||
248 | 184 | self.assertEquals("doc1.8", version.get_maas_doc_version()) | ||
249 | 185 | |||
250 | 186 | def test__returns_doc_version_with_equal_to_1_decimals(self): | ||
251 | 187 | mock_version = self.patch(version, "get_maas_main_version") | ||
252 | 188 | mock_version.return_value = "1.8" | ||
253 | 189 | self.assertEquals("doc1.8", version.get_maas_doc_version()) | ||
254 | 190 | |||
255 | 191 | def test__returns_just_doc_if_version_is_empty(self): | ||
256 | 192 | mock_version = self.patch(version, "get_maas_main_version") | ||
257 | 193 | mock_version.return_value = "" | ||
258 | 194 | self.assertEquals("doc", version.get_maas_doc_version()) | ||
259 | 0 | 195 | ||
260 | === added file 'src/maasserver/utils/version.py' | |||
261 | --- src/maasserver/utils/version.py 1970-01-01 00:00:00 +0000 | |||
262 | +++ src/maasserver/utils/version.py 2015-03-03 16:09:28 +0000 | |||
263 | @@ -0,0 +1,129 @@ | |||
264 | 1 | # Copyright 2015 Canonical Ltd. This software is licensed under the | ||
265 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
266 | 3 | |||
267 | 4 | """Version utilities.""" | ||
268 | 5 | |||
269 | 6 | from __future__ import ( | ||
270 | 7 | absolute_import, | ||
271 | 8 | print_function, | ||
272 | 9 | unicode_literals, | ||
273 | 10 | ) | ||
274 | 11 | |||
275 | 12 | str = None | ||
276 | 13 | |||
277 | 14 | __metaclass__ = type | ||
278 | 15 | __all__ = [ | ||
279 | 16 | ] | ||
280 | 17 | |||
281 | 18 | import apt_pkg | ||
282 | 19 | |||
283 | 20 | |||
284 | 21 | try: | ||
285 | 22 | from bzrlib.branch import Branch | ||
286 | 23 | from bzrlib.errors import NotBranchError | ||
287 | 24 | except ImportError: | ||
288 | 25 | Branch = None | ||
289 | 26 | |||
290 | 27 | # Initialize apt_pkg. | ||
291 | 28 | apt_pkg.init() | ||
292 | 29 | |||
293 | 30 | # Holds the version of maas. | ||
294 | 31 | MAAS_VERSION = None | ||
295 | 32 | |||
296 | 33 | # Name of maas package to get version from. | ||
297 | 34 | REGION_PACKAGE_NAME = "maas-region-controller" | ||
298 | 35 | |||
299 | 36 | |||
300 | 37 | def get_version_from_apt(package): | ||
301 | 38 | """Return the version output from `apt_pkg.Cache` for the given package.""" | ||
302 | 39 | cache = apt_pkg.Cache() | ||
303 | 40 | version = None | ||
304 | 41 | if package in cache: | ||
305 | 42 | apt_package = cache[package] | ||
306 | 43 | version = apt_package.current_ver | ||
307 | 44 | |||
308 | 45 | if version is not None: | ||
309 | 46 | return version.ver_str | ||
310 | 47 | else: | ||
311 | 48 | return "" | ||
312 | 49 | |||
313 | 50 | |||
314 | 51 | def format_version(version): | ||
315 | 52 | """Format `version` into a better looking string for the UI.""" | ||
316 | 53 | if "~" in version: | ||
317 | 54 | main_version, extra = version.split("~", 1) | ||
318 | 55 | return "%s (%s)" % (main_version, extra.split("-", 1)[0]) | ||
319 | 56 | elif "+" in version: | ||
320 | 57 | main_version, extra = version.split("+", 1) | ||
321 | 58 | return "%s (+%s)" % (main_version, extra.split("-", 1)[0]) | ||
322 | 59 | else: | ||
323 | 60 | return version.split("-", 1)[0] | ||
324 | 61 | |||
325 | 62 | |||
326 | 63 | def get_maas_region_package_version(): | ||
327 | 64 | """Return the dpkg version for `REGION_PACKAGE_NAME`. | ||
328 | 65 | |||
329 | 66 | Lazy loads the version. Once loaded it will not be loaded again. | ||
330 | 67 | This is to speed up the call to this method and also to require the | ||
331 | 68 | region to be restarted to see the new version. | ||
332 | 69 | """ | ||
333 | 70 | global MAAS_VERSION | ||
334 | 71 | if MAAS_VERSION is None: | ||
335 | 72 | MAAS_VERSION = get_version_from_apt(REGION_PACKAGE_NAME) | ||
336 | 73 | # Possible this returned an empty string, meaning its not installed | ||
337 | 74 | # and no need to call again. | ||
338 | 75 | if MAAS_VERSION: | ||
339 | 76 | # It is a valid version so set the correct format. | ||
340 | 77 | MAAS_VERSION = format_version(MAAS_VERSION) | ||
341 | 78 | return MAAS_VERSION | ||
342 | 79 | |||
343 | 80 | |||
344 | 81 | def get_maas_branch(): | ||
345 | 82 | """Return the `bzrlib.branch.Branch` for this running MAAS.""" | ||
346 | 83 | if Branch is None: | ||
347 | 84 | return None | ||
348 | 85 | try: | ||
349 | 86 | return Branch.open(".") | ||
350 | 87 | except NotBranchError: | ||
351 | 88 | return None | ||
352 | 89 | |||
353 | 90 | |||
354 | 91 | def get_maas_version(): | ||
355 | 92 | """Return the version string for the running MAAS region.""" | ||
356 | 93 | # MAAS is installed from package, return the version string. | ||
357 | 94 | version = get_maas_region_package_version() | ||
358 | 95 | if version: | ||
359 | 96 | return version | ||
360 | 97 | else: | ||
361 | 98 | # Get the branch information | ||
362 | 99 | branch = get_maas_branch() | ||
363 | 100 | if branch is None: | ||
364 | 101 | # Not installed not in branch, then no way to identify. This should | ||
365 | 102 | # not happen, but just in case. | ||
366 | 103 | return "unknown" | ||
367 | 104 | else: | ||
368 | 105 | return "from source (+bzr%s)" % branch.revno() | ||
369 | 106 | |||
370 | 107 | |||
371 | 108 | def get_maas_main_version(): | ||
372 | 109 | """Return the main version for the running MAAS region.""" | ||
373 | 110 | # MAAS is installed from package, return the version string. | ||
374 | 111 | version = get_maas_region_package_version() | ||
375 | 112 | if version: | ||
376 | 113 | if " " in version: | ||
377 | 114 | return version.split(" ")[0] | ||
378 | 115 | else: | ||
379 | 116 | return version | ||
380 | 117 | else: | ||
381 | 118 | return "" | ||
382 | 119 | |||
383 | 120 | |||
384 | 121 | def get_maas_doc_version(): | ||
385 | 122 | """Return the doc version for the running MAAS region.""" | ||
386 | 123 | main_version = get_maas_main_version() | ||
387 | 124 | if not main_version: | ||
388 | 125 | return "doc" | ||
389 | 126 | if main_version.count('.') > 1: | ||
390 | 127 | return "doc%s" % '.'.join(main_version.split('.')[:2]) | ||
391 | 128 | else: | ||
392 | 129 | return "doc%s" % main_version |
On Tue, Mar 03, 2015 at 03:22:27PM -0000, Blake Rouse wrote: version" >MAAS</ span> <a href="http:// maas.ubuntu. com/docs1. 7/changelog. html#id1">View release notes</a>|<a href="https:/ /maas.ubuntu. com/documentati on/">View documentation</a> version" >MAAS Version {{version}}</span> <a href="http:// maas.ubuntu. com/docs1. 7/changelog. html#id1">View release notes</a>|<a href="https:/ /maas.ubuntu. com/documentati on/">View documentation</a>
> - <span class="
> + <span class="
You may have considered this already but could we use the version string launchpad. net/~kiko
to automatically select the right subdirectory in the URL?
--
Christian Robottom Reis | [+1] 612 888 4935 | http://
Canonical VP Hyperscale | [+55 16] 9 9112 6430