~openstack-charmers-archive/charms/precise/swift-storage/old-1501

« back to all changes in this revision

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

  • Committer: Corey Bryant
  • Date: 2014-12-18 13:30:39 UTC
  • mfrom: (51.1.1 swift-storage)
  • Revision ID: corey.bryant@canonical.com-20141218133039-fp90dyx570ela0jn
[dosaboy,r=corey.bryant] Retry crm resource check if not running.

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
    uid = pwd.getpwnam(owner).pw_uid
163
163
    gid = grp.getgrnam(group).gr_gid
164
164
    realpath = os.path.abspath(path)
165
 
    if os.path.exists(realpath):
166
 
        if force and not os.path.isdir(realpath):
 
165
    path_exists = os.path.exists(realpath)
 
166
    if path_exists and force:
 
167
        if not os.path.isdir(realpath):
167
168
            log("Removing non-directory file {} prior to mkdir()".format(path))
168
169
            os.unlink(realpath)
169
 
    else:
 
170
            os.makedirs(realpath, perms)
 
171
        os.chown(realpath, uid, gid)
 
172
    elif not path_exists:
170
173
        os.makedirs(realpath, perms)
171
 
    os.chown(realpath, uid, gid)
 
174
        os.chown(realpath, uid, gid)
172
175
 
173
176
 
174
177
def write_file(path, content, owner='root', group='root', perms=0o444):