Skip to content

Commit

Permalink
Release 0.0.9 (bugfixing)
Browse files Browse the repository at this point in the history
See merge request cloud/polemarch!33
  • Loading branch information
onegreyonewhite committed Oct 18, 2017
2 parents 7ab0338 + 5f620e4 commit 26d844a
Show file tree
Hide file tree
Showing 48 changed files with 896 additions and 820 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ compile: build-clean
-rm -rf dist
find ./polemarch -name "*.c" -print0 | xargs -0 rm -rf
-rm -rf polemarch/doc/*
$(PY) setup.py build_sphinx --build-dir polemarch/doc
$(PY) setup.py compile -v

install:
Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ Ubuntu/Debian installation
sudo service polemarchweb start
sudo service polemarchworker start

Note for Debian 9 users: Polemarch currently built with libssl1.0.0, so you
need to install it for your distro:

.. sourcecode:: bash

wget http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.2l-1~bpo8+1_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.2l-1~bpo8+1_amd64.deb

That's it. Polemarch web panel on 8080 port. Default administrative account is
admin/admin.

Expand Down
4 changes: 2 additions & 2 deletions deb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ chown -R $(USER):$(USER) /var/log/$(NAME)
chown -R $(USER):$(USER) /var/run/$(NAME)
chown -R $(USER):$(USER) /var/lock/$(NAME)
# making migration and activate services
sudo -u $(USER) /opt/$(NAME)/bin/polemarchctl migrate > /dev/null 2>&1
sudo -H -u $(USER) /opt/$(NAME)/bin/polemarchctl migrate
systemctl daemon-reload
systemctl enable polemarchweb.service
systemctl enable polemarchworker.service
systemctl daemon-reload
endef
export DEBIAN_POSTINST

Expand Down
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.0.8"
__version__ = "0.0.9"

def _main(**kwargs):
# pylint: disable=unused-variable
Expand Down
8 changes: 5 additions & 3 deletions polemarch/api/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ def register_view(self, prefix, view, name=None):
self.custom_urls.append((prefix, view, name))

def _unreg(self, prefix, objects_list):
del self._urls
index = 0
for reg_prefix, _, _ in objects_list:
if reg_prefix == prefix:
del objects_list[index]
break
index += 1
return objects_list

def unregister_view(self, prefix):
self._unreg(prefix, self.custom_urls) # nocv
self.custom_urls = self._unreg(prefix, self.custom_urls) # nocv

def unregister(self, prefix):
self._unreg(prefix, self.registry)
self.registry = self._unreg(prefix, self.registry)


class APIRouter(_AbstractRouter):
Expand Down Expand Up @@ -125,7 +127,7 @@ def register_router(self, prefix, router, name=None):
self.routers.append((prefix, router, name))

def unregister_router(self, prefix):
self._unreg(prefix, self.routers) # nocv
self.routers = self._unreg(prefix, self.routers) # nocv

def get_urls(self):
urls = super(MainRouter, self).get_urls()
Expand Down
1 change: 0 additions & 1 deletion polemarch/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

# Register globals


urls = [
url(r'^api/', include(router.urls)),
]
20 changes: 20 additions & 0 deletions polemarch/main/migrations/0018_auto_20170929_0657.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-29 06:57
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0017_periodictask_save_result'),
]

operations = [
migrations.AlterField(
model_name='group',
name='hosts',
field=models.ManyToManyField(related_name='groups', related_query_name='groups', to='main.Host'),
),
]
14 changes: 8 additions & 6 deletions polemarch/main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
__kwargs = dict(HOME=BASE_DIR, PY=PY_VER, TMP=TMP_DIR)

# Hack for keep user settings in /etc/polemarch/settings.ini
# or in file thats setups in env IHS_SETTINGS_FILE
# or in file thats setups in env POLEMARCH_SETTINGS_FILE
DEV_SETTINGS_FILE = os.getenv("POLEMARCH_DEV_SETTINGS_FILE",
os.path.join(BASE_DIR, 'main/settings.ini'))
CONFIG_FILE = os.getenv("POLEMARCH_SETTINGS_FILE", "/etc/polemarch/settings.ini")
config = ConfigParser()
config.read([CONFIG_FILE, os.path.join(BASE_DIR, 'main/settings.ini')])
config.read([CONFIG_FILE, DEV_SETTINGS_FILE])

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
Expand Down Expand Up @@ -358,16 +360,16 @@

TASKS_HANDLERS = {
"REPO": {
"BACKEND": "polemarch.main.tasks.RepoTask"
"BACKEND": "polemarch.main.tasks.tasks.RepoTask"
},
"SCHEDUER": {
"BACKEND": "polemarch.main.tasks.ScheduledTask"
"BACKEND": "polemarch.main.tasks.tasks.ScheduledTask"
},
"MODULE": {
"BACKEND": "polemarch.main.tasks.ExecuteAnsibleModule"
"BACKEND": "polemarch.main.tasks.tasks.ExecuteAnsibleModule"
},
"PLAYBOOK": {
"BACKEND": "polemarch.main.tasks.ExecuteAnsiblePlaybook"
"BACKEND": "polemarch.main.tasks.tasks.ExecuteAnsiblePlaybook"
},
}

Expand Down
6 changes: 4 additions & 2 deletions polemarch/main/templates/gui/gui.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@
<script defer src="{% static 'js/pmModuleTemplates.js' %}"></script>
<script defer src="{% static 'js/pmAnsibleModule.js' %}"></script>
<script defer src="{% static 'js/pmDashboard.js' %}"></script>
<script defer src="{% static 'js/moduleArgsEditor.js' %}"></script>
{% endblock %}

{% block script %}
<script>
$(document).ready(function()
{
var templates = [
'templates/common',
'templates/jsonEditor',
'templates/crontabEditor',
'templates/pmItems',
'templates/pmDashboard',
'templates/pmGroups',
'templates/pmHosts',
Expand All @@ -56,7 +57,8 @@
'templates/pmHistory',
'templates/pmTasksTemplates',
'templates/pmModuleTemplates',
'templates/pmAnsibleModule'
'templates/pmAnsibleModule',
'templates/moduleArgsEditor'
]

// alert("New-")
Expand Down
9 changes: 8 additions & 1 deletion polemarch/main/unittests/routers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django.test import TestCase

from ...api.urls import router_v1
from ...api.urls import router_v1, v1


class RoutersTestCase(TestCase):
def test_uregister(self):
router_v1.unregister("history")
for pattern in router_v1.get_urls():
self.assertIsNone(pattern.regex.search("history/1/"))
router_v1.register('history', v1.UserViewSet)
checked = False
for pattern in router_v1.registry:
if pattern[0] == 'history':
checked = True
self.assertEqual(pattern[1], v1.UserViewSet)
self.assertTrue(checked, "Not registered!")
7 changes: 7 additions & 0 deletions polemarch/static/css/gui.css
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ table{
z-index: 1;
opacity: 0;
cursor: pointer;
overflow: hidden;
}

.history-status{
Expand Down Expand Up @@ -531,4 +532,10 @@ table{
.btn-right{
float: right;
margin-left: 5px;
}

.resize-options{
max-width: 100%;
min-width: 100%;
width: 100%;
}
70 changes: 51 additions & 19 deletions polemarch/static/js/jsonEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function jsonEditor(){

jsonEditor.model = {}
jsonEditor.model.isLoaded_cli_reference = false;
jsonEditor.model.isLoading_cli_reference = false;

jsonEditor.options = {};

Expand Down Expand Up @@ -160,6 +161,19 @@ mergeDeep(jsonEditor.options['inventories'], jsonEditor.options['item'])
// jsonEditor
////////////////////////////////////////////////

/**
* Хранит данные модели для всех редакторов на странице.
* Ключ берётся как `opt.prefix`
* @type Object
*/
jsonEditor.model.data = {}

/**
* Строит форму заполнения vars
* @param {Object} json объект для заполнения параметрами и их значениями (имеет двусторонний биндинг)
* @param {Object} opt
* @returns {string} текст шаблона формы
*/
jsonEditor.editor = function(json, opt)
{
if(!opt)
Expand All @@ -172,16 +186,18 @@ jsonEditor.editor = function(json, opt)
opt.title1 = 'Variables'
}

if(!opt.prefix)
if(!opt.title2)
{
opt.prefix = 'prefix'
opt.title2 = 'Adding new variable'
}
opt.prefix = opt.prefix.replace(/[^A-z0-9]/g, "_").replace(/[\[\]]/gi, "_")

if(!opt.title2)
if(!opt.prefix)
{
opt.title2 = 'Adding new variable'
opt.prefix = 'prefix'
}

opt.prefix = opt.prefix.replace(/[^A-z0-9]/g, "_").replace(/[\[\]]/gi, "_")
jsonEditor.model.data[opt.prefix] = json;

return spajs.just.render('jsonEditor', {data:json, optionsblock:opt.block, opt:opt})
}
Expand All @@ -205,7 +221,14 @@ jsonEditor.jsonEditorGetValues = function(prefix)
}
prefix = prefix.replace(/[^A-z0-9]/g, "_").replace(/[\[\]]/gi, "_")

var data = {}
if(jsonEditor.model.data[prefix] === undefined)
{
return {}
}

return jsonEditor.model.data[prefix];

/*var data = {}
var arr = $(".jsonEditor-data"+prefix)
for(var i = 0; i< arr.length; i++)
{
Expand All @@ -225,7 +248,7 @@ jsonEditor.jsonEditorGetValues = function(prefix)
}
}
return data
return data*/
}

jsonEditor.jsonEditorRmVar = function(name, prefix)
Expand All @@ -241,6 +264,10 @@ jsonEditor.jsonEditorRmVar = function(name, prefix)
{
$("#jsonEditorVarListHolder"+prefix).hide()
}

delete jsonEditor.model.data[prefix][name]
tabSignal.emit(prefix+".jsonEditorUpdate",{name:name, value:undefined, prefix:prefix})
tabSignal.emit("jsonEditorUpdate",{name:name, value:undefined, prefix:prefix})
}

/**
Expand All @@ -262,9 +289,12 @@ jsonEditor.__devAddVar = function(name, value, optionsblock, prefix)
optionsblock = 'base'
}


jsonEditor.model.data[prefix][name] = value
$("#jsonEditorVarList"+prefix).appendTpl(spajs.just.render('jsonEditorLine', {name:name, value:value, optionsblock:optionsblock, opt:{prefix:prefix}}))
$("#jsonEditorVarListHolder"+prefix).show()

tabSignal.emit(prefix+".jsonEditorUpdate",{name:name, value:value, prefix:prefix})
tabSignal.emit("jsonEditorUpdate",{name:name, value:value, prefix:prefix})
}

jsonEditor.jsonEditorAddVar = function(optionsblock, prefix)
Expand Down Expand Up @@ -295,11 +325,6 @@ jsonEditor.jsonEditorAddVar = function(optionsblock, prefix)
return;
}

/*if(/^--/.test(name))
{
name = name.replace(/^--/, "ansible_")
}*/

if(/^-[A-z0-9]$/.test(name))
{
for(var i in jsonEditor.options[optionsblock])
Expand Down Expand Up @@ -329,8 +354,12 @@ jsonEditor.jsonEditorAddVar = function(optionsblock, prefix)
prefix:prefix
}

jsonEditor.model.data[prefix][name] = value
$("#jsonEditorVarList"+prefix).appendTpl(spajs.just.render('jsonEditorLine', {name:name, value:value, optionsblock:optionsblock, opt:opt}))
$("#jsonEditorVarListHolder"+prefix).show()

tabSignal.emit(prefix+".jsonEditorUpdate",{name:name, value:value, prefix:prefix})
tabSignal.emit("jsonEditorUpdate",{name:name, value:value, prefix:prefix})
}

jsonEditor.initAutoComplete = function(optionsblock, prefix)
Expand Down Expand Up @@ -388,30 +417,30 @@ jsonEditor.initForm = function(optionsblock, prefix)
}
prefix = prefix.replace(/[^A-z0-9]/g, "_").replace(/[\[\]]/gi, "_")

//console.log(optionsblock, jsonEditor.options[optionsblock])
if(jsonEditor.options[optionsblock])
{
jsonEditor.initAutoComplete(optionsblock, prefix)
return;
}

if(!jsonEditor.model.isLoaded_cli_reference)
else
{
jsonEditor.model.isLoaded_cli_reference = true;
return spajs.ajax.Call({
url: "/api/v1/ansible/cli_reference/",
type: "GET",
contentType:'application/json',
data: "",
success: function(data)
{
Object.assign(jsonEditor.options, data)
jsonEditor.initAutoComplete(optionsblock, prefix)
Object.assign(jsonEditor.options, data)
jsonEditor.initAutoComplete(optionsblock, prefix)
jsonEditor.model.isLoaded_cli_reference = true;
}
});
}
}

jsonEditor.loadFile = function(event, element)
jsonEditor.loadFile = function(event, element, name, prefix)
{
console.log("jsonEditor.loadFile", event.target.files)
for(var i=0; i<event.target.files.length; i++)
Expand All @@ -426,7 +455,10 @@ jsonEditor.loadFile = function(event, element)
var reader = new FileReader();
reader.onload = function(e)
{
$(element)[0].setAttribute("value", e.target.result)
$(element).val(e.target.result)
tabSignal.emit(prefix+".jsonEditorUpdate",{name:name, value:e.target.result, prefix:prefix})
tabSignal.emit("jsonEditorUpdate",{name:name, value:e.target.result, prefix:prefix})
}

reader.readAsText(event.target.files[i]);
Expand Down
Loading

0 comments on commit 26d844a

Please sign in to comment.