Commit 2f71c25a authored by Paul Graydon's avatar Paul Graydon

software/ors-wendelin: Add ORS Wendelin software release

parent 11d198d0
[template-extend]
filename = instance.cfg.in
md5sum = f1136bb5482db1c2b8c6394bed386813
[template-ors-wendelin]
filename = instance-ors-wendelin.cfg.in
md5sum = 40d329c2f0eb5a064d385c7003e3edf8
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"project-title": {
"description": "Title of the ORS client project to register",
"title": "Client Project Title",
"type": "string"
},
"client-username": {
"description": "Username for the client project's user account",
"title": "Client Project Account Username",
"type": "string"
},
"ors-tag": {
"description": "Fluentbit tag of the ORS to register to the client project",
"title": "ORS Tag",
"type": "string"
},
"ors-title": {
"description": "Title of the ORS to register to the client project",
"title": "ORS Title",
"type": "string"
}
}
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Values returned by ORS Wendelin",
"type": "object",
"properties": {
"ors-wendelin-homepage": {
"description": "URL to the homepage of the ORS Wendelin platform",
"type": "string"
},
"username": {
"description": "Username for the project's user account",
"type": "string"
},
"init-password": {
"description": "Initial password for the project's user account",
"type": "string"
}
}
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"client-frontend-url": {
"description": "Base URL of the ORS Wendelin frontend instance intended for use by the clients.",
"type": "string"
}
}
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Values returned by ORS Wendelin",
"type": "object",
"properties": {
"slave-amount": {
"description": "Amount of slaves attached to this instance",
"type": "number"
}
}
}
[buildout]
extends =
{{ instance_erp5 }}
parts +=
ors-client-project-register
[directory]
ors-client-project-register = ${:etc}/ors-client-project-register
[ors-client-project-register]
recipe = slapos.recipe.build
slave-instance-list = {{ dumps(slave_instance_list) }}
ors-client-project-register-path = ${directory:ors-client-project-register}
backend-url = ${publish:family-default-v6}
client-frontend-url = {{ slapparameter_dict.get('client-frontend-url', '')}}
inituser-login = ${publish:inituser-login}
inituser-password = ${publish-early:inituser-password}
update =
import json
import logging
import os
import requests
import slapos
log = logging.getLogger('SLAPOS-ORS-WENDELIN')
logging.basicConfig(level=logging.INFO)
slap = slapos.slap.slap()
slap_connection = self.buildout['slap-connection']
self.computer_id = slap_connection['computer-id']
self.computer_partition_id = slap_connection['partition-id']
self.server_url = slap_connection['server-url']
self.software_release_url = slap_connection['software-release-url']
self.key_file = slap_connection.get('key-file')
self.cert_file = slap_connection.get('cert-file')
self.slave_instance_list = list(options['slave-instance-list'])
# Redeploy instance to update published information
slap.initializeConnection(self.server_url, self.key_file, self.cert_file)
computer_partition = slap.registerComputerPartition(self.computer_id, self.computer_partition_id)
ors_client_project_register_path = options['ors-client-project-register-path']
ors_wendelin_backend_url = options['backend-url']
ors_wendelin_client_frontend_url = options['client-frontend-url']
inituser_login = options['inituser-login']
inituser_password = options['inituser-password']
for slave in self.slave_instance_list:
slave_reference = slave['slave_reference']
try:
project_title = slave['project-title']
project_reference = project_title.replace(" ", "-").lower()
client_username = slave['client-username']
ors_tag = slave['ors-tag']
ors_title = slave['ors-title']
except KeyError as e:
log.fatal("%s: Parameter %s not found, skipping registration" % (slave_reference, e))
continue
register_file = os.path.join(ors_client_project_register_path, '%s.json' % slave_reference)
connection_dict = {}
if not os.path.exists(register_file):
with open(register_file, 'w') as file:
json.dump(connection_dict, file)
else:
with open(register_file, 'r') as file:
connection_dict = json.load(file)
request_url = "%s/erp5/ERP5Site_registerOrsClientProject?project_title=%s&project_reference=%s&client_username=%s&ors_tag=%s&ors_title=%s" \
% (ors_wendelin_backend_url, project_title, project_reference, client_username, ors_tag, ors_title)
response = requests.get(request_url, verify=False, auth=(inituser_login, inituser_password))
response = response.json()
error_msg_key = "error_msg"
if error_msg_key in response:
error_msg = response[error_msg_key]
log.info(error_msg)
else:
if "username" in response and "init_password" in response:
connection_dict = {
"username": response['username'],
"init-password": response['init_password']
}
with open(register_file, 'w') as file:
json.dump(connection_dict, file)
log.info("ORS client project successfully registered: %s" % slave_reference)
else:
log.fatal("Error while fetching client user account credentials")
continue
no_client_frontend_url_msg = "ORS Wendelin website has not been configured."
connection_dict['ors-wendelin-homepage'] = ors_wendelin_client_frontend_url or no_client_frontend_url_msg
try:
log.info("Update parameters for client project %s" % slave_reference)
computer_partition.setConnectionDict(connection_dict, slave_reference)
except Exception:
log.fatal("Error while sending slave %s information: %s",
slave_reference, traceback.format_exc())
[publish]
slave-amount = {{ len(slave_instance_list) }}
[buildout]
extends =
{{ template_base }}
[jinja2-template-extend]
recipe = slapos.recipe.template:jinja2
output = ${buildout:parts-directory}/${:_buildout_section_name_}/${:filename}
extra-context =
context =
key slapparameter_dict slap-configuration:configuration
${:extra-context}
[dynamic-template-ors-wendelin]
<= jinja2-template-extend
url = {{ template_ors_wendelin }}
filename = instance-ors-wendelin.cfg
extensions = jinja2.ext.do
extra-context =
import json_module json
key slave_instance_list slap-configuration:slave-instance-list
key instance_erp5 dynamic-template-erp5:output
[switch-softwaretype]
default = dynamic-template-ors-wendelin:output
[buildout]
extends =
buildout.hash.cfg
../../software/wendelin/software.cfg
parts +=
ors-wendelin
template-extend
[eggs]
eggs +=
websocket-client
${xlte:egg}
extra-paths +=
${ors-wendelin:location}
[xlte-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/kirr/xlte.git
branch = py2
git-executable = ${git:location}/bin/git
[xlte]
recipe = zc.recipe.egg:develop
setup = ${xlte-repository:location}
egg = xlte
depends =
${numpy:egg}
${pygolang:egg}
websocket-client
[wendelin]
recipe = slapos.recipe.build:gitclone
git-executable = ${git:location}/bin/git
repository = https://lab.nexedi.com/paul.graydon/wendelin.git
branch = ors_wendelin
revision =
[ors-wendelin]
<= erp5
repository = https://lab.nexedi.com/paul.graydon/ors-wendelin.git
branch = master
revision =
[local-bt5-repository]
list += ${ors-wendelin:location}/bt5
[erp5_repository_list]
repository_id_list += ors-wendelin
[default-bt5]
list =
erp5_full_text_mroonga_catalog
ors_configurator
[template]
output = ${buildout:directory}/template-base.cfg
[template-extend]
recipe = slapos.recipe.template:jinja2
url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/instance.cfg
extensions = jinja2.ext.do
context =
section buildout buildout
key template_base template:output
key template_ors_wendelin template-ors-wendelin:target
[download-base-extend]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename}
[template-ors-wendelin]
<= download-base-extend
[versions]
websocket-client = 0.59.0
backports.ssl-match-hostname = 3.7.0.1
{
"name": "ORS Wendelin",
"description": "Master instance of ORS Wendelin",
"serialisation": "xml",
"software-type": {
"default": {
"title": "Default",
"description": "ORS Wendelin",
"request": "instance-ors-wendelin-input-schema.json",
"response": "instance-ors-wendelin-output-schema.json",
"index": 0
},
"default-slave": {
"title": "Default (Shared)",
"description": "ORS Client Project Registration",
"software-type": "default",
"request": "instance-ors-shared-input-schema.json",
"response": "instance-ors-shared-output-schema.json",
"shared": true,
"index": 1
}
}
}
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