From e94e163df91dcc1ac56dd4219f942e6097b14509 Mon Sep 17 00:00:00 2001
From: Ayush Tiwari <ayush.tiwari@nexedi.com>
Date: Wed, 10 Jun 2015 12:58:16 +0000
Subject: [PATCH] IPynb: Added notebook software type in the IPython Notebook
 software release

---
 .../instance-ipython-default.cfg.in           | 174 +-----------------
 .../instance-ipython-notebook.cfg.in          | 165 +++++++++++++++++
 software/ipython_notebook/instance.cfg        |   3 +-
 software/ipython_notebook/software.cfg        |  12 +-
 4 files changed, 187 insertions(+), 167 deletions(-)
 create mode 100644 software/ipython_notebook/instance-ipython-notebook.cfg.in

diff --git a/software/ipython_notebook/instance-ipython-default.cfg.in b/software/ipython_notebook/instance-ipython-default.cfg.in
index 7b21aab5e..905bd101f 100644
--- a/software/ipython_notebook/instance-ipython-default.cfg.in
+++ b/software/ipython_notebook/instance-ipython-default.cfg.in
@@ -1,165 +1,11 @@
 [buildout]
-parts =
-  instance
-  publish-connection-parameter
-## Monitoring part XXX whe should not have to specify all parts like this
-## Parts to add for monitoring
-  certificate-authority
-  cron
-  cron-entry-monitor
-  cron-entry-rss
-  deploy-index
-  deploy-settings-cgi
-  deploy-status-cgi
-  deploy-status-history-cgi
-  setup-static-files
-  certificate-authority
-  zero-parameters
-  public-symlink
-  cgi-httpd-wrapper
-  cgi-httpd-graceful-wrapper
-  monitor-promise
-  monitor-instance-log-access
-## Monitor for ipython
-  monitor-current-log-access
-  monitor-deploy-set-password-cgi
-  erp5-kernel
-  kernel-json
-
-extends = ${monitor-template:output}
-
-eggs-directory = ${buildout:eggs-directory}
-develop-eggs-directory = ${buildout:develop-eggs-directory}
-offline = true
-
-[slapconfiguration]
-recipe = slapos.cookbook:slapconfiguration
-computer = $${slap-connection:computer-id}
-partition = $${slap-connection:partition-id}
-url = $${slap-connection:server-url}
-key = $${slap-connection:key-file}
-cert = $${slap-connection:cert-file}
-configuration.erp5_url = https://softinst60318.host.vifib.net/erp5/Base_executePython
-
-[jinja2-template-base]
-recipe = slapos.recipe.template:jinja2
-rendered = $${buildout:directory}/$${:filename}
-extra-context =
-context =
-    import json_module json
-    key eggs_directory buildout:eggs-directory
-    key develop_eggs_directory buildout:develop-eggs-directory
-    key slap_software_type slap-parameters:slap-software-type
-    key slapparameter_dict slap-parameters:configuration
-    key slave_instance_list slap-parameters:slave-instance-list
-    $${:extra-context}
-
-[instance-parameter]
-port = 8888
-host = $${slapconfiguration:ipv6-random}
-cert_file = $${generate-certificate:cert_file}
-key_file = $${generate-certificate:key_file}
-logfile = $${directory:log}/ipython_notebook.log
-notebook_dir = $${directory:notebook_dir}
-
-[generate-certificate]
-; TODO: there is a slapos recipe to generate certificates. Use it instead
-recipe = plone.recipe.command
-command =
-  if [ ! -e $${instance-parameter:key_file} ]
-  then
-    ${openssl-output:openssl} req -x509 -nodes -days 3650 \
-      -subj "/C=AA/ST=X/L=X/O=Dis/CN=$${instance-parameter:host}" \
-      -newkey rsa:1024 -keyout $${instance-parameter:key_file} \
-      -out $${instance-parameter:cert_file}
-  fi
-update-command = $${:command}
-cert_file = $${directory:etc}/ipython_notebook_cert.crt
-key_file = $${directory:etc}/ipython_notebook_cert.key
-
-[instance]
-recipe = slapos.cookbook:wrapper
-command-line =
-  ${buildout:bin-directory}/ipython notebook
-  --no-browser
-  --matplotlib=inline
-  --ip=$${instance-parameter:host}
-  --port=$${instance-parameter:port}
-  --port-retries=0
-  --certfile=$${instance-parameter:cert_file}
-  --keyfile=$${instance-parameter:key_file}
-  --notebook-dir=$${instance-parameter:notebook_dir}
-  --logfile=$${instance-parameter:logfile}
-  --config=$${ipython_notebook_config:rendered}
-## Adding log-level as parameter is only for development process
-## and would be removed later.
-  --log-level="DEBUG"
-wrapper-path = $${directory:service}/ipython_notebook
-parameters-extra = true
-environment = IPYTHONDIR=$${directory:ipython_dir}
-
-[ipython_notebook_config]
-recipe = slapos.recipe.template:jinja2
-template = ${ipython_notebook_config:location}/${ipython_notebook_config:filename}
-rendered = $${directory:etc}/ipython_notebook_config.py
-mode = 0744
-context =
-  raw config_cfg $${buildout:directory}/knowledge0.cfg
-  raw ipython_dir $${directory:ipython_dir}
-
-[monitor-current-log-access]
-< = monitor-directory-access
-source = $${instance-parameter:logfile}
-
-[monitor-deploy-set-password-cgi]
-recipe = slapos.recipe.template:jinja2
-template = ${ipython_notebook_set_password:location}/${ipython_notebook_set_password:filename}
-rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
-filename = ipython-notebook-password.cgi
-mode = 0744
-context =
-  raw config_cfg $${buildout:directory}/knowledge0.cfg
-  raw python_executable ${buildout:bin-directory}/ipython
-  key pwd monitor-directory:knowledge0-cgi
-  key this_file :filename
-  key httpd_graceful cgi-httpd-graceful-wrapper:rendered
-
-[directory]
-recipe = slapos.cookbook:mkdirectory
-home = $${buildout:directory}
-etc = $${:home}/etc
-var = $${:home}/var
-script = $${:etc}/run/
-service = $${:etc}/service
-promise = $${:etc}/promise/
-log = $${:var}/log
-notebook_dir = $${:var}/notebooks
-ipython_dir = $${:home}/ipython
-ipython_kernel_dir = $${:ipython_dir}/kernels
-erp5_kernel_dir = $${:ipython_kernel_dir}/ERP5
-
-[publish-connection-parameter]
-recipe = slapos.cookbook:publish
-url = https://[$${instance-parameter:host}]:$${instance-parameter:port}
-monitor_url = $${monitor-parameters:url}
-erp5_url = $${slapconfiguration:configuration.erp5_url}
-
-[erp5-kernel]
-recipe = slapos.recipe.template:jinja2
-template = ${erp5-kernel:location}/${erp5-kernel:filename}
-rendered = $${directory:erp5_kernel_dir}/ERP5kernel.py
-mode = 0744
-context =
-  raw python_executable ${buildout:bin-directory}/pythonwitheggs
-  key erp5_url slapconfiguration:configuration.erp5_url
-
-[kernel-json]
-recipe = slapos.recipe.template:jinja2
-template = ${kernel-json:location}/${kernel-json:filename}
-rendered = $${directory:erp5_kernel_dir}/kernel.json
-mode = 0744
-context =
-  raw python_executable ${buildout:bin-directory}/pythonwitheggs
-  key kernel_dir erp5-kernel:rendered
-  raw display_name ERP5
-  raw language_name python
+extends = 
+    ${template-ipynb:output}
+
+[request-ipynb]
+<= slap-connection
+recipe = slapos.cookbook:request
+name = IPython Notebook
+software-url = $${slap-connection:software-release-url}
+software-type = notebook
+return = url
diff --git a/software/ipython_notebook/instance-ipython-notebook.cfg.in b/software/ipython_notebook/instance-ipython-notebook.cfg.in
new file mode 100644
index 000000000..7b21aab5e
--- /dev/null
+++ b/software/ipython_notebook/instance-ipython-notebook.cfg.in
@@ -0,0 +1,165 @@
+[buildout]
+parts =
+  instance
+  publish-connection-parameter
+## Monitoring part XXX whe should not have to specify all parts like this
+## Parts to add for monitoring
+  certificate-authority
+  cron
+  cron-entry-monitor
+  cron-entry-rss
+  deploy-index
+  deploy-settings-cgi
+  deploy-status-cgi
+  deploy-status-history-cgi
+  setup-static-files
+  certificate-authority
+  zero-parameters
+  public-symlink
+  cgi-httpd-wrapper
+  cgi-httpd-graceful-wrapper
+  monitor-promise
+  monitor-instance-log-access
+## Monitor for ipython
+  monitor-current-log-access
+  monitor-deploy-set-password-cgi
+  erp5-kernel
+  kernel-json
+
+extends = ${monitor-template:output}
+
+eggs-directory = ${buildout:eggs-directory}
+develop-eggs-directory = ${buildout:develop-eggs-directory}
+offline = true
+
+[slapconfiguration]
+recipe = slapos.cookbook:slapconfiguration
+computer = $${slap-connection:computer-id}
+partition = $${slap-connection:partition-id}
+url = $${slap-connection:server-url}
+key = $${slap-connection:key-file}
+cert = $${slap-connection:cert-file}
+configuration.erp5_url = https://softinst60318.host.vifib.net/erp5/Base_executePython
+
+[jinja2-template-base]
+recipe = slapos.recipe.template:jinja2
+rendered = $${buildout:directory}/$${:filename}
+extra-context =
+context =
+    import json_module json
+    key eggs_directory buildout:eggs-directory
+    key develop_eggs_directory buildout:develop-eggs-directory
+    key slap_software_type slap-parameters:slap-software-type
+    key slapparameter_dict slap-parameters:configuration
+    key slave_instance_list slap-parameters:slave-instance-list
+    $${:extra-context}
+
+[instance-parameter]
+port = 8888
+host = $${slapconfiguration:ipv6-random}
+cert_file = $${generate-certificate:cert_file}
+key_file = $${generate-certificate:key_file}
+logfile = $${directory:log}/ipython_notebook.log
+notebook_dir = $${directory:notebook_dir}
+
+[generate-certificate]
+; TODO: there is a slapos recipe to generate certificates. Use it instead
+recipe = plone.recipe.command
+command =
+  if [ ! -e $${instance-parameter:key_file} ]
+  then
+    ${openssl-output:openssl} req -x509 -nodes -days 3650 \
+      -subj "/C=AA/ST=X/L=X/O=Dis/CN=$${instance-parameter:host}" \
+      -newkey rsa:1024 -keyout $${instance-parameter:key_file} \
+      -out $${instance-parameter:cert_file}
+  fi
+update-command = $${:command}
+cert_file = $${directory:etc}/ipython_notebook_cert.crt
+key_file = $${directory:etc}/ipython_notebook_cert.key
+
+[instance]
+recipe = slapos.cookbook:wrapper
+command-line =
+  ${buildout:bin-directory}/ipython notebook
+  --no-browser
+  --matplotlib=inline
+  --ip=$${instance-parameter:host}
+  --port=$${instance-parameter:port}
+  --port-retries=0
+  --certfile=$${instance-parameter:cert_file}
+  --keyfile=$${instance-parameter:key_file}
+  --notebook-dir=$${instance-parameter:notebook_dir}
+  --logfile=$${instance-parameter:logfile}
+  --config=$${ipython_notebook_config:rendered}
+## Adding log-level as parameter is only for development process
+## and would be removed later.
+  --log-level="DEBUG"
+wrapper-path = $${directory:service}/ipython_notebook
+parameters-extra = true
+environment = IPYTHONDIR=$${directory:ipython_dir}
+
+[ipython_notebook_config]
+recipe = slapos.recipe.template:jinja2
+template = ${ipython_notebook_config:location}/${ipython_notebook_config:filename}
+rendered = $${directory:etc}/ipython_notebook_config.py
+mode = 0744
+context =
+  raw config_cfg $${buildout:directory}/knowledge0.cfg
+  raw ipython_dir $${directory:ipython_dir}
+
+[monitor-current-log-access]
+< = monitor-directory-access
+source = $${instance-parameter:logfile}
+
+[monitor-deploy-set-password-cgi]
+recipe = slapos.recipe.template:jinja2
+template = ${ipython_notebook_set_password:location}/${ipython_notebook_set_password:filename}
+rendered = $${monitor-directory:knowledge0-cgi}/$${:filename}
+filename = ipython-notebook-password.cgi
+mode = 0744
+context =
+  raw config_cfg $${buildout:directory}/knowledge0.cfg
+  raw python_executable ${buildout:bin-directory}/ipython
+  key pwd monitor-directory:knowledge0-cgi
+  key this_file :filename
+  key httpd_graceful cgi-httpd-graceful-wrapper:rendered
+
+[directory]
+recipe = slapos.cookbook:mkdirectory
+home = $${buildout:directory}
+etc = $${:home}/etc
+var = $${:home}/var
+script = $${:etc}/run/
+service = $${:etc}/service
+promise = $${:etc}/promise/
+log = $${:var}/log
+notebook_dir = $${:var}/notebooks
+ipython_dir = $${:home}/ipython
+ipython_kernel_dir = $${:ipython_dir}/kernels
+erp5_kernel_dir = $${:ipython_kernel_dir}/ERP5
+
+[publish-connection-parameter]
+recipe = slapos.cookbook:publish
+url = https://[$${instance-parameter:host}]:$${instance-parameter:port}
+monitor_url = $${monitor-parameters:url}
+erp5_url = $${slapconfiguration:configuration.erp5_url}
+
+[erp5-kernel]
+recipe = slapos.recipe.template:jinja2
+template = ${erp5-kernel:location}/${erp5-kernel:filename}
+rendered = $${directory:erp5_kernel_dir}/ERP5kernel.py
+mode = 0744
+context =
+  raw python_executable ${buildout:bin-directory}/pythonwitheggs
+  key erp5_url slapconfiguration:configuration.erp5_url
+
+[kernel-json]
+recipe = slapos.recipe.template:jinja2
+template = ${kernel-json:location}/${kernel-json:filename}
+rendered = $${directory:erp5_kernel_dir}/kernel.json
+mode = 0744
+context =
+  raw python_executable ${buildout:bin-directory}/pythonwitheggs
+  key kernel_dir erp5-kernel:rendered
+  raw display_name ERP5
+  raw language_name python
diff --git a/software/ipython_notebook/instance.cfg b/software/ipython_notebook/instance.cfg
index cb694587a..f86edf76a 100644
--- a/software/ipython_notebook/instance.cfg
+++ b/software/ipython_notebook/instance.cfg
@@ -8,4 +8,5 @@ offline = true
 
 [switch-softwaretype]
 recipe = slapos.cookbook:softwaretype
-default = ${template-ipynb:output}
+default = ${default-template-ipynb:output}
+notebook = ${template-ipynb:output}
\ No newline at end of file
diff --git a/software/ipython_notebook/software.cfg b/software/ipython_notebook/software.cfg
index edb70b92a..23f522310 100644
--- a/software/ipython_notebook/software.cfg
+++ b/software/ipython_notebook/software.cfg
@@ -16,6 +16,7 @@ parts =
   ipython_notebook_set_password
   instance
   template-ipynb
+  default-template-ipynb
 
 [ipython_notebook]
 ; In the ipython notebook software, we use more eggs than in the minimal
@@ -54,9 +55,16 @@ output = ${buildout:directory}/instance.cfg
 
 [template-ipynb]
 recipe = slapos.recipe.template
-url = ${:_profile_base_location_}/instance-ipython-default.cfg.in
+url = ${:_profile_base_location_}/instance-ipython-notebook.cfg.in
 md5sum = 5ba2484c3550a3254d14fcf1ed5fa6f4
-output = ${buildout:directory}/template-ipython.cfg
+output = ${buildout:directory}/template-ipython-notebook.cfg
+mode = 0644
+
+[default-template-ipynb]
+recipe = slapos.recipe.template
+url = ${:_profile_base_location_}/instance-ipython-default.cfg.in
+md5sum = bd573c4ab5e1893d3bf91ae5c7c0d792
+output = ${buildout:directory}/temlate-ipython-default.cfg.in
 mode = 0644
 
 [erp5-kernel]
-- 
2.30.9