当前位置: 首页>>代码示例>>Python>>正文


Python osi.is_share_mounted函数代码示例

本文整理汇总了Python中system.osi.is_share_mounted函数的典型用法代码示例。如果您正苦于以下问题:Python is_share_mounted函数的具体用法?Python is_share_mounted怎么用?Python is_share_mounted使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_share_mounted函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_snap

def remove_snap(pool_name, pool_device, share_name, snap_name):
    full_name = ('%s/%s' % (share_name, snap_name))
    if (is_share_mounted(full_name)):
        umount_root('%s%s' % (DEFAULT_MNT_DIR, full_name))
    root_pool_mnt = mount_root(pool_name, pool_device)
    subvol_mnt_pt = ('%s/%s_%s' % (root_pool_mnt, share_name, snap_name))
    return run_command([BTRFS, 'subvolume', 'delete', subvol_mnt_pt])
开发者ID:neuroradiology,项目名称:rockstor-core,代码行数:7,代码来源:btrfs.py

示例2: remove_share

def remove_share(pool, share_name, pqgroup, force=False):
    """
    umount share if its mounted.
    mount root pool
    btrfs subvolume delete root_mnt/vol_name
    umount root pool
    """
    if (is_share_mounted(share_name)):
        mnt_pt = ('%s%s' % (DEFAULT_MNT_DIR, share_name))
        umount_root(mnt_pt)
    root_pool_mnt = mount_root(pool)
    subvol_mnt_pt = root_pool_mnt + '/' + share_name
    if (not is_subvol(subvol_mnt_pt)):
        return
    if (force):
        o, e, rc = run_command([BTRFS, 'subvolume', 'list', '-o', subvol_mnt_pt])
        for l in o:
            if (re.match('ID ', l) is not None):
                subvol = root_pool_mnt + '/' + l.split()[-1]
                run_command([BTRFS, 'subvolume', 'delete', subvol], log=True)
    qgroup = ('0/%s' % share_id(pool, share_name))
    delete_cmd = [BTRFS, 'subvolume', 'delete', subvol_mnt_pt]
    run_command(delete_cmd, log=True)
    qgroup_destroy(qgroup, root_pool_mnt)
    return qgroup_destroy(pqgroup, root_pool_mnt)
开发者ID:sfranzen,项目名称:rockstor-core,代码行数:25,代码来源:btrfs.py

示例3: post

    def post(self, request, command):
        if (command == 'bootstrap'):

            self._refresh_pool_state()
            for p in Pool.objects.all():
                import_shares(p, request)

            for share in Share.objects.all():
                try:
                    if (share.pqgroup == settings.MODEL_DEFS['pqgroup']):
                        share.pqgroup = qgroup_create(share.pool)
                        share.save()
                    if (not is_share_mounted(share.name)):
                        mnt_pt = ('%s%s' % (settings.MNT_PT, share.name))
                        mount_share(share, mnt_pt)
                except Exception, e:
                    e_msg = ('Exception while mounting a share(%s) during '
                             'bootstrap: %s' % (share.name, e.__str__()))
                    logger.error(e_msg)
                    logger.exception(e)

                try:
                    import_snapshots(share)
                except Exception, e:
                    e_msg = ('Exception while importing Snapshots of '
                             'Share(%s): %s' % (share.name, e.__str__()))
                    logger.error(e_msg)
                    logger.exception(e)
开发者ID:Ajunboys,项目名称:rockstor-core,代码行数:28,代码来源:command.py

示例4: mount_root

def mount_root(pool_name, device):
    root_pool_mnt = DEFAULT_MNT_DIR + pool_name
    if (is_share_mounted(pool_name)):
        return root_pool_mnt
    create_tmp_dir(root_pool_mnt)
    mnt_cmd = [MOUNT, '-t', 'btrfs', device, root_pool_mnt]
    run_command(mnt_cmd)
    return root_pool_mnt
开发者ID:neuroradiology,项目名称:rockstor-core,代码行数:8,代码来源:btrfs.py

示例5: run

    def run(self):
        #0. mount destination share
        dest_mnt_pt = ('%s/%s' % (settings.MNT_PT, self.dest_share))
        msg = ('Destination share(%s) not mounted' % self.dest_share)
        with self._update_trail_and_quit(msg):
            if (not is_share_mounted(self.dest_share)):
                mount_share(self.dest_share, self.dest_pool, dest_mnt_pt)
            if (not is_share_mounted(self.dest_share)):
                raise Exception(msg)

        #1. mount source share
        msg = ('Failed to mount source(%s:%s)' % (self.source_ip,
                                                  self.source_path))
        with self._update_trail_and_quit(msg):
            mount_source(self.source_ip, self.source_path)

        #2. create a snapshot
        snap_name = ('snap-%d' % self.tid)
        msg = ('Failed to create snapshot(%s) for share(%s)' %
               (snap_name, self.dest_share))
        data = {'status': 'snapshot created',}
        with self._update_trail_and_quit(msg, data=data):
            create_snapshot(self.dest_share, snap_name, logger)

        #3. rsync
        src_mnt = ('/mnt/backup/%s_%s' % (self.source_ip, self.source_path))
        cmd = [RSYNC, '-az', src_mnt, dest_mnt_pt]
        msg = ('Unable to start sync')
        data = {'status': 'sync started',}
        with self._update_trail_and_quit(msg, data=data):
            rp = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
        while True:
            if (os.getppid() != self.ppid):
                msg = ('Backup plugin scheduler exited. Aborting...')
                with self._update_trail_and_quit(msg):
                    rp.terminate()

            if (rp.poll() is not None):
                msg = ('sync finished. But failed to update trail status')
                data = {'status': 'succeeded',}
                with self._update_trail_and_quit(msg, data):
                    logger.debug('sync finished')
                break
            time.sleep(1)
开发者ID:YukihitoHARA,项目名称:rockstor-core,代码行数:45,代码来源:worker.py

示例6: remove_snap_old

def remove_snap_old(pool, pool_device, share_name, snap_name):
    full_name = "%s/%s" % (share_name, snap_name)
    if is_share_mounted(full_name):
        umount_root("%s%s" % (DEFAULT_MNT_DIR, full_name))
    root_pool_mnt = mount_root(pool, pool_device)
    subvol_mnt_pt = "%s/%s_%s" % (root_pool_mnt, share_name, snap_name)
    if is_subvol(subvol_mnt_pt):
        return run_command([BTRFS, "subvolume", "delete", subvol_mnt_pt])
    return True
开发者ID:sujeetsr,项目名称:rockstor-core,代码行数:9,代码来源:btrfs.py

示例7: mount_root

def mount_root(pool):
    """
    Mounts a given pool at the default mount root (usually /mnt2/) using the
    pool.name as the final path entry. Ie pool.name = test-pool will be mounted
    at /mnt2/test-pool. Any mount options held in pool.mnt_options will be added
    to the mount command via the -o option as will a compress=pool.compression
    entry.
    N.B. Initially the mount target is defined by /dev/disk/by-label/pool.name,
    if this fails then an attempt to mount by each member of
    /dev/disk/by-id/pool.disk_set.all() but only if there are any members.
    If this second method also fails then an exception is raised, currently all
    but the last failed mount by device name is logged. If no disk members were
    reported by pool.disk_set.count() a separate Exception is raised.
    :param pool: pool object
    :return: either the relevant mount point or an Exception which either
    indicates 'no disks in pool' or 'Unknown Reason'
    """
    root_pool_mnt = DEFAULT_MNT_DIR + pool.name
    if (is_share_mounted(pool.name)):
        return root_pool_mnt
    # Creates a directory to act as the mount point.
    create_tmp_dir(root_pool_mnt)
    mnt_device = '/dev/disk/by-label/%s' % pool.name
    mnt_cmd = [MOUNT, mnt_device, root_pool_mnt, ]
    mnt_options = ''
    if (pool.mnt_options is not None):
        mnt_options = pool.mnt_options
    if (pool.compression is not None):
        if (re.search('compress', mnt_options) is None):
            mnt_options = ('%s,compress=%s' % (mnt_options, pool.compression))
    if (os.path.exists(mnt_device)):
        if (len(mnt_options) > 0):
            mnt_cmd.extend(['-o', mnt_options])
        run_command(mnt_cmd)
        return root_pool_mnt
    # If we cannot mount by-label, let's try mounting by device; one by one
    # until we get our first success.
    if (pool.disk_set.count() < 1):
        raise Exception('Cannot mount Pool(%s) as it has no disks in it.' % pool.name)
    last_device = pool.disk_set.last()
    for device in pool.disk_set.all():
        mnt_device = ('/dev/disk/by-id/%s' % device.name)
        if (os.path.exists(mnt_device)):
            mnt_cmd = [MOUNT, mnt_device, root_pool_mnt, ]
            if (len(mnt_options) > 0):
                mnt_cmd.extend(['-o', mnt_options])
            try:
                run_command(mnt_cmd)
                return root_pool_mnt
            except Exception, e:
                if (device.name == last_device.name):
                    # exhausted mounting using all devices in the pool
                    raise e
                logger.error('Error mounting: %s. Will try using another device.' % mnt_cmd)
                logger.exception(e)
开发者ID:sfranzen,项目名称:rockstor-core,代码行数:55,代码来源:btrfs.py

示例8: rollback_snap

def rollback_snap(snap_name, sname, subvol_name, pool_name, pool_device):
    """
    1. umount the share
    2. mount the snap as the share
    3. remove the share
    """
    mnt_pt = ('%s%s' % (DEFAULT_MNT_DIR, sname))
    if (is_share_mounted(sname)):
        umount_root(mnt_pt)
    mount_share(snap_name, pool_device, mnt_pt)
    remove_share(pool_name, pool_device, subvol_name)
开发者ID:neuroradiology,项目名称:rockstor-core,代码行数:11,代码来源:btrfs.py

示例9: post

    def post(self, request):
        with self._handle_exception(request):
            pool_name = request.data.get('pool', None)
            try:
                pool = Pool.objects.get(name=pool_name)
            except:
                e_msg = ('Pool(%s) does not exist.' % pool_name)
                handle_exception(Exception(e_msg), request)
            compression = self._validate_compression(request)
            size = self._validate_share_size(request, pool)
            sname = request.data.get('sname', None)
            if ((sname is None or
                 re.match('%s$' % settings.SHARE_REGEX, sname) is None)):
                e_msg = ('Share name must start with a alphanumeric(a-z0-9) '
                         'character and can be followed by any of the '
                         'following characters: letter(a-z), digits(0-9), '
                         'hyphen(-), underscore(_) or a period(.).')
                handle_exception(Exception(e_msg), request)

            if (Share.objects.filter(name=sname).exists()):
                e_msg = ('Share(%s) already exists. Choose a different name' % sname)
                handle_exception(Exception(e_msg), request)

            if (Pool.objects.filter(name=sname).exists()):
                e_msg = ('A Pool with this name(%s) exists. Share and Pool names '
                         'must be distinct. Choose a different name' % sname)
                handle_exception(Exception(e_msg), request)
            disk = Disk.objects.filter(pool=pool)[0]
            replica = False
            if ('replica' in request.data):
                replica = request.data['replica']
                if (type(replica) != bool):
                    e_msg = ('replica must be a boolean, not %s' %
                             type(replica))
                    handle_exception(Exception(e_msg), request)
            add_share(pool, disk.name, sname)
            qid = qgroup_id(pool, disk.name, sname)
            update_quota(pool, disk.name, qid, size * 1024)
            s = Share(pool=pool, qgroup=qgroup_id, name=sname, size=size,
                      subvol_name=sname, replica=replica,
                      compression_algo=compression)
            s.save()
            mnt_pt = '%s%s' % (settings.MNT_PT, sname)
            if (not is_share_mounted(sname)):
                disk = Disk.objects.filter(pool=pool)[0].name
                mount_share(s, disk, mnt_pt)
            if (compression != 'no'):
                set_property(mnt_pt, 'compression', compression)
            return Response(ShareSerializer(s).data)
开发者ID:drtyhbo,项目名称:rockstor-core,代码行数:49,代码来源:share.py

示例10: remove_share

def remove_share(pool_name, pool_device, share_name):
    """
    umount share if its mounted.
    mount root pool
    btrfs subvolume delete root_mnt/vol_name
    umount root pool
    """
    if (is_share_mounted(share_name)):
        mnt_pt = ('%s%s' % (DEFAULT_MNT_DIR, share_name))
        umount_root(mnt_pt)
    pool_device = '/dev/' + pool_device
    root_pool_mnt = mount_root(pool_name, pool_device)
    subvol_mnt_pt = root_pool_mnt + '/' + share_name
    delete_cmd = [BTRFS, 'subvolume', 'delete', subvol_mnt_pt]
    run_command(delete_cmd)
开发者ID:neuroradiology,项目名称:rockstor-core,代码行数:15,代码来源:btrfs.py

示例11: remove_share

def remove_share(pool, pool_device, share_name):
    """
    umount share if its mounted.
    mount root pool
    btrfs subvolume delete root_mnt/vol_name
    umount root pool
    """
    if is_share_mounted(share_name):
        mnt_pt = "%s%s" % (DEFAULT_MNT_DIR, share_name)
        umount_root(mnt_pt)
    pool_device = "/dev/" + pool_device
    root_pool_mnt = mount_root(pool, pool_device)
    subvol_mnt_pt = root_pool_mnt + "/" + share_name
    if not is_subvol(subvol_mnt_pt):
        return
    delete_cmd = [BTRFS, "subvolume", "delete", subvol_mnt_pt]
    run_command(delete_cmd)
开发者ID:sujeetsr,项目名称:rockstor-core,代码行数:17,代码来源:btrfs.py

示例12: mount_root

def mount_root(pool, device):
    root_pool_mnt = DEFAULT_MNT_DIR + pool.name
    if is_share_mounted(pool.name):
        return root_pool_mnt
    create_tmp_dir(root_pool_mnt)
    mnt_device = "/dev/disk/by-label/%s" % pool.name
    if not os.path.exists(mnt_device):
        mnt_device = device
    mnt_cmd = [MOUNT, mnt_device, root_pool_mnt]
    mnt_options = ""
    if pool.mnt_options is not None:
        mnt_options = pool.mnt_options
    if pool.compression is not None:
        if re.search("compress", mnt_options) is None:
            mnt_options = "%s,compress=%s" % (mnt_options, pool.compression)
    if len(mnt_options) > 0:
        mnt_cmd.extend(["-o", mnt_options])
    run_command(mnt_cmd)
    return root_pool_mnt
开发者ID:sujeetsr,项目名称:rockstor-core,代码行数:19,代码来源:btrfs.py

示例13: remove_share

def remove_share(pool, share_name, pqgroup):
    """
    umount share if its mounted.
    mount root pool
    btrfs subvolume delete root_mnt/vol_name
    umount root pool
    """
    if (is_share_mounted(share_name)):
        mnt_pt = ('%s%s' % (DEFAULT_MNT_DIR, share_name))
        umount_root(mnt_pt)
    root_pool_mnt = mount_root(pool)
    subvol_mnt_pt = root_pool_mnt + '/' + share_name
    if (not is_subvol(subvol_mnt_pt)):
        return
    qgroup = ('0/%s' % share_id(pool, share_name))
    delete_cmd = [BTRFS, 'subvolume', 'delete', subvol_mnt_pt]
    run_command(delete_cmd, log=True)
    qgroup_destroy(qgroup, root_pool_mnt)
    return qgroup_destroy(pqgroup, root_pool_mnt)
开发者ID:BillTheBest,项目名称:rockstor-core,代码行数:19,代码来源:btrfs.py

示例14: remove_share

def remove_share(pool, share_name, pqgroup):
    """
    umount share if its mounted.
    mount root pool
    btrfs subvolume delete root_mnt/vol_name
    umount root pool
    """
    if is_share_mounted(share_name):
        mnt_pt = "%s%s" % (DEFAULT_MNT_DIR, share_name)
        umount_root(mnt_pt)
    root_pool_mnt = mount_root(pool)
    subvol_mnt_pt = root_pool_mnt + "/" + share_name
    if not is_subvol(subvol_mnt_pt):
        return
    qgroup = "0/%s" % share_id(pool, share_name)
    delete_cmd = [BTRFS, "subvolume", "delete", subvol_mnt_pt]
    run_command(delete_cmd, log=True)
    qgroup_destroy(qgroup, root_pool_mnt)
    return qgroup_destroy(pqgroup, root_pool_mnt)
开发者ID:jhdulaney,项目名称:rockstor-core,代码行数:19,代码来源:btrfs.py

示例15: shares_usage

def shares_usage(pool_name, pool_device, share_map, snap_map):
    #don't mount the pool if at least one share in the map is mounted.
    usage_map = {}
    mnt_pt = None
    for s in share_map.keys():
        if (is_share_mounted(share_map[s])):
            mnt_pt = ('%s%s' % (DEFAULT_MNT_DIR, share_map[s]))
            break
    if (mnt_pt is None):
        mnt_pt = mount_root(pool_name, '/dev/' + pool_device)
    cmd = [BTRFS, 'qgroup', 'show', mnt_pt]
    out, err, rc = run_command(cmd)
    combined_map = dict(share_map, **snap_map)
    for line in out:
        fields = line.split()
        if (len(fields) > 0 and fields[0] in combined_map):
            r_usage = int(fields[-2]) / 1024 # referenced usage in KB
            e_usage = int(fields[-1]) / 1024 # exclusive usage in KB
            usage_map[combined_map[fields[0]]] = (r_usage, e_usage)
    return usage_map
开发者ID:neuroradiology,项目名称:rockstor-core,代码行数:20,代码来源:btrfs.py


注:本文中的system.osi.is_share_mounted函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。