hobo deploy: handle maintenance related variables (#65447)

This commit is contained in:
Emmanuel Cazenave 2022-06-02 12:28:12 +02:00
parent 9c8a2e03bb
commit f5539aa24e
2 changed files with 22 additions and 0 deletions

View File

@ -208,6 +208,10 @@ HOBO_JSON = {
'theme': 'clapotis-les-canards',
'sms_url': 'http://passerelle.example.net',
'sms_sender': 'EO',
'SETTING_TENANT_DISABLE_CRON_JOBS': True,
'SETTING_MAINTENANCE_PAGE': True,
'SETTING_MAINTENANCE_PAGE_MESSAGE': 'foo',
'SETTING_MAINTENANCE_PASS_THROUGH_HEADER': 'X-bar',
},
'users': [
{
@ -277,6 +281,11 @@ def test_configure_site_options(setuptest, alt_tempdir):
assert pub.get_site_option('portal_agent_url', 'variables') == 'http://agents.example.net/'
assert pub.get_site_option('portal_url', 'variables') == 'http://portal.example.net/'
assert pub.get_site_option('test_wcs_url', 'variables') == 'http://wcs.example.net/'
assert pub.get_site_option('disable_cron_jobs', 'variables') == 'True'
assert pub.get_site_option('maintenance_page', 'variables') == 'True'
assert pub.get_site_option('maintenance_page_message', 'variables') == 'foo'
assert pub.get_site_option('maintenance_pass_through_header', 'variables') == 'X-bar'
key = '109fca71e7dc8ec49708a08fa7c02795de13f34f7d29d27bd150f203b3e0ab40'
assert pub.get_site_option('authentic.example.net', 'api-secrets') == key
assert pub.get_site_option('authentic.example.net', 'wscall-secrets') == key

View File

@ -422,6 +422,18 @@ class CmdCheckHobos(Command):
instance_path += '+%s' % parsed_url.path.replace('/', '+')
return instance_path
def handle_maintenance_variables(self, name, value):
match = False
if name == 'SETTING_TENANT_DISABLE_CRON_JOBS':
name = 'disable_cron_jobs'
match = True
if name.startswith('SETTING_MAINTENANCE'):
name = name[8:]
match = True
if match and not value:
value = None
return name, value
def configure_site_options(self, current_service, pub, ignore_timestamp=False):
# configure site-options.cfg
config = configparser.RawConfigParser()
@ -498,6 +510,7 @@ class CmdCheckHobos(Command):
if self.all_services.get('variables'):
for key, value in self.all_services.get('variables').items():
key, value = self.handle_maintenance_variables(key, value)
variables[key] = value
for key, value in current_service.get('variables', {}).items():
variables[key] = value