From: Alfredo Deza Date: Fri, 6 Jun 2014 14:42:17 +0000 (-0400) Subject: add a remote helper function to set priorities in ceph.repo X-Git-Tag: v1.5.4~3^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3f2e481e03a635989dd1bc035c1f59384b5d18f7;p=ceph-deploy.git add a remote helper function to set priorities in ceph.repo Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index e3f716a..b11f7c6 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -1,3 +1,4 @@ +import ConfigParser import errno import socket import os @@ -56,6 +57,34 @@ def write_yum_repo(content, filename='ceph.repo'): write_file(repo_path, content) +def set_repo_priority(sections, path='/etc/yum.repos.d/ceph.repo', priority='1'): + Config = ConfigParser.ConfigParser() + Config.read(path) + Config.sections() + for section in sections: + Config.set(section, 'priority', priority) + + with open(path, 'wb') as fout: + Config.write(fout) + + # And now, because ConfigParser is super duper, we need to remove the + # assignments so this looks like it was before + def remove_whitespace_from_assignments(): + separator = "=" + lines = file(path).readlines() + fp = open(path, "w") + for line in lines: + line = line.strip() + if not line.startswith("#") and separator in line: + assignment = line.split(separator, 1) + assignment = map(str.strip, assignment) + fp.write("%s%s%s\n" % (assignment[0], separator, assignment[1])) + else: + fp.write(line + "\n") + + remove_whitespace_from_assignments() + + def write_conf(cluster, conf, overwrite): """ write cluster configuration to /etc/ceph/{cluster}.conf """ path = '/etc/ceph/{cluster}.conf'.format(cluster=cluster)