~mattyw/charms/trusty/mongodb/mongodb-deployu

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/templating.py

  • Committer: Marco Ceppi
  • Date: 2015-03-24 19:55:48 UTC
  • mfrom: (66.1.3 mongodb)
  • Revision ID: marco@ceppi.net-20150324195548-qms64mwxd1w70vhe
[brad-marshall] Adds nrpe-external-master interface and adds basic nrpe checks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014-2015 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
5
# charm-helpers is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Lesser General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# charm-helpers is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
1
17
import os
2
18
 
3
19
from charmhelpers.core import host
5
21
 
6
22
 
7
23
def render(source, target, context, owner='root', group='root',
8
 
           perms=0o444, templates_dir=None):
 
24
           perms=0o444, templates_dir=None, encoding='UTF-8'):
9
25
    """
10
26
    Render a template.
11
27
 
48
64
                    level=hookenv.ERROR)
49
65
        raise e
50
66
    content = template.render(context)
51
 
    host.mkdir(os.path.dirname(target), owner, group)
52
 
    host.write_file(target, content, owner, group, perms)
 
67
    host.mkdir(os.path.dirname(target), owner, group, perms=0o755)
 
68
    host.write_file(target, content.encode(encoding), owner, group, perms)