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
Labels
Merge Requests
103
Merge Requests
103
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
4787818d
Commit
4787818d
authored
Dec 08, 2021
by
Xavier Thompson
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/theia: Generate supply/request script for embedded instance
parent
ef393d63
Pipeline
#18887
failed with stage
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
44 deletions
+58
-44
software/theia/buildout.hash.cfg
software/theia/buildout.hash.cfg
+2
-2
software/theia/instance-theia.cfg.jinja.in
software/theia/instance-theia.cfg.jinja.in
+35
-14
software/theia/instance.cfg.in
software/theia/instance.cfg.in
+3
-1
software/theia/software.cfg
software/theia/software.cfg
+10
-22
software/theia/test/test.py
software/theia/test/test.py
+8
-5
No files found.
software/theia/buildout.hash.cfg
View file @
4787818d
...
...
@@ -15,11 +15,11 @@
[instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = 7
76d9275483b7378d13c5cf43a0ad886
md5sum = 7
8c99ef4799063dc5b67e76b8dba2112
[instance]
_update_hash_filename_ = instance.cfg.in
md5sum =
4d8d3a351f17c45048fd3ffaee978875
md5sum =
94703df1104405a5a73aa1bc980ea370
[instance-import]
_update_hash_filename_ = instance-import.cfg.jinja.in
...
...
software/theia/instance-theia.cfg.jinja.in
View file @
4787818d
...
...
@@ -444,6 +444,39 @@ command =
${buildout:bin-directory}/slapos complete --shell fish > $${directory:fish-completions}/slapos.fish
# Embedded Instance
# -----------------
{%- set embedded_sr = parameter_dict['embedded-sr'] %}
{%- set embedded_sr_type = parameter_dict['embedded-sr-type'] %}
{%- set embedded_instance_parameters = parameter_dict['embedded-instance-parameters'] %}
{%- if embedded_sr %}
{%- if embedded_sr.startswith('~/') %}
{%- set embedded_sr = os_module.path.join(partition_root_path, embedded_sr[2:]) %}
{%- set embedded_sr = os_module.path.normpath(embedded_sr) %}
{%- endif %}
[request-embedded-instance-script]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:project}/request_embedded.sh
mode = 0700
template =
inline:#!/bin/sh
slapos supply {{ embedded_sr }} slaprunner
slapos request "Embedded Instance" {{ embedded_sr }}
{%- if embedded_sr_type %} --type {{ embedded_sr_type }} {%- endif %}
{%- if embedded_instance_parameters %} --parameters-file $${embedded-instance-parameters:rendered}
[embedded-instance-parameters]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:project}/$${:_buildout_section_name_}.json
template =
inline:{{ embedded_instance_parameters | indent(2) }}
{%- endif %}
{%- endif %}
# SlapOS Standalone
# -----------------
...
...
@@ -488,12 +521,8 @@ template =
$${slapos-standalone-config:port} \
$${slapos-standalone-config:local-software-release-root} \
$${slapos-standalone-config:computer-id} \
{%- if parameter_dict.get('embedded-sr') %}
--sr='{{ parameter_dict['embedded-sr'] }}' \
{%- if parameter_dict.get('embedded-sr-type') %}
--srtype='{{ parameter_dict['embedded-sr-type'] }}' \
{%- endif %}
--srparams='$${embedded-instance-parameters:rendered}' \
{%- if embedded_sr %}
--slapos_script=$${request-embedded-instance-script:rendered} \
{%- endif %}
$${slap-connection:server-url} \
$${slap-connection:computer-id} \
...
...
@@ -622,14 +651,6 @@ recipe = slapos.cookbook:symbolic.link
target-directory = $${directory:project}
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]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:project}/$${:_buildout_section_name_}.sh
...
...
software/theia/instance.cfg.in
View file @
4787818d
...
...
@@ -36,14 +36,16 @@ context =
jsonkey default_parameter_dict :default-parameters
key parameter_dict slap-configuration:configuration
key root_title slap-configuration:root-instance-title
key partition_root_path buildout:directory
key ipv6_random slap-configuration:ipv6-random
key ipv4_random slap-configuration:ipv4-random
import os_module os
default-parameters =
{
"autorun": "running",
"embedded-sr": null,
"embedded-sr-type": null,
"embedded-instance-parameters":
"null"
,
"embedded-instance-parameters":
null
,
"frontend-name": "Theia Frontend",
"frontend-sr": "$${:frontend-sr}",
"frontend-sr-type": "RootSoftwareInstance",
...
...
software/theia/software.cfg
View file @
4787818d
...
...
@@ -62,6 +62,7 @@ initialization =
import os
import signal
import socket
import subprocess
import sys
import time
...
...
@@ -74,9 +75,7 @@ initialization =
parser.add_argument('server_port', type=int)
parser.add_argument('local_software_release_root')
parser.add_argument('computer_id')
parser.add_argument('--sr')
parser.add_argument('--srtype')
parser.add_argument('--srparams')
parser.add_argument('--slapos_script')
forwarded_arguments = parser.add_argument_group('forwarded')
forwarded_arguments.add_argument('master_url')
forwarded_arguments.add_argument('computer')
...
...
@@ -130,25 +129,14 @@ initialization =
except slapos.slap.standalone.SlapOSNodeCommandError as e:
print("Error instanciating: {}".format(e))
if 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.request(
args.sr,
"Embedded Instance",
args.srtype,
partition_parameter_kw=params,
)
if args.slapos_script:
print("Running SlapOS script {}".format(args.slapos_script))
slapos_env = {
'PATH': os.path.dirname(standalone._slapos_bin),
'SLAPOS_CONFIGURATION': standalone._slapos_config,
'SLAPOS_CLIENT_CONFIGURATION': standalone._slapos_config
}
subprocess.call((args.slapos_script,), env=slapos_env)
s = socket.socket(socket.AF_UNIX)
s.bind('\0' + os.path.join(args.base_directory, 'standalone_ready'))
...
...
software/theia/test/test.py
View file @
4787818d
...
...
@@ -230,9 +230,9 @@ class TestTheiaEmbeddedSlapOSShutdown(TheiaTestCase):
class
TestTheiaWithSR
(
TheiaTestCase
):
sr_url
=
'bogus/software.cfg'
sr_url
=
'
~/
bogus/software.cfg'
sr_type
=
'bogus_type'
instance_parameters
=
'{
\
n
"bogus_param": "bogus_value"
\
n
}'
instance_parameters
=
'{
\
n
"bogus_param": "bogus_value"
,
\
n
"bogus_param2": "bogus_value2"
\
n
}'
@
classmethod
def
getInstanceParameterDict
(
cls
):
...
...
@@ -243,15 +243,18 @@ class TestTheiaWithSR(TheiaTestCase):
}
def
test
(
self
):
home
=
self
.
computer_partition_root_path
bogus_sr
=
os
.
path
.
join
(
home
,
self
.
sr_url
[
2
:])
slapos
=
self
.
_getSlapos
()
info
=
subprocess
.
check_output
((
slapos
,
'proxy'
,
'show'
),
universal_newlines
=
True
)
instance_name
=
"Embedded Instance"
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+sl
aprunner\
s+
available"
%
(
bogus_sr
,),
info
),
info
)
self
.
assertIsNotNone
(
re
.
search
(
r"%s\
s+%s
\s+%s"
%
(
bogus_sr
,
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
)
self
.
assertIn
(
"{'bogus_param': 'bogus_value'
, 'bogus_param2': 'bogus_value2'
}"
,
service_info
)
class
TestTheiaFrontend
(
TheiaTestCase
):
...
...
Xavier Thompson
@xavier_thompson
mentioned in merge request
!1105 (merged)
·
Dec 17, 2021
mentioned in merge request
!1105 (merged)
mentioned in merge request !1105
Toggle commit list
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