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


Python vdisklist.VDiskList类代码示例

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


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

示例1: resize_from_voldrv

    def resize_from_voldrv(volumename, volumesize, volumepath, storagedriver_id):
        """
        Resize a disk
        Triggered by volumedriver messages on the queue

        @param volumepath: path on hypervisor to the volume
        @param volumename: volume id of the disk
        @param volumesize: size of the volume
        """
        pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id)
        storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
        hypervisor = Factory.get(pmachine)
        volumepath = hypervisor.clean_backing_disk_filename(volumepath)
        mutex = VolatileMutex('{}_{}'.format(volumename, volumepath))
        try:
            mutex.acquire(wait=30)
            disk = VDiskList.get_vdisk_by_volume_id(volumename)
            if disk is None:
                disk = VDiskList.get_by_devicename_and_vpool(volumepath, storagedriver.vpool)
                if disk is None:
                    disk = VDisk()
        finally:
            mutex.release()
        disk.devicename = volumepath
        disk.volume_id = volumename
        disk.size = volumesize
        disk.vpool = storagedriver.vpool
        disk.save()
        VDiskController.sync_with_mgmtcenter(disk, pmachine, storagedriver)
        MDSServiceController.ensure_safety(disk)
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:30,代码来源:vdisk.py

示例2: devicename_exists

    def devicename_exists(self, vpool, name=None, names=None):
        """
        Checks whether a given name can be created on the vpool
        :param vpool: vPool object
        :type vpool: VPool
        :param name: Candidate name
        :type name: str
        :param names: Candidate names
        :type names: list
        :return: Whether the devicename exists
        :rtype: bool
        """
        error_message = None
        if not (name is None) ^ (names is None):
            error_message = 'Either the name (string) or the names (list of strings) parameter must be passed'
        if name is not None and not isinstance(name, basestring):
            error_message = 'The name parameter must be a string'
        if names is not None and not isinstance(names, list):
            error_message = 'The names parameter must be a list of strings'
        if error_message is not None:
            raise HttpNotAcceptableException(error_description=error_message,
                                             error='impossible_request')

        if name is not None:
            devicename = VDiskController.clean_devicename(name)
            return VDiskList.get_by_devicename_and_vpool(devicename, vpool) is not None
        for name in names:
            devicename = VDiskController.clean_devicename(name)
            if VDiskList.get_by_devicename_and_vpool(devicename, vpool) is not None:
                return True
        return False
开发者ID:grimpy,项目名称:openvstorage,代码行数:31,代码来源:vpools.py

示例3: test_event_resize_from_volumedriver

    def test_event_resize_from_volumedriver(self):
        """
        Test resize from volumedriver event
            - Create a vDisk using the resize event
            - Resize the created vDisk using the same resize event
        """
        structure = Helper.build_service_structure(
            {'vpools': [1],
             'storagerouters': [1],
             'storagedrivers': [(1, 1, 1)],  # (<id>, <vpool_id>, <storagerouter_id>)
             'mds_services': [(1, 1)]}  # (<id>, <storagedriver_id>)
        )
        vpools = structure['vpools']
        storagedrivers = structure['storagedrivers']
        mds_service = structure['mds_services'][1]

        # Create volume using resize from voldrv
        device_name = '/vdisk.raw'
        srclient = StorageRouterClient(vpools[1].guid, None)
        mds_backend_config = Helper._generate_mdsmetadatabackendconfig([mds_service])
        volume_id = srclient.create_volume(device_name, mds_backend_config, 1024 ** 4, str(storagedrivers[1].storagedriver_id))
        VDiskController.resize_from_voldrv(volume_id=volume_id,
                                           volume_size=1024 ** 4,
                                           volume_path=device_name,
                                           storagedriver_id=storagedrivers[1].storagedriver_id)
        vdisks = VDiskList.get_vdisks()
        self.assertTrue(expr=len(vdisks) == 1,
                        msg='Expected to find 1 vDisk in model')
        self.assertEqual(first=vdisks[0].name,
                         second='vdisk',
                         msg='Volume name should be vdisk')
        self.assertEqual(first=vdisks[0].volume_id,
                         second=volume_id,
                         msg='Volume ID should be {0}'.format(volume_id))
        self.assertEqual(first=vdisks[0].devicename,
                         second=device_name,
                         msg='Device name should be {0}'.format(device_name))
        self.assertEqual(first=vdisks[0].size,
                         second=1024 ** 4,
                         msg='Size should be 1 TiB')

        # Resize volume using resize from voldrv
        VDiskController.resize_from_voldrv(volume_id=volume_id,
                                           volume_size=2 * 1024 ** 4,
                                           volume_path=device_name,
                                           storagedriver_id=storagedrivers[1].storagedriver_id)
        vdisks = VDiskList.get_vdisks()
        self.assertTrue(expr=len(vdisks) == 1,
                        msg='Expected to find 1 vDisk in model')
        self.assertEqual(first=vdisks[0].name,
                         second='vdisk',
                         msg='Volume name should be vdisk')
        self.assertEqual(first=vdisks[0].size,
                         second=2 * 1024 ** 4,
                         msg='Size should be 2 TiB')
开发者ID:grimpy,项目名称:openvstorage,代码行数:55,代码来源:test_vdisk.py

示例4: test_clone_from_template_happypath

    def test_clone_from_template_happypath(self):
        """
        Test clone from template - happy path
        """
        StorageDriverModule.use_good_client()
        vdisk_1_1, pmachine = self._prepare()

        VDiskController.create_from_template(vdisk_1_1.guid, 'vmachine_2', 'vdisk_1_1-clone', pmachine.guid)

        vdisks = VDiskList.get_vdisk_by_name('vdisk_1_1')
        self.assertEqual(len(vdisks), 1, 'Vdisk not modeled')
        clones = VDiskList.get_vdisk_by_name('vdisk_1_1-clone')
        self.assertEqual(len(clones), 1, 'Clone not modeled')
开发者ID:dawnpower,项目名称:framework,代码行数:13,代码来源:test_vdisk_operations.py

示例5: list

 def list(self, vpoolguid=None, storagerouterguid=None, query=None):
     """
     Overview of all vDisks
     :param vpoolguid: Guid of the vPool to retrieve its disks
     :type vpoolguid: str
     :param storagerouterguid: Guid of the StorageRouter to retrieve its disks
     :type storagerouterguid: str
     :param query: A query to be executed if required
     :type query: DataQuery
     """
     if vpoolguid is not None:
         vpool = VPool(vpoolguid)
         vdisks = vpool.vdisks
     elif storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         vdisks = DataList(
             VDisk,
             {
                 "type": DataList.where_operator.AND,
                 "items": [("guid", DataList.operator.IN, storagerouter.vdisks_guids)],
             },
         )
     else:
         vdisks = VDiskList.get_vdisks()
     if query is not None:
         query_vdisk_guids = DataList(VDisk, query).guids
         vdisks = [vdisk for vdisk in vdisks if vdisk.guid in query_vdisk_guids]
     return vdisks
开发者ID:grimpy,项目名称:openvstorage,代码行数:28,代码来源:vdisks.py

示例6: _find_ovs_model_disk_by_location

 def _find_ovs_model_disk_by_location(self, location, hostname, retry=3,
                                      timeout=3):
     """Find OVS disk object based on location and hostname
     :return VDisk: OVS DAL model object
     """
     hostname = self._get_real_hostname(hostname)
     LOG.debug('[_FIND OVS DISK] Location %s, hostname %s'
               % (location, hostname))
     attempt = 0
     while attempt <= retry:
         for vd in VDiskList.get_vdisks():
             if vd.vpool:
                 for vsr in vd.vpool.storagedrivers:
                     if vsr.storagerouter.name == hostname:
                         _location = "{0}/{1}".format(vsr.mountpoint,
                                                      vd.devicename)
                         if _location == location:
                             LOG.info('Location %s Disk found %s'
                                      % (location, vd.guid))
                             disk = VDisk(vd.guid)
                             return disk
         msg = ' NO RESULT Attempt %s timeout %s max attempts %s'
         LOG.debug(msg % (attempt, timeout, retry))
         if timeout:
             time.sleep(timeout)
         attempt += 1
     raise RuntimeError('No disk found for location %s' % location)
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:27,代码来源:openvstorage.py

示例7: delete_from_voldrv

 def delete_from_voldrv(volumename, storagedriver_id):
     """
     Delete a disk
     Triggered by volumedriver messages on the queue
     @param volumename: volume id of the disk
     """
     _ = storagedriver_id  # For logging purposes
     disk = VDiskList.get_vdisk_by_volume_id(volumename)
     if disk is not None:
         mutex = VolatileMutex('{}_{}'.format(volumename, disk.devicename))
         try:
             mutex.acquire(wait=20)
             pmachine = None
             try:
                 pmachine = PMachineList.get_by_storagedriver_id(disk.storagedriver_id)
             except RuntimeError as ex:
                 if 'could not be found' not in str(ex):
                     raise
                 # else: pmachine can't be loaded, because the volumedriver doesn't know about it anymore
             if pmachine is not None:
                 limit = 5
                 hypervisor = Factory.get(pmachine)
                 exists = hypervisor.file_exists(disk.vpool, disk.devicename)
                 while limit > 0 and exists is True:
                     time.sleep(1)
                     exists = hypervisor.file_exists(disk.vpool, disk.devicename)
                     limit -= 1
                 if exists is True:
                     logger.info('Disk {0} still exists, ignoring delete'.format(disk.devicename))
                     return
             logger.info('Delete disk {}'.format(disk.name))
             disk.delete()
         finally:
             mutex.release()
开发者ID:mflu,项目名称:openvstorage_centos,代码行数:34,代码来源:vdisk.py

示例8: create_new

    def create_new(diskname, size, storagedriver_guid):
        """
        Create a new vdisk/volume using filesystem calls
        :param diskname: name of the disk
        :param size: size of the disk (GB)
        :param storagedriver_guid: guid of the Storagedriver
        :return: guid of the new disk
        """
        logger.info('Creating new empty disk {0} of {1} GB'.format(diskname, size))
        storagedriver = StorageDriver(storagedriver_guid)
        vp_mountpoint = storagedriver.mountpoint
        hypervisor = Factory.get(storagedriver.storagerouter.pmachine)
        disk_path = hypervisor.clean_backing_disk_filename(hypervisor.get_disk_path(None, diskname))
        location = os.path.join(vp_mountpoint, disk_path)
        VDiskController.create_volume(location, size)

        backoff = 1
        timeout = 30  # seconds
        start = time.time()
        while time.time() < start + timeout:
            vdisk = VDiskList.get_by_devicename_and_vpool(disk_path, storagedriver.vpool)
            if vdisk is None:
                logger.debug('Waiting for disk to be picked up by voldrv')
                time.sleep(backoff)
                backoff += 1
            else:
                return vdisk.guid
        raise RuntimeError('Disk {0} was not created in {1} seconds.'.format(diskname, timeout))
开发者ID:jamie-liu,项目名称:openvstorage,代码行数:28,代码来源:vdisk.py

示例9: get_vdisk_by_name

 def get_vdisk_by_name(name):
     """
     Retrieve the DAL vDisk object based on its name
     :param name: Name of the virtual disk
     :return: vDisk DAL object
     """
     return VDiskList.get_vdisk_by_name(vdiskname=name)
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:7,代码来源:general_vdisk.py

示例10: delete_volume

    def delete_volume(vdisk, vpool, loop_device=None, root_client=None, wait=True):
        """
        Delete a volume
        :param vdisk: Virtual disk to delete
        :param vpool: vPool which hosts the Virtual Disk
        :param loop_device: Loop device where volume is mounted on
        :param root_client: SSHClient object
        :param wait: Wait for the volume to be deleted from model
        :return: None
        """
        location = GeneralVDisk.get_filesystem_location(vpool=vpool,
                                                        vdisk_name=vdisk.name)
        if root_client is None:
            root_client = SSHClient('127.0.0.1', username='root')

        if loop_device is not None:
            GeneralVDisk.disconnect_volume(loop_device, root_client)
        root_client.file_delete(location)

        if wait is True:
            counter = 0
            timeout = 60
            volume_name = '/' + os.path.basename(location)
            while True and counter < timeout:
                time.sleep(1)
                vdisks = VDiskList.get_by_devicename_and_vpool(volume_name, vpool)
                if vdisks is None:
                    break
                counter += 1
            if counter == timeout:
                raise RuntimeError('Disk {0} was not deleted from model after {1} seconds'.format(volume_name, timeout))
开发者ID:openvstorage,项目名称:integrationtests,代码行数:31,代码来源:general_vdisk.py

示例11: update_vdisk_name

    def update_vdisk_name(volume_id, old_name, new_name):
        """
        Update a vDisk name using Management Center: set new name
        """
        vdisk = None
        for mgmt_center in MgmtCenterList.get_mgmtcenters():
            mgmt = Factory.get_mgmtcenter(mgmt_center = mgmt_center)
            try:
                disk_info = mgmt.get_vdisk_device_info(volume_id)
                device_path = disk_info['device_path']
                vpool_name = disk_info['vpool_name']
                vp = VPoolList.get_vpool_by_name(vpool_name)
                file_name = os.path.basename(device_path)
                vdisk = VDiskList.get_by_devicename_and_vpool(file_name, vp)
                if vdisk:
                    break
            except Exception as ex:
                logger.info('Trying to get mgmt center failed for disk {0} with volume_id {1}. {2}'.format(old_name, volume_id, ex))
        if not vdisk:
            logger.error('No vdisk found for name {0}'.format(old_name))
            return

        vpool = vdisk.vpool
        mutex = VolatileMutex('{}_{}'.format(old_name, vpool.guid if vpool is not None else 'none'))
        try:
            mutex.acquire(wait=5)
            vdisk.name = new_name
            vdisk.save()
        finally:
            mutex.release()
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:30,代码来源:vdisk.py

示例12: volumedriver_error

 def volumedriver_error(code, volumename):
     """
     Handles error messages/events from the volumedriver
     """
     if code == VolumeDriverEvents.MDSFailover:
         disk = VDiskList.get_vdisk_by_volume_id(volumename)
         if disk is not None:
             MDSServiceController.ensure_safety(disk)
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:8,代码来源:storagedriver.py

示例13: volumedriver_error

 def volumedriver_error(code, volumename, storagedriver_id):
     """
     Handles error messages/events from the volumedriver
     """
     _ = storagedriver_id  # Required for the @log decorator
     if code == VolumeDriverEvents.MDSFailover:
         disk = VDiskList.get_vdisk_by_volume_id(volumename)
         if disk is not None:
             MDSServiceController.ensure_safety(disk)
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:9,代码来源:storagedriver.py

示例14: _snapshot_has_children

 def _snapshot_has_children(self, snapshotid):
     """Find if snapshot has children, in OVS Model
     :return True/False
     """
     LOG.debug('[_FIND CHILDREN OF SNAPSHOT] Snapshotid %s' % snapshotid)
     for vdisk in VDiskList.get_vdisks():
         if vdisk.parentsnapshot == snapshotid:
             return True
     return False
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:9,代码来源:openvstorage.py

示例15: _vdisks_guids

 def _vdisks_guids(self):
     """
     Gets the vDisk guids served by this StorageDriver.
     """
     from ovs.dal.lists.vdisklist import VDiskList
     volume_ids = []
     for entry in self.vpool.objectregistry_client.get_all_registrations():
         if entry.node_id() == self.storagedriver_id:
             volume_ids.append(entry.object_id())
     return VDiskList.get_in_volume_ids(volume_ids).guids
开发者ID:grimpy,项目名称:openvstorage,代码行数:10,代码来源:storagedriver.py


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