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"] {
height: 18px;
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
$(function() {
if ($("#ace-meta-data").length && $("#ace-user-data").length) {
var meta_data = ace.edit('ace-meta-data', {
mode: "ace/mode/yaml", useWorker: false,
selectionStyle: "text" });
......@@ -26,7 +26,6 @@ $(function() {
document.getElementById('ace-user-data').style.fontSize='14px';
/* */
$('#vm-details-cidata-save').click(function(e) {
$.ajax({
type: 'POST',
url: $(this).parents("form").prop('action'),
......@@ -48,9 +47,9 @@ $(function() {
}
}
});
e.preventDefault()
})
}
/* save resources */
$('#vm-details-resources-save').click(function(e) {
var error = false;
......
......@@ -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>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.loadjson(url: str)</code> - load json object from remote url" %}</li>
</ul>
<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>
<pre>{% verbatim %}
#cloud-config
......@@ -39,7 +44,7 @@ users:
ssh_authorized_keys:
- {{ ssh.keys['my-key'] }}
{% for u in acl.operators %}
- name: {{i}}
- name: {{u}}
shell: /bin/bash
{% endfor %}
{% endverbatim %}</pre>
......
......@@ -26,6 +26,7 @@
{{ form.req_traits|as_crispy_field }}
{{ form.description|as_crispy_field }}
{{ form.system|as_crispy_field }}
{{ form.has_agent|as_crispy_field }}
<hr/>
{% include "dashboard/_ci-data-help.html" %}
<div class="alert alert-warning">
......
......@@ -43,7 +43,7 @@ import jinja2
from passlib.hash import sha512_crypt
import yaml
import re
import urllib3, json
from model_utils import Choices
from model_utils.managers import QueryManager
......@@ -80,13 +80,14 @@ ACCESS_METHODS = [(key, name) for key, (name, port, transport)
CI_META_DATA_DEF = """
instance-id: {{ hostname }}
local-hostname: {{ hostname }}
cloud-name: circle3
platform: circle3
""".strip()
CI_USER_DATA_DEF = """
#cloud-config
users:
- default
- name: {{ sysuser }}
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
......@@ -158,7 +159,7 @@ class VirtualMachineDescModel(BaseResourceConfigModel):
help_text=(_('Name of operating system in format like '
'"Ubuntu 12.04 LTS Desktop amd64".')))
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=_(
'If the machine has agent installed, and '
'the manager should wait for its start.'))
......@@ -259,6 +260,14 @@ class CITemplate:
def rndstr(self, 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'):
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