Commit adc48463 authored by Iliya Manolov's avatar Iliya Manolov

Updated md5sum.

parent f9707a05
[buildout]
parts =
instance
create-knowledge0
read-knowledge0
publish-connection-parameter
erp5-kernel
kernel-json
custom-js
monitor-base
extends =
{{ monitor_template_rendered }}/template-monitor.cfg
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
......@@ -79,6 +83,14 @@ mode = 0744
context =
raw config_cfg ${buildout:directory}/knowledge0.cfg
# [ipython-notebook-set-password]
# <= dynamic-jinja-template-base
# template = {{ ipython_notebook_config_location }}/{{ ipython_notebook_set_password_filename }}
# rendered = ${directory:etc}/ipython_notebook_set_password.py
# mode = 0744
# context =
# raw config_cfg ${buildout:directory}/knowledge0.cfg
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
......@@ -94,8 +106,25 @@ ipython_dir = ${:home}/ipython
ipython_kernel_dir = ${:ipython_dir}/kernels
erp5_kernel_dir = ${:ipython_kernel_dir}/ERP5
[create-knowledge0]
recipe = slapos.cookbook:zero-knowledge.write
filename = knowledge0.cfg
[read-knowledge0]
recipe = slapos.cookbook:zero-knowledge.read
filename = knowledge0.cfg
[monitor-instance-parameter]
monitor-base-url = ${monitor-httpd-conf-parameter:url}
cors-domains = softinst65443.host.vifib.net
interface-url = https://softinst65443.host.vifib.net/erp5/web_site_module/monitoring_rjs_unsafe
instance-configuration =
raw jupyter-password ${read-knowledge0:password}
# raw kek topdeck
[publish-connection-parameter]
recipe = slapos.cookbook:publish.serialised
<= monitor-publish
url = https://[${instance-parameter:host}]:${instance-parameter:port}
[erp5-kernel]
......@@ -123,4 +152,3 @@ context =
template = {{ custom_js_location }}/{{ custom_js_filename }}
rendered = ${directory:ipython_dir}/profile_default/static/custom/custom.js
mode = 0744
......@@ -7,6 +7,7 @@ extends =
../../component/scikit-learn/buildout.cfg
../../component/pandas/buildout.cfg
../../component/openssl/buildout.cfg
../../stack/monitor/buildout.cfg
parts =
slapos-cookbook
ipython-notebook
......@@ -33,7 +34,7 @@ mode = 0644
[ipython-notebook-config]
<= download-file-base
filename = ipython_notebook_config.py.jinja
md5sum = a5bc4ee8539109d1de7ab33b4c2c97ea
# md5sum = 67f71a392b6dbe446290011009b42116
[ipython-notebook-set-password]
<= download-file-base
......@@ -60,7 +61,7 @@ recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in
rendered = ${buildout:directory}/template.cfg
mode = 0644
md5sum = 26a28b74c8b18c92108c751b87abe80c
#md5sum = 4a933553588035fb91cfcced08aed576
context =
key bin_directory buildout:bin-directory
key develop_eggs_directory buildout:develop-eggs-directory
......@@ -77,6 +78,16 @@ context =
key kernel_json_filename kernel-json:filename
key custom_js_location custom-js:location
key custom_js_filename custom-js:filename
key monitor_template_rendered buildout:directory
#[instance-jupyter-password-updater]
#recipe = slapos.recipe.template:jinja2
#template = ${:_profile_base_location_}/template/jupyter_password_updater.py.jinja
#rendered = ${monitor-directory:reports}/jupyter_password_updater.py
#mode = 0744
# md5sum =
#context =
# key knowledge0_directory buildout:directory
[versions]
PyRSS2Gen = 1.1
......
```
This script initializes Jupyter's configuration such as passwords and other
things. It is run by IPython hence why it can use functions like get_config().
```
import ConfigParser
import os
knowledge_0 = '{{ config_cfg }}'
if not os.path.exists(knowledge_0):
print "Your software does <b>not</b> embed 0-knowledge. \
This interface is useless in this case</body></html>"
exit(0)
c = get_config()
parser = ConfigParser.ConfigParser()
parser.read(knowledge_0)
if parser.has_option("ipython_notebook", "password"):
c.NotebookApp.password = parser.get("ipython_notebook", "password")
if not parser.has_section("ipython_notebook"):
parser.add_section("ipython_notebook")
if not parser.has_option("ipython_notebook", "password"):
parser.set("ipython_notebook", "password", "abcdefgh")
c.NotebookApp.password = parser.get("ipython_notebook", "password")
with open(knowledge_0, 'w') as file:
parser.write(file)
......@@ -61,4 +61,3 @@ print """<div class="pure-control-group">
<script type="text/javascript" src="static/monitor-register.js"></script>
</body></html>
"""
\ No newline at end of file
#!{{ python_executable }}
import os
knowledge0 =
\ No newline at end of file
#!{{ python_executable }}
import os
import time
import calendar
import random
import ConfigParser
knowledge0_dir = '{{ knowledge0_directory }}/knowledge0.cfg'
set_random_password = True
random_password_length = 10
```
def generate_random_password(password_length):
result = ''
for i in range(0, password_length):
result += chr(ord('a')+random.randint(0, 25))
return result
def set_password(newPassword, target):
parser = ConfigParser.ConfigParser()
parser.read(knowledge_0)
parser.set("ipython_notebook", "password", "abcdefgh")
if set_random_password:
newPassword = generate_random_password(random_password_length)
set_password(newPassword, knowledge0_dir)
else:
lastModifiedTime = os.path.getmtime(knowledge0_dir)
currentTime = calendar.timegm(time.gmtime())
timeBetweenUpdates = currentTime - lastModifiedTime
timeDelta = 60
if (timeBetweenUpdates < timeDelta):
newPassword = read_password(knowledge0_dir)
set_password(newPassword, knowledge0_dir)
```
\ No newline at end of file
......@@ -102,7 +102,7 @@ recipe = slapos.recipe.template:jinja2
filename = template-monitor.cfg
template = ${:_profile_base_location_}/instance-monitor.cfg.jinja2.in
rendered = ${buildout:directory}/template-monitor.cfg
md5sum = be07297494e08377c4dfecb26c2919ef
md5sum = 2b6f160f6324e9e11e3bb03267279691
context =
key apache_location apache:location
key gzip_location gzip:location
......
......@@ -379,7 +379,7 @@ depends =
[monitor-publish]
monitor-base-url = ${publish:monitor-base-url}
monitor-setup-url = ${monitor-instance-parameter:interface-url}/#page=settings_configurator&url=${publish:monitor-url}&username=$${publish:monitor-user}&password=${publish:monitor-password}
monitor-setup-url = ${monitor-instance-parameter:interface-url}/#page=settings_configurator&url=${publish:monitor-url}&username=${publish:monitor-user}&password=${publish:monitor-password}
[buildout]
......
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 to comment