~negronjl/charms/precise/mysql/mysql-file-permissions

« back to all changes in this revision

Viewing changes to hooks/lib/ceph_utils.py

  • Committer: Adam Gandelman
  • Date: 2013-08-09 11:08:20 UTC
  • mfrom: (103.1.1 wait-for-rbd-device)
  • Revision ID: adamg@ubuntu.com-20130809110820-rv9dvdoosmokdwye
[ahasenack] Wait for the rbd device to be available before attempting to format it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
import subprocess
13
13
import os
14
14
import shutil
 
15
import time
15
16
import lib.utils as utils
16
17
 
17
18
KEYRING = '/etc/ceph/ceph.client.%s.keyring'
153
154
 
154
155
 
155
156
def make_filesystem(blk_device, fstype='ext4'):
156
 
    utils.juju_log('INFO',
157
 
                   'ceph: Formatting block device %s as filesystem %s.' %\
158
 
                   (blk_device, fstype))
159
 
    cmd = ['mkfs', '-t', fstype, blk_device]
160
 
    execute(cmd)
 
157
    count = 0
 
158
    e_noent = os.errno.ENOENT
 
159
    while not os.path.exists(blk_device):
 
160
        if count >= 10:
 
161
            utils.juju_log('ERROR',
 
162
                'ceph: gave up waiting on block device %s' % blk_device)
 
163
            raise IOError(e_noent, os.strerror(e_noent), blk_device)
 
164
        utils.juju_log('INFO',
 
165
            'ceph: waiting for block device %s to appear' % blk_device)
 
166
        count += 1
 
167
        time.sleep(1)
 
168
    else:
 
169
        utils.juju_log('INFO',
 
170
            'ceph: Formatting block device %s as filesystem %s.' %
 
171
            (blk_device, fstype))
 
172
        execute(['mkfs', '-t', fstype, blk_device])
161
173
 
162
174
 
163
175
def place_data_on_ceph(service, blk_device, data_src_dst, fstype='ext4'):