~alexlist/charms/trusty/ceilometer/add-execd-preinstall

« back to all changes in this revision

Viewing changes to hooks/ceilometer_utils.py

  • Committer: James Page
  • Date: 2013-10-14 15:50:27 UTC
  • Revision ID: james.page@canonical.com-20131014155027-k68089t0jfzbqjrg
Tidy for redux part1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
2
import uuid
3
 
import ConfigParser
4
 
import sys
5
3
from charmhelpers.fetch import apt_install as install
6
 
from charmhelpers.core.hookenv import log as juju_log, ERROR
7
4
 
8
5
RABBIT_USER = "ceilometer"
9
6
RABBIT_VHOST = "ceilometer"
48
45
    return secret
49
46
 
50
47
 
51
 
def modify_config_file(nova_conf, values):
52
 
    # check if config file exists
53
 
    if not os.path.exists(nova_conf):
54
 
        juju_log('ERROR', 'nova config file must exist at this point')
55
 
        sys.exit(1)
56
 
 
57
 
    try:
58
 
        config = ConfigParser.ConfigParser()
59
 
        with open(nova_conf, "r") as f:
60
 
            config.readfp(f)
61
 
 
62
 
        # add needed config lines - tuple with section,key,value
63
 
        for value in values:
64
 
            config.set(value[0], value[1], value[2])
65
 
 
66
 
        with open(nova_conf, "w") as f:
67
 
            config.write(f)
68
 
 
69
 
        f.close()
70
 
    except IOError:
71
 
        juju_log('Error updating nova config file', level=ERROR)
72
 
        sys.exit(1)
73
 
 
74
 
 
75
48
TEMPLATES_DIR = 'templates'
76
49
 
77
50
try: