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


Python StorageDriverList.get_by_storagedriver_id方法代码示例

本文整理汇总了Python中ovs.dal.lists.storagedriverlist.StorageDriverList.get_by_storagedriver_id方法的典型用法代码示例。如果您正苦于以下问题:Python StorageDriverList.get_by_storagedriver_id方法的具体用法?Python StorageDriverList.get_by_storagedriver_id怎么用?Python StorageDriverList.get_by_storagedriver_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ovs.dal.lists.storagedriverlist.StorageDriverList的用法示例。


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

示例1: sync_with_hypervisor

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def sync_with_hypervisor(vmachineguid, storagedriver_id=None):
        """
        Updates a given vmachine with data retrieved from a given pmachine
        :param vmachineguid: Guid of the virtual machine
        :param storagedriver_id: Storage Driver hosting the vmachine
        """
        try:
            vmachine = VMachine(vmachineguid)
        except Exception as ex:
            VMachineController._logger.info('Cannot get VMachine object: {0}'.format(str(ex)))
            raise

        vm_object = None
        if vmachine.pmachine.mgmtcenter and storagedriver_id is not None and vmachine.devicename is not None:
            try:
                mgmt_center = Factory.get_mgmtcenter(vmachine.pmachine)
                storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
                VMachineController._logger.info('Syncing vMachine (name {0}) with Management center {1}'.format(vmachine.name, vmachine.pmachine.mgmtcenter.name))
                vm_object = mgmt_center.get_vm_agnostic_object(devicename=vmachine.devicename,
                                                               ip=storagedriver.storage_ip,
                                                               mountpoint=storagedriver.mountpoint)
            except Exception as ex:
                VMachineController._logger.info('Error while fetching vMachine info from management center: {0}'.format(str(ex)))

        if vm_object is None and storagedriver_id is None and vmachine.hypervisor_id is not None and vmachine.pmachine is not None:
            try:
                # Only the vmachine was received, so base the sync on hypervisor id and pmachine
                hypervisor = Factory.get(vmachine.pmachine)
                VMachineController._logger.info('Syncing vMachine (name {0})'.format(vmachine.name))
                vm_object = hypervisor.get_vm_agnostic_object(vmid=vmachine.hypervisor_id)
            except Exception as ex:
                VMachineController._logger.info('Error while fetching vMachine info from hypervisor: {0}'.format(str(ex)))

        if vm_object is None and storagedriver_id is not None and vmachine.devicename is not None:
            try:
                # Storage Driver id was given, using the devicename instead (to allow hypervisor id updates
                # which can be caused by re-adding a vm to the inventory)
                pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id)
                storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
                hypervisor = Factory.get(pmachine)
                if not hypervisor.file_exists(storagedriver, hypervisor.clean_vmachine_filename(vmachine.devicename)):
                    return
                vmachine.pmachine = pmachine
                vmachine.save()

                VMachineController._logger.info('Syncing vMachine (device {0}, ip {1}, mountpoint {2})'.format(vmachine.devicename,
                                                                                                               storagedriver.storage_ip,
                                                                                                               storagedriver.mountpoint))
                vm_object = hypervisor.get_vm_object_by_devicename(devicename=vmachine.devicename,
                                                                   ip=storagedriver.storage_ip,
                                                                   mountpoint=storagedriver.mountpoint)
            except Exception as ex:
                VMachineController._logger.info('Error while fetching vMachine info from hypervisor using devicename: {0}'.format(str(ex)))

        if vm_object is None:
            message = 'Not enough information to sync vmachine'
            VMachineController._logger.info('Error: {0}'.format(message))
            raise RuntimeError(message)

        VMachineController.update_vmachine_config(vmachine, vm_object)
开发者ID:DarumasLegs,项目名称:framework,代码行数:62,代码来源:vmachine.py

示例2: update_status

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def update_status(storagedriver_id):
     """
     Sets Storage Driver offline in case hypervisor management Center
     reports the hypervisor pmachine related to this Storage Driver
     as unavailable.
     :param storagedriver_id: ID of the storagedriver to update its status
     """
     pmachine = PMachineList.get_by_storagedriver_id(storagedriver_id)
     storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
     storagerouter = storagedriver.storagerouter
     if pmachine.mgmtcenter:
         # Update status
         pmachine.invalidate_dynamics(['host_status'])
     else:
         # No management Center, cannot update status via api
         logger.info('Updating status of pmachine {0} using SSHClient'.format(pmachine.name))
         host_status = 'RUNNING'
         try:
             client = SSHClient(storagerouter, username='root')
             configuration_dir = EtcdConfiguration.get('/ovs/framework/paths|cfgdir')
             logger.info('SSHClient connected successfully to {0} at {1}'.format(pmachine.name, client.ip))
             with Remote(client.ip, [LocalStorageRouterClient]) as remote:
                 lsrc = remote.LocalStorageRouterClient('{0}/storagedriver/storagedriver/{1}.json'.format(configuration_dir,
                                                                                                          storagedriver.vpool.name))
                 lsrc.server_revision()
             logger.info('LocalStorageRouterClient connected successfully to {0} at {1}'.format(pmachine.name, client.ip))
         except Exception as ex:
             logger.error('Connectivity check failed, assuming host {0} is halted. {1}'.format(pmachine.name, ex))
             host_status = 'HALTED'
         if host_status != 'RUNNING':
             # Host is stopped
             storagedriver_client = StorageDriverClient.load(storagedriver.vpool)
             storagedriver_client.mark_node_offline(str(storagedriver.storagedriver_id))
开发者ID:jeroenmaelbrancke,项目名称:openvstorage,代码行数:35,代码来源:storagedriver.py

示例3: resize_from_voldrv

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    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,代码行数:32,代码来源:vdisk.py

示例4: clone

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def clone(diskguid, snapshotid, devicename, pmachineguid, machinename, machineguid=None):
        """
        Clone a disk
        """
        pmachine = PMachine(pmachineguid)
        hypervisor = Factory.get(pmachine)
        description = '{} {}'.format(machinename, devicename)
        properties_to_clone = ['description', 'size', 'type', 'retentionpolicyguid',
                               'snapshotpolicyguid', 'autobackup']
        vdisk = VDisk(diskguid)
        location = hypervisor.get_backing_disk_path(machinename, devicename)

        new_vdisk = VDisk()
        new_vdisk.copy(vdisk, include=properties_to_clone)
        new_vdisk.parent_vdisk = vdisk
        new_vdisk.name = '{0}-clone'.format(vdisk.name)
        new_vdisk.description = description
        new_vdisk.devicename = hypervisor.clean_backing_disk_filename(location)
        new_vdisk.parentsnapshot = snapshotid
        new_vdisk.vmachine = VMachine(machineguid) if machineguid else vdisk.vmachine
        new_vdisk.vpool = vdisk.vpool
        new_vdisk.save()

        try:
            storagedriver = StorageDriverList.get_by_storagedriver_id(vdisk.storagedriver_id)
            if storagedriver is None:
                raise RuntimeError('Could not find StorageDriver with id {0}'.format(vdisk.storagedriver_id))

            mds_service = MDSServiceController.get_preferred_mds(storagedriver.storagerouter, vdisk.vpool)
            if mds_service is None:
                raise RuntimeError('Could not find a MDS service')

            logger.info('Clone snapshot {} of disk {} to location {}'.format(snapshotid, vdisk.name, location))
            volume_id = vdisk.storagedriver_client.create_clone(
                target_path=location,
                metadata_backend_config=MDSMetaDataBackendConfig([MDSNodeConfig(address=str(mds_service.service.storagerouter.ip),
                                                                                port=mds_service.service.ports[0])]),
                parent_volume_id=str(vdisk.volume_id),
                parent_snapshot_id=str(snapshotid),
                node_id=str(vdisk.storagedriver_id)
            )
        except Exception as ex:
            logger.error('Caught exception during clone, trying to delete the volume. {0}'.format(ex))
            new_vdisk.delete()
            VDiskController.delete_volume(location)
            raise

        new_vdisk.volume_id = volume_id
        new_vdisk.save()

        try:
            MDSServiceController.ensure_safety(new_vdisk)
        except Exception as ex:
            logger.error('Caught exception during "ensure_safety" {0}'.format(ex))

        return {'diskguid': new_vdisk.guid,
                'name': new_vdisk.name,
                'backingdevice': location}
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:60,代码来源:vdisk.py

示例5: _log

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
def _log(task, kwargs, storagedriver_id):
    log = Log()
    log.source = 'VOLUMEDRIVER_EVENT'
    log.module = task.__class__.__module__
    log.method = task.__class__.__name__
    log.method_kwargs = kwargs
    log.time = time.time()
    log.storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
    log.save()
开发者ID:mflu,项目名称:openvstorage_centos,代码行数:11,代码来源:processor.py

示例6: up_and_running

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def up_and_running(storagedriver_id):
     """
     Volumedriver informs us that the service is completely started. Post-start events can be executed
     :param storagedriver_id: ID of the storagedriver
     """
     storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
     if storagedriver is None:
         raise RuntimeError('A Storage Driver with id {0} could not be found.'.format(storagedriver_id))
     storagedriver.startup_counter += 1
     storagedriver.save()
开发者ID:grimpy,项目名称:openvstorage,代码行数:12,代码来源:vpool.py

示例7: migrate

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def migrate(self, volume_id, node_id, force_restart, req_timeout_secs=None):
        """
        Dummy migrate method
        """
        _ = force_restart, req_timeout_secs
        from ovs.dal.lists.storagedriverlist import StorageDriverList

        storagedriver = StorageDriverList.get_by_storagedriver_id(node_id)
        if storagedriver is None:
            raise ValueError("Failed to retrieve storagedriver with ID {0}".format(node_id))
        StorageRouterClient.vrouter_id[self.vpool_guid][volume_id] = node_id
开发者ID:openvstorage,项目名称:framework,代码行数:13,代码来源:mockups.py

示例8: delete

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def delete(diskguid):
     """
     Delete a vdisk through API
     @param diskguid: GUID of the vdisk to delete
     """
     vdisk = VDisk(diskguid)
     storagedriver = StorageDriverList.get_by_storagedriver_id(vdisk.storagedriver_id)
     location = os.path.join(storagedriver.mountpoint, vdisk.devicename)
     logger.info('Deleting disk {0} on location {1}'.format(vdisk.name, location))
     VDiskController.delete_volume(location=location)
     logger.info('Deleted disk {0}'.format(location))
开发者ID:jamie-liu,项目名称:openvstorage,代码行数:13,代码来源:vdisk.py

示例9: _execute_scrub_work

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def _execute_scrub_work(scrub_location, vdisk_guids):
        def _verify_mds_config(current_vdisk):
            current_vdisk.invalidate_dynamics(['info'])
            vdisk_configs = current_vdisk.info['metadata_backend_config']
            if len(vdisk_configs) == 0:
                raise RuntimeError('Could not load MDS configuration')
            return vdisk_configs

        ScheduledTaskController._logger.info('Execute Scrub - Started')
        ScheduledTaskController._logger.info('Execute Scrub - Scrub location - {0}'.format(scrub_location))
        total = len(vdisk_guids)
        skipped = 0
        storagedrivers = {}
        failures = []
        for vdisk_guid in vdisk_guids:
            vdisk = VDisk(vdisk_guid)
            try:
                # Load the vDisk's StorageDriver
                ScheduledTaskController._logger.info('Execute Scrub - Virtual disk {0} - {1} - Started'.format(vdisk.guid, vdisk.name))
                vdisk.invalidate_dynamics(['storagedriver_id'])
                if vdisk.storagedriver_id not in storagedrivers:
                    storagedrivers[vdisk.storagedriver_id] = StorageDriverList.get_by_storagedriver_id(vdisk.storagedriver_id)
                storagedriver = storagedrivers[vdisk.storagedriver_id]

                # Load the vDisk's MDS configuration
                configs = _verify_mds_config(current_vdisk=vdisk)

                # Check MDS master is local. Trigger MDS handover if necessary
                if configs[0].get('ip') != storagedriver.storagerouter.ip:
                    ScheduledTaskController._logger.debug('Execute Scrub - Virtual disk {0} - {1} - MDS master is not local, trigger handover'.format(vdisk.guid, vdisk.name))
                    MDSServiceController.ensure_safety(vdisk)
                    configs = _verify_mds_config(current_vdisk=vdisk)
                    if configs[0].get('ip') != storagedriver.storagerouter.ip:
                        skipped += 1
                        ScheduledTaskController._logger.info('Execute Scrub - Virtual disk {0} - {1} - Skipping because master MDS still not local'.format(vdisk.guid, vdisk.name))
                        continue
                with vdisk.storagedriver_client.make_locked_client(str(vdisk.volume_id)) as locked_client:
                    ScheduledTaskController._logger.info('Execute Scrub - Virtual disk {0} - {1} - Retrieve and apply scrub work'.format(vdisk.guid, vdisk.name))
                    work_units = locked_client.get_scrubbing_workunits()
                    for work_unit in work_units:
                        scrubbing_result = locked_client.scrub(work_unit, scrub_location, log_sinks=[SCRUBBER_LOGFILE_LOCATION])
                        locked_client.apply_scrubbing_result(scrubbing_result)
                    if work_units:
                        ScheduledTaskController._logger.info('Execute Scrub - Virtual disk {0} - {1} - Scrub successfully applied'.format(vdisk.guid, vdisk.name))
                    else:
                        ScheduledTaskController._logger.info('Execute Scrub - Virtual disk {0} - {1} - No scrubbing required'.format(vdisk.guid, vdisk.name))
            except Exception as ex:
                failures.append('Failed scrubbing work unit for volume {0} with guid {1}: {2}'.format(vdisk.name, vdisk.guid, ex))

        failed = len(failures)
        ScheduledTaskController._logger.info('Execute Scrub - Finished - Success: {0} - Failed: {1} - Skipped: {2}'.format((total - failed - skipped), failed, skipped))
        if failed > 0:
            raise Exception('\n - '.join(failures))
        return vdisk_guids
开发者ID:DarumasLegs,项目名称:framework,代码行数:56,代码来源:scheduledtask.py

示例10: mountpoint_available_from_voldrv

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def mountpoint_available_from_voldrv(mountpoint, storagedriver_id):
     """
     Hook for (re)exporting the NFS mountpoint
     """
     storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
     if storagedriver is None:
         raise RuntimeError('A Storage Driver with id {0} could not be found.'.format(storagedriver_id))
     if storagedriver.storagerouter.pmachine.hvtype == 'VMWARE':
         nfs = Nfsexports()
         nfs.unexport(mountpoint)
         nfs.export(mountpoint)
         nfs.trigger_rpc_mountd()
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:14,代码来源:vpool.py

示例11: _log

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
def _log(task, kwargs, storagedriver_id):
    """
    Log an event
    """
    metadata = {'storagedriver': StorageDriverList.get_by_storagedriver_id(storagedriver_id).guid}
    _logger = LogHandler.get('log', name='volumedriver_event')
    _logger.info('[{0}.{1}] - {2} - {3}'.format(
        task.__class__.__module__,
        task.__class__.__name__,
        json.dumps(kwargs),
        json.dumps(metadata)
    ))
开发者ID:JasperLue,项目名称:openvstorage,代码行数:14,代码来源:processor.py

示例12: _execute_scrub_work

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def _execute_scrub_work(scrub_location, vdisk_guids):
        def verify_mds_config(current_vdisk):
            current_vdisk.invalidate_dynamics(["info"])
            vdisk_configs = current_vdisk.info["metadata_backend_config"]
            if len(vdisk_configs) == 0:
                raise RuntimeError("Could not load MDS configuration")
            return vdisk_configs

        logger.info("Scrub location: {0}".format(scrub_location))
        total = len(vdisk_guids)
        skipped = 0
        storagedrivers = {}
        failures = []
        for vdisk_guid in vdisk_guids:
            vdisk = VDisk(vdisk_guid)
            try:
                # Load the vDisk's StorageDriver
                logger.info("Scrubbing virtual disk {0} with guid {1}".format(vdisk.name, vdisk.guid))
                vdisk.invalidate_dynamics(["storagedriver_id"])
                if vdisk.storagedriver_id not in storagedrivers:
                    storagedrivers[vdisk.storagedriver_id] = StorageDriverList.get_by_storagedriver_id(
                        vdisk.storagedriver_id
                    )
                storagedriver = storagedrivers[vdisk.storagedriver_id]

                # Load the vDisk's MDS configuration
                configs = verify_mds_config(current_vdisk=vdisk)

                # Check MDS master is local. Trigger MDS handover if necessary
                if configs[0].get("ip") != storagedriver.storagerouter.ip:
                    logger.debug("MDS for volume {0} is not local. Trigger handover".format(vdisk.volume_id))
                    MDSServiceController.ensure_safety(vdisk)
                    configs = verify_mds_config(current_vdisk=vdisk)
                    if configs[0].get("ip") != storagedriver.storagerouter.ip:
                        skipped += 1
                        logger.info(
                            "Skipping scrubbing work unit for volume {0}: MDS master is not local".format(
                                vdisk.volume_id
                            )
                        )
                        continue
                with vdisk.storagedriver_client.make_locked_client(str(vdisk.volume_id)) as locked_client:
                    work_units = locked_client.get_scrubbing_workunits()
                    for work_unit in work_units:
                        scrubbing_result = locked_client.scrub(work_unit, scrub_location)
                        locked_client.apply_scrubbing_result(scrubbing_result)
                    if work_units:
                        logger.info("Scrubbing successfully applied")
            except Exception, ex:
                failures.append(
                    "Failed scrubbing work unit for volume {0} with guid {1}: {2}".format(vdisk.name, vdisk.guid, ex)
                )
开发者ID:JasperLue,项目名称:openvstorage,代码行数:54,代码来源:scheduledtask.py

示例13: get_by_storagedriver_id

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def get_by_storagedriver_id(storagedriver_id):
     """
     Get pMachine that hosts a given storagedriver_id
     """
     storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
     if storagedriver is None:
         raise RuntimeError('StorageDriver {0} could not be found'.format(storagedriver_id))
     storagerouter = storagedriver.storagerouter
     if storagerouter is None:
         raise RuntimeError('StorageDriver {0} not linked to a StorageRouter'.format(storagedriver.name))
     pmachine = storagerouter.pmachine
     if pmachine is None:
         raise RuntimeError('StorageRouter {0} not linked to a pMachine'.format(storagerouter.name))
     return pmachine
开发者ID:JasperLue,项目名称:openvstorage,代码行数:16,代码来源:pmachinelist.py

示例14: up_and_running

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
 def up_and_running(mountpoint, storagedriver_id):
     """
     Volumedriver informs us that the service is completely started. Post-start events can be executed
     """
     storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
     if storagedriver is None:
         raise RuntimeError('A Storage Driver with id {0} could not be found.'.format(storagedriver_id))
     storagedriver.startup_counter += 1
     storagedriver.save()
     if storagedriver.storagerouter.pmachine.hvtype == 'VMWARE':
         client = SSHClient(storagedriver.storagerouter)
         if client.config_read('ovs.storagedriver.vmware_mode') == 'classic':
             nfs = Nfsexports()
             nfs.unexport(mountpoint)
             nfs.export(mountpoint)
             nfs.trigger_rpc_mountd()
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:18,代码来源:vpool.py

示例15: create_volume

# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_by_storagedriver_id [as 别名]
    def create_volume(self, target_path, metadata_backend_config, volume_size, node_id):
        """
        Create a mocked volume
        """
        from ovs.dal.lists.storagedriverlist import StorageDriverList

        volume_id = str(uuid.uuid4())
        storagedriver = StorageDriverList.get_by_storagedriver_id(node_id)
        if storagedriver is None:
            raise ValueError('Failed to retrieve storagedriver with ID {0}'.format(node_id))
        StorageRouterClient.vrouter_id[self.vpool_guid][volume_id] = node_id
        StorageRouterClient._metadata_backend_config[self.vpool_guid][volume_id] = metadata_backend_config
        StorageRouterClient.volumes[self.vpool_guid][volume_id] = {'volume_id': volume_id,
                                                                   'volume_size': volume_size,
                                                                   'target_path': target_path}
        return volume_id
开发者ID:grimpy,项目名称:openvstorage,代码行数:18,代码来源:mockups.py


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