Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos
Commits
329ca8b3
Commit
329ca8b3
authored
May 27, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Plain Diff
software/theia: Add embedded-instance-parameters option
See merge request
nexedi/slapos!987
parents
24463a79
ebec62b3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
43 deletions
+81
-43
software/theia/buildout.hash.cfg
software/theia/buildout.hash.cfg
+2
-2
software/theia/instance-input-schema.json
software/theia/instance-input-schema.json
+5
-0
software/theia/instance-theia.cfg.jinja.in
software/theia/instance-theia.cfg.jinja.in
+30
-24
software/theia/instance.cfg.in
software/theia/instance.cfg.in
+20
-15
software/theia/software.cfg
software/theia/software.cfg
+19
-2
software/theia/test/test.py
software/theia/test/test.py
+5
-0
No files found.
software/theia/buildout.hash.cfg
View file @
329ca8b3
...
@@ -15,11 +15,11 @@
...
@@ -15,11 +15,11 @@
[instance-theia]
[instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in
_update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum =
65c66a4cc4eb1d074dcafddf945a34d4
md5sum =
a4211295ecd3919b61abbcd51085971f
[instance]
[instance]
_update_hash_filename_ = instance.cfg.in
_update_hash_filename_ = instance.cfg.in
md5sum =
43923e3e1f27c43696ecbca9ee147bdb
md5sum =
9a5d6ac099c460481af7c1bdfd8de770
[yarn.lock]
[yarn.lock]
_update_hash_filename_ = yarn.lock
_update_hash_filename_ = yarn.lock
...
...
software/theia/instance-input-schema.json
View file @
329ca8b3
...
@@ -24,6 +24,11 @@
...
@@ -24,6 +24,11 @@
"description"
:
"Type of the optional embedded software"
,
"description"
:
"Type of the optional embedded software"
,
"type"
:
"string"
"type"
:
"string"
},
},
"embedded-instance-parameters"
:
{
"title"
:
"Embedded Instance Parameters"
,
"description"
:
"Parameters for the embedded instance, as a JSON dict"
,
"type"
:
"string"
},
"frontend-guid"
:
{
"frontend-guid"
:
{
"title"
:
"Frontend Instance ID"
,
"title"
:
"Frontend Instance ID"
,
"description"
:
"Unique identifier of the frontend instance, like
\"
SOFTINST-11031
\"
."
,
"description"
:
"Unique identifier of the frontend instance, like
\"
SOFTINST-11031
\"
."
,
...
...
software/theia/instance-theia.cfg.jinja.in
View file @
329ca8b3
{% set additional_frontend = slapconfiguration_section['configuration.additional-frontend-guid'] %}
{% set parameter_dict = dict(default_parameter_dict, **parameter_dict) %}
{% set additional_frontend = parameter_dict['additional-frontend-guid'] %}
[buildout]
[buildout]
extends =
extends =
...
@@ -26,12 +27,6 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
...
@@ -26,12 +27,6 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
offline = true
[instance-parameter]
{% for k, v in slapconfiguration_section.items() -%}
{{ k }} = {{ v }}
{% endfor -%}
[publish-connection-parameter]
[publish-connection-parameter]
<= monitor-publish
<= monitor-publish
recipe = slapos.cookbook:publish
recipe = slapos.cookbook:publish
...
@@ -142,18 +137,18 @@ return = domain secure_access
...
@@ -142,18 +137,18 @@ return = domain secure_access
[remote-frontend]
[remote-frontend]
<= remote-frontend-base
<= remote-frontend-base
name =
$${instance-parameter:configuration.frontend-name
}
name =
{{ parameter_dict['frontend-name'] }
}
software-url =
$${instance-parameter:configuration.frontend-sr
}
software-url =
{{ parameter_dict['frontend-sr'] }
}
software-type =
$${instance-parameter:configuration.frontend-sr-type
}
software-type =
{{ parameter_dict['frontend-sr-type'] }
}
sla-instance_guid =
$${instance-parameter:configuration.frontend-guid
}
sla-instance_guid =
{{ parameter_dict['frontend-guid'] }
}
{% if additional_frontend %}
{% if additional_frontend %}
[remote-additional-frontend]
[remote-additional-frontend]
<= remote-frontend-base
<= remote-frontend-base
name =
$${instance-parameter:configuration.additional-frontend-name
}
name =
{{ parameter_dict['additional-frontend-name'] }
}
software-url =
$${instance-parameter:configuration.additional-frontend-sr
}
software-url =
{{ parameter_dict['additional-frontend-sr'] }
}
software-type =
$${instance-parameter:configuration.additional-frontend-sr-type
}
software-type =
{{ parameter_dict['additional-frontend-sr-type'] }
}
sla-instance_guid =
$${instance-parameter:configuration.additional-frontend-guid
}
sla-instance_guid =
{{ parameter_dict['additional-frontend-guid'] }
}
{% endif %}
{% endif %}
...
@@ -169,7 +164,7 @@ bytes = 12
...
@@ -169,7 +164,7 @@ bytes = 12
recipe = slapos.cookbook:free_port
recipe = slapos.cookbook:free_port
minimum = 3000
minimum = 3000
maximum = 3100
maximum = 3100
ip =
$${instance-parameter:ipv6-random
}
ip =
{{ ipv6_random }
}
[frontend-instance-certificate]
[frontend-instance-certificate]
recipe = plone.recipe.command
recipe = plone.recipe.command
...
@@ -325,7 +320,7 @@ template =
...
@@ -325,7 +320,7 @@ template =
recipe = slapos.cookbook:free_port
recipe = slapos.cookbook:free_port
minimum = 3500
minimum = 3500
maximum = 3600
maximum = 3600
ip =
$${instance-parameter:ipv4-random
}
ip =
{{ ipv4_random }
}
[theia-service]
[theia-service]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
...
@@ -360,7 +355,7 @@ command-line = $${theia-service:rendered} --hostname=$${:hostname} --port=$${:p
...
@@ -360,7 +355,7 @@ command-line = $${theia-service:rendered} --hostname=$${:hostname} --port=$${:p
hash-existing-files =
hash-existing-files =
${yarn.lock:output}
${yarn.lock:output}
${theia-wrapper:rendered}
${theia-wrapper:rendered}
ip =
$${instance-parameter:ipv4-random
}
ip =
{{ ipv4_random }
}
hostname = $${:ip}
hostname = $${:ip}
port = $${theia-service:port}
port = $${theia-service:port}
base-url = $${theia-service:base-url}
base-url = $${theia-service:base-url}
...
@@ -416,11 +411,11 @@ command =
...
@@ -416,11 +411,11 @@ command =
recipe = slapos.cookbook:free_port
recipe = slapos.cookbook:free_port
minimum = 4000
minimum = 4000
maximum = 4100
maximum = 4100
ip =
$${instance-parameter:ipv4-random
}
ip =
{{ ipv4_random }
}
[slapos-standalone-config]
[slapos-standalone-config]
ipv4 =
$${instance-parameter:ipv4-random
}
ipv4 =
{{ ipv4_random }
}
ipv6 =
$${instance-parameter:ipv6-random
}
ipv6 =
{{ ipv6_random }
}
port = $${slapos-standalone-port:port}
port = $${slapos-standalone-port:port}
slapos-configuration = $${directory:runner}/etc/slapos.cfg
slapos-configuration = $${directory:runner}/etc/slapos.cfg
computer-id = slaprunner
computer-id = slaprunner
...
@@ -451,8 +446,11 @@ template =
...
@@ -451,8 +446,11 @@ template =
$${slapos-standalone-config:ipv6} \
$${slapos-standalone-config:ipv6} \
$${slapos-standalone-config:port} \
$${slapos-standalone-config:port} \
$${slapos-standalone-config:computer-id} \
$${slapos-standalone-config:computer-id} \
--sr='$${instance-parameter:configuration.embedded-sr}' \
{% if parameter_dict.get('embedded-sr') %} \
--srtype='$${instance-parameter:configuration.embedded-sr-type}' \
--sr='{{ parameter_dict['embedded-sr'] }}' \
--srtype='{{ parameter_dict['embedded-sr-type'] }}' \
--srparams='$${embedded-instance-parameters:rendered}' \
{% endif %} \
$${slap-connection:server-url} \
$${slap-connection:server-url} \
$${slap-connection:computer-id} \
$${slap-connection:computer-id} \
$${slap-connection:partition-id} \
$${slap-connection:partition-id} \
...
@@ -482,7 +480,7 @@ command =
...
@@ -482,7 +480,7 @@ command =
update-command = $${:command}
update-command = $${:command}
service-name = slapos-node-auto
service-name = slapos-node-auto
supervisor-conf = $${directory:runner}/etc/supervisord.conf
supervisor-conf = $${directory:runner}/etc/supervisord.conf
autorun =
$${instance-parameter:configuration.autorun
}
autorun =
{{ parameter_dict['autorun'] }
}
# Theia Local Environment Setup
# Theia Local Environment Setup
...
@@ -579,6 +577,14 @@ recipe = slapos.cookbook:symbolic.link
...
@@ -579,6 +577,14 @@ recipe = slapos.cookbook:symbolic.link
target-directory = $${directory:project}
target-directory = $${directory:project}
link-binary = $${directory:runner}
link-binary = $${directory:runner}
{% if parameter_dict.get('embedded-sr') -%}
[embedded-instance-parameters]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:etc}/$${:_buildout_section_name_}.json
template =
inline:{{ parameter_dict['embedded-instance-parameters'] | indent(2) }}
{%- endif %}
[request-script-template]
[request-script-template]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
rendered = $${directory:project}/$${:_buildout_section_name_}.sh
rendered = $${directory:project}/$${:_buildout_section_name_}.sh
...
...
software/theia/instance.cfg.in
View file @
329ca8b3
...
@@ -12,20 +12,6 @@ partition = $${slap-connection:partition-id}
...
@@ -12,20 +12,6 @@ partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
cert = $${slap-connection:cert-file}
;Theia default configuration
configuration.autorun = running
configuration.embedded-sr =
configuration.embedded-sr-type =
;Frontend default configuration
configuration.frontend-name = Theia Frontend
configuration.frontend-sr = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
configuration.frontend-sr-type = RootSoftwareInstance
configuration.frontend-guid =
;Additional frontend default configuration
configuration.additional-frontend-name = Theia Additional Frontend
configuration.additional-frontend-sr = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
configuration.additional-frontend-sr-type = RootSoftwareInstance
configuration.additional-frontend-guid =
[switch-softwaretype]
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
recipe = slapos.cookbook:switch-softwaretype
...
@@ -39,4 +25,23 @@ template = ${instance-theia:output}
...
@@ -39,4 +25,23 @@ template = ${instance-theia:output}
rendered = $${buildout:directory}/instance-theia.cfg
rendered = $${buildout:directory}/instance-theia.cfg
mode = 0644
mode = 0644
context =
context =
section slapconfiguration_section slap-configuration
jsonkey default_parameter_dict :default-parameters
key parameter_dict slap-configuration:configuration
key ipv6_random slap-configuration:ipv6-random
key ipv4_random slap-configuration:ipv4-random
default-parameters =
{
"autorun": "running",
"embedded-sr": null,
"embedded-sr-type": null,
"embedded-instance-parameters": "null",
"frontend-name": "Theia Frontend",
"frontend-sr": "$${:frontend-sr}",
"frontend-sr-type": "RootSoftwareInstance",
"frontend-guid": null,
"additional-frontend-name":"Theia Additional Frontend",
"additional-frontend-sr": "$${:frontend-sr}",
"additional-frontend-sr-type": "RootSoftwareInstance",
"additional-frontend-guid": null
}
frontend-sr = http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg
software/theia/software.cfg
View file @
329ca8b3
...
@@ -53,6 +53,7 @@ entry-points =
...
@@ -53,6 +53,7 @@ entry-points =
initialization =
initialization =
import argparse
import argparse
import glob
import glob
import json
import os.path
import os.path
import sys
import sys
import signal
import signal
...
@@ -68,6 +69,7 @@ initialization =
...
@@ -68,6 +69,7 @@ initialization =
parser.add_argument('computer_id')
parser.add_argument('computer_id')
parser.add_argument('--sr')
parser.add_argument('--sr')
parser.add_argument('--srtype')
parser.add_argument('--srtype')
parser.add_argument('--srparams')
forwarded_arguments = parser.add_argument_group('forwarded')
forwarded_arguments = parser.add_argument_group('forwarded')
forwarded_arguments.add_argument('master_url')
forwarded_arguments.add_argument('master_url')
forwarded_arguments.add_argument('computer')
forwarded_arguments.add_argument('computer')
...
@@ -118,9 +120,24 @@ initialization =
...
@@ -118,9 +120,24 @@ initialization =
print("Error instanciating: {}".format(e))
print("Error instanciating: {}".format(e))
if args.sr:
if args.sr:
print("Supplying and Requesting Embedded Software {}".format(args.sr))
try:
with open(args.srparams) as f:
params = json.load(f)
except Exception:
params = None
if not isinstance(params, dict):
params = None
print("Supplying and Requesting Embedded Software {sr} with type {srtype}".format(
sr=args.sr, srtype=args.srtype))
print("With parameters {param_dict} parsed from '{srparams}'".format(
param_dict=params, srparams=args.srparams))
standalone.supply(args.sr)
standalone.supply(args.sr)
standalone.request(args.sr, "Embedded Instance", args.srtype or None)
standalone.request(
args.sr,
"Embedded Instance",
args.srtype or None,
partition_parameter_kw=params,
)
quit_requested = []
quit_requested = []
def signal_handler(signum, frame):
def signal_handler(signum, frame):
...
...
software/theia/test/test.py
View file @
329ca8b3
...
@@ -232,12 +232,14 @@ class TestTheiaEmbeddedSlapOSShutdown(TheiaTestCase):
...
@@ -232,12 +232,14 @@ class TestTheiaEmbeddedSlapOSShutdown(TheiaTestCase):
class
TestTheiaWithSR
(
TheiaTestCase
):
class
TestTheiaWithSR
(
TheiaTestCase
):
sr_url
=
'bogus/software.cfg'
sr_url
=
'bogus/software.cfg'
sr_type
=
'bogus_type'
sr_type
=
'bogus_type'
instance_parameters
=
'{
\
n
"bogus_param": "bogus_value"
\
n
}'
@
classmethod
@
classmethod
def
getInstanceParameterDict
(
cls
):
def
getInstanceParameterDict
(
cls
):
return
{
return
{
'embedded-sr'
:
cls
.
sr_url
,
'embedded-sr'
:
cls
.
sr_url
,
'embedded-sr-type'
:
cls
.
sr_type
,
'embedded-sr-type'
:
cls
.
sr_type
,
'embedded-instance-parameters'
:
cls
.
instance_parameters
}
}
def
test
(
self
):
def
test
(
self
):
...
@@ -248,6 +250,9 @@ class TestTheiaWithSR(TheiaTestCase):
...
@@ -248,6 +250,9 @@ class TestTheiaWithSR(TheiaTestCase):
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+sl
aprunner\
s+
available"
%
(
self
.
sr_url
,),
info
),
info
)
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+sl
aprunner\
s+
available"
%
(
self
.
sr_url
,),
info
),
info
)
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+%s
\s+%s"
%
(
self
.
sr_url
,
self
.
sr_type
,
instance_name
),
info
),
info
)
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+%s
\s+%s"
%
(
self
.
sr_url
,
self
.
sr_type
,
instance_name
),
info
),
info
)
service_info
=
subprocess
.
check_output
((
slapos
,
'service'
,
'info'
,
instance_name
),
universal_newlines
=
True
)
self
.
assertIn
(
"{'bogus_param': 'bogus_value'}"
,
service_info
)
class
TestTheiaFrontend
(
TheiaTestCase
):
class
TestTheiaFrontend
(
TheiaTestCase
):
@
classmethod
@
classmethod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment