Skip to content

Commit b7b026e

Browse files
1.6.0
Changelog: * Add support for Ansible 2.9. * Add RU locale. * Some GUI and API optimization and fixes. See merge request polemarch/ce!177
2 parents a640db9 + e2bef43 commit b7b026e

File tree

21 files changed

+320
-58
lines changed

21 files changed

+320
-58
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ code_style:
7373
refs:
7474
- merge_requests
7575
- web
76-
- master
7776
retry: 2
7877

7978
py37-coverage:

.jshintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"devel": true,
1818

1919
"globals": {
20+
"_translate": true,
2021
"addCssClassesToElement": true,
2122
"ApiConnector": true,
2223
"api_connector_config": true,

doc/api_schema.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ info:
5858
library: 1.5.2
5959
vstutils: 2.11.2
6060
django: 2.2.7
61-
ansible: 2.8.7
61+
ansible: 2.9.2
6262
version: v2
6363
host: localhost:8080
6464
schemes:
@@ -11423,7 +11423,7 @@ definitions:
1142311423
view_field: path
1142411424
args:
1142511425
title: Args
11426-
description: module arguments
11426+
description: host pattern
1142711427
type: string
1142811428
background:
1142911429
title: Background
@@ -11436,7 +11436,7 @@ definitions:
1143611436
default: false
1143711437
become_method:
1143811438
title: Become method
11439-
description: privilege escalation method to use (default=%default), use `ansible-doc
11439+
description: privilege escalation method to use (default=sudo), use `ansible-doc
1144011440
-t become -l` to list valid choices.
1144111441
type: string
1144211442
become_user:
@@ -11479,11 +11479,6 @@ definitions:
1147911479
$ref: '#/definitions/Inventory'
1148011480
value_field: id
1148111481
view_field: name
11482-
key_file:
11483-
title: Key file
11484-
description: use this file to authenticate the connection
11485-
type: string
11486-
format: secretfile
1148711482
limit:
1148811483
title: Limit
1148911484
description: further limit selected hosts to an additional pattern
@@ -11602,14 +11597,18 @@ definitions:
1160211597
$ref: '#/definitions/Playbook'
1160311598
value_field: playbook
1160411599
view_field: name
11600+
args:
11601+
title: Args
11602+
description: Playbook(s)
11603+
type: string
1160511604
become:
1160611605
title: Become
1160711606
description: run operations with become (does not imply password prompting)
1160811607
type: boolean
1160911608
default: false
1161011609
become_method:
1161111610
title: Become method
11612-
description: privilege escalation method to use (default=%default), use `ansible-doc
11611+
description: privilege escalation method to use (default=sudo), use `ansible-doc
1161311612
-t become -l` to list valid choices.
1161411613
type: string
1161511614
become_user:
@@ -11662,11 +11661,6 @@ definitions:
1166211661
$ref: '#/definitions/Inventory'
1166311662
value_field: id
1166411663
view_field: name
11665-
key_file:
11666-
title: Key file
11667-
description: use this file to authenticate the connection
11668-
type: string
11669-
format: secretfile
1167011664
limit:
1167111665
title: Limit
1167211666
description: further limit selected hosts to an additional pattern

polemarch/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
"VST_ROOT_URLCONF": os.getenv("VST_ROOT_URLCONF", 'vstutils.urls'),
3232
}
3333

34-
__version__ = "1.5.2"
34+
__version__ = "1.6.0"
3535

3636
prepare_environment(**default_settings)

polemarch/api/v2/swagger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from vstutils.api import swagger
1+
from vstutils.api.schema.info import api_info_dict, openapi
22
from ...main.utils import AnsibleArgumentsReference
33

4-
api_info_dict = swagger.api_info_dict.copy()
4+
api_info_dict = api_info_dict.copy()
55
api_info_dict['x-versions']['ansible'] = AnsibleArgumentsReference().version
66

7-
api_info = swagger.openapi.Info(**api_info_dict)
7+
api_info = openapi.Info(**api_info_dict)

polemarch/main/models/vars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pylint: disable=protected-access,no-member
22
from __future__ import unicode_literals
3-
from typing import Any, NoReturn, Tuple, Dict, List, Text
3+
from typing import Any, NoReturn, Tuple, Dict, List, Text, Union
44
import logging
55
import uuid
66

@@ -137,7 +137,7 @@ def set_vars(self, variables) -> NoReturn:
137137
for key, value in other_vars.items():
138138
self.variables.create(key=key, value=value)
139139

140-
def get_vars(self) -> [OrderedDict, Dict]:
140+
def get_vars(self) -> Union[OrderedDict, Dict]:
141141
qs = self.variables.all().sort_by_key().values_list('key', 'value')
142142
return reduce(update_boolean, self.BOOLEAN_VARS, OrderedDict(qs))
143143

polemarch/main/tests/api.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ def setUp(self):
353353

354354
def test_api_versions_list(self):
355355
result = self.get_result("get", "/api/")
356-
self.assertEqual(len(result), 3)
357-
self.assertTrue(result.get(self._settings('VST_API_VERSION'), False))
356+
self.assertEqual(len(result['available_versions']), 1)
357+
self.assertTrue(result['available_versions'].get(self._settings('VST_API_VERSION'), False))
358358
self.assertTrue(result.get('openapi', False))
359359

360360
def test_api_v1_list(self):
@@ -370,7 +370,7 @@ def test_api_v1_list(self):
370370

371371
def test_api_router(self):
372372
result = self.get_result('get', "/api/?format=json")
373-
url = result[self._settings('VST_API_VERSION')].replace("http://testserver", "")
373+
url = result['available_versions'][self._settings('VST_API_VERSION')].replace("http://testserver", "")
374374
self.get_result('get', url)
375375

376376
def _generate_history(self, days_ago, count, status="OK"):
@@ -470,3 +470,20 @@ def test_bulk_unsupported(self):
470470
self.assertIn("set", result["operations_types"])
471471
self.assertIn("del", result["operations_types"])
472472
self.assertIn("mod", result["operations_types"])
473+
474+
def test_lang(self):
475+
bulk_data = [
476+
{'data_type': ['_lang'], 'method': 'get'},
477+
{'data_type': ['_lang', 'en'], 'method': 'get'},
478+
{'data_type': ['_lang', 'ru'], 'method': 'get'},
479+
]
480+
481+
results = self.make_bulk(bulk_data)
482+
self.assertEqual(results[0]['status'], 200)
483+
self.assertEqual(results[0]['data']['count'], 2)
484+
self.assertEqual(results[1]['data']['code'], 'en')
485+
self.assertEqual(results[1]['data']['name'], 'English')
486+
self.assertEqual(results[1]['data']['translations']['pmwuserscounter'], 'users counter')
487+
self.assertEqual(results[2]['data']['code'], 'ru')
488+
self.assertEqual(results[2]['data']['name'], 'Russian')
489+
self.assertEqual(results[2]['data']['translations']['pmwuserscounter'], 'счетчик пользователей')

polemarch/main/tests/openapi.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ class OApiTestCase(BaseTestCase):
1414

1515
@skipUnless(openapi_schema_yaml.is_file(), "OpenApi schema file doesn't exist")
1616
def test_openapi_schema(self):
17+
'''
18+
Regenerate new doc schema:
19+
20+
Examples:
21+
.. sourcecode:: bash
22+
23+
python -m polemarch generate_swagger \
24+
--format yaml \
25+
--overwrite \
26+
--url 'http://localhost:8080/' \
27+
--user admin \
28+
-m doc/api_schema.yaml
29+
'''
1730
schema = self.get_result('get', '/api/openapi/?format=openapi')
1831

1932
with openapi_schema_yaml.open('r') as fin:
@@ -23,5 +36,17 @@ def test_openapi_schema(self):
2336
openapi_schema_yml['schemes'][0] = 'https'
2437
openapi_schema_yml['info']['contact'] = schema['info']['contact']
2538
openapi_schema_yml['info']['x-versions'] = schema['info']['x-versions']
26-
27-
self.assertDictEqual(openapi_schema_yml, schema)
39+
openapi_schema_yml['info']['x-links'] = schema['info']['x-links']
40+
41+
for key in list(filter(lambda x: 'Ansible' in x, openapi_schema_yml['definitions'].keys())):
42+
del openapi_schema_yml['definitions'][key]
43+
del schema['definitions'][key]
44+
45+
for key, value in openapi_schema_yml.items():
46+
cmp_value = schema.get(key, None)
47+
if isinstance(value, dict):
48+
self.assertDictEqual(value, cmp_value, key)
49+
elif isinstance(value, list):
50+
self.assertListEqual(value, cmp_value, key)
51+
else:
52+
self.assertEqual(value, cmp_value, key)

polemarch/static/css/polemarch-gui.css

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,23 +349,34 @@ body {
349349
display: block;
350350
}
351351

352-
@media (max-width: 452px) {
353-
#period-list {
354-
width: 100%!important;
355-
margin-top: 10px;
356-
}
357352

353+
354+
.chart-period-select-wrapper {
355+
display: flex;
356+
margin-right: 10px;
358357
}
359358

360359
.chart-period-select {
361-
max-width: 145px;
360+
width: 100%;
362361
height: 30px!important;
363362
line-height: 30px;
364363
padding: 3px 12px;
365364
display: inline-block;
366365
float: left;
367366
}
368367

368+
@media (max-width: 452px) {
369+
#period-list {
370+
width: 100%!important;
371+
margin-top: 10px;
372+
}
373+
374+
.chart-period-select-wrapper {
375+
margin-right: 0;
376+
}
377+
378+
}
379+
369380
.guifield-one_history_boolean .boolean-true, .guifield-one_history_boolean .boolean-false{
370381
font-size: 24px;
371382
}

polemarch/static/js/pmCustomizer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const pmSkinDefaultMixin = {
101101

102102
chart_axes_text_color: {
103103
color_var:"--chart-axes-text-color",
104-
title:'Chart legend text color',
104+
title:'Chart axes text color',
105105
format:'color',
106106
default:"#666666",
107107
// priority: 53,

0 commit comments

Comments
 (0)