From a93f35dc9afa7b2823b73ad1838ba7ac5eb2fdc4 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Sat, 26 Nov 2016 16:22:11 -0800 Subject: [PATCH 1/4] [ADD] clouder_template_elasticsearch: Provide Elastic --- clouder_template_elasticsearch/README.rst | 52 +++++++++++++++ clouder_template_elasticsearch/__init__.py | 5 ++ clouder_template_elasticsearch/__openerp__.py | 29 +++++++++ .../data/application.xml | 41 ++++++++++++ .../data/application_link.xml | 20 ++++++ .../data/application_template.xml | 13 ++++ .../data/application_type.xml | 17 +++++ .../data/application_type_option.xml | 29 +++++++++ clouder_template_elasticsearch/data/image.xml | 24 +++++++ .../data/image_port.xml | 23 +++++++ .../data/image_template.xml | 19 ++++++ .../data/image_volume.xml | 61 +++++++++++++++++ .../images/5.0-data/Dockerfile | 6 ++ .../images/5.0-data/etc/elasticsearch.yml | 5 ++ .../images/5.0-data/etc/logging.yml | 15 +++++ .../images/5.0-exec/Dockerfile | 65 +++++++++++++++++++ .../images/5.0-exec/docker-entrypoint.sh | 28 ++++++++ .../models/__init__.py | 5 ++ .../models/backup.py | 28 ++++++++ 19 files changed, 485 insertions(+) create mode 100644 clouder_template_elasticsearch/README.rst create mode 100644 clouder_template_elasticsearch/__init__.py create mode 100644 clouder_template_elasticsearch/__openerp__.py create mode 100644 clouder_template_elasticsearch/data/application.xml create mode 100644 clouder_template_elasticsearch/data/application_link.xml create mode 100644 clouder_template_elasticsearch/data/application_template.xml create mode 100644 clouder_template_elasticsearch/data/application_type.xml create mode 100644 clouder_template_elasticsearch/data/application_type_option.xml create mode 100644 clouder_template_elasticsearch/data/image.xml create mode 100644 clouder_template_elasticsearch/data/image_port.xml create mode 100644 clouder_template_elasticsearch/data/image_template.xml create mode 100644 clouder_template_elasticsearch/data/image_volume.xml create mode 100644 clouder_template_elasticsearch/images/5.0-data/Dockerfile create mode 100644 clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml create mode 100644 clouder_template_elasticsearch/images/5.0-data/etc/logging.yml create mode 100644 clouder_template_elasticsearch/images/5.0-exec/Dockerfile create mode 100755 clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh create mode 100644 clouder_template_elasticsearch/models/__init__.py create mode 100644 clouder_template_elasticsearch/models/backup.py diff --git a/clouder_template_elasticsearch/README.rst b/clouder_template_elasticsearch/README.rst new file mode 100644 index 0000000..4ab4931 --- /dev/null +++ b/clouder_template_elasticsearch/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +================================ +Clouder Template - Elasticsearch +================================ + +This module provides a template for Elasticsearch in Clouder. + + +Configuration +============= + +Clouder configuration instructions are available at https://clouder.readthedocs.io/ + +Usage +===== + +To use this module, you need to: + +#. Create an Elasticsearch Service in the Clouder Control Panel + +Known issues / Roadmap +====================== + +* Add ElasticDump db backup & restore +* ElasticDump should be a separate service +* Add SSL (Requires CA - https://github.com/clouder-community/clouder/issues/167) + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Dave Lasley + +Maintainer +---------- + +This module is maintained by Clouder Community. + +To contribute to this module, please visit https://github.com/clouder-community/clouder diff --git a/clouder_template_elasticsearch/__init__.py b/clouder_template_elasticsearch/__init__.py new file mode 100644 index 0000000..5f02bbb --- /dev/null +++ b/clouder_template_elasticsearch/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/clouder_template_elasticsearch/__openerp__.py b/clouder_template_elasticsearch/__openerp__.py new file mode 100644 index 0000000..844d8ee --- /dev/null +++ b/clouder_template_elasticsearch/__openerp__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'Clouder Template Elasticsearch', + 'version': '9.0.10.0.0', + 'category': 'Clouder', + 'depends': [ + 'clouder', + 'clouder_template_proxy', + ], + 'author': 'LasLabs Inc.', + 'license': 'LGPL-3', + 'website': 'https://github.com/clouder-community/clouder', + 'data': [ + 'data/image_template.xml', + 'data/image.xml', + 'data/image_port.xml', + 'data/image_volume.xml', + 'data/application_type.xml', + 'data/application_type_option.xml', + 'data/application_template.xml', + 'data/application.xml', + 'data/application_link.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/clouder_template_elasticsearch/data/application.xml b/clouder_template_elasticsearch/data/application.xml new file mode 100644 index 0000000..406369e --- /dev/null +++ b/clouder_template_elasticsearch/data/application.xml @@ -0,0 +1,41 @@ + + + + + + + Elasticsearch Data + data + + + + 1 + + + + + Elasticsearch Exec + exec + + + + 2 + + auto + + + + Elasticsearch + elasticsearch + + + 1 + + + + diff --git a/clouder_template_elasticsearch/data/application_link.xml b/clouder_template_elasticsearch/data/application_link.xml new file mode 100644 index 0000000..1d7970f --- /dev/null +++ b/clouder_template_elasticsearch/data/application_link.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/clouder_template_elasticsearch/data/application_template.xml b/clouder_template_elasticsearch/data/application_template.xml new file mode 100644 index 0000000..c8489b3 --- /dev/null +++ b/clouder_template_elasticsearch/data/application_template.xml @@ -0,0 +1,13 @@ + + + + + + + Elasticsearch + + + diff --git a/clouder_template_elasticsearch/data/application_type.xml b/clouder_template_elasticsearch/data/application_type.xml new file mode 100644 index 0000000..c68ad5a --- /dev/null +++ b/clouder_template_elasticsearch/data/application_type.xml @@ -0,0 +1,17 @@ + + + + + + + elasticsearch + elasticsearch + + + + diff --git a/clouder_template_elasticsearch/data/application_type_option.xml b/clouder_template_elasticsearch/data/application_type_option.xml new file mode 100644 index 0000000..263e531 --- /dev/null +++ b/clouder_template_elasticsearch/data/application_type_option.xml @@ -0,0 +1,29 @@ + + + + + + + + network + service + 172.17.0.0/16 + + + + + listen + service + * + + + diff --git a/clouder_template_elasticsearch/data/image.xml b/clouder_template_elasticsearch/data/image.xml new file mode 100644 index 0000000..4b12e08 --- /dev/null +++ b/clouder_template_elasticsearch/data/image.xml @@ -0,0 +1,24 @@ + + + + + + + image_elasticsearch_data + + lasley/elasticsearch-data + + + + image_elasticsearch_exec + + lasley/elasticsearch-exec + data + + + diff --git a/clouder_template_elasticsearch/data/image_port.xml b/clouder_template_elasticsearch/data/image_port.xml new file mode 100644 index 0000000..0f1b9fb --- /dev/null +++ b/clouder_template_elasticsearch/data/image_port.xml @@ -0,0 +1,23 @@ + + + + + + + + elasticsearch-http + 9200 + + + + + elasticsearch-transport + 9300 + + + diff --git a/clouder_template_elasticsearch/data/image_template.xml b/clouder_template_elasticsearch/data/image_template.xml new file mode 100644 index 0000000..fa3c403 --- /dev/null +++ b/clouder_template_elasticsearch/data/image_template.xml @@ -0,0 +1,19 @@ + + + + + + + image_template_elasticsearch_data + + + + image_template_elasticsearch_exec + + + diff --git a/clouder_template_elasticsearch/data/image_volume.xml b/clouder_template_elasticsearch/data/image_volume.xml new file mode 100644 index 0000000..1e5c09e --- /dev/null +++ b/clouder_template_elasticsearch/data/image_volume.xml @@ -0,0 +1,61 @@ + + + + + + + + data + /opt/elasticsearch/data + elasticsearch + + + + + etc + /opt/elasticsearch/config + elasticsearch + + + + + log + /opt/elasticsearch/logs + elasticsearch + + + + + lib + /opt/elasticsearch/lib + elasticsearch + + + + + module + /opt/elasticsearch/modules + elasticsearch + + + + + plugin + /opt/elasticsearch/plugins + elasticsearch + + + diff --git a/clouder_template_elasticsearch/images/5.0-data/Dockerfile b/clouder_template_elasticsearch/images/5.0-data/Dockerfile new file mode 100644 index 0000000..65a9443 --- /dev/null +++ b/clouder_template_elasticsearch/images/5.0-data/Dockerfile @@ -0,0 +1,6 @@ +FROM yannickburon/clouder:base +MAINTAINER Dave Lasley + +COPY etc ./config + +CMD tail -f /dev/null diff --git a/clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml b/clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml new file mode 100644 index 0000000..bee2cfe --- /dev/null +++ b/clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml @@ -0,0 +1,5 @@ +network.host: 0.0.0.0 + +# this value is required because we set "network.host" +# be sure to modify it appropriately for a production cluster deployment +discovery.zen.minimum_master_nodes: 1 diff --git a/clouder_template_elasticsearch/images/5.0-data/etc/logging.yml b/clouder_template_elasticsearch/images/5.0-data/etc/logging.yml new file mode 100644 index 0000000..c2681ac --- /dev/null +++ b/clouder_template_elasticsearch/images/5.0-data/etc/logging.yml @@ -0,0 +1,15 @@ +# you can override this using by setting a system property, for example -Des.logger.level=DEBUG +es.logger.level: INFO +rootLogger: ${es.logger.level}, console +logger: + # log action execution errors for easier debugging + action: DEBUG + # reduce the logging for aws, too much is logged under the default INFO + com.amazonaws: WARN + +appender: + console: + type: console + layout: + type: consolePattern + conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n" diff --git a/clouder_template_elasticsearch/images/5.0-exec/Dockerfile b/clouder_template_elasticsearch/images/5.0-exec/Dockerfile new file mode 100644 index 0000000..5e51cb3 --- /dev/null +++ b/clouder_template_elasticsearch/images/5.0-exec/Dockerfile @@ -0,0 +1,65 @@ +FROM yannickburon/clouder:base +MAINTAINER Dave Lasley + +# Loosely based on https://github.com/docker-library/elasticsearch/blob/master/Dockerfile.template + +ENV ES_VERSION 5.0.1 +ENV ES_BASE https://artifacts.elastic.co/downloads/elasticsearch + +ENV GOSU_VERSION 1.10 +ENV GOSU_BASE https://github.com/tianon/gosu/releases/download + +ENV PACKAGES "ca-certificates curl nodejs openjdk8-jre openssl wget" + +RUN apk add --update $PACKAGES + +WORKDIR /tmp + +# Install glibc +RUN apk --no-cache add ca-certificates openssl \ + && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub \ + && apk --no-cache -X http://apkproxy.heroku.com/sgerrand/alpine-pkg-glibc add glibc glibc-bin + +# Install Go based sudo (gosu) +RUN set -x \ + && apk add gnupg \ + && wget -O /usr/local/bin/gosu "$GOSU_BASE/$GOSU_VERSION/gosu-$(apk --print-arch |sed -e 's/x86_64/amd64/')" \ + && wget -O /usr/local/bin/gosu.asc "$GOSU_BASE/$GOSU_VERSION/gosu-$(apk --print-arch |sed -e 's/x86_64/amd64/').asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg2 --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ + && gpg2 --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ + && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && gosu nobody true \ + && apk del gnupg + +# Install Elasticsearch +WORKDIR /opt + +RUN mkdir -p /opt \ + && adduser -h /opt/elasticsearch -g elasticsearch -s /bin/bash -D elasticsearch + +RUN ln -s elasticsearch elasticsearch-$ES_VERSION +USER elasticsearch +RUN set -x \ + && wget -O - "${ES_BASE}/elasticsearch-${ES_VERSION}.tar.gz" | tar -xz + +ENV PATH /opt/elasticsearch/bin:$PATH + +WORKDIR /opt/elasticsearch +RUN set -ex \ + && for path in \ + ./data \ + ./logs \ + ./config \ + ./config/scripts \ + ; do \ + mkdir -p "$path"; \ + chown -R elasticsearch:elasticsearch "$path"; \ + done + +# Entrypoint +COPY docker-entrypoint.sh / + +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["elasticsearch"] diff --git a/clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh b/clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh new file mode 100755 index 0000000..39ba938 --- /dev/null +++ b/clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# ElasticSearch Docker Entrypoint: +# https://github.com/docker-library/elasticsearch +# Apache Licensed: +# https://github.com/docker-library/elasticsearch/blob/b6fe7dbafc4508c3a1fcf40cbe74c06188c361aa/LICENSE + +set -e + +# Add elasticsearch as command if needed +if [ "${1:0:1}" = '-' ]; then + set -- elasticsearch "$@" +fi + +# Drop root privileges if we are running elasticsearch +# allow the container to be started with `--user` +if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then + # Change the ownership of /usr/share/elasticsearch/data to elasticsearch + chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data + + set -- gosu elasticsearch "$@" + #exec gosu elasticsearch "$BASH_SOURCE" "$@" +fi + +# As argument is not related to elasticsearch, +# then assume that user wants to run his own process, +# for example a `bash` shell to explore this image +exec "$@" diff --git a/clouder_template_elasticsearch/models/__init__.py b/clouder_template_elasticsearch/models/__init__.py new file mode 100644 index 0000000..29c5798 --- /dev/null +++ b/clouder_template_elasticsearch/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import backup diff --git a/clouder_template_elasticsearch/models/backup.py b/clouder_template_elasticsearch/models/backup.py new file mode 100644 index 0000000..28d4c39 --- /dev/null +++ b/clouder_template_elasticsearch/models/backup.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, models + + +class ClouderBackup(models.Model): + """ It provides Elasticsearch context for Clouder Saves + + All methods and properties are to be prefixed with ``elastic_`` in order + to prevent namespace clashes with existing operations, unless overloading + and calling + returning the super. + """ + + _inherit = 'clouder.backup' + + @api.multi + def backup_database(self): + if self.base_id.service_id.db_type == 'elasticsearch': + pass + return super(ClouderBackup, self).backup_database() + + @api.multi + def restore_database(self): + if self.base_id.service_id.db_type == 'elasticsearch': + pass + return super(ClouderBackup, self).restore_database() From 697b647c57c44b34d072259e47364081f00271df Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Wed, 14 Dec 2016 14:00:12 -0800 Subject: [PATCH 2/4] [REF] clouder_template_elasticsearch: PR Review updates --- clouder_template_elasticsearch/__init__.py | 2 +- clouder_template_elasticsearch/__openerp__.py | 3 +- .../data/application.xml | 5 +- .../data/application_link.xml | 2 +- .../data/application_template.xml | 2 +- .../data/application_type.xml | 2 +- .../data/application_type_option.xml | 29 -------- clouder_template_elasticsearch/data/image.xml | 2 +- .../data/image_port.xml | 6 +- .../data/image_template.xml | 2 +- .../data/image_volume.xml | 2 +- .../images/5.0-data/Dockerfile | 2 +- .../images/5.0-exec/Dockerfile | 2 +- .../models/__init__.py | 2 +- .../models/backup copy.py | 28 ++++++++ .../models/backup.py | 69 +++++++++++++++---- 16 files changed, 103 insertions(+), 57 deletions(-) delete mode 100644 clouder_template_elasticsearch/data/application_type_option.xml create mode 100644 clouder_template_elasticsearch/models/backup copy.py diff --git a/clouder_template_elasticsearch/__init__.py b/clouder_template_elasticsearch/__init__.py index 5f02bbb..6b7b00c 100644 --- a/clouder_template_elasticsearch/__init__.py +++ b/clouder_template_elasticsearch/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- # Copyright 2016 LasLabs Inc. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/clouder_template_elasticsearch/__openerp__.py b/clouder_template_elasticsearch/__openerp__.py index 844d8ee..fac2540 100644 --- a/clouder_template_elasticsearch/__openerp__.py +++ b/clouder_template_elasticsearch/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2016 LasLabs Inc. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). { 'name': 'Clouder Template Elasticsearch', @@ -9,6 +9,7 @@ 'depends': [ 'clouder', 'clouder_template_proxy', + 'clouder_template_dns', ], 'author': 'LasLabs Inc.', 'license': 'LGPL-3', diff --git a/clouder_template_elasticsearch/data/application.xml b/clouder_template_elasticsearch/data/application.xml index 406369e..c3e25fe 100644 --- a/clouder_template_elasticsearch/data/application.xml +++ b/clouder_template_elasticsearch/data/application.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> @@ -29,6 +29,9 @@ Elasticsearch elasticsearch + + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/data/application_template.xml b/clouder_template_elasticsearch/data/application_template.xml index c8489b3..a13d396 100644 --- a/clouder_template_elasticsearch/data/application_template.xml +++ b/clouder_template_elasticsearch/data/application_template.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/data/application_type.xml b/clouder_template_elasticsearch/data/application_type.xml index c68ad5a..79f1f8a 100644 --- a/clouder_template_elasticsearch/data/application_type.xml +++ b/clouder_template_elasticsearch/data/application_type.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/data/application_type_option.xml b/clouder_template_elasticsearch/data/application_type_option.xml deleted file mode 100644 index 263e531..0000000 --- a/clouder_template_elasticsearch/data/application_type_option.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - network - service - 172.17.0.0/16 - - - - - listen - service - * - - - diff --git a/clouder_template_elasticsearch/data/image.xml b/clouder_template_elasticsearch/data/image.xml index 4b12e08..e4ad392 100644 --- a/clouder_template_elasticsearch/data/image.xml +++ b/clouder_template_elasticsearch/data/image.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/data/image_port.xml b/clouder_template_elasticsearch/data/image_port.xml index 0f1b9fb..64a28eb 100644 --- a/clouder_template_elasticsearch/data/image_port.xml +++ b/clouder_template_elasticsearch/data/image_port.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> @@ -8,7 +8,7 @@ model="clouder.image.port" > - elasticsearch-http + http 9200 @@ -16,7 +16,7 @@ model="clouder.image.port" > - elasticsearch-transport + transport 9300 diff --git a/clouder_template_elasticsearch/data/image_template.xml b/clouder_template_elasticsearch/data/image_template.xml index fa3c403..ec1308a 100644 --- a/clouder_template_elasticsearch/data/image_template.xml +++ b/clouder_template_elasticsearch/data/image_template.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/data/image_volume.xml b/clouder_template_elasticsearch/data/image_volume.xml index 1e5c09e..b64e60e 100644 --- a/clouder_template_elasticsearch/data/image_volume.xml +++ b/clouder_template_elasticsearch/data/image_volume.xml @@ -1,6 +1,6 @@ + License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). --> diff --git a/clouder_template_elasticsearch/images/5.0-data/Dockerfile b/clouder_template_elasticsearch/images/5.0-data/Dockerfile index 65a9443..630b028 100644 --- a/clouder_template_elasticsearch/images/5.0-data/Dockerfile +++ b/clouder_template_elasticsearch/images/5.0-data/Dockerfile @@ -1,4 +1,4 @@ -FROM yannickburon/clouder:base +FROM clouder/base:3.4 MAINTAINER Dave Lasley COPY etc ./config diff --git a/clouder_template_elasticsearch/images/5.0-exec/Dockerfile b/clouder_template_elasticsearch/images/5.0-exec/Dockerfile index 5e51cb3..fdb9aed 100644 --- a/clouder_template_elasticsearch/images/5.0-exec/Dockerfile +++ b/clouder_template_elasticsearch/images/5.0-exec/Dockerfile @@ -1,4 +1,4 @@ -FROM yannickburon/clouder:base +FROM clouder/base:3.4 MAINTAINER Dave Lasley # Loosely based on https://github.com/docker-library/elasticsearch/blob/master/Dockerfile.template diff --git a/clouder_template_elasticsearch/models/__init__.py b/clouder_template_elasticsearch/models/__init__.py index 29c5798..a3df682 100644 --- a/clouder_template_elasticsearch/models/__init__.py +++ b/clouder_template_elasticsearch/models/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- # Copyright 2016 LasLabs Inc. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). from . import backup diff --git a/clouder_template_elasticsearch/models/backup copy.py b/clouder_template_elasticsearch/models/backup copy.py new file mode 100644 index 0000000..087fbe3 --- /dev/null +++ b/clouder_template_elasticsearch/models/backup copy.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Copyright 2016 LasLabs Inc. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from openerp import api, models + + +class ClouderBackup(models.Model): + """ It provides Elasticsearch context for Clouder Saves + + All methods and properties are to be prefixed with ``elastic_`` in order + to prevent namespace clashes with existing operations, unless overloading + and calling + returning the super. + """ + + _inherit = 'clouder.backup' + + @api.multi + def backup_database(self): + if self.base_id.service_id.db_type == 'elasticsearch': + pass + return super(ClouderBackup, self).backup_database() + + @api.multi + def restore_database(self): + if self.base_id.service_id.db_type == 'elasticsearch': + pass + return super(ClouderBackup, self).restore_database() diff --git a/clouder_template_elasticsearch/models/backup.py b/clouder_template_elasticsearch/models/backup.py index 28d4c39..29d373b 100644 --- a/clouder_template_elasticsearch/models/backup.py +++ b/clouder_template_elasticsearch/models/backup.py @@ -1,28 +1,71 @@ # -*- coding: utf-8 -*- # Copyright 2016 LasLabs Inc. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). + +from os import path from openerp import api, models class ClouderBackup(models.Model): - """ It provides Elasticsearch context for Clouder Saves + """ It provides Elasticsearch context for Clouder Backups - All methods and properties are to be prefixed with ``elastic_`` in order - to prevent namespace clashes with existing operations, unless overloading - and calling + returning the super. + All public methods and properties are to be prefixed with ``elastic_`` in + order to prevent namespace clashes with existing operations, unless + overloading and calling + returning the super. """ _inherit = 'clouder.backup' + @property + def elasticsearch_volumes_data(self): + """ It returns a ``clouder.image.volume`` Recordset for data vols. """ + res = self.env['clouder.image.volume'] + for volume in ['data', 'etc', 'log']: + res += self.__get_internal_ref( + 'image_volume_elasticsearch_%s' % volume, + ) + return res + + @api.multi + def deploy_base(self): + """ It backs up the file store """ + res = super(ClouderBackup, self).deploy_base() + if self.base_id.application_id.type_id.name == 'elasticsearch': + self.elasticsearch_deploy_base() + return res + @api.multi - def backup_database(self): - if self.base_id.service_id.db_type == 'elasticsearch': - pass - return super(ClouderBackup, self).backup_database() + def restore_base(self): + """ It restores a backup of the file store """ + res = super(ClouderBackup, self).deploy_base() + if self.base_id.application_id.type_id.name == 'elasticsearch': + self.elasticsearch_restore_base() + return res @api.multi - def restore_database(self): - if self.base_id.service_id.db_type == 'elasticsearch': - pass - return super(ClouderBackup, self).restore_database() + def elasticsearch_deploy_base(self): + """ It backs up the filestore for Elasticsearch applications. """ + for volume in self.elasticsearch_volumes_data(): + self.service_id.base_backup_container.execute([ + 'rsync', '--progres', '-aze', + volume.localpath, + path.join(self.BACKUP_BASE_DIR, self.name, volume.name), + ], + username=self.base_id.application_id.type_id.system_user, + ) + + @api.multi + def elasticsearch_restore_base(self, base): + """ It restores a backup of the file store """ + for volume in self.elasticsearch_volumes_data(): + self.service_id.base_backup_container.execute([ + 'rsync', '--progres', '-aze', '--delete', + path.join(self.BACKUP_BASE_DIR, self.name, volume.name), + volume.localpath, + ], + username=self.base_id.application_id.type_id.system_user, + ) + + def __get_internal_ref(self, name): + return self.env.ref('clouder_template_elasticsearch.%s' % name) From 1f028ae53a35012726c51c7831e81e1e44e9e17c Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Wed, 14 Dec 2016 16:10:02 -0800 Subject: [PATCH 3/4] [REF] clouder_template_elasticsearch: PR Review updates --- clouder_template_elasticsearch/__openerp__.py | 1 - clouder_template_elasticsearch/data/application_type.xml | 3 --- .../images/{5.0-data => elasticsearch5-data}/Dockerfile | 0 .../{5.0-data => elasticsearch5-data}/etc/elasticsearch.yml | 0 .../images/{5.0-data => elasticsearch5-data}/etc/logging.yml | 0 .../images/{5.0-exec => elasticsearch5-exec}/Dockerfile | 0 .../{5.0-exec => elasticsearch5-exec}/docker-entrypoint.sh | 0 7 files changed, 4 deletions(-) rename clouder_template_elasticsearch/images/{5.0-data => elasticsearch5-data}/Dockerfile (100%) rename clouder_template_elasticsearch/images/{5.0-data => elasticsearch5-data}/etc/elasticsearch.yml (100%) rename clouder_template_elasticsearch/images/{5.0-data => elasticsearch5-data}/etc/logging.yml (100%) rename clouder_template_elasticsearch/images/{5.0-exec => elasticsearch5-exec}/Dockerfile (100%) rename clouder_template_elasticsearch/images/{5.0-exec => elasticsearch5-exec}/docker-entrypoint.sh (100%) diff --git a/clouder_template_elasticsearch/__openerp__.py b/clouder_template_elasticsearch/__openerp__.py index fac2540..f924e4d 100644 --- a/clouder_template_elasticsearch/__openerp__.py +++ b/clouder_template_elasticsearch/__openerp__.py @@ -20,7 +20,6 @@ 'data/image_port.xml', 'data/image_volume.xml', 'data/application_type.xml', - 'data/application_type_option.xml', 'data/application_template.xml', 'data/application.xml', 'data/application_link.xml', diff --git a/clouder_template_elasticsearch/data/application_type.xml b/clouder_template_elasticsearch/data/application_type.xml index 79f1f8a..ea8d64e 100644 --- a/clouder_template_elasticsearch/data/application_type.xml +++ b/clouder_template_elasticsearch/data/application_type.xml @@ -9,9 +9,6 @@ > elasticsearch elasticsearch - diff --git a/clouder_template_elasticsearch/images/5.0-data/Dockerfile b/clouder_template_elasticsearch/images/elasticsearch5-data/Dockerfile similarity index 100% rename from clouder_template_elasticsearch/images/5.0-data/Dockerfile rename to clouder_template_elasticsearch/images/elasticsearch5-data/Dockerfile diff --git a/clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml b/clouder_template_elasticsearch/images/elasticsearch5-data/etc/elasticsearch.yml similarity index 100% rename from clouder_template_elasticsearch/images/5.0-data/etc/elasticsearch.yml rename to clouder_template_elasticsearch/images/elasticsearch5-data/etc/elasticsearch.yml diff --git a/clouder_template_elasticsearch/images/5.0-data/etc/logging.yml b/clouder_template_elasticsearch/images/elasticsearch5-data/etc/logging.yml similarity index 100% rename from clouder_template_elasticsearch/images/5.0-data/etc/logging.yml rename to clouder_template_elasticsearch/images/elasticsearch5-data/etc/logging.yml diff --git a/clouder_template_elasticsearch/images/5.0-exec/Dockerfile b/clouder_template_elasticsearch/images/elasticsearch5-exec/Dockerfile similarity index 100% rename from clouder_template_elasticsearch/images/5.0-exec/Dockerfile rename to clouder_template_elasticsearch/images/elasticsearch5-exec/Dockerfile diff --git a/clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh b/clouder_template_elasticsearch/images/elasticsearch5-exec/docker-entrypoint.sh similarity index 100% rename from clouder_template_elasticsearch/images/5.0-exec/docker-entrypoint.sh rename to clouder_template_elasticsearch/images/elasticsearch5-exec/docker-entrypoint.sh From c868b64e734eefc261c0093722eb1575fe64b7a5 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Wed, 14 Dec 2016 16:12:52 -0800 Subject: [PATCH 4/4] [MIG] clouder_template_elasticsearch: Upgrade to v10 * Bump version * Change openerp references to odoo * Rename manifest --- .../{__openerp__.py => __manifest__.py} | 2 +- clouder_template_elasticsearch/models/backup copy.py | 2 +- clouder_template_elasticsearch/models/backup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename clouder_template_elasticsearch/{__openerp__.py => __manifest__.py} (96%) diff --git a/clouder_template_elasticsearch/__openerp__.py b/clouder_template_elasticsearch/__manifest__.py similarity index 96% rename from clouder_template_elasticsearch/__openerp__.py rename to clouder_template_elasticsearch/__manifest__.py index f924e4d..d79de5d 100644 --- a/clouder_template_elasticsearch/__openerp__.py +++ b/clouder_template_elasticsearch/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Clouder Template Elasticsearch', - 'version': '9.0.10.0.0', + 'version': '10.0.10.0.0', 'category': 'Clouder', 'depends': [ 'clouder', diff --git a/clouder_template_elasticsearch/models/backup copy.py b/clouder_template_elasticsearch/models/backup copy.py index 087fbe3..612fedb 100644 --- a/clouder_template_elasticsearch/models/backup copy.py +++ b/clouder_template_elasticsearch/models/backup copy.py @@ -2,7 +2,7 @@ # Copyright 2016 LasLabs Inc. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). -from openerp import api, models +from odoo import api, models class ClouderBackup(models.Model): diff --git a/clouder_template_elasticsearch/models/backup.py b/clouder_template_elasticsearch/models/backup.py index 29d373b..c18a0a0 100644 --- a/clouder_template_elasticsearch/models/backup.py +++ b/clouder_template_elasticsearch/models/backup.py @@ -4,7 +4,7 @@ from os import path -from openerp import api, models +from odoo import api, models class ClouderBackup(models.Model):