'Initialize volume to be specified filesystem type.'

def _mkfs(self, volume, filesystem, label=None):

    if (filesystem == 'swap'):
        cmd = ['mkswap']
    else:
        cmd = ['mkfs', '-t', filesystem]
    if (filesystem in ('ext3', 'ext4')):
        cmd.append('-F')
    if label:
        if (filesystem in ('msdos', 'vfat')):
            label_opt = '-n'
        else:
            label_opt = '-L'
        cmd.extend([label_opt, label])
    path = self.local_path(volume)
    cmd.append(path)
    try:
        self._execute(run_as_root=True, *cmd)
    except processutils.ProcessExecutionError as exc:
        exception_message = (_('mkfs    failed    on    volume    %(vol)s,    error    message    was:    %(err)s.') % {'vol': volume['name'], 'err': exc.stderr})
        LOG.error(exception_message)
        raise exception.VolumeBackendAPIException(data=exception_message)
