mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
Add OVH as an option for the cloud platform
This commit is contained in:
committed by
Guewen Baconnier
co-authored by
Guewen Baconnier
parent
5d30207963
commit
66748534f6
@@ -1,7 +1,8 @@
|
||||
Cloud Platform
|
||||
==============
|
||||
|
||||
Install addons required for the Camptocamp Cloud platform.
|
||||
Install addons required for the Camptocamp Cloud platform, and that are
|
||||
common to all platform providers.
|
||||
|
||||
* Provide a quick install that we can call at the setup / migration
|
||||
of a database
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Extra Tools',
|
||||
'depends': [
|
||||
'attachment_s3',
|
||||
'session_redis',
|
||||
'monitoring_status',
|
||||
'logging_json',
|
||||
|
||||
@@ -30,6 +30,7 @@ PlatformConfig = namedtuple(
|
||||
class FilestoreKind(object):
|
||||
db = 'db'
|
||||
s3 = 's3' # or compatible s3 object storage
|
||||
swift = 'swift'
|
||||
file = 'file'
|
||||
|
||||
|
||||
@@ -46,6 +47,8 @@ class CloudPlatform(models.AbstractModel):
|
||||
}
|
||||
return configs.get(environment) or configs['dev']
|
||||
|
||||
# Due to the addition of the ovh cloud platform
|
||||
# This will be moved to cloud_platform_exoscale on v11
|
||||
@api.model
|
||||
def install_exoscale(self):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
@@ -58,6 +61,54 @@ class CloudPlatform(models.AbstractModel):
|
||||
self.env['ir.attachment'].sudo().force_storage()
|
||||
_logger.info('cloud platform configured for exoscale')
|
||||
|
||||
@api.model
|
||||
def _check_swift(self, environment_name):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
use_swift = (params.get_param('ir_attachment.location') ==
|
||||
FilestoreKind.swift)
|
||||
if environment_name in ('prod', 'integration'):
|
||||
assert use_swift, (
|
||||
"Swift must be used on production and integration instances. "
|
||||
"It is activated, setting 'ir_attachment.location.' to 'swift'"
|
||||
" The 'install_exoscale()' function sets this option "
|
||||
"automatically."
|
||||
)
|
||||
if use_swift:
|
||||
assert os.environ.get('SWIFT_HOST'), (
|
||||
"SWIFT_HOST environment variable is required when "
|
||||
"ir_attachment.location is 'swift'."
|
||||
)
|
||||
assert os.environ.get('SWIFT_ACCOUNT'), (
|
||||
"SWIFT_ACCOUNT environment variable is required when "
|
||||
"ir_attachment.location is 'swift'."
|
||||
)
|
||||
assert os.environ.get('SWIFT_PASSWORD'), (
|
||||
"SWIFT_PASSWORD environment variable is required when "
|
||||
"ir_attachment.location is 'swift'."
|
||||
)
|
||||
container_name = os.environ['SWIFT_WRITE_CONTAINER']
|
||||
prod_container = bool(re.match(r'[a-z]+-odoo-prod',
|
||||
container_name))
|
||||
if environment_name == 'prod':
|
||||
assert prod_container, (
|
||||
"SWIFT_WRITE_CONTAINER should match '<client>-odoo-prod', "
|
||||
"we got: '%s'" % (container_name,)
|
||||
)
|
||||
else:
|
||||
# if we are using the prod bucket on another instance
|
||||
# such as an integration, we must be sure to be in read only!
|
||||
assert not prod_container, (
|
||||
"SWIFT_WRITE_CONTAINER should not match "
|
||||
"'<client>-odoo-prod', we got: '%s'" % (container_name,)
|
||||
)
|
||||
elif environment_name == 'test':
|
||||
# store in DB so we don't have files local to the host
|
||||
assert params.get_param('ir_attachment.location') == 'db', (
|
||||
"In test instances, files must be stored in the database with "
|
||||
"'ir_attachment.location' set to 'db'. This is "
|
||||
"automatically set by the function 'install_ovh()'."
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _check_s3(self, environment_name):
|
||||
params = self.env['ir.config_parameter'].sudo()
|
||||
@@ -148,7 +199,10 @@ class CloudPlatform(models.AbstractModel):
|
||||
)
|
||||
return
|
||||
environment_name = config['running_env']
|
||||
self._check_s3(environment_name)
|
||||
if kind == 'exoscale':
|
||||
self._check_s3(environment_name)
|
||||
elif kind == 'ovh':
|
||||
self._check_swift(environment_name)
|
||||
self._check_redis(environment_name)
|
||||
|
||||
@api.model_cr
|
||||
|
||||
@@ -3,3 +3,7 @@
|
||||
|
||||
def install_exoscale(ctx):
|
||||
ctx.env['cloud.platform'].install_exoscale()
|
||||
|
||||
|
||||
def install_ovh(ctx):
|
||||
ctx.env['cloud.platform'].install_ovh()
|
||||
|
||||
Reference in New Issue
Block a user