Commit 7a712e61 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

software/kvm,theia: request additional frontend even if only additional software URL is given

Also upgrade slapos.toolbox to have better promises.

See merge request !1711
parent ec91edf6
Pipeline #38742 failed with stage
in 0 seconds
...@@ -19,15 +19,15 @@ md5sum = bf0a70140e4775efaacdd5fe03ac3b62 ...@@ -19,15 +19,15 @@ md5sum = bf0a70140e4775efaacdd5fe03ac3b62
[template-kvm] [template-kvm]
filename = instance-kvm.cfg.jinja2 filename = instance-kvm.cfg.jinja2
md5sum = 20554e40f9fe666839ef86ff8216cebf md5sum = 957f3a3c8e5f9a905026cc01a25b326e
[template-kvm-cluster] [template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in filename = instance-kvm-cluster.cfg.jinja2.in
md5sum = 8ce14c5ae114dcfa6e9aff0511b218d4 md5sum = 4cf9362641f6fb61158ff901cf81dffd
[template-kvm-resilient] [template-kvm-resilient]
filename = instance-kvm-resilient.cfg.jinja2 filename = instance-kvm-resilient.cfg.jinja2
md5sum = 839fc16c112d3b87e2dbd2e382e326de md5sum = 12d46a7d45f00e091d18e6d4552d0973
[template-kvm-import] [template-kvm-import]
filename = instance-kvm-import.cfg.jinja2.in filename = instance-kvm-import.cfg.jinja2.in
......
...@@ -27,18 +27,18 @@ ...@@ -27,18 +27,18 @@
}, },
"frontend-additional-instance-guid": { "frontend-additional-instance-guid": {
"title": "Additional Frontend Instance ID", "title": "Additional Frontend Instance ID",
"description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\", if empty won't be requested.", "description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string" "type": "string"
}, },
"frontend-additional-software-type": { "frontend-additional-software-type": {
"title": "Additional Frontend Software Type", "title": "Additional Frontend Software Type",
"description": "Type of the frontend instance, like \"default\".", "description": "Type of the additional frontend instance, like \"default\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"default": "default" "default": "default"
}, },
"frontend-additional-software-url": { "frontend-additional-software-url": {
"title": "Additional Frontend Software URL", "title": "Additional Frontend Software URL",
"description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".", "description": "Software Release URL of the additional frontend instance, like \"http://example.com/path/to/software.cfg\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"format": "uri", "format": "uri",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg" "default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
{% set slave_frontend_iguid = slave_frontend_dict.get('instance-guid', '') -%} {% set slave_frontend_iguid = slave_frontend_dict.get('instance-guid', '') -%}
{% set WEBSOCKET_FRONTEND_DEFAULT_SR = 'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg' %} {% set WEBSOCKET_FRONTEND_DEFAULT_SR = 'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg' %}
{% set WEBSOCKET_FRONTEND_DEFAULT_ST = 'default' %} {% set WEBSOCKET_FRONTEND_DEFAULT_ST = 'default' %}
{% set additional_frontend = frontend_dict.get('frontend-additional-instance-guid') or frontend_dict.get('frontend-additional-software-type') or frontend_dict.get('frontend-additional-software-url')%}
{% set kvm_instance_dict = {} -%} {% set kvm_instance_dict = {} -%}
{% set kvm_hostname_list = [] -%} {% set kvm_hostname_list = [] -%}
{% set monitor_base_url_dict = {} -%} {% set monitor_base_url_dict = {} -%}
...@@ -62,14 +63,16 @@ state = stopped ...@@ -62,14 +63,16 @@ state = stopped
{% endif -%} {% endif -%}
config-frontend-instance-name = {{ instance_name ~ ' VNC Real Frontend' }} config-frontend-instance-name = {{ instance_name ~ ' VNC Real Frontend' }}
{{ setconfig('frontend-software-url', frontend_dict.get('frontend-software-url', WEBSOCKET_FRONTEND_DEFAULT_SR)) }} {{ setconfig('frontend-software-url', frontend_dict.get('frontend-software-url')) }}
{{ setconfig('frontend-software-type', frontend_dict.get('frontend-software-type', WEBSOCKET_FRONTEND_DEFAULT_ST)) }} {{ setconfig('frontend-software-type', frontend_dict.get('frontend-software-type')) }}
{{ setconfig('frontend-instance-guid', frontend_dict.get('frontend-instance-guid', '')) }} {{ setconfig('frontend-instance-guid', frontend_dict.get('frontend-instance-guid')) }}
{% if additional_frontend -%}
config-frontend-additional-instance-name = {{ instance_name ~ ' VNC Real Frontend Additional' }} config-frontend-additional-instance-name = {{ instance_name ~ ' VNC Real Frontend Additional' }}
{{ setconfig('frontend-additional-software-url', frontend_dict.get('frontend-additional-software-url', WEBSOCKET_FRONTEND_DEFAULT_SR)) }} {{ setconfig('frontend-additional-software-url', frontend_dict.get('frontend-additional-software-url')) }}
{{ setconfig('frontend-additional-software-type', frontend_dict.get('frontend-additional-software-type', WEBSOCKET_FRONTEND_DEFAULT_ST)) }} {{ setconfig('frontend-additional-software-type', frontend_dict.get('frontend-additional-software-type')) }}
{{ setconfig('frontend-additional-instance-guid', frontend_dict.get('frontend-additional-instance-guid', '')) }} {{ setconfig('frontend-additional-instance-guid', frontend_dict.get('frontend-additional-instance-guid')) }}
{% endif -%}
config-name = {{ instance_name }} config-name = {{ instance_name }}
{% if slapparameter_dict.get('authorized-keys', []) -%} {% if slapparameter_dict.get('authorized-keys', []) -%}
...@@ -157,7 +160,7 @@ sla-fw_restricted_access = {{ dumps(slapparameter_dict.get('fw-restricted-access ...@@ -157,7 +160,7 @@ sla-fw_restricted_access = {{ dumps(slapparameter_dict.get('fw-restricted-access
return = return =
url url
{% if frontend_dict.get('frontend-additional-instance-guid') %} {% if additional_frontend %}
url-additional url-additional
{% endif %} {% endif %}
backend-url backend-url
...@@ -185,7 +188,7 @@ return = ...@@ -185,7 +188,7 @@ return =
{% do monitor_base_url_dict.__setitem__(instance_name, '${' ~ section ~ ':connection-monitor-base-url}') -%} {% do monitor_base_url_dict.__setitem__(instance_name, '${' ~ section ~ ':connection-monitor-base-url}') -%}
{% do publish_dict.__setitem__(instance_name ~ '-backend-url', '${' ~ section ~ ':connection-backend-url}') -%} {% do publish_dict.__setitem__(instance_name ~ '-backend-url', '${' ~ section ~ ':connection-backend-url}') -%}
{% do publish_dict.__setitem__(instance_name ~ '-url', '${' ~ section ~ ':connection-url}') -%} {% do publish_dict.__setitem__(instance_name ~ '-url', '${' ~ section ~ ':connection-url}') -%}
{% if frontend_dict.get('frontend-additional-instance-guid') %} {% if additional_frontend %}
{% do publish_dict.__setitem__(instance_name ~ '-url-additional', '${' ~ section ~ ':connection-url-additional}') -%} {% do publish_dict.__setitem__(instance_name ~ '-url-additional', '${' ~ section ~ ':connection-url-additional}') -%}
{% endif %} {% endif %}
{% do kvm_instance_dict.__setitem__(instance_name, (use_nat, nat_rules_list)) -%} {% do kvm_instance_dict.__setitem__(instance_name, (use_nat, nat_rules_list)) -%}
......
...@@ -269,18 +269,18 @@ ...@@ -269,18 +269,18 @@
}, },
"frontend-additional-instance-guid": { "frontend-additional-instance-guid": {
"title": "Additional Frontend Instance ID", "title": "Additional Frontend Instance ID",
"description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\", if empty won't be requested.", "description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string" "type": "string"
}, },
"frontend-additional-software-type": { "frontend-additional-software-type": {
"title": "Additional Frontend Software Type", "title": "Additional Frontend Software Type",
"description": "Type of the frontend instance, like \"frontend\".", "description": "Type of the additional frontend instance, like \"frontend\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"default": "default" "default": "default"
}, },
"frontend-additional-software-url": { "frontend-additional-software-url": {
"title": "Additional Frontend Software URL", "title": "Additional Frontend Software URL",
"description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".", "description": "Software Release URL of the additional frontend instance, like \"http://example.com/path/to/software.cfg\". Note that if the 3 options 'frontend-additional-instance-guid', 'frontend-additional-software-type' and 'frontend-additional-software-url' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"format": "uri", "format": "uri",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg" "default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
{% set monitor_dict = {'parameter': monitor_parameter, 'return': monitor_return} -%} {% set monitor_dict = {'parameter': monitor_parameter, 'return': monitor_return} -%}
{% endif -%} {% endif -%}
{% set monitor_interface_url = slapparameter_dict.pop('monitor-interface-url', 'https://monitor.app.officejs.com') -%} {% set monitor_interface_url = slapparameter_dict.pop('monitor-interface-url', 'https://monitor.app.officejs.com') -%}
{% set additional_frontend = (slapparameter_dict.get('frontend-additional-instance-guid', '').strip() != '') %} {% set additional_frontend = slapparameter_dict.get('frontend-additional-instance-guid') or slapparameter_dict.get('frontend-additional-software-type') or slapparameter_dict.get('frontend-additional-software-url')%}
[buildout] [buildout]
eggs-directory = {{ eggs_directory }} eggs-directory = {{ eggs_directory }}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% do slapparameter_dict.__setitem__(k, '') %} {% do slapparameter_dict.__setitem__(k, '') %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% set additional_frontend = slapparameter_dict.get('frontend-additional-instance-guid') %} {% set additional_frontend = slapparameter_dict.get('frontend-additional-instance-guid') or slapparameter_dict.get('frontend-additional-software-type') or slapparameter_dict.get('frontend-additional-software-url')%}
{% set enable_http = slapparameter_dict.get('enable-http-server', False) -%} {% set enable_http = slapparameter_dict.get('enable-http-server', False) -%}
{% set use_tap = slapparameter_dict.get('use-tap', True) -%} {% set use_tap = slapparameter_dict.get('use-tap', True) -%}
{% set use_nat = slapparameter_dict.get('use-nat', True) -%} {% set use_nat = slapparameter_dict.get('use-nat', True) -%}
...@@ -773,7 +773,9 @@ config-content-to-receive = {{ dumps('RFB 003.008\n'.encode()) }} ...@@ -773,7 +773,9 @@ config-content-to-receive = {{ dumps('RFB 003.008\n'.encode()) }}
software-url = ${slap-parameter:frontend-additional-software-url} software-url = ${slap-parameter:frontend-additional-software-url}
software-type = ${slap-parameter:frontend-additional-software-type} software-type = ${slap-parameter:frontend-additional-software-type}
name = ${slap-parameter:frontend-additional-instance-name} name = ${slap-parameter:frontend-additional-instance-name}
{% if slapparameter_dict.get('frontend-additional-instance-guid') %}
sla-instance_guid = ${slap-parameter:frontend-additional-instance-guid} sla-instance_guid = ${slap-parameter:frontend-additional-instance-guid}
{% endif %}
[frontend-additional-promise] [frontend-additional-promise]
<= monitor-promise-base <= monitor-promise-base
......
...@@ -629,6 +629,13 @@ class TestAccessDefaultAdditional(MonitorAccessMixin, KVMTestCase): ...@@ -629,6 +629,13 @@ class TestAccessDefaultAdditional(MonitorAccessMixin, KVMTestCase):
) )
self.assertIn('<title>noVNC</title>', result.text) self.assertIn('<title>noVNC</title>', result.text)
@skipUnlessKvm
class TestAccessDefaultAdditionalJson(TestAccessDefaultAdditional):
@classmethod
def getInstanceParameterDict(cls):
return {
'frontend-additional-software-url': 'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg'
}
@skipUnlessKvm @skipUnlessKvm
class TestAccessDefaultAdditionalJson( class TestAccessDefaultAdditionalJson(
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance-theia] [instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in _update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = b4e87cff99a8521e6d0b911e3ef35b30 md5sum = 6ea30357440478f3fe5400184da73315
[instance] [instance]
_update_hash_filename_ = instance.cfg.in _update_hash_filename_ = instance.cfg.in
......
...@@ -56,19 +56,19 @@ ...@@ -56,19 +56,19 @@
}, },
"additional-frontend-guid": { "additional-frontend-guid": {
"title": "Additional Frontend Instance ID", "title": "Additional Frontend Instance ID",
"description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\", if empty won't be requested.", "description": "Unique identifier of the additional frontend instance, like \"SOFTINST-11031\". Note that if the 3 options 'additional-frontend-guid', 'additional-frontend-sr-type' and 'additional-frontend-sr' are empty, the additional frontend won't be requested.",
"type": "string" "type": "string"
}, },
"additional-frontend-sr": { "additional-frontend-sr": {
"title": "Additional Frontend Software URL", "title": "Additional Frontend Software URL",
"description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\".", "description": "Software Release URL of the frontend instance, like \"http://example.com/path/to/software.cfg\". Note that if the 3 options 'additional-frontend-guid', 'additional-frontend-sr-type' and 'additional-frontend-sr' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"format": "uri", "format": "uri",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg" "default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
}, },
"additional-frontend-sr-type": { "additional-frontend-sr-type": {
"title": "Additional Frontend Software Type", "title": "Additional Frontend Software Type",
"description": "Type of the frontend instance, like \"frontend\".", "description": "Type of the frontend instance, like \"frontend\". Note that if the 3 options 'additional-frontend-guid', 'additional-frontend-sr-type' and 'additional-frontend-sr' are empty, the additional frontend won't be requested.",
"type": "string", "type": "string",
"default": "default" "default": "default"
} }
......
# compute additional_frontend before resolving the defaults
{%- set additional_frontend = parameter_dict.get('additional-frontend-guid') or parameter_dict.get('additional-frontend-sr') or parameter_dict.get('additional-frontend-sr-type') %}
{%- set parameter_dict = dict(default_parameter_dict, **parameter_dict) %} {%- set parameter_dict = dict(default_parameter_dict, **parameter_dict) %}
{%- set additional_frontend = parameter_dict['additional-frontend-guid'] %}
{%- set embedded_instance_config = parameter_dict['initial-embedded-instance'] %} {%- set embedded_instance_config = parameter_dict['initial-embedded-instance'] %}
[buildout] [buildout]
......
...@@ -400,6 +400,12 @@ class TestTheiaFrontend(TheiaTestCase): ...@@ -400,6 +400,12 @@ class TestTheiaFrontend(TheiaTestCase):
resp = requests.get(self.connection_parameters[key], verify=False) resp = requests.get(self.connection_parameters[key], verify=False)
self.assertEqual(requests.codes.unauthorized, resp.status_code) self.assertEqual(requests.codes.unauthorized, resp.status_code)
class TestTheiaFrontendOtherAdditional(TestTheiaFrontend):
@classmethod
def getInstanceParameterDict(cls):
return {
'additional-frontend-sr': 'http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg'
}
class TestTheiaForwardFrontendRequestsEnabled(TheiaTestCase): class TestTheiaForwardFrontendRequestsEnabled(TheiaTestCase):
......
...@@ -366,7 +366,7 @@ slapos.rebootstrap = 4.7 ...@@ -366,7 +366,7 @@ slapos.rebootstrap = 4.7
slapos.recipe.build = 0.57 slapos.recipe.build = 0.57
slapos.recipe.cmmi = 0.22 slapos.recipe.cmmi = 0.22
slapos.recipe.template = 5.1 slapos.recipe.template = 5.1
slapos.toolbox = 0.142 slapos.toolbox = 0.146
smmap = 5.0.0 smmap = 5.0.0
sniffio = 1.3.0 sniffio = 1.3.0
sortedcontainers = 2.4.0 sortedcontainers = 2.4.0
......
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