First round of updates to functional base charm
This commit is contained in:
parent
1a9a8da5bd
commit
bde9af6434
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ build/
|
|||||||
.tox/
|
.tox/
|
||||||
func-results.json
|
func-results.json
|
||||||
test-charm/
|
test-charm/
|
||||||
|
.project
|
||||||
|
.pydevproject
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
options:
|
|
||||||
os-data-network:
|
|
||||||
type: string
|
|
||||||
default:
|
|
||||||
description: |
|
|
||||||
The IP address and netmask of the OpenStack Data network (e.g.,
|
|
||||||
192.168.0.0/24)
|
|
||||||
.
|
|
||||||
This network will be used for tenant network traffic in overlay
|
|
||||||
networks.
|
|
@ -1,4 +1,4 @@
|
|||||||
includes: ['layer:openstack-api']
|
includes: ['layer:openstack-api', 'interface:ceph-client']
|
||||||
options:
|
options:
|
||||||
basic:
|
basic:
|
||||||
use_venv: True
|
use_venv: True
|
||||||
|
@ -1,16 +1,61 @@
|
|||||||
|
import os
|
||||||
import collections
|
import collections
|
||||||
import socket
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import charmhelpers.core.hookenv as hookenv
|
import charmhelpers.core.hookenv as hookenv
|
||||||
|
import charmhelpers.core.host as host
|
||||||
|
|
||||||
import charms_openstack.charm
|
import charms_openstack.charm
|
||||||
|
import charms_openstack.adapters as adapters
|
||||||
import charms_openstack.ip as os_ip
|
import charms_openstack.ip as os_ip
|
||||||
|
|
||||||
# import charms_openstack.sdn.odl as odl
|
|
||||||
# import charms_openstack.sdn.ovs as ovs
|
GNOCCHI_DIR = '/etc/gnocchi'
|
||||||
|
GNOCCHI_CONF = os.path.join(GNOCCHI_DIR, 'gnocchi.conf')
|
||||||
|
GNOCCHI_APACHE_SITE = 'gnocchi-api'
|
||||||
|
GNOCCHI_WSGI_CONF = '/etc/apache2/sites-available/{}.conf'.format(GNOCCHI_APACHE_SITE)
|
||||||
|
|
||||||
|
CEPH_CONF = '/etc/ceph/ceph.conf'
|
||||||
|
|
||||||
|
CEPH_POOL_NAME = 'gnocchi'
|
||||||
|
|
||||||
|
|
||||||
|
class StorageCephRelationAdapter(adapters.OpenStackRelationAdapter):
|
||||||
|
"""
|
||||||
|
Adapter for the CephClientRequires relation interface.
|
||||||
|
"""
|
||||||
|
|
||||||
|
interface_type = "ceph-client"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def monitors(self):
|
||||||
|
"""
|
||||||
|
Comma separated list of hosts that should be used
|
||||||
|
to access Ceph.
|
||||||
|
"""
|
||||||
|
hosts = self.relation.mon_hosts()
|
||||||
|
if len(hosts) > 1:
|
||||||
|
return ','.join(hosts)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class GnocchiCharmRelationAdapaters(adapters.OpenStackAPIRelationAdapters):
|
||||||
|
"""
|
||||||
|
Adapters collection to append ceph-client adapter for Gnocchi
|
||||||
|
"""
|
||||||
|
|
||||||
|
relation_adapters = {
|
||||||
|
'storage_ceph': StorageCephRelationAdapter,
|
||||||
|
'shared_db': adapters.DatabaseRelationAdapter,
|
||||||
|
'cluster': adapters.PeerHARelationAdapter,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
|
class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
|
||||||
|
"""
|
||||||
|
Charm for Juju deployment of Gnocchi
|
||||||
|
"""
|
||||||
|
|
||||||
# Internal name of charm
|
# Internal name of charm
|
||||||
service_name = name = 'gnocchi'
|
service_name = name = 'gnocchi'
|
||||||
@ -19,26 +64,30 @@ class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
|
|||||||
release = 'mitaka'
|
release = 'mitaka'
|
||||||
|
|
||||||
# List of packages to install for this charm
|
# List of packages to install for this charm
|
||||||
packages = ['gnocchi-api', 'gnocchi-metricd', 'python-apt']
|
packages = ['gnocchi-api', 'gnocchi-metricd', 'python-apt',
|
||||||
|
'ceph-common', 'python-rados', 'python-keystonemiddleware',
|
||||||
|
'apache2', 'libapache2-mod-wsgi']
|
||||||
|
|
||||||
api_ports = {
|
api_ports = {
|
||||||
'apache2': {
|
'gnocchi-api': {
|
||||||
os_ip.PUBLIC: 8041,
|
os_ip.PUBLIC: 8041,
|
||||||
os_ip.ADMIN: 8041,
|
os_ip.ADMIN: 8041,
|
||||||
os_ip.INTERNAL: 8041,
|
os_ip.INTERNAL: 8041,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service_type = 'gnocchi'
|
default_service = 'gnocchi-api'
|
||||||
default_service = 'apache2'
|
|
||||||
services = ['haproxy', 'apache2 gnocchi-metricd', 'apache2']
|
|
||||||
|
|
||||||
# Note that the hsm interface is optional - defined in config.yaml
|
service_type = 'gnocchi'
|
||||||
required_relations = ['shared-db', 'amqp', 'identity-service']
|
|
||||||
|
services = ['gnocchi-metricd', 'apache2']
|
||||||
|
|
||||||
|
required_relations = ['shared-db', 'identity-service', 'storage-ceph']
|
||||||
|
|
||||||
restart_map = {
|
restart_map = {
|
||||||
|
GNOCCHI_CONF: services,
|
||||||
'/etc/gnocchi/gnocchi.conf': services,
|
GNOCCHI_WSGI_CONF: ['apache2'],
|
||||||
|
CEPH_CONF: services,
|
||||||
}
|
}
|
||||||
|
|
||||||
ha_resources = ['vips', 'haproxy']
|
ha_resources = ['vips', 'haproxy']
|
||||||
@ -49,15 +98,32 @@ class GnocchiCharm(charms_openstack.charm.HAOpenStackCharm):
|
|||||||
'gnocchi-common': collections.OrderedDict([
|
'gnocchi-common': collections.OrderedDict([
|
||||||
('2', 'mitaka'),
|
('2', 'mitaka'),
|
||||||
('3', 'newton'),
|
('3', 'newton'),
|
||||||
('4', 'ocata'),
|
('4', 'pike'),
|
||||||
]),
|
]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sync_cmd = ['gnocchi-upgrade']
|
sync_cmd = ['gnocchi-upgrade']
|
||||||
|
|
||||||
def get_amqp_credentials(self):
|
adapters_class = GnocchiCharmRelationAdapaters
|
||||||
return ('gnocchi', 'gnocchi')
|
|
||||||
|
def install(self):
|
||||||
|
super(GnocchiCharm, self).install()
|
||||||
|
# NOTE(jamespage): always pause gnocchi-api service as we force
|
||||||
|
# execution with Apache2+mod_wsgi
|
||||||
|
host.service_pause('gnocchi-api')
|
||||||
|
|
||||||
|
def enable_apache2_site(self):
|
||||||
|
"""Enable Gnocchi API apache2 site if rendered or installed"""
|
||||||
|
if os.path.exists(GNOCCHI_WSGI_CONF):
|
||||||
|
check_enabled = subprocess.call(
|
||||||
|
['a2query', '-s', GNOCCHI_APACHE_SITE]
|
||||||
|
)
|
||||||
|
if check_enabled != 0:
|
||||||
|
subprocess.check_call(['a2ensite',
|
||||||
|
GNOCCHI_APACHE_SITE])
|
||||||
|
host.service_reload('apache2',
|
||||||
|
restart_on_failure=True)
|
||||||
|
|
||||||
def get_database_setup(self):
|
def get_database_setup(self):
|
||||||
return [{
|
return [{
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
name: gnocchi
|
name: gnocchi
|
||||||
maintainer: example@example.com
|
maintainer: OpenStack Charmers <openstack-dev@lists.openstack.org>
|
||||||
summary: Short summary of charm
|
summary: Multi-tenant timeseries, metrics and resources database
|
||||||
description: |
|
description: |
|
||||||
Longline summary of charm
|
Gnocchi is an open-source, multi-tenant timeseries, metrics
|
||||||
|
and resources database. It provides an HTTP REST interface
|
||||||
|
to create and manipulate the data. It is designed to store
|
||||||
|
metrics at a very large scale while providing access to
|
||||||
|
metrics and resources information and history.
|
||||||
tags:
|
tags:
|
||||||
- openstack
|
- openstack
|
||||||
series:
|
series:
|
||||||
- xenial
|
- xenial
|
||||||
- trusty
|
- trusty
|
||||||
- yakkety
|
- yakkety
|
||||||
|
- zesty
|
||||||
|
requires:
|
||||||
|
storage-ceph:
|
||||||
|
interface: ceph-client
|
||||||
|
@ -15,41 +15,61 @@
|
|||||||
import charms_openstack.charm as charm
|
import charms_openstack.charm as charm
|
||||||
import charms.reactive as reactive
|
import charms.reactive as reactive
|
||||||
|
|
||||||
# This charm's library contains all of the handler code associated with
|
|
||||||
# sdn_charm
|
|
||||||
import charm.openstack.gnocchi as gnocchi # noqa
|
import charm.openstack.gnocchi as gnocchi # noqa
|
||||||
|
|
||||||
|
import charmhelpers.contrib.storage.linux.ceph as ceph_helper
|
||||||
|
import charmhelpers.core.hookenv as hookenv
|
||||||
|
|
||||||
charm.use_defaults(
|
charm.use_defaults(
|
||||||
'charm.installed',
|
'charm.installed',
|
||||||
'amqp.connected',
|
|
||||||
'shared-db.connected',
|
'shared-db.connected',
|
||||||
'identity-service.connected',
|
'identity-service.connected',
|
||||||
'identity-service.available', # enables SSL support
|
'identity-service.available', # enables SSL support
|
||||||
'config.changed',
|
'config.changed',
|
||||||
'update-status')
|
'update-status')
|
||||||
|
|
||||||
|
|
||||||
@reactive.when('shared-db.available')
|
@reactive.when('shared-db.available')
|
||||||
@reactive.when('identity-service.available')
|
@reactive.when('identity-service.available')
|
||||||
@reactive.when('amqp.available')
|
@reactive.when('storage-ceph.available')
|
||||||
|
@reactive.when('storage-ceph.pools.available')
|
||||||
def render_config(*args):
|
def render_config(*args):
|
||||||
"""Render the configuration for charm when all the interfaces are
|
"""Render the configuration for charm when all the interfaces are
|
||||||
available.
|
available.
|
||||||
"""
|
"""
|
||||||
with charm.provide_charm_instance() as charm_class:
|
with charm.provide_charm_instance() as charm_class:
|
||||||
charm_class.upgrade_if_available(args)
|
|
||||||
charm_class.render_with_interfaces(args)
|
charm_class.render_with_interfaces(args)
|
||||||
|
charm_class.enable_apache2_site()
|
||||||
charm_class.assess_status()
|
charm_class.assess_status()
|
||||||
reactive.set_state('config.rendered')
|
reactive.set_state('config.rendered')
|
||||||
|
|
||||||
|
|
||||||
# db_sync checks if sync has been done so rerunning is a noop
|
# db_sync checks if sync has been done so rerunning is a noop
|
||||||
@reactive.when('config.rendered')
|
@reactive.when('config.rendered')
|
||||||
def init_db():
|
def init_db():
|
||||||
with charm.provide_charm_instance() as charm_class:
|
with charm.provide_charm_instance() as charm_class:
|
||||||
charm_class.db_sync()
|
charm_class.db_sync()
|
||||||
|
|
||||||
|
|
||||||
@reactive.when('ha.connected')
|
@reactive.when('ha.connected')
|
||||||
def cluster_connected(hacluster):
|
def cluster_connected(hacluster):
|
||||||
"""Configure HA resources in corosync"""
|
"""Configure HA resources in corosync"""
|
||||||
with charm.provide_charm_instance() as charm_class:
|
with charm.provide_charm_instance() as charm_class:
|
||||||
charm_class.configure_ha_resources(hacluster)
|
charm_class.configure_ha_resources(hacluster)
|
||||||
charm_class.assess_status()
|
charm_class.assess_status()
|
||||||
|
|
||||||
|
|
||||||
|
@reactive.when('storage-ceph.connected')
|
||||||
|
def storage_ceph_connected(ceph):
|
||||||
|
ceph.create_pool(gnocchi.CEPH_POOL_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
@reactive.when('storage-ceph.available')
|
||||||
|
def configure_ceph(ceph):
|
||||||
|
ceph_helper.create_keyring(hookenv.service_name(),
|
||||||
|
ceph.key())
|
||||||
|
|
||||||
|
|
||||||
|
@reactive.when_not('storage-ceph.connected')
|
||||||
|
def storage_ceph_disconnected():
|
||||||
|
ceph_helper.delete_keyring(hookenv.service_name())
|
||||||
|
10
src/templates/ceph.conf
Normal file
10
src/templates/ceph.conf
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
###############################################################################
|
||||||
|
# [ WARNING ]
|
||||||
|
# configuration file maintained by Juju
|
||||||
|
# local changes will be overwritten.
|
||||||
|
###############################################################################
|
||||||
|
[global]
|
||||||
|
{% if storage_ceph.auth -%}
|
||||||
|
auth_supported = {{ storage_ceph.auth }}
|
||||||
|
mon host = {{ storage_ceph.monitors }}
|
||||||
|
{% endif -%}
|
25
src/templates/gnocchi-api.conf
Normal file
25
src/templates/gnocchi-api.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
###############################################################################
|
||||||
|
# [ WARNING ]
|
||||||
|
# configuration file maintained by Juju
|
||||||
|
# local changes will be overwritten.
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Listen {{ options.service_listen_info.gnocchi_api.public_port }}
|
||||||
|
|
||||||
|
<VirtualHost *:{{ options.service_listen_info.gnocchi_api.public_port }}>
|
||||||
|
WSGIDaemonProcess gnocchi-api processes=2 threads=10 user=gnocchi display-name=%{GROUP}
|
||||||
|
WSGIProcessGroup gnocchi-api
|
||||||
|
WSGIScriptAlias / /usr/lib/python2.7/dist-packages/gnocchi/rest/app.wsgi
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
<Directory /usr/lib/python2.7/dist-packages/gnocchi/rest>
|
||||||
|
<IfVersion >= 2.4>
|
||||||
|
Require all granted
|
||||||
|
</IfVersion>
|
||||||
|
<IfVersion < 2.4>
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</IfVersion>
|
||||||
|
</Directory>
|
||||||
|
ErrorLog /var/log/apache2/gnocchi_error.log
|
||||||
|
CustomLog /var/log/apache2/gnocchi_access.log combined
|
||||||
|
</VirtualHost>
|
28
src/templates/gnocchi.conf
Normal file
28
src/templates/gnocchi.conf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
###############################################################################
|
||||||
|
# [ WARNING ]
|
||||||
|
# configuration file maintained by Juju
|
||||||
|
# local changes will be overwritten.
|
||||||
|
###############################################################################
|
||||||
|
[DEFAULT]
|
||||||
|
debug = {{ options.debug }}
|
||||||
|
use_syslog = {{ options.use_syslog }}
|
||||||
|
log_file = /var/log/gnocchi/gnocchi-api.log
|
||||||
|
|
||||||
|
[api]
|
||||||
|
auth_mode = keystone
|
||||||
|
|
||||||
|
[indexer]
|
||||||
|
{% if shared_db.uri -%}
|
||||||
|
url = {{ shared_db.uri }}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
[storage]
|
||||||
|
{% if storage_ceph.key -%}
|
||||||
|
driver = ceph
|
||||||
|
ceph_pool = gnocchi
|
||||||
|
ceph_username = {{ options.service_name }}
|
||||||
|
ceph_secret = {{ storage_ceph.key }}
|
||||||
|
ceph_conffile = /etc/ceph/ceph.conf
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{% include "parts/section-keystone-authtoken" %}
|
25
src/templates/newton/gnocchi-api.conf
Normal file
25
src/templates/newton/gnocchi-api.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
###############################################################################
|
||||||
|
# [ WARNING ]
|
||||||
|
# configuration file maintained by Juju
|
||||||
|
# local changes will be overwritten.
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Listen {{ options.service_listen_info.gnocchi_api.public_port }}
|
||||||
|
|
||||||
|
<VirtualHost *:{{ options.service_listen_info.gnocchi_api.public_port }}>
|
||||||
|
WSGIDaemonProcess gnocchi-api processes=2 threads=10 user=gnocchi display-name=%{GROUP}
|
||||||
|
WSGIProcessGroup gnocchi-api
|
||||||
|
WSGIScriptAlias / /usr/bin/gnocchi-api
|
||||||
|
WSGIApplicationGroup %{GLOBAL}
|
||||||
|
<Directory /usr/bin>
|
||||||
|
<IfVersion >= 2.4>
|
||||||
|
Require all granted
|
||||||
|
</IfVersion>
|
||||||
|
<IfVersion < 2.4>
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</IfVersion>
|
||||||
|
</Directory>
|
||||||
|
ErrorLog /var/log/apache2/gnocchi_error.log
|
||||||
|
CustomLog /var/log/apache2/gnocchi_access.log combined
|
||||||
|
</VirtualHost>
|
Loading…
Reference in New Issue
Block a user