~james-page/charms/trusty/nova-compute/stable-bug-1413862

« back to all changes in this revision

Viewing changes to hooks/nova-compute-common

  • Committer: Adam Gandelman
  • Date: 2011-07-07 00:08:37 UTC
  • Revision ID: adamg@canonical.com-20110707000837-pfnc6fwayus4e6qc
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
SERVICES="nova-compute"
 
3
NOVA_CONF="/etc/nova/nova.conf"
 
4
RABBIT_USER="nova-compute"
 
5
DB_USER="nova"
 
6
NOVA_DB="nova"
 
7
DEFAULT_ETH=$(ip route  | grep default | awk '{ print $5 }')
 
8
IP=$(ifconfig  $DEFAULT_ETH | grep 'inet addr' | awk '{ print $2 }' | cut -d: -f2)
 
9
 
 
10
function set_or_update {
 
11
  # set or update a key=value config option in nova.conf
 
12
  KEY=$1
 
13
  VALUE=$2
 
14
  [[ -z $KEY ]] && exit 1
 
15
  [[ -z $VALUE ]] && exit 1
 
16
  cat $NOVA_CONF | grep "\-\-$KEY=$VALUE" >/dev/null \
 
17
   && ensemble-log "nova-cloud-controller: $KEY=$VALUE already set" exit 0
 
18
  if cat $NOVA_CONF | grep "\-\-$KEY=" >/dev/null ; then
 
19
    sed -i "s|\(--$KEY=\).*|\1$VALUE|" $NOVA_CONF
 
20
  else
 
21
    echo "--$KEY=$VALUE" >>$NOVA_CONF
 
22
  fi
 
23
}
 
24
 
 
25
function nova_ctl {
 
26
  if [[ $1 == "all" ]] ; then
 
27
    CTL=$SERVICES
 
28
  else
 
29
    CTL=$1
 
30
  fi
 
31
  ACTION=$2
 
32
  if [[ -z $CTL ]] || [[ -z $ACTION ]] ; then
 
33
    ensemble-log "ERROR nova_ctl: Not enough arguments"
 
34
    exit 1
 
35
  fi
 
36
  for i in $CTL ; do
 
37
    service $i $ACTION
 
38
    if [[ $? != 0 ]] ; then
 
39
      ensemble-log "ERROR nova_ctl: Service $i failed to $ACTION"
 
40
    fi
 
41
  done
 
42
}
 
43