~ubuntu-branches/debian/stretch/fuel-agent/stretch

« back to all changes in this revision

Viewing changes to fuel_agent/utils/fs.py

  • Committer: Package Import Robot
  • Author(s): Thomas Goirand
  • Date: 2016-03-16 17:12:17 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20160316171217-p5b360dfuxm5yidy
Tags: 9.0~0+2016.03.09.git.b1ba4b7747+dfsg1-1
* New upstream release based on commit b1ba4b7747.
* Uploading to unstable.
* Lots of tweaks to make Debian provisionning works.
* Standards-Version: 3.9.7 (no change).

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from fuel_agent.openstack.common import log as logging
17
17
from fuel_agent.utils import utils
18
18
 
 
19
import six
 
20
 
19
21
LOG = logging.getLogger(__name__)
 
22
MAX_MKFS_TRIES = 5
20
23
 
21
24
 
22
25
def format_fs_label(label):
42
45
        # NOTE(agordeev): force xfs creation.
43
46
        # Othwerwise, it will fail to proceed if filesystem exists.
44
47
        fs_options += ' -f '
 
48
    if fs_type == 'swap':
 
49
        fs_options += ' -f '
45
50
    cmd_line.append(cmd_name)
46
51
    for opt in (fs_options, format_fs_label(fs_label)):
47
52
        cmd_line.extend([s for s in opt.split(' ') if s])
48
53
    cmd_line.append(dev)
49
 
    utils.execute(*cmd_line)
 
54
 
 
55
    # NOTE(dbilunov): make sure the newly-created fs can
 
56
    # be observed by blkid. Currently known problem is
 
57
    # that generated UUID could possibly collide with
 
58
    # minix filesystem magic (0x8f13)
 
59
    mkfs_ok = False
 
60
    for _ in six.moves.range(MAX_MKFS_TRIES):
 
61
        utils.execute(*cmd_line)
 
62
        try:
 
63
            utils.execute('blkid', '-c', '/dev/null', '-o', 'value',
 
64
                          '-s', 'UUID', dev)
 
65
        except errors.ProcessExecutionError:
 
66
            LOG.warning('blkid has failed on %s, retrying...', dev)
 
67
        else:
 
68
            mkfs_ok = True
 
69
            break
 
70
    if not mkfs_ok:
 
71
        raise errors.FsUtilsError('Cannot get UUID of a newly-created ' +
 
72
                                  '{0} on {1}'.format(fs_type, dev))
50
73
 
51
74
 
52
75
def extend_fs(fs_type, fs_dev):