make vsm-agent style-agnostic wrt ceph.conf

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

make vsm-agent style-agnostic wrt ceph.conf

jcalcote
Hi Yaguang,

Here's a patch that makes vsm-agent not care whether you use ceph.conf key names with spaces or underscores:

diff -u agent/cephconfigparser.py.orig agent/cephconfigparser.py
--- agent/cephconfigparser.py.orig   2016-01-04 13:34:22.361455125 -0700
+++ agent/cephconfigparser.py   2016-01-04 13:33:23.045219951 -0700
@@ -229,8 +229,11 @@
         parser = Parser()
         parser.read(FLAGS.ceph_conf)
         fs_type = parser.get('osd', 'osd mkfs type')
+        if not fs_type:
+            fs_type = parser.get('osd', 'osd_mkfs_type')
         mount_attr = parser.get('osd', 'osd mount options %s' % fs_type)
-        file_system = parser.get('osd', 'osd mkfs type')
+        if not mount_attr:
+            mount_attr = parser.get('osd', 'osd_mount_options_%s' % fs_type)

         for sec in parser.sections():
             if sec.find('osd.') != -1:
@@ -240,7 +243,7 @@
                 mount_host = parser.get(sec, 'host')
                 if FLAGS.host == mount_host:
                     line = mount_disk + ' ' + mount_path
-                    line = line + ' ' + file_system
+                    line = line + ' ' + fs_type
                     line = line + ' ' + mount_attr + ' 0 0'
                     line = line + ' ' + '## forvsmosd'
                     utils.write_file_as_root('/etc/fstab', line)

This would not be the correct approach if there were dozens of places in vsm source, but this is the only affected file and there are only two keys it cares about.

Note I also removed a redundant cfg get (it was reading the same key twice).

John