mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
committed by
GitHub
co-authored by
GitHub
commit
23634feb46
+13
-3
@@ -1,13 +1,19 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
cache: pip
|
language: python
|
||||||
|
|
||||||
|
cache:
|
||||||
|
apt: true
|
||||||
|
directories:
|
||||||
|
- $HOME/.cache/pip
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- expect-dev # provides unbuffer utility
|
- expect-dev # provides unbuffer utility
|
||||||
- python-lxml # because pip installation is slow
|
- python-lxml # because pip installation is slow
|
||||||
|
- python-simplejson
|
||||||
language: python
|
- python-serial
|
||||||
|
- python-yaml
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- '2.7'
|
- '2.7'
|
||||||
@@ -20,11 +26,15 @@ env:
|
|||||||
- LINT_CHECK="1"
|
- LINT_CHECK="1"
|
||||||
- TESTS="1" ODOO_REPO="odoo/odoo"
|
- TESTS="1" ODOO_REPO="odoo/odoo"
|
||||||
- TESTS="1" ODOO_REPO="OCA/OCB"
|
- TESTS="1" ODOO_REPO="OCA/OCB"
|
||||||
|
global:
|
||||||
|
- VERSION="9.0" LINT_CHECK="0" TESTS="0"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
|
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
|
||||||
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
|
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
|
||||||
- travis_install_nightly
|
- travis_install_nightly
|
||||||
|
- if [ "$LINT_CHECK" != "1" ] ; then ln -s ${HOME}/dependencies/server-tools/server_environment_files_sample ${HOME}/dependencies/server-tools/server_environment_files; fi
|
||||||
|
- printf '[options]\n\nrunning_env = dev' > ${HOME}/.openerp_serverrc
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- postgresql
|
- postgresql
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Libraries that must be added in ``requirements.txt``:
|
|||||||
```
|
```
|
||||||
boto==2.42.0
|
boto==2.42.0
|
||||||
redis==2.10.5
|
redis==2.10.5
|
||||||
|
python-json-logger==0.1.5
|
||||||
```
|
```
|
||||||
|
|
||||||
### Server Environment
|
### Server Environment
|
||||||
@@ -75,6 +76,13 @@ Besides, the
|
|||||||
* `ODOO_SESSION_REDIS_PREFIX`: `<client>-odoo-test`
|
* `ODOO_SESSION_REDIS_PREFIX`: `<client>-odoo-test`
|
||||||
* `ODOO_SESSION_REDIS_EXPIRATION`: `86400` (1 day)
|
* `ODOO_SESSION_REDIS_EXPIRATION`: `86400` (1 day)
|
||||||
|
|
||||||
|
### JSON Logging
|
||||||
|
|
||||||
|
At least on production and integration, activate:
|
||||||
|
* `ODOO_LOGGING_JSON`: 1
|
||||||
|
* Add ``logging_json`` in the ``server_wide_modules`` option in the
|
||||||
|
configuration file
|
||||||
|
|
||||||
### Automatic Configuration
|
### Automatic Configuration
|
||||||
|
|
||||||
Calling `ctx.env['cloud.platform'].install_exoscale()` in an
|
Calling `ctx.env['cloud.platform'].install_exoscale()` in an
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
{'name': 'Attachments on S3 storage',
|
{'name': 'Attachments on S3 storage',
|
||||||
'summary': 'Store assets and attachments on a S3 compatible object storage',
|
'summary': 'Store assets and attachments on a S3 compatible object storage',
|
||||||
'version': '9.0.1.1.0',
|
'version': '9.0.1.1.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Knowledge Management',
|
'category': 'Knowledge Management',
|
||||||
'depends': ['base'],
|
'depends': ['base'],
|
||||||
|
|||||||
@@ -10,17 +10,20 @@ import xml.dom.minidom
|
|||||||
from contextlib import closing, contextmanager
|
from contextlib import closing, contextmanager
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from distutils.util import strtobool
|
|
||||||
|
|
||||||
import boto
|
|
||||||
from boto.exception import S3ResponseError
|
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import _, api, exceptions, fields, models, SUPERUSER_ID
|
from openerp import _, api, exceptions, models, SUPERUSER_ID
|
||||||
from ..s3uri import S3Uri
|
from ..s3uri import S3Uri
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import boto
|
||||||
|
from boto.exception import S3ResponseError
|
||||||
|
except ImportError:
|
||||||
|
boto = None # noqa
|
||||||
|
S3ResponseError = None # noqa
|
||||||
|
_logger.debug("Cannot 'import boto'.")
|
||||||
|
|
||||||
|
|
||||||
class IrAttachment(models.Model):
|
class IrAttachment(models.Model):
|
||||||
_inherit = "ir.attachment"
|
_inherit = "ir.attachment"
|
||||||
@@ -217,7 +220,8 @@ class IrAttachment(models.Model):
|
|||||||
elif attachment.db_datas:
|
elif attachment.db_datas:
|
||||||
_logger.info('moving on the object storage from database')
|
_logger.info('moving on the object storage from database')
|
||||||
attachment.write({'datas': attachment.datas})
|
attachment.write({'datas': attachment.datas})
|
||||||
new_env.cr.commit()
|
# we are in a new env, this is a valid commit
|
||||||
|
new_env.cr.commit() # pylint: disable=invalid-commit
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def do_in_new_env(self):
|
def do_in_new_env(self):
|
||||||
@@ -238,7 +242,9 @@ class IrAttachment(models.Model):
|
|||||||
cr.rollback()
|
cr.rollback()
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
cr.commit()
|
# disable pylint error because this is a valid commit,
|
||||||
|
# we are in a new env
|
||||||
|
cr.commit() # pylint: disable=invalid-commit
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def force_storage(self):
|
def force_storage(self):
|
||||||
|
|||||||
@@ -6,14 +6,15 @@
|
|||||||
{'name': 'Cloud Platform',
|
{'name': 'Cloud Platform',
|
||||||
'summary': 'Addons required for the Camptocamp Cloud Platform',
|
'summary': 'Addons required for the Camptocamp Cloud Platform',
|
||||||
'version': '9.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Extra Tools',
|
'category': 'Extra Tools',
|
||||||
'depends': [
|
'depends': [
|
||||||
'attachment_s3',
|
'attachment_s3',
|
||||||
'session_redis',
|
'session_redis',
|
||||||
'monitoring_status',
|
'monitoring_status',
|
||||||
#'monitoring_log_requests',
|
'logging_json',
|
||||||
|
# 'monitoring_log_requests',
|
||||||
'server_environment', # OCA/server-tools
|
'server_environment', # OCA/server-tools
|
||||||
],
|
],
|
||||||
'website': 'http://www.camptocamp.com',
|
'website': 'http://www.camptocamp.com',
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class FilestoreKind(object):
|
|||||||
file = 'file'
|
file = 'file'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CloudPlatform(models.AbstractModel):
|
class CloudPlatform(models.AbstractModel):
|
||||||
_name = 'cloud.platform'
|
_name = 'cloud.platform'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
def install_exoscale(ctx):
|
def install_exoscale(ctx):
|
||||||
ctx.env['cloud.platform'].install_exoscale()
|
ctx.env['cloud.platform'].install_exoscale()
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
JSON Logging
|
||||||
|
============
|
||||||
|
|
||||||
|
This addon allows to output the Odoo logs in JSON.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
-------------
|
||||||
|
|
||||||
|
The json logging is activated with the environment variable
|
||||||
|
``ODOO_LOGGING_JSON`` set to ``1``.
|
||||||
|
|
||||||
|
In order to have the logs from the start of the server, you should add
|
||||||
|
``logging_json`` in the ``--load`` flag or in the ``server_wide_modules``
|
||||||
|
option in the configuration file.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import json_log
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2016 Camptocamp SA
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||||
|
|
||||||
|
{'name': 'JSON Logging',
|
||||||
|
'version': '9.0.1.0.0',
|
||||||
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
|
'license': 'AGPL-3',
|
||||||
|
'category': 'Extra Tools',
|
||||||
|
'depends': ['base',
|
||||||
|
],
|
||||||
|
'external_dependencies': {
|
||||||
|
'python': ['pythonjsonlogger'],
|
||||||
|
},
|
||||||
|
'website': 'http://www.camptocamp.com',
|
||||||
|
'data': [],
|
||||||
|
'installable': True,
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from distutils.util import strtobool
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pythonjsonlogger import jsonlogger
|
||||||
|
except ImportError:
|
||||||
|
jsonlogger = None # noqa
|
||||||
|
_logger.debug("Cannot 'import pythonjsonlogger'.")
|
||||||
|
|
||||||
|
|
||||||
|
def is_true(strval):
|
||||||
|
return bool(strtobool(strval or '0'.lower()))
|
||||||
|
|
||||||
|
|
||||||
|
class OdooJsonFormatter(jsonlogger.JsonFormatter):
|
||||||
|
|
||||||
|
def add_fields(self, log_record, record, message_dict):
|
||||||
|
record.pid = os.getpid()
|
||||||
|
record.dbname = getattr(threading.currentThread(), 'dbname', '?')
|
||||||
|
_super = super(OdooJsonFormatter, self)
|
||||||
|
return _super.add_fields(log_record, record, message_dict)
|
||||||
|
|
||||||
|
|
||||||
|
if is_true(os.environ.get('ODOO_LOGGING_JSON')):
|
||||||
|
format = ('%(asctime)s %(pid)s %(levelname)s'
|
||||||
|
'%(dbname)s %(name)s: %(message)s')
|
||||||
|
formatter = OdooJsonFormatter(format)
|
||||||
|
logging.getLogger().handlers[0].formatter = formatter
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{'name': 'Monitoring: Requests Logging',
|
{'name': 'Monitoring: Requests Logging',
|
||||||
'version': '9.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'category',
|
'category': 'category',
|
||||||
'depends': ['base', 'web'],
|
'depends': ['base', 'web'],
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{'name': 'Monitoring: Status',
|
{'name': 'Monitoring: Status',
|
||||||
'version': '9.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'category',
|
'category': 'category',
|
||||||
'depends': ['base', 'web'],
|
'depends': ['base', 'web'],
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
server-tools
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
boto==2.42.0
|
||||||
|
redis==2.10.5
|
||||||
|
python-json-logger==0.1.5
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
{'name': 'Sessions in Redis',
|
{'name': 'Sessions in Redis',
|
||||||
'summary': 'Store web sessions in Redis',
|
'summary': 'Store web sessions in Redis',
|
||||||
'version': '9.0.1.0.0',
|
'version': '9.0.1.0.0',
|
||||||
'author': 'Camptocamp',
|
'author': 'Camptocamp,Odoo Community Association (OCA)',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'category': 'Extra Tools',
|
'category': 'Extra Tools',
|
||||||
'depends': ['base'],
|
'depends': ['base'],
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import os
|
|||||||
|
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
|
|
||||||
import redis
|
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp import http
|
from openerp import http
|
||||||
from openerp.tools.func import lazy_property
|
from openerp.tools.func import lazy_property
|
||||||
@@ -17,6 +15,12 @@ from .session import RedisSessionStore
|
|||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import redis
|
||||||
|
except ImportError:
|
||||||
|
redis = None # noqa
|
||||||
|
_logger.debug("Cannot 'import redis'.")
|
||||||
|
|
||||||
|
|
||||||
def is_true(strval):
|
def is_true(strval):
|
||||||
return bool(strtobool(strval or '0'.lower()))
|
return bool(strtobool(strval or '0'.lower()))
|
||||||
|
|||||||
Reference in New Issue
Block a user