From 241edba98f029a4019e8c46393507c025eda4ba8 Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Wed, 25 Jan 2017 22:02:03 +0200 Subject: [PATCH] Larify the charm --- hooks/config-changed | 2 -- hooks/install | 24 ------------------------ hooks/relation-name-relation-broken | 2 -- hooks/relation-name-relation-changed | 9 --------- hooks/relation-name-relation-departed | 5 ----- hooks/relation-name-relation-joined | 5 ----- hooks/start | 4 ---- hooks/stop | 7 ------- hooks/upgrade-charm | 6 ------ layer.yaml | 17 +++++++++++++++++ reactive/netdata.py | 15 +++++++++++++++ revision | 1 - 12 files changed, 32 insertions(+), 65 deletions(-) delete mode 100755 hooks/config-changed delete mode 100755 hooks/install delete mode 100755 hooks/relation-name-relation-broken delete mode 100755 hooks/relation-name-relation-changed delete mode 100755 hooks/relation-name-relation-departed delete mode 100755 hooks/relation-name-relation-joined delete mode 100755 hooks/start delete mode 100755 hooks/stop delete mode 100755 hooks/upgrade-charm create mode 100644 layer.yaml create mode 100644 reactive/netdata.py delete mode 100644 revision diff --git a/hooks/config-changed b/hooks/config-changed deleted file mode 100755 index cd6a671..0000000 --- a/hooks/config-changed +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# config-changed occurs everytime a new configuration value is updated (juju set) diff --git a/hooks/install b/hooks/install deleted file mode 100755 index 0c342e3..0000000 --- a/hooks/install +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Here do anything needed to install the service -# i.e. apt-get install -y foo or bzr branch http://myserver/mycode /srv/webroot -# Make sure this hook exits cleanly and is idempotent, common problems here are -# failing to account for a debconf question on a dependency, or trying to pull -# from github without installing git first. - -set -e - -status-set maintenance "Installing netdata prerequisites" -apt-get install -y zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl - -status-set maintenance "Fetching netdata" -# download it - the directory 'netdata' will be created -git clone https://github.com/firehol/netdata.git --depth=1 -cd netdata - -status-set maintenance "Installing netdata" -# build it, install it, start it -./netdata-installer.sh - -open-port 19999 - -status-set active "Installed" diff --git a/hooks/relation-name-relation-broken b/hooks/relation-name-relation-broken deleted file mode 100755 index 8551a4e..0000000 --- a/hooks/relation-name-relation-broken +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -# This hook runs when the full relation is removed (not just a single member) diff --git a/hooks/relation-name-relation-changed b/hooks/relation-name-relation-changed deleted file mode 100755 index c310707..0000000 --- a/hooks/relation-name-relation-changed +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# This must be renamed to the name of the relation. The goal here is to -# affect any change needed by relationships being formed, modified, or broken -# This script should be idempotent. -juju-log $JUJU_REMOTE_UNIT modified its settings -juju-log Relation settings: -relation-get -juju-log Relation members: -relation-list diff --git a/hooks/relation-name-relation-departed b/hooks/relation-name-relation-departed deleted file mode 100755 index f1d8e9f..0000000 --- a/hooks/relation-name-relation-departed +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# This must be renamed to the name of the relation. The goal here is to -# affect any change needed by the remote unit leaving the relationship. -# This script should be idempotent. -juju-log $JUJU_REMOTE_UNIT departed diff --git a/hooks/relation-name-relation-joined b/hooks/relation-name-relation-joined deleted file mode 100755 index da1328e..0000000 --- a/hooks/relation-name-relation-joined +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# This must be renamed to the name of the relation. The goal here is to -# affect any change needed by relationships being formed -# This script should be idempotent. -juju-log $JUJU_REMOTE_UNIT joined diff --git a/hooks/start b/hooks/start deleted file mode 100755 index a5ea040..0000000 --- a/hooks/start +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Here put anything that is needed to start the service. -# Note that currently this is run directly after install -# i.e. 'service apache2 start' diff --git a/hooks/stop b/hooks/stop deleted file mode 100755 index 1068769..0000000 --- a/hooks/stop +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -# This will be run when the service is being torn down, allowing you to disable -# it in various ways.. -# For example, if your web app uses a text file to signal to the load balancer -# that it is live... you could remove it and sleep for a bit to allow the load -# balancer to stop sending traffic. -# rm /srv/webroot/server-live.txt && sleep 30 diff --git a/hooks/upgrade-charm b/hooks/upgrade-charm deleted file mode 100755 index cc8c166..0000000 --- a/hooks/upgrade-charm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# This hook is executed each time a charm is upgraded after the new charm -# contents have been unpacked -# Best practice suggests you execute the hooks/install and -# hooks/config-changed to ensure all updates are processed - diff --git a/layer.yaml b/layer.yaml new file mode 100644 index 0000000..0b5742a --- /dev/null +++ b/layer.yaml @@ -0,0 +1,17 @@ +repo: git@github.com:juju-solutions/layer-apache-spark.git +includes: ['layer:basic'] +options: + basic: + packages: + - zlib1g-dev + - uuid-dev + - libmnl-dev + - gcc + - make + - git + - autoconf + - autoconf-archive + - autogen + - automake + - pkg-config + - curl diff --git a/reactive/netdata.py b/reactive/netdata.py new file mode 100644 index 0000000..62709f8 --- /dev/null +++ b/reactive/netdata.py @@ -0,0 +1,15 @@ +import subprocess +from charms.reactive import when, when_not +from charms.reactive import set_state, remove_state, is_state +from charmhelpers.core import hookenv, host + + +@when_not("netdata.installed") +def install_netdata(): + hookenv.status_set('maintenance', 'Installing netdata') + subprocess.check_call(["/usr/bin/git", "clone", "https://github.com/firehol/netdata.git", "--depth=1"]) + with host.chdir("netdata"): + subprocess.check_call(["./netdata-installer.sh"]) + hookenv.open_port(19999) + hookenv.status_set('active', 'Ready') + set_state("netdata.installed") diff --git a/revision b/revision deleted file mode 100644 index d00491f..0000000 --- a/revision +++ /dev/null @@ -1 +0,0 @@ -1