mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-23 18:04:34 +00:00
feat: remove unused modules
This commit is contained in:
committed by
Florent Xicluna
co-authored by
Florent Xicluna
parent
e529e00fd7
commit
a04aa15191
@@ -17,5 +17,5 @@
|
||||
],
|
||||
"website": "https://github.com/camptocamp/odoo-cloud-platform",
|
||||
"data": [],
|
||||
"installable": False,
|
||||
"installable": True,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016-2019 Camptocamp SA
|
||||
# Copyright 2016-2025 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
import logging
|
||||
@@ -18,39 +18,10 @@ def is_true(strval):
|
||||
return bool(strtobool(strval or "0"))
|
||||
|
||||
|
||||
PlatformConfig = namedtuple("PlatformConfig", "filestore")
|
||||
|
||||
|
||||
FilestoreKind = namedtuple("FilestoreKind", ["name", "location"])
|
||||
|
||||
|
||||
class CloudPlatform(models.AbstractModel):
|
||||
_name = "cloud.platform"
|
||||
_description = "cloud.platform"
|
||||
|
||||
@api.model
|
||||
def _default_config(self):
|
||||
return PlatformConfig(self._filestore_kinds()["db"])
|
||||
|
||||
@api.model
|
||||
def _filestore_kinds(self):
|
||||
return {
|
||||
"db": FilestoreKind("db", "local"),
|
||||
"file": FilestoreKind("file", "local"),
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _platform_kinds(self):
|
||||
return []
|
||||
|
||||
@api.model
|
||||
def _config_by_server_env(self, platform_kind, environment):
|
||||
configs_getter = getattr(
|
||||
self, "_config_by_server_env_for_%s" % platform_kind, None
|
||||
)
|
||||
configs = configs_getter() if configs_getter else {}
|
||||
return configs.get(environment) or self._default_config()
|
||||
|
||||
def _get_running_env(self):
|
||||
environment_name = config["running_env"]
|
||||
if environment_name.startswith("labs"):
|
||||
@@ -60,25 +31,9 @@ class CloudPlatform(models.AbstractModel):
|
||||
return environment_name
|
||||
|
||||
@api.model
|
||||
def _install(self, platform_kind):
|
||||
assert platform_kind in self._platform_kinds()
|
||||
params = self.env["ir.config_parameter"].sudo()
|
||||
params.set_param("cloud.platform.kind", platform_kind)
|
||||
environment_name = self._get_running_env()
|
||||
configs = self._config_by_server_env(platform_kind, environment_name)
|
||||
params.set_param("ir_attachment.location", configs.filestore.name)
|
||||
def _install(self, environment):
|
||||
self.check()
|
||||
if configs.filestore.location == "remote":
|
||||
self.env["ir.attachment"].sudo().force_storage()
|
||||
_logger.info(f"cloud platform configured for {platform_kind}")
|
||||
|
||||
@api.model
|
||||
def install(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@api.model
|
||||
def _check_filestore(self, environment_name):
|
||||
raise NotImplementedError
|
||||
_logger.info(f"cloud platform configured for {environment}")
|
||||
|
||||
@api.model
|
||||
def _check_redis(self, environment_name):
|
||||
@@ -110,19 +65,7 @@ class CloudPlatform(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def check(self):
|
||||
if is_true(os.environ.get("ODOO_CLOUD_PLATFORM_UNSAFE")):
|
||||
_logger.warning("cloud platform checks disabled, this is not safe")
|
||||
return
|
||||
params = self.env["ir.config_parameter"].sudo()
|
||||
kind = params.get_param("cloud.platform.kind")
|
||||
if not kind:
|
||||
_logger.warning(
|
||||
"cloud platform not configured, you should "
|
||||
"probably run 'env['cloud.platform'].install()'"
|
||||
)
|
||||
return
|
||||
environment_name = self._get_running_env()
|
||||
self._check_filestore(environment_name)
|
||||
self._check_redis(environment_name)
|
||||
|
||||
def _register_hook(self):
|
||||
|
||||
Reference in New Issue
Block a user