Merge lp:~james-page/charm-helpers/fixup-ceph-pool-creation into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 78
Proposed branch: lp:~james-page/charm-helpers/fixup-ceph-pool-creation
Merge into: lp:charm-helpers
Diff against target: 85 lines (+15/-14)
2 files modified
charmhelpers/contrib/storage/linux/ceph.py (+7/-6)
tests/contrib/storage/test_linux_ceph.py (+8/-8)
To merge this branch: bzr merge lp:~james-page/charm-helpers/fixup-ceph-pool-creation
Reviewer Review Type Date Requested Status
Charm Helper Maintainers Pending
Review via email: mp+187260@code.launchpad.net

Description of the change

Misc fixes for ceph pool creation functions.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/storage/linux/ceph.py'
--- charmhelpers/contrib/storage/linux/ceph.py 2013-08-23 14:07:52 +0000
+++ charmhelpers/contrib/storage/linux/ceph.py 2013-09-24 14:48:01 +0000
@@ -97,12 +97,13 @@
97 return name in out97 return name in out
9898
9999
100def get_osds():100def get_osds(service):
101 '''101 '''
102 Return a list of all Ceph Object Storage Daemons102 Return a list of all Ceph Object Storage Daemons
103 currently in the cluster103 currently in the cluster
104 '''104 '''
105 return json.loads(check_output(['ceph', 'osd', 'ls', '--format=json']))105 return json.loads(check_output(['ceph', '--id', service,
106 'osd', 'ls', '--format=json']))
106107
107108
108def create_pool(service, name, replicas=2):109def create_pool(service, name, replicas=2):
@@ -113,17 +114,17 @@
113 return114 return
114 # Calculate the number of placement groups based115 # Calculate the number of placement groups based
115 # on upstream recommended best practices.116 # on upstream recommended best practices.
116 pgnum = (len(get_osds()) * 100 / replicas)117 pgnum = (len(get_osds(service)) * 100 / replicas)
117 cmd = [118 cmd = [
118 'ceph', '--id', service,119 'ceph', '--id', service,
119 'osd', 'pool', 'create',120 'osd', 'pool', 'create',
120 name, pgnum121 name, str(pgnum)
121 ]122 ]
122 check_call(cmd)123 check_call(cmd)
123 cmd = [124 cmd = [
124 'ceph', '--id', service,125 'ceph', '--id', service,
125 'osd', 'set', name,126 'osd', 'pool', 'set', name,
126 'size', replicas127 'size', str(replicas)
127 ]128 ]
128 check_call(cmd)129 check_call(cmd)
129130
130131
=== modified file 'tests/contrib/storage/test_linux_ceph.py'
--- tests/contrib/storage/test_linux_ceph.py 2013-09-23 10:50:53 +0000
+++ tests/contrib/storage/test_linux_ceph.py 2013-09-24 14:48:01 +0000
@@ -92,11 +92,11 @@
9292
93 def test_get_osds(self):93 def test_get_osds(self):
94 self.check_output.return_value = json.dumps([1, 2, 3])94 self.check_output.return_value = json.dumps([1, 2, 3])
95 self.assertEquals(ceph_utils.get_osds(), [1, 2, 3])95 self.assertEquals(ceph_utils.get_osds('test'), [1, 2, 3])
9696
97 def test_get_osds_none(self):97 def test_get_osds_none(self):
98 self.check_output.return_value = json.dumps(None)98 self.check_output.return_value = json.dumps(None)
99 self.assertEquals(ceph_utils.get_osds(), None)99 self.assertEquals(ceph_utils.get_osds('test'), None)
100100
101 @patch.object(ceph_utils, 'get_osds')101 @patch.object(ceph_utils, 'get_osds')
102 @patch.object(ceph_utils, 'pool_exists')102 @patch.object(ceph_utils, 'pool_exists')
@@ -107,9 +107,9 @@
107 ceph_utils.create_pool(service='cinder', name='foo')107 ceph_utils.create_pool(service='cinder', name='foo')
108 self.check_call.assert_has_calls([108 self.check_call.assert_has_calls([
109 call(['ceph', '--id', 'cinder', 'osd', 'pool',109 call(['ceph', '--id', 'cinder', 'osd', 'pool',
110 'create', 'foo', 150]),110 'create', 'foo', '150']),
111 call(['ceph', '--id', 'cinder', 'osd', 'set',111 call(['ceph', '--id', 'cinder', 'osd', 'pool', 'set',
112 'foo', 'size', 2])112 'foo', 'size', '2'])
113 ])113 ])
114114
115 @patch.object(ceph_utils, 'get_osds')115 @patch.object(ceph_utils, 'get_osds')
@@ -121,9 +121,9 @@
121 ceph_utils.create_pool(service='cinder', name='foo', replicas=3)121 ceph_utils.create_pool(service='cinder', name='foo', replicas=3)
122 self.check_call.assert_has_calls([122 self.check_call.assert_has_calls([
123 call(['ceph', '--id', 'cinder', 'osd', 'pool',123 call(['ceph', '--id', 'cinder', 'osd', 'pool',
124 'create', 'foo', 100]),124 'create', 'foo', '100']),
125 call(['ceph', '--id', 'cinder', 'osd', 'set',125 call(['ceph', '--id', 'cinder', 'osd', 'pool', 'set',
126 'foo', 'size', 3])126 'foo', 'size', '3'])
127 ])127 ])
128128
129 def test_create_pool_already_exists(self):129 def test_create_pool_already_exists(self):

Subscribers

People subscribed via source and target branches