Commit 1caf8013 by Szeberényi Imre

Merge branch 'ci-integration' into 'master'

Bugfix - JS

See merge request !12
parents 7739d371 bdb49d44
...@@ -1364,5 +1364,13 @@ textarea[name="new_members"] { ...@@ -1364,5 +1364,13 @@ textarea[name="new_members"] {
height: 18px; height: 18px;
margin-right: 8px; margin-right: 8px;
} }
#ace-meta-data {
position: absolute;
width: 95%;
height: 150px;
}
#ace-user-data {
position: absolute;
width: 95%;
height: 350px;
}
var Websock_native; // not sure var Websock_native; // not sure
$(function() { $(function() {
if ($("#ace-meta-data").length && $("#ace-user-data").length) {
var meta_data = ace.edit('ace-meta-data', { var meta_data = ace.edit('ace-meta-data', {
mode: "ace/mode/yaml", useWorker: false, mode: "ace/mode/yaml", useWorker: false,
selectionStyle: "text" }); selectionStyle: "text" });
...@@ -26,7 +26,6 @@ $(function() { ...@@ -26,7 +26,6 @@ $(function() {
document.getElementById('ace-user-data').style.fontSize='14px'; document.getElementById('ace-user-data').style.fontSize='14px';
/* */ /* */
$('#vm-details-cidata-save').click(function(e) { $('#vm-details-cidata-save').click(function(e) {
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: $(this).parents("form").prop('action'), url: $(this).parents("form").prop('action'),
...@@ -48,9 +47,9 @@ $(function() { ...@@ -48,9 +47,9 @@ $(function() {
} }
} }
}); });
e.preventDefault() e.preventDefault()
}) })
}
/* save resources */ /* save resources */
$('#vm-details-resources-save').click(function(e) { $('#vm-details-resources-save').click(function(e) {
var error = false; var error = false;
......
...@@ -21,8 +21,13 @@ ...@@ -21,8 +21,13 @@
<li>{% trans "<code>net.vlans</code> - associated vlans: list of objects (name: vlan name, ipv4/ipv6: host ip in vlan)" %}</li> <li>{% trans "<code>net.vlans</code> - associated vlans: list of objects (name: vlan name, ipv4/ipv6: host ip in vlan)" %}</li>
<li>{% trans "<code>ssh.keys</code> - owner's ssh-keys dictionary: the key is the ssh-key's name" %}</li> <li>{% trans "<code>ssh.keys</code> - owner's ssh-keys dictionary: the key is the ssh-key's name" %}</li>
<li>{% trans "<code>ci.rndstr(len: int)</code> - function: make random string with 'len' charachters lenght" %}</li> <li>{% trans "<code>ci.rndstr(len: int)</code> - function: make random string with 'len' charachters lenght" %}</li>
<li>{% trans "<code>ci.loadjson(url: str)</code> - load json object from remote url" %}</li>
</ul> </ul>
<p>{% trans "Filters: hash - sha512 hash method" %}</p> <p>{% trans "Filters: hash - sha512 hash method" %}</p>
<p>{% trans "Use this commands, to clean cloud-init setup (for save as template example):" %}</p>
<pre>
cloud-init clean
userdel -p -f cloud # delete default user</pre>
<b>Example:</b> <b>Example:</b>
<pre>{% verbatim %} <pre>{% verbatim %}
#cloud-config #cloud-config
...@@ -39,7 +44,7 @@ users: ...@@ -39,7 +44,7 @@ users:
ssh_authorized_keys: ssh_authorized_keys:
- {{ ssh.keys['my-key'] }} - {{ ssh.keys['my-key'] }}
{% for u in acl.operators %} {% for u in acl.operators %}
- name: {{i}} - name: {{u}}
shell: /bin/bash shell: /bin/bash
{% endfor %} {% endfor %}
{% endverbatim %}</pre> {% endverbatim %}</pre>
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
{{ form.req_traits|as_crispy_field }} {{ form.req_traits|as_crispy_field }}
{{ form.description|as_crispy_field }} {{ form.description|as_crispy_field }}
{{ form.system|as_crispy_field }} {{ form.system|as_crispy_field }}
{{ form.has_agent|as_crispy_field }}
<hr/> <hr/>
{% include "dashboard/_ci-data-help.html" %} {% include "dashboard/_ci-data-help.html" %}
<div class="alert alert-warning"> <div class="alert alert-warning">
......
...@@ -43,7 +43,7 @@ import jinja2 ...@@ -43,7 +43,7 @@ import jinja2
from passlib.hash import sha512_crypt from passlib.hash import sha512_crypt
import yaml import yaml
import re import urllib3, json
from model_utils import Choices from model_utils import Choices
from model_utils.managers import QueryManager from model_utils.managers import QueryManager
...@@ -80,13 +80,14 @@ ACCESS_METHODS = [(key, name) for key, (name, port, transport) ...@@ -80,13 +80,14 @@ ACCESS_METHODS = [(key, name) for key, (name, port, transport)
CI_META_DATA_DEF = """ CI_META_DATA_DEF = """
instance-id: {{ hostname }} instance-id: {{ hostname }}
local-hostname: {{ hostname }} local-hostname: {{ hostname }}
cloud-name: circle3
platform: circle3
""".strip() """.strip()
CI_USER_DATA_DEF = """ CI_USER_DATA_DEF = """
#cloud-config #cloud-config
users: users:
- default
- name: {{ sysuser }} - name: {{ sysuser }}
sudo: ['ALL=(ALL) NOPASSWD:ALL'] sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo groups: sudo
...@@ -158,7 +159,7 @@ class VirtualMachineDescModel(BaseResourceConfigModel): ...@@ -158,7 +159,7 @@ class VirtualMachineDescModel(BaseResourceConfigModel):
help_text=(_('Name of operating system in format like ' help_text=(_('Name of operating system in format like '
'"Ubuntu 12.04 LTS Desktop amd64".'))) '"Ubuntu 12.04 LTS Desktop amd64".')))
tags = TaggableManager(blank=True, verbose_name=_("tags")) tags = TaggableManager(blank=True, verbose_name=_("tags"))
has_agent = BooleanField(verbose_name=_('has agent'), default=True, has_agent = BooleanField(verbose_name=_('has agent'), default=False,
help_text=_( help_text=_(
'If the machine has agent installed, and ' 'If the machine has agent installed, and '
'the manager should wait for its start.')) 'the manager should wait for its start.'))
...@@ -259,6 +260,14 @@ class CITemplate: ...@@ -259,6 +260,14 @@ class CITemplate:
def rndstr(self, len): def rndstr(self, len):
return ''.join(random.choice(string.ascii_letters) for i in range(int(len))) return ''.join(random.choice(string.ascii_letters) for i in range(int(len)))
def jsonload(self, url):
http = urllib3.PoolManager()
r = http.request('GET', url)
if r.status != 200:
raise forms.ValidationError(f'Status code: {r.status}')
myjson = r.data.decode('utf8')
return json.loads(myjson)
def j2_hash(value, hash='sha512'): def j2_hash(value, hash='sha512'):
return sha512_crypt.hash(value) return sha512_crypt.hash(value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment