'Map partitions of the device to the file system namespace.'

def map_dev(self):

    assert os.path.exists(self.device)
    LOG.debug('Map    dev    %s', self.device)
    automapped_path = ('/dev/%sp%s' % (os.path.basename(self.device), self.partition))
    if (self.partition == (-1)):
        self.error = (_('partition    search    unsupported    with    %s') % self.mode)
    elif (self.partition and (not os.path.exists(automapped_path))):
        map_path = ('/dev/mapper/%sp%s' % (os.path.basename(self.device), self.partition))
        assert (not os.path.exists(map_path))
        (_out, err) = utils.trycmd('kpartx', '-a', self.device, run_as_root=True, discard_warnings=True)
        @loopingcall.RetryDecorator(max_retry_count=(MAX_FILE_CHECKS - 1), max_sleep_time=FILE_CHECK_INTERVAL, exceptions=IOError)
        def recheck_path(map_path):
            if (not os.path.exists(map_path)):
                raise IOError()
        try:
            recheck_path(map_path)
            self.mapped_device = map_path
            self.mapped = True
        except IOError:
            if (not err):
                err = (_('partition    %s    not    found') % self.partition)
            self.error = (_('Failed    to    map    partitions:    %s') % err)
    elif (self.partition and os.path.exists(automapped_path)):
        self.mapped_device = automapped_path
        self.mapped = True
        self.automapped = True
    else:
        self.mapped_device = self.device
        self.mapped = True
    return self.mapped
