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
Léo-Paul Géneau
slapos
Commits
4787818d
Commit
4787818d
authored
Dec 08, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/theia: Generate supply/request script for embedded instance
parent
ef393d63
Changes
5
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 @@
...
@@ -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 = 7
76d9275483b7378d13c5cf43a0ad886
md5sum = 7
8c99ef4799063dc5b67e76b8dba2112
[instance]
[instance]
_update_hash_filename_ = instance.cfg.in
_update_hash_filename_ = instance.cfg.in
md5sum =
4d8d3a351f17c45048fd3ffaee978875
md5sum =
94703df1104405a5a73aa1bc980ea370
[instance-import]
[instance-import]
_update_hash_filename_ = instance-import.cfg.jinja.in
_update_hash_filename_ = instance-import.cfg.jinja.in
...
...
software/theia/instance-theia.cfg.jinja.in
View file @
4787818d
...
@@ -444,6 +444,39 @@ command =
...
@@ -444,6 +444,39 @@ command =
${buildout:bin-directory}/slapos complete --shell fish > $${directory:fish-completions}/slapos.fish
${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
# SlapOS Standalone
# -----------------
# -----------------
...
@@ -488,12 +521,8 @@ template =
...
@@ -488,12 +521,8 @@ template =
$${slapos-standalone-config:port} \
$${slapos-standalone-config:port} \
$${slapos-standalone-config:local-software-release-root} \
$${slapos-standalone-config:local-software-release-root} \
$${slapos-standalone-config:computer-id} \
$${slapos-standalone-config:computer-id} \
{%- if parameter_dict.get('embedded-sr') %}
{%- if embedded_sr %}
--sr='{{ parameter_dict['embedded-sr'] }}' \
--slapos_script=$${request-embedded-instance-script:rendered} \
{%- if parameter_dict.get('embedded-sr-type') %}
--srtype='{{ parameter_dict['embedded-sr-type'] }}' \
{%- endif %}
--srparams='$${embedded-instance-parameters:rendered}' \
{%- endif %}
{%- endif %}
$${slap-connection:server-url} \
$${slap-connection:server-url} \
$${slap-connection:computer-id} \
$${slap-connection:computer-id} \
...
@@ -622,14 +651,6 @@ recipe = slapos.cookbook:symbolic.link
...
@@ -622,14 +651,6 @@ 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 @
4787818d
...
@@ -36,14 +36,16 @@ context =
...
@@ -36,14 +36,16 @@ context =
jsonkey default_parameter_dict :default-parameters
jsonkey default_parameter_dict :default-parameters
key parameter_dict slap-configuration:configuration
key parameter_dict slap-configuration:configuration
key root_title slap-configuration:root-instance-title
key root_title slap-configuration:root-instance-title
key partition_root_path buildout:directory
key ipv6_random slap-configuration:ipv6-random
key ipv6_random slap-configuration:ipv6-random
key ipv4_random slap-configuration:ipv4-random
key ipv4_random slap-configuration:ipv4-random
import os_module os
default-parameters =
default-parameters =
{
{
"autorun": "running",
"autorun": "running",
"embedded-sr": null,
"embedded-sr": null,
"embedded-sr-type": null,
"embedded-sr-type": null,
"embedded-instance-parameters":
"null"
,
"embedded-instance-parameters":
null
,
"frontend-name": "Theia Frontend",
"frontend-name": "Theia Frontend",
"frontend-sr": "$${:frontend-sr}",
"frontend-sr": "$${:frontend-sr}",
"frontend-sr-type": "RootSoftwareInstance",
"frontend-sr-type": "RootSoftwareInstance",
...
...
software/theia/software.cfg
View file @
4787818d
...
@@ -62,6 +62,7 @@ initialization =
...
@@ -62,6 +62,7 @@ initialization =
import os
import os
import signal
import signal
import socket
import socket
import subprocess
import sys
import sys
import time
import time
...
@@ -74,9 +75,7 @@ initialization =
...
@@ -74,9 +75,7 @@ initialization =
parser.add_argument('server_port', type=int)
parser.add_argument('server_port', type=int)
parser.add_argument('local_software_release_root')
parser.add_argument('local_software_release_root')
parser.add_argument('computer_id')
parser.add_argument('computer_id')
parser.add_argument('--sr')
parser.add_argument('--slapos_script')
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')
...
@@ -130,25 +129,14 @@ initialization =
...
@@ -130,25 +129,14 @@ initialization =
except slapos.slap.standalone.SlapOSNodeCommandError as e:
except slapos.slap.standalone.SlapOSNodeCommandError as e:
print("Error instanciating: {}".format(e))
print("Error instanciating: {}".format(e))
if args.sr:
if args.slapos_script:
try:
print("Running SlapOS script {}".format(args.slapos_script))
with open(args.srparams) as f:
slapos_env = {
params = json.load(f)
'PATH': os.path.dirname(standalone._slapos_bin),
except Exception:
'SLAPOS_CONFIGURATION': standalone._slapos_config,
params = None
'SLAPOS_CLIENT_CONFIGURATION': standalone._slapos_config
if not isinstance(params, dict):
}
params = None
subprocess.call((args.slapos_script,), env=slapos_env)
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,
)
s = socket.socket(socket.AF_UNIX)
s = socket.socket(socket.AF_UNIX)
s.bind('\0' + os.path.join(args.base_directory, 'standalone_ready'))
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):
...
@@ -230,9 +230,9 @@ 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
}'
instance_parameters
=
'{
\
n
"bogus_param": "bogus_value"
,
\
n
"bogus_param2": "bogus_value2"
\
n
}'
@
classmethod
@
classmethod
def
getInstanceParameterDict
(
cls
):
def
getInstanceParameterDict
(
cls
):
...
@@ -243,15 +243,18 @@ class TestTheiaWithSR(TheiaTestCase):
...
@@ -243,15 +243,18 @@ class TestTheiaWithSR(TheiaTestCase):
}
}
def
test
(
self
):
def
test
(
self
):
home
=
self
.
computer_partition_root_path
bogus_sr
=
os
.
path
.
join
(
home
,
self
.
sr_url
[
2
:])
slapos
=
self
.
_getSlapos
()
slapos
=
self
.
_getSlapos
()
info
=
subprocess
.
check_output
((
slapos
,
'proxy'
,
'show'
),
universal_newlines
=
True
)
info
=
subprocess
.
check_output
((
slapos
,
'proxy'
,
'show'
),
universal_newlines
=
True
)
instance_name
=
"Embedded Instance"
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+sl
aprunner\
s+
available"
%
(
bogus_sr
,),
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"
%
(
bogus_sr
,
self
.
sr_type
,
instance_name
),
info
),
info
)
service_info
=
subprocess
.
check_output
((
slapos
,
'service'
,
'info'
,
instance_name
),
universal_newlines
=
True
)
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
):
class
TestTheiaFrontend
(
TheiaTestCase
):
...
...
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