Skip to content

Commit

Permalink
Release 0.1.4
Browse files Browse the repository at this point in the history
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
  • Loading branch information
onegreyonewhite committed Mar 2, 2018
2 parents 9327f6d + a319e66 commit a68eece
Show file tree
Hide file tree
Showing 75 changed files with 11,875 additions and 7,909 deletions.
106 changes: 106 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.static_storage/
.media/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build
*egg-info
dist
env
polemarch/polemarch/static
# polemarch/polemarch/static
*.log
*.pid
*nbproject
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export DESCRIPTION
SUMMARY = Infrastructure Heat Service for orchestration infrastructure by ansible.
VENDOR = VST Consulting <sergey.k@vstconsulting.net>
RELEASE = 0
COMPOSE = docker-compose-testrun.yml
COMPOSE_ARGS = --abort-on-container-exit
COMPLEX_TESTS_COMPOSE = docker-compose-tests.yml
COMPLEX_TESTS_COMPOSE_ARGS = '--abort-on-container-exit --build'

include rpm.mk
include deb.mk
Expand Down Expand Up @@ -66,7 +70,10 @@ build-clean:
find . -name "*.pyc" -print0 | xargs -0 rm -rf
-rm -rf build
-rm -rf *.egg-info
-rm pylint_*
-rm -rf pylint_*

clean_dist:
-rm -rf dist

fclean: clean
find ./polemarch -name "*.c" -print0 | xargs -0 rm -rf
Expand Down Expand Up @@ -105,3 +112,12 @@ deb:
mv -v ../$(NAME)_$(VER)*.deb dist/
# cleanup
rm -rf debian

compose:
docker-compose -f $(COMPOSE) build

run:
docker-compose -f $(COMPOSE) up $(COMPOSE_ARGS)

complex_tests:
$(MAKE) run COMPOSE=$(COMPLEX_TESTS_COMPOSE) COMPOSE_ARGS=$(COMPLEX_TESTS_COMPOSE_ARGS)
5 changes: 3 additions & 2 deletions deb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Source: $(NAME)
Section: unknown
Priority: optional
Maintainer: $(VENDOR)
Build-Depends: debhelper (>= 9), python-virtualenv, python-pip, python-dev, gcc, libffi-dev, libssl-dev, libyaml-dev
Build-Depends: debhelper (>= 9), python-virtualenv, python-pip, python-dev, gcc, libffi-dev, libssl-dev, libyaml-dev, libkrb5-dev
Standards-Version: 3.9.5
Homepage: https://gitlab.com/vstconsulting/polemarch
Vcs-Git: git@gitlab.com:vstconsulting/polemarch.git
Vcs-Browser: https://gitlab.com/vstconsulting/polemarch.git

Package: $(NAME)
Architecture: amd64
Depends: $${shlibs:Depends}, $${misc:Depends}, python-virtualenv, libffi6, libssl-dev, sshpass, libpython2.7, git, libyaml-dev
Depends: $${shlibs:Depends}, $${misc:Depends}, python-virtualenv, libffi6, libssl-dev, sshpass, libpython2.7, git, libyaml-dev, libkrb5-dev
Description: $(SUMMARY)
$(DESCRIPTION)
endef
Expand Down Expand Up @@ -67,6 +67,7 @@ override_dh_auto_install:
rm -rf $(BUILDROOT)/*
# install our package with all required python dependencies in virtualenv
virtualenv --no-site-packages $(BUILDROOT)/$(INSTALLDIR)
rm -rf $(BUILDROOT)/$(INSTALLDIR)/local
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) -r requirements-doc.txt
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) dist/$(NAME)-$(VER).tar.gz
$(BUILDROOT)/$(INSTALLDIR)/bin/pip install $(PIPARGS) -r requirements-git.txt
Expand Down
50 changes: 50 additions & 0 deletions docker-compose-testrun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: '3'
services:
db-server:
image: mysql:latest
environment:
- MYSQL_DATABASE=polemarch
- MYSQL_ROOT_PASSWORD=polemarch
- MYSQL_USER=polemarch
- MYSQL_PASSWORD=polemarch
volumes:
- "db_data:/var/lib/mysql"
memcache-server:
image: memcached
rabbitmq-server:
image: rabbitmq:latest
environment:
- RABBITMQ_DEFAULT_USER=polemarch
- RABBITMQ_DEFAULT_PASS=polemarch
- RABBITMQ_DEFAULT_VHOST=polemarch
polemarch:
build:
context: .
dockerfile: docker/Dockerfile.dev
entrypoint: /bin/bash -c "/bin/bash -c \"$${@}\""
command: |
/bin/bash -c "
set -e
curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh | tee ./wait-for-it.sh
chmod +x wait-for-it.sh
./wait-for-it.sh db-server:3306
./wait-for-it.sh rabbitmq-server:5672
mkdir -p /var/run/polemarch
chown polemarch:polemarch /projects /var/run/polemarch
sudo -u polemarch /opt/polemarch/bin/polemarchctl migrate
sudo -u polemarch /opt/polemarch/bin/uwsgi /opt/polemarch/lib/python2.7/site-packages/polemarch/web.ini
/bin/bash || exit 0
"
external_links:
- db-server
- cache-server:memcache-server
- locks-server:memcache-server
- rabbitmq-server
volumes:
- "project_data:/projects"
ports:
- "8080:8080"

volumes:
project_data:
db_data:
36 changes: 36 additions & 0 deletions docker-compose-tests.rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.3'
services:
db-server:
container_name: dbtest
image: mysql:latest
environment:
- MYSQL_DATABASE=polemarch
- MYSQL_ROOT_PASSWORD=polemarch
- MYSQL_USER=polemarch
- MYSQL_PASSWORD=polemarch
volumes:
- type: tmpfs
target: /var/lib/mysql
memcache-server:
container_name: cachetest
image: memcached
polemarch_test_rpm:
build:
context: .
dockerfile: docker/Dockerfile.test.rpm
entrypoint: /bin/bash -c "/bin/bash -c \"$${@}\""
command: |
/bin/bash -c "
set -e
curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > wait-for-it.sh
chmod +x wait-for-it.sh
./wait-for-it.sh db-server:3306
cd /home/polemarch
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
sudo -u polemarch -H /opt/polemarch/bin/coverage report -m
/bin/bash || exit 0
"
external_links:
- db-server
- cache-server:memcache-server
- locks-server:memcache-server
40 changes: 40 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM centos:7
MAINTAINER sergey.k@vstconsulting.net

#Update and install required packages
RUN yum check-update || true
RUN yum install epel-release -y
RUN yum -y install sudo python-pip python-devel ansible sshpass git \
rpm-build make gcc openssl-devel libffi libffi-devel \
libyaml-devel python-virtualenv

# For future tests
# RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm
# RUN yum -y install python3{5,6}u{,-devel,-pip}


# Install pip requires
RUN pip2 install -U pip
RUN pip2 install -U -I pip tox coverage rpmvenv editdistance pyyaml
RUN pip2 install -U 'cython>=0.25.2'


# Build and install rpm
COPY requirements-doc.txt /tmp/requirements-doc.txt
COPY requirements-git.txt /tmp/requirements-git.txt
COPY requirements.txt /tmp/requirements.txt
RUN pip2 install -U -r /tmp/requirements-doc.txt \
-r /tmp/requirements-git.txt \
-r /tmp/requirements.txt
RUN mkdir /tmp/polemarch
ADD . /tmp/polemarch/
RUN cd /tmp/polemarch && make rpm
RUN yum install /tmp/polemarch/dist/*.rpm -y
RUN cp -vf /tmp/polemarch/test_settings.ini /etc/polemarch/settings.ini


# Run options
ENV DJANGO_DEBUG=true
EXPOSE 8080

ENTRYPOINT sudo -u polemarch /opt/polemarch/bin/uwsgi /opt/polemarch/lib/python2.7/site-packages/polemarch/web.ini
17 changes: 17 additions & 0 deletions docker/Dockerfile.test.rpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM git.vst.lan/vst/tests:tox
MAINTAINER sergey.k@vstconsulting.net

RUN mkdir /tmp/polemarch
ADD . /tmp/polemarch/
RUN make rpm -C /tmp/polemarch/
RUN yum install /tmp/polemarch/dist/*.rpm -y
RUN cp -vf /tmp/polemarch/test_settings.ini /etc/polemarch/settings.ini && \
sudo chown polemarch:polemarch /etc/polemarch/settings.ini && \
sudo -H -u polemarch /opt/polemarch/bin/pip install -r /tmp/polemarch/requirements-test.txt && \
cp -vf /tmp/polemarch/.coveragerc /home/polemarch/


# Run options
ENV DJANGO_DEBUG=true

ENTRYPOINT sudo -H -u polemarch /opt/polemarch/bin/polemarchctl test -v2 polemarch.main.tests
2 changes: 1 addition & 1 deletion polemarch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .environment import prepare_environment

__version__ = "0.1.3"
__version__ = "0.1.4"

def _main(**kwargs):
# pylint: disable=unused-variable
Expand Down
6 changes: 2 additions & 4 deletions polemarch/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ def has_permission(self, request, view):
return super(ModelPermission, self).has_permission(request, view)

def has_object_permission(self, request, view, obj):
if request.user.is_staff:
return True
if request.user == obj: # nocv
if request.user.is_staff or request.user == obj:
return True
if request.method in permissions.SAFE_METHODS: # nocv
return obj.viewable_by(request.user) # nocv
if view.action in view.POST_WHITE_LIST: # nocv
return obj.viewable_by(request.user) # nocv
return obj.editable_by(request.user)
return obj.editable_by(request.user) # noce


class SuperUserPermission(ModelPermission):
Expand Down
Loading

0 comments on commit a68eece

Please sign in to comment.