Skip to content

Commit a68eece

Browse files
Release 0.1.4
Changes: * GUI bugfixes * User profile * Link to inventory in history * Update graph and movement of charts * Get info from api-stats for dashboard * Add feature: clean history details (ansible log output) * Fix broken symlinks in debian packages * Add user settings storage and movable charts * Add kerberos package to deps * Execute options to templates * Setup git-projects branch * Fix bug with symbols `<`, `>`, `'`, `"` and `&` in inventory * Hide some secret vars in history raw_inventory See merge request cloud/polemarch!53
2 parents 9327f6d + a319e66 commit a68eece

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+11875
-7909
lines changed

.dockerignore

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
.hypothesis/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
.static_storage/
58+
.media/
59+
local_settings.py
60+
61+
# Flask stuff:
62+
instance/
63+
.webassets-cache
64+
65+
# Scrapy stuff:
66+
.scrapy
67+
68+
# Sphinx documentation
69+
docs/_build/
70+
71+
# PyBuilder
72+
target/
73+
74+
# Jupyter Notebook
75+
.ipynb_checkpoints
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Environments
87+
.env
88+
.venv
89+
env/
90+
venv/
91+
ENV/
92+
env.bak/
93+
venv.bak/
94+
95+
# Spyder project settings
96+
.spyderproject
97+
.spyproject
98+
99+
# Rope project settings
100+
.ropeproject
101+
102+
# mkdocs documentation
103+
/site
104+
105+
# mypy
106+
.mypy_cache/

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ build
1111
*egg-info
1212
dist
1313
env
14-
polemarch/polemarch/static
14+
# polemarch/polemarch/static
1515
*.log
1616
*.pid
1717
*nbproject

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export DESCRIPTION
1717
SUMMARY = Infrastructure Heat Service for orchestration infrastructure by ansible.
1818
VENDOR = VST Consulting <sergey.k@vstconsulting.net>
1919
RELEASE = 0
20+
COMPOSE = docker-compose-testrun.yml
21+
COMPOSE_ARGS = --abort-on-container-exit
22+
COMPLEX_TESTS_COMPOSE = docker-compose-tests.yml
23+
COMPLEX_TESTS_COMPOSE_ARGS = '--abort-on-container-exit --build'
2024

2125
include rpm.mk
2226
include deb.mk
@@ -66,7 +70,10 @@ build-clean:
6670
find . -name "*.pyc" -print0 | xargs -0 rm -rf
6771
-rm -rf build
6872
-rm -rf *.egg-info
69-
-rm pylint_*
73+
-rm -rf pylint_*
74+
75+
clean_dist:
76+
-rm -rf dist
7077

7178
fclean: clean
7279
find ./polemarch -name "*.c" -print0 | xargs -0 rm -rf
@@ -105,3 +112,12 @@ deb:
105112
mv -v ../$(NAME)_$(VER)*.deb dist/
106113
# cleanup
107114
rm -rf debian
115+
116+
compose:
117+
docker-compose -f $(COMPOSE) build
118+
119+
run:
120+
docker-compose -f $(COMPOSE) up $(COMPOSE_ARGS)
121+
122+
complex_tests:
123+
$(MAKE) run COMPOSE=$(COMPLEX_TESTS_COMPOSE) COMPOSE_ARGS=$(COMPLEX_TESTS_COMPOSE_ARGS)

deb.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ Source: $(NAME)
33
Section: unknown
44
Priority: optional
55
Maintainer: $(VENDOR)
6-
Build-Depends: debhelper (>= 9), python-virtualenv, python-pip, python-dev, gcc, libffi-dev, libssl-dev, libyaml-dev
6+
Build-Depends: debhelper (>= 9), python-virtualenv, python-pip, python-dev, gcc, libffi-dev, libssl-dev, libyaml-dev, libkrb5-dev
77
Standards-Version: 3.9.5
88
Homepage: https://gitlab.com/vstconsulting/polemarch
99
Vcs-Git: git@gitlab.com:vstconsulting/polemarch.git
1010
Vcs-Browser: https://gitlab.com/vstconsulting/polemarch.git
1111

1212
Package: $(NAME)
1313
Architecture: amd64
14-
Depends: $${shlibs:Depends}, $${misc:Depends}, python-virtualenv, libffi6, libssl-dev, sshpass, libpython2.7, git, libyaml-dev
14+
Depends: $${shlibs:Depends}, $${misc:Depends}, python-virtualenv, libffi6, libssl-dev, sshpass, libpython2.7, git, libyaml-dev, libkrb5-dev
1515
Description: $(SUMMARY)
1616
$(DESCRIPTION)
1717
endef
@@ -67,6 +67,7 @@ override_dh_auto_install:
6767
rm -rf $(BUILDROOT)/*
6868
# install our package with all required python dependencies in virtualenv
6969
virtualenv --no-site-packages $(BUILDROOT)/$(INSTALLDIR)
70+
rm -rf $(BUILDROOT)/$(INSTALLDIR)/local
7071
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) -r requirements-doc.txt
7172
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) dist/$(NAME)-$(VER).tar.gz
7273
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) -r requirements-git.txt

docker-compose-testrun.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
version: '3'
2+
services:
3+
db-server:
4+
image: mysql:latest
5+
environment:
6+
- MYSQL_DATABASE=polemarch
7+
- MYSQL_ROOT_PASSWORD=polemarch
8+
- MYSQL_USER=polemarch
9+
- MYSQL_PASSWORD=polemarch
10+
volumes:
11+
- "db_data:/var/lib/mysql"
12+
memcache-server:
13+
image: memcached
14+
rabbitmq-server:
15+
image: rabbitmq:latest
16+
environment:
17+
- RABBITMQ_DEFAULT_USER=polemarch
18+
- RABBITMQ_DEFAULT_PASS=polemarch
19+
- RABBITMQ_DEFAULT_VHOST=polemarch
20+
polemarch:
21+
build:
22+
context: .
23+
dockerfile: docker/Dockerfile.dev
24+
entrypoint: /bin/bash -c "/bin/bash -c \"$${@}\""
25+
command: |
26+
/bin/bash -c "
27+
set -e
28+
curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh | tee ./wait-for-it.sh
29+
chmod +x wait-for-it.sh
30+
./wait-for-it.sh db-server:3306
31+
./wait-for-it.sh rabbitmq-server:5672
32+
mkdir -p /var/run/polemarch
33+
chown polemarch:polemarch /projects /var/run/polemarch
34+
sudo -u polemarch /opt/polemarch/bin/polemarchctl migrate
35+
sudo -u polemarch /opt/polemarch/bin/uwsgi /opt/polemarch/lib/python2.7/site-packages/polemarch/web.ini
36+
/bin/bash || exit 0
37+
"
38+
external_links:
39+
- db-server
40+
- cache-server:memcache-server
41+
- locks-server:memcache-server
42+
- rabbitmq-server
43+
volumes:
44+
- "project_data:/projects"
45+
ports:
46+
- "8080:8080"
47+
48+
volumes:
49+
project_data:
50+
db_data:

docker-compose-tests.rpm.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.3'
2+
services:
3+
db-server:
4+
container_name: dbtest
5+
image: mysql:latest
6+
environment:
7+
- MYSQL_DATABASE=polemarch
8+
- MYSQL_ROOT_PASSWORD=polemarch
9+
- MYSQL_USER=polemarch
10+
- MYSQL_PASSWORD=polemarch
11+
volumes:
12+
- type: tmpfs
13+
target: /var/lib/mysql
14+
memcache-server:
15+
container_name: cachetest
16+
image: memcached
17+
polemarch_test_rpm:
18+
build:
19+
context: .
20+
dockerfile: docker/Dockerfile.test.rpm
21+
entrypoint: /bin/bash -c "/bin/bash -c \"$${@}\""
22+
command: |
23+
/bin/bash -c "
24+
set -e
25+
curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > wait-for-it.sh
26+
chmod +x wait-for-it.sh
27+
./wait-for-it.sh db-server:3306
28+
cd /home/polemarch
29+
sudo -u polemarch -H /opt/polemarch/bin/coverage run --source='/opt/polemarch/lib/python2.7/site-packages/polemarch' -m polemarch test -v 2 polemarch.main.tests
30+
sudo -u polemarch -H /opt/polemarch/bin/coverage report -m
31+
/bin/bash || exit 0
32+
"
33+
external_links:
34+
- db-server
35+
- cache-server:memcache-server
36+
- locks-server:memcache-server

docker/Dockerfile.dev

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM centos:7
2+
MAINTAINER sergey.k@vstconsulting.net
3+
4+
#Update and install required packages
5+
RUN yum check-update || true
6+
RUN yum install epel-release -y
7+
RUN yum -y install sudo python-pip python-devel ansible sshpass git \
8+
rpm-build make gcc openssl-devel libffi libffi-devel \
9+
libyaml-devel python-virtualenv
10+
11+
# For future tests
12+
# RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm
13+
# RUN yum -y install python3{5,6}u{,-devel,-pip}
14+
15+
16+
# Install pip requires
17+
RUN pip2 install -U pip
18+
RUN pip2 install -U -I pip tox coverage rpmvenv editdistance pyyaml
19+
RUN pip2 install -U 'cython>=0.25.2'
20+
21+
22+
# Build and install rpm
23+
COPY requirements-doc.txt /tmp/requirements-doc.txt
24+
COPY requirements-git.txt /tmp/requirements-git.txt
25+
COPY requirements.txt /tmp/requirements.txt
26+
RUN pip2 install -U -r /tmp/requirements-doc.txt \
27+
-r /tmp/requirements-git.txt \
28+
-r /tmp/requirements.txt
29+
RUN mkdir /tmp/polemarch
30+
ADD . /tmp/polemarch/
31+
RUN cd /tmp/polemarch && make rpm
32+
RUN yum install /tmp/polemarch/dist/*.rpm -y
33+
RUN cp -vf /tmp/polemarch/test_settings.ini /etc/polemarch/settings.ini
34+
35+
36+
# Run options
37+
ENV DJANGO_DEBUG=true
38+
EXPOSE 8080
39+
40+
ENTRYPOINT sudo -u polemarch /opt/polemarch/bin/uwsgi /opt/polemarch/lib/python2.7/site-packages/polemarch/web.ini

docker/Dockerfile.test.rpm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM git.vst.lan/vst/tests:tox
2+
MAINTAINER sergey.k@vstconsulting.net
3+
4+
RUN mkdir /tmp/polemarch
5+
ADD . /tmp/polemarch/
6+
RUN make rpm -C /tmp/polemarch/
7+
RUN yum install /tmp/polemarch/dist/*.rpm -y
8+
RUN cp -vf /tmp/polemarch/test_settings.ini /etc/polemarch/settings.ini && \
9+
sudo chown polemarch:polemarch /etc/polemarch/settings.ini && \
10+
sudo -H -u polemarch /opt/polemarch/bin/pip install -r /tmp/polemarch/requirements-test.txt && \
11+
cp -vf /tmp/polemarch/.coveragerc /home/polemarch/
12+
13+
14+
# Run options
15+
ENV DJANGO_DEBUG=true
16+
17+
ENTRYPOINT sudo -H -u polemarch /opt/polemarch/bin/polemarchctl test -v2 polemarch.main.tests

polemarch/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .environment import prepare_environment
22

3-
__version__ = "0.1.3"
3+
__version__ = "0.1.4"
44

55
def _main(**kwargs):
66
# pylint: disable=unused-variable

polemarch/api/permissions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ def has_permission(self, request, view):
66
return super(ModelPermission, self).has_permission(request, view)
77

88
def has_object_permission(self, request, view, obj):
9-
if request.user.is_staff:
10-
return True
11-
if request.user == obj: # nocv
9+
if request.user.is_staff or request.user == obj:
1210
return True
1311
if request.method in permissions.SAFE_METHODS: # nocv
1412
return obj.viewable_by(request.user) # nocv
1513
if view.action in view.POST_WHITE_LIST: # nocv
1614
return obj.viewable_by(request.user) # nocv
17-
return obj.editable_by(request.user)
15+
return obj.editable_by(request.user) # noce
1816

1917

2018
class SuperUserPermission(ModelPermission):

0 commit comments

Comments
 (0)