commit 0fe84902e4074b7a2a80590329061affa5f15fd5 Author: Chris MacNaughton Date: Thu Jun 30 13:06:08 2016 -0400 initial commit diff --git a/src/README.ex b/src/README.ex new file mode 100644 index 0000000..b6816b2 --- /dev/null +++ b/src/README.ex @@ -0,0 +1,65 @@ +# Overview + +Describe the intended usage of this charm and anything unique about how this +charm relates to others here. + +This README will be displayed in the Charm Store, it should be either Markdown +or RST. Ideal READMEs include instructions on how to use the charm, expected +usage, and charm features that your audience might be interested in. For an +example of a well written README check out Hadoop: +http://jujucharms.com/charms/precise/hadoop + +Use this as a Markdown reference if you need help with the formatting of this +README: http://askubuntu.com/editing-help + +This charm provides [service][]. Add a description here of what the service +itself actually does. + +Also remember to check the [icon guidelines][] so that your charm looks good +in the Juju GUI. + +# Usage + +Step by step instructions on using the charm: + +juju deploy servicename + +and so on. If you're providing a web service or something that the end user +needs to go to, tell them here, especially if you're deploying a service that +might listen to a non-default port. + +You can then browse to http://ip-address to configure the service. + +## Scale out Usage + +If the charm has any recommendations for running at scale, outline them in +examples here. For example if you have a memcached relation that improves +performance, mention it here. + +## Known Limitations and Issues + +This not only helps users but gives people a place to start if they want to help +you add features to your charm. + +# Configuration + +The configuration options will be listed on the charm store, however If you're +making assumptions or opinionated decisions in the charm (like setting a default +administrator password), you should detail that here so the user knows how to +change it immediately, etc. + +# Contact Information + +Though this will be listed in the charm store itself don't assume a user will +know that, so include that information here: + +## Upstream Project Name + + - Upstream website + - Upstream bug tracker + - Upstream mailing list or contact information + - Feel free to add things if it's useful for users + + +[service]: http://example.com +[icon guidelines]: https://jujucharms.com/docs/stable/authors-charm-icon diff --git a/src/config.yaml b/src/config.yaml new file mode 100644 index 0000000..49d6f9e --- /dev/null +++ b/src/config.yaml @@ -0,0 +1,28 @@ +options: + loglevel: + default: 1 + type: int + description: Mon and OSD debug level. Max is 20. + use-syslog: + type: boolean + default: False + description: | + If set to True, supporting services will log to syslog. + ceph-public-network: + type: string + default: + description: | + The IP address and netmask of the public (front-side) network (e.g., + 192.168.0.0/24) + . + If multiple networks are to be used, a space-delimited list of a.b.c.d/x + can be provided. + ceph-cluster-network: + type: string + default: + description: | + The IP address and netmask of the cluster (back-side) network (e.g., + 192.168.0.0/24) + . + If multiple networks are to be used, a space-delimited list of a.b.c.d/x + can be provided. \ No newline at end of file diff --git a/src/icon.svg b/src/icon.svg new file mode 100644 index 0000000..e092eef --- /dev/null +++ b/src/icon.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/layer.yaml b/src/layer.yaml new file mode 100644 index 0000000..c58e112 --- /dev/null +++ b/src/layer.yaml @@ -0,0 +1 @@ +includes: ['layer:ceph-base'] # if you use any interfaces, add them here diff --git a/src/metadata.yaml b/src/metadata.yaml new file mode 100644 index 0000000..0361478 --- /dev/null +++ b/src/metadata.yaml @@ -0,0 +1,19 @@ +name: charm-ceph-fs +summary: +maintainer: chris +description: | + +tags: + # Replace "misc" with one or more whitelisted tags from this list: + # https://jujucharms.com/docs/stable/authors-charm-metadata + - misc +subordinate: false +provides: + provides-relation: + interface: interface-name +requires: + requires-relation: + interface: interface-name +peers: + peer-relation: + interface: interface-name diff --git a/src/reactive/charm_ceph_fs.py b/src/reactive/charm_ceph_fs.py new file mode 100644 index 0000000..83c463f --- /dev/null +++ b/src/reactive/charm_ceph_fs.py @@ -0,0 +1,46 @@ +from charms.reactive import when, when_not, set_state + +from charmhelpers.core.hookenv import ( + config, +) + +from charmhelpers.contrib.network.ip import ( + get_address_in_network +) + +@when('ceph.installed') +@when('ceph-mon.available') +def setup_mds(mon): + + +@when('config.changed', 'ceph-mon.available') +def config_changed(): + networks = get_networks('ceph-public-network') + public_network = ', '.join(networks) + + networks = get_networks('ceph-cluster-network') + cluster_network = ', '.join(networks) + + cephcontext = { + # 'mon_hosts': ' '.join(get_mon_hosts()), + # 'fsid': leader_get('fsid'), + 'osd_journal_size': config('osd-journal-size'), + 'use_syslog': str(config('use-syslog')).lower(), + 'ceph_public_network': public_network, + 'ceph_cluster_network': cluster_network, + 'loglevel': config('loglevel'), + } + + +def get_networks(config_opt='ceph-public-network'): + """Get all configured networks from provided config option. + + If public network(s) are provided, go through them and return those for + which we have an address configured. + """ + networks = config(config_opt) + if networks: + networks = networks.split() + return [n for n in networks if get_address_in_network(n)] + + return [] diff --git a/src/templates/ceph.conf b/src/templates/ceph.conf new file mode 100644 index 0000000..ea9b733 --- /dev/null +++ b/src/templates/ceph.conf @@ -0,0 +1,33 @@ +[global] +auth cluster required = {{ auth_supported }} +auth service required = {{ auth_supported }} +auth client required = {{ auth_supported }} +{% endif %} +keyring = /etc/ceph/$cluster.$name.keyring +mon host = {{ mon_hosts }} +fsid = {{ fsid }} + +log to syslog = {{ use_syslog }} +err to syslog = {{ use_syslog }} +clog to syslog = {{ use_syslog }} +mon cluster log to syslog = {{ use_syslog }} +debug mon = {{ loglevel }}/5 +debug osd = {{ loglevel }}/5 + +{%- if ceph_public_network is string %} +public network = {{ ceph_public_network }} +{%- endif %} +{%- if ceph_cluster_network is string %} +cluster network = {{ ceph_cluster_network }} +{%- endif %} + +{% if public_addr %} +public addr = {{ public_addr }} +{% endif %} +{% if cluster_addr %} +cluster addr = {{ cluster_addr }} +{%- endif %} + +[mds] +keyring = /var/lib/ceph/mds/$cluster-$id/keyring + diff --git a/src/tests/00-setup b/src/tests/00-setup new file mode 100755 index 0000000..f0616a5 --- /dev/null +++ b/src/tests/00-setup @@ -0,0 +1,5 @@ +#!/bin/bash + +sudo add-apt-repository ppa:juju/stable -y +sudo apt-get update +sudo apt-get install amulet python-requests -y diff --git a/src/tests/10-deploy b/src/tests/10-deploy new file mode 100755 index 0000000..d5778b0 --- /dev/null +++ b/src/tests/10-deploy @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import amulet +import requests +import unittest + + +class TestCharm(unittest.TestCase): + def setUp(self): + self.d = amulet.Deployment() + + self.d.add('charm-ceph-fs') + self.d.expose('charm-ceph-fs') + + self.d.setup(timeout=900) + self.d.sentry.wait() + + self.unit = self.d.sentry['charm-ceph-fs'][0] + + def test_service(self): + # test we can access over http + page = requests.get('http://{}'.format(self.unit.info['public-address'])) + self.assertEqual(page.status_code, 200) + # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform + # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods: + # - .info - An array of the information of that unit from Juju + # - .file(PATH) - Get the details of a file on that unit + # - .file_contents(PATH) - Get plain text output of PATH file from that unit + # - .directory(PATH) - Get details of directory + # - .directory_contents(PATH) - List files and folders in PATH on that unit + # - .relation(relation, service:rel) - Get relation data from return service diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e69de29