mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
Abstract install method
This commit is contained in:
committed by
Guewen Baconnier
co-authored by
Guewen Baconnier
parent
66748534f6
commit
1548fd674a
@@ -138,14 +138,17 @@ Should be active at least on the production server
|
||||
|
||||
### Automatic Configuration
|
||||
|
||||
Calling
|
||||
`ctx.env['cloud.platform'].install_exoscale()`
|
||||
or
|
||||
`ctx.env['cloud.platform'].install_ovh()`
|
||||
in an `anthem` song will configure some parameters such as the
|
||||
`ir_attachment.location` and migrate the existing attachments to the
|
||||
object storage.
|
||||
An automatic configuration can be executed from an `anthem` song to configure
|
||||
some parameters such as the `ir_attachment.location` and migrate the existing
|
||||
attachments to the object storage.
|
||||
|
||||
It can be called like this:
|
||||
`ctx.env['cloud.platform'].install(cloud_platform_kind)`
|
||||
Replacing `cloud_platform_kind` with 'exoscale' or 'ovh'
|
||||
|
||||
When there was only Exoscale as a provider of the cloud platform the following
|
||||
would do the trick and will work until v.11 :
|
||||
`ctx.env['cloud.platform'].install_exoscale()`
|
||||
|
||||
### Startup checks
|
||||
|
||||
|
||||
@@ -61,6 +61,18 @@ class CloudPlatform(models.AbstractModel):
|
||||
self.env['ir.attachment'].sudo().force_storage()
|
||||
_logger.info('cloud platform configured for exoscale')
|
||||
|
||||
@api.model
|
||||
def install(self, platform_kind):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
params.set_param('cloud.platform.kind', platform_kind)
|
||||
environment = config['running_env']
|
||||
configs = self._config_by_server_env(environment)
|
||||
params.set_param('ir_attachment.location', configs.filestore)
|
||||
self.check()
|
||||
if configs.filestore in [FilestoreKind.swift, FilestoreKind.s3]:
|
||||
self.env['ir.attachment'].sudo().force_storage()
|
||||
_logger.info('cloud platform configured for {}'.format(platform_kind))
|
||||
|
||||
@api.model
|
||||
def _check_swift(self, environment_name):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
|
||||
@@ -6,4 +6,4 @@ def install_exoscale(ctx):
|
||||
|
||||
|
||||
def install_ovh(ctx):
|
||||
ctx.env['cloud.platform'].install_ovh()
|
||||
ctx.env['cloud.platform'].install('ovh')
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Camptocamp SA
|
||||
# Copyright 2017 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.tools.config import config
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -30,15 +29,3 @@ class CloudPlatform(models.AbstractModel):
|
||||
'dev': PlatformConfig(filestore=FilestoreKind.db),
|
||||
}
|
||||
return configs.get(environment) or configs['dev']
|
||||
|
||||
@api.model
|
||||
def install_ovh(self):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
params.set_param('cloud.platform.kind', 'ovh')
|
||||
environment = config['running_env']
|
||||
configs = self._config_by_server_env(environment)
|
||||
params.set_param('ir_attachment.location', configs.filestore)
|
||||
self.check()
|
||||
if configs.filestore == FilestoreKind.swift:
|
||||
self.env['ir.attachment'].sudo().force_storage()
|
||||
_logger.info('cloud platform configured for ovh')
|
||||
|
||||
Reference in New Issue
Block a user