Commit 1b01e6b7 by Karsa Zoltán István

prism init

parent d1030b90
......@@ -198,6 +198,7 @@ PIPELINE = {
"network/network.less",
"autocomplete_light/vendor/select2/dist/css/select2.css",
"autocomplete_light/select2.css",
"dashboard/prism.css"
),
"output_filename": "all.css",
}
......@@ -239,6 +240,7 @@ PIPELINE = {
"output_filename": "all.js",
},
"vm-detail": {"source_filenames": (
"dashboard/js/prism.js",
"clipboard/dist/clipboard.min.js",
"dashboard/vm-details.js",
"no-vnc/include/util.js",
......
var Websock_native; // not sure
function data() {
Prism.hooks.add("before-highlight", function (env) {
env.code = env.element.innerText;
});
$('#meta_data_code').text($('#id_ci_meta_data').val())
$('#id_ci_meta_data').on('input', function() {
let result_element = document.querySelector("#meta_data_code");
res = Prism.highlight(document.getElementById("id_ci_meta_data").value, Prism.languages.yaml, 'yaml')
result_element.innerHTML = Prism.highlight(res, Prism.languages.jinja2, 'jinja2')
})
}
$(function() {
/* */
$('#vm-details-cidata-save').click(function(e) {
......
......@@ -19,6 +19,7 @@
<li>{% trans "<code>net.ipv4</code> - default host ip address" %}</li>
<li>{% trans "<code>net.ipv6</code> - default host ipv6 address" %}</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>ci.rndstr(len: int)</code> - function: make random string with 'len' charachters lenght" %}</li>
</ul>
<b>Example:</b>
......@@ -34,6 +35,8 @@ users:
chpasswd: { expire: False }
lock-passwd: false
passwd: "{{password}}"
ssh_authorized_keys:
- {{ ssh.keys['my-key'] }}
{% for u in acl.operators %}
- name: {{i}}
- shell: /bin/bash
......
......@@ -49,9 +49,9 @@ from model_utils import Choices
from model_utils.managers import QueryManager
from model_utils.models import TimeStampedModel, StatusModel
from taggit.managers import TaggableManager
from simplesshkey.models import UserKey
from django.db import models
import json
from acl.models import AclBase
from django import forms
from common.models import (
......@@ -64,6 +64,7 @@ from .common import BaseResourceConfigModel, Lease
from .network import Interface
from .node import Node, Trait
logger = getLogger(__name__)
pre_state_changed = Signal(providing_args=["new_state"])
post_state_changed = Signal(providing_args=["new_state"])
......@@ -265,6 +266,12 @@ class AclTemplate:
self.operators = list(k['username'] for k in self.user_levels if k['level'] == 'operator')
self.users = list(k['username'] for k in self.user_levels if k['level'] == 'user')
class SSHKeyTemplate:
def __init__(self, instance):
owner = instance.owner
self.keys = {}
for k in UserKey.objects.filter(user=owner):
self.keys[k.name] = k.key
class NetTemplate:
class Host:
......@@ -279,6 +286,8 @@ class NetTemplate:
self.ipv6 = str(instance.ipv6)
class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
TimeStampedModel):
......@@ -402,7 +411,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
"password": sha512_crypt.hash(self.pw),
"owner": str(self.owner.username),
"net": NetTemplate(self),
"acl": AclTemplate(self)
"acl": AclTemplate(self),
"ssh": SSHKeyTemplate(self),
}
return datas
......
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