~charm-demo/charms/trusty/nrpe/trunk

« back to all changes in this revision

Viewing changes to hooks/local-monitors-relation-changed

  • Committer: Clint Byrum
  • Date: 2012-07-13 18:58:50 UTC
  • Revision ID: clint@ubuntu.com-20120713185850-djtwietqlvwaliht
fixes to hooks

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
import os
3
3
import json
4
4
import sys
 
5
import subprocess
 
6
import yaml
5
7
 
6
8
primary_id=os.environ.get('JUJU_REMOTE_UNIT','testing/0').replace('/','-')
7
 
os.mkdir('data')
 
9
if not os.path.exists('data'):
 
10
    os.mkdir('data')
8
11
with open('data/primary_id','w') as primid:
9
12
    primid.write(primary_id)
10
13
 
14
17
 
15
18
with open('primary-monitors.yaml', 'w') as pmons:
16
19
    if type(monitors) == dict:
17
 
        yaml.dumps(monitors, pmons)
 
20
        yaml.safe_dump(monitors, pmons)
18
21
    else:
19
22
        pmons.write(monitors)