diff --git a/config.yaml b/config.yaml index 9ee036c8..122eab56 100644 --- a/config.yaml +++ b/config.yaml @@ -38,6 +38,10 @@ options: default: kvm type: string description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu" + multi-host: + default: "yes" + type: string + description: Whether to run nova-api and nova-network on the compute nodes. # needed if using flatmanager bridge-interface: default: br100 @@ -60,3 +64,13 @@ options: default: None type: string description: Comma separated list of key=value config flags to be set in nova.conf. + nagios_context: + default: "juju" + type: string + description: | + Used by the nrpe-external-master subordinate charm. + A string that will be prepended to instance name to set the host name + in nagios. So for instance the hostname would be something like: + juju-myservice-0 + If you're running multiple environments with the same services in them + this allows you to differentiate between them. diff --git a/hooks/nova-compute-common b/hooks/nova-compute-common index 2faf19f1..2ce04546 100755 --- a/hooks/nova-compute-common +++ b/hooks/nova-compute-common @@ -7,6 +7,7 @@ CONF_DIR="/etc/nova" NOVA_CONF=$(config-get nova-config) API_CONF="/etc/nova/api-paste.ini" QUANTUM_CONF="/etc/quantum/quantum.conf" +MULTI_HOST=$(config-get multi-host) if [ -f /etc/nova/nm.conf ]; then NET_MANAGER=$(cat /etc/nova/nm.conf) @@ -28,7 +29,9 @@ case $NET_MANAGER in esac ;; "FlatManager"|"FlatDHCPManager") - SERVICES="$SERVICES nova-api nova-network" + if [[ "$MULTI_HOST" == "yes" ]] ; then + SERVICES="$SERVICES nova-api nova-network" + fi ;; esac @@ -102,8 +105,10 @@ function configure_network_manager { case $net_manager in "FlatManager"|"FlatDHCPManager") - apt-get -y install nova-api nova-network - SERVICES="$SERVICES nova-api nova-network" + if [[ "$MULTI_HOST" == "yes" ]] ; then + apt-get -y install nova-api nova-network + SERVICES="$SERVICES nova-api nova-network" + fi ;;& "FlatManager") local bridge_ip=$(config-get bridge-ip) @@ -177,3 +182,30 @@ cgroup_device_acl = [ EOF service libvirt-bin reload } + +function give_me_numbers { + local name="$1" + local address= + + case "$name" in + [A-Za-z]*) + address=$(getent hosts "$name" | awk '{print $1}') + case "$address" in + 127.*) + address=$(dig +short "$name") + if [ -z "$address" ]; then + echo "$name" + fi + echo "$address" + ;; + *) + echo "$address" + ;; + esac + ;; + *) + # not a name, maybe it's an address? + echo "$name" + ;; + esac +} diff --git a/hooks/nova-compute-relations b/hooks/nova-compute-relations index 976bc9b5..a1c449c9 100755 --- a/hooks/nova-compute-relations +++ b/hooks/nova-compute-relations @@ -9,6 +9,7 @@ else fi function install_hook { + [ -d exec.d ] && ( for f in exec.d/*/charm-pre-install; do [ -x $f ] && /bin/sh -c "$f";done ) local virt_type=$(config-get virt-type) local compute_pkg=$(determine_compute_package "$virt_type") apt-get -y install python-software-properties || exit 1 @@ -20,6 +21,10 @@ function install_hook { configure_libvirt } +function upgrade_hook { + [ -d exec.d ] && ( for f in exec.d/*/charm-pre-install; do [ -x $f ] && /bin/sh -c "$f";done ) +} + function config_changed() { # Determine whether or not we should do an upgrade, based on whether or not @@ -203,7 +208,7 @@ function ceph_changed { MONS=`relation-list` mon_hosts="" for mon in $MONS; do - mon_hosts="$mon_hosts `relation-get private-address $mon`:6789" + mon_hosts="$mon_hosts $(give_me_numbers $(relation-get private-address $mon)):6789" done cat > /etc/ceph/ceph.conf << EOF [global] @@ -234,6 +239,7 @@ EOF case $ARG0 in "install") install_hook ;; + "upgrade-charm") upgrade_hook ;; "start"|"stop") exit 0 ;; "config-changed") config_changed ;; "amqp-relation-joined") amqp_joined ;; diff --git a/metadata.yaml b/metadata.yaml index ef7235b6..45421201 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -8,6 +8,9 @@ description: | provides: cloud-compute: interface: nova-compute + nrpe-external-master: + interface: nrpe-external-master + scope: container requires: shared-db: interface: mysql-shared