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


Python VPoolList.get_vpool_by_name方法代码示例

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


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

示例1: update_vdisk_name

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

示例2: get_vpool_by_name

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def get_vpool_by_name(vpool_name):
     """
     Retrieve the vPool object by its name
     :param vpool_name: Name of the vPool
     :return: vPool DAL object
     """
     return VPoolList.get_vpool_by_name(vpool_name)
开发者ID:DarumasLegs,项目名称:integrationtests,代码行数:9,代码来源:general_vpool.py

示例3: _create_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
    def _create_vpool(self):
        """
        Needed to actually run tests on
        This is not actually a test of "Add Vpool to OVS",
        so any failure here will be reported as a setUp error and no tests will run
        """
        pmachine = System.get_my_storagerouter().pmachine
        mgmt_center = MgmtCenter(data={'name':'Openstack',
                                       'description':'test',
                                       'username':CINDER_USER,
                                       'password':CINDER_PASS,
                                       'ip':CINDER_CONTROLLER,
                                       'port':80,
                                       'type':'OPENSTACK',
                                       'metadata':{'integratemgmt':True}})
        mgmt_center.save()
        pmachine.mgmtcenter = mgmt_center
        pmachine.save()
        self._debug('Creating vpool')
        backend_type = 'local'
        fields = ['storage_ip', 'vrouter_port']

        parameters = {'storagerouter_ip': IP,
                      'vpool_name': VPOOL_NAME,
                      'type': 'local',
                      'mountpoint_bfs': VPOOL_BFS,
                      'mountpoint_temp': VPOOL_TEMP,
                      'mountpoint_md': VPOOL_MD,
                      'mountpoint_readcaches': [VPOOL_READCACHE],
                      'mountpoint_writecaches': [VPOOL_WRITECACHE],
                      'mountpoint_foc': VPOOL_FOC,
                      'storage_ip': '127.0.0.1', #KVM
                      'vrouter_port': VPOOL_PORT,
                      'integrate_vpool': True,
                      'connection_host': IP,
                      'connection_port': VPOOL_PORT,
                      'connection_username': '',
                      'connection_password': '',
                      'connection_backend': {},
                      }
        StorageRouterController.add_vpool(parameters)
        attempt = 0
        while attempt < 10:
            vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
            if vpool is not None:
                self._debug('vpool %s created' % VPOOL_NAME)
                try:
                    os.listdir(VPOOL_MOUNTPOINT)
                    return vpool
                except Exception as ex:
                    #either it doesn't exist, or we don't have permission
                    self._debug('vpool not ready yet %s' % (str(ex)))
                    pass
            attempt += 1
            time.sleep(2)
        raise RuntimeError('Vpool %s was not modeled correctly or did not start.' % VPOOL_NAME)
开发者ID:tcpcloud,项目名称:openvstorage,代码行数:58,代码来源:ovs_common.py

示例4: _create_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
    def _create_vpool(self):
        """
        Needed to actually run tests on
        This is not actually a test of "Add Vpool to OVS",
        so any failure here will be reported as a setUp error and no tests will run
        """
        pmachine = System.get_my_storagerouter().pmachine
        mgmt_center = MgmtCenter(
            data={
                "name": "Openstack",
                "description": "test",
                "username": CINDER_USER,
                "password": CINDER_PASS,
                "ip": CINDER_CONTROLLER,
                "port": 80,
                "type": "OPENSTACK",
                "metadata": {"integratemgmt": True},
            }
        )
        mgmt_center.save()
        pmachine.mgmtcenter = mgmt_center
        pmachine.save()
        self._debug("Creating vpool")

        parameters = {
            "storagerouter_ip": IP,
            "vpool_name": VPOOL_NAME,
            "type": "local",
            "storage_ip": "127.0.0.1",  # KVM
            "vrouter_port": VPOOL_PORT,
            "integrate_vpool": True,
            "connection_host": IP,
            "connection_port": VPOOL_PORT,
            "connection_username": "",
            "connection_password": "",
            "connection_backend": {},
            "readcache_size": 50,
            "writecache_size": 50,
        }
        StorageRouterController.add_vpool(parameters)
        attempt = 0
        while attempt < 10:
            vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
            if vpool is not None:
                self._debug("vpool {0} created".format(VPOOL_NAME))
                try:
                    os.listdir(VPOOL_MOUNTPOINT)
                    return vpool
                except Exception as ex:
                    # either it doesn't exist, or we don't have permission
                    self._debug("vpool not ready yet {0}".format(str(ex)))
                    pass
            attempt += 1
            time.sleep(2)
        raise RuntimeError("Vpool {0} was not modeled correctly or did not start.".format(VPOOL_NAME))
开发者ID:jamie-liu,项目名称:openvstorage,代码行数:57,代码来源:ovs_common.py

示例5: __init__

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def __init__(self, *args, **kwargs):
     """Init: args, kwargs pass through;
     Options come from CONF
     """
     super(OVSVolumeDriver, self).__init__(*args, **kwargs)
     LOG.info('INIT %s %s %s ' % (CONF.vpool_name, str(args), str(kwargs)))
     self.configuration.append_config_values(OPTS)
     self._vpool_name = self.configuration.vpool_name
     self._vp = VPoolList.get_vpool_by_name(self._vpool_name)
     self._context = None
     self._db = kwargs.get('db', None)
     self._api = api.API()
开发者ID:jianyongchen,项目名称:openvstorage,代码行数:14,代码来源:openvstorage.py

示例6: _remove_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _remove_vpool(self):
     """
     Clean up
     This is not actually a test of "Remove Vpool from OVS",
     so any failure here will be reported as a tearDown error and no cleanup will occur
     """
     self._debug('Removing vpool')
     vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
     if vpool is None:
         self._debug('already removed')
         return
     for storagedriver_guid in vpool.storagedrivers_guids:
         self._debug('removing storagedriver {0}'.format(storagedriver_guid))
         StorageRouterController.remove_storagedriver(storagedriver_guid)
     attempt = 0
     while attempt < 10:
         vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
         if vpool is None:
             self._debug('vpool {0} deleted'.format(VPOOL_NAME))
             return
         attempt += 1
         time.sleep(2)
     raise RuntimeError('Vpool {0} was not removed correctly.'.format(VPOOL_NAME))
开发者ID:JasperLue,项目名称:openvstorage,代码行数:25,代码来源:ovs_common.py

示例7: _create_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
    def _create_vpool(self):
        """
        Needed to actually run tests on
        This is not actually a test of "Add Vpool to OVS",
        so any failure here will be reported as a setUp error and no tests will run
        """
        pmachine = System.get_my_storagerouter().pmachine
        mgmt_center = MgmtCenter(data={'name': 'Openstack',
                                       'description': 'test',
                                       'username': OVSPluginTestCase.CINDER_USER,
                                       'password': OVSPluginTestCase.CINDER_PASS,
                                       'ip': OVSPluginTestCase.CINDER_CONTROLLER,
                                       'port': 80,
                                       'type': 'OPENSTACK',
                                       'metadata': {'integratemgmt': True}})
        mgmt_center.save()
        pmachine.mgmtcenter = mgmt_center
        pmachine.save()
        self._debug('Creating vpool')

        parameters = {'storagerouter_ip': OVSPluginTestCase.ip,
                      'vpool_name': OVSPluginTestCase.VPOOL_NAME,
                      'type': 'local',
                      'storage_ip': '127.0.0.1',  # KVM
                      'vrouter_port': OVSPluginTestCase.VPOOL_PORT,
                      'integrate_vpool': True,
                      'connection_host': OVSPluginTestCase.ip,
                      'connection_port': OVSPluginTestCase.VPOOL_PORT,
                      'connection_username': '',
                      'connection_password': '',
                      'connection_backend': {},
                      'readcache_size': 50,
                      'writecache_size': 50
                      }
        StorageRouterController.add_vpool(parameters)
        attempt = 0
        while attempt < 10:
            vpool = VPoolList.get_vpool_by_name(OVSPluginTestCase.VPOOL_NAME)
            if vpool is not None:
                self._debug('vpool {0} created'.format(OVSPluginTestCase.VPOOL_NAME))
                try:
                    os.listdir(OVSPluginTestCase.VPOOL_MOUNTPOINT)
                    return vpool
                except Exception as ex:
                    # either it doesn't exist, or we don't have permission
                    self._debug('vpool not ready yet {0}'.format(str(ex)))
                    pass
            attempt += 1
            time.sleep(2)
        raise RuntimeError('Vpool {0} was not modeled correctly or did not start.'.format(OVSPluginTestCase.VPOOL_NAME))
开发者ID:DarumasLegs,项目名称:framework,代码行数:52,代码来源:ovs_common.py

示例8: get_vdisk_by_name

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def get_vdisk_by_name(vdisk_name, vpool_name):
     """
     Fetch disk partitions by disk guid
     :param vdisk_name: location of a vdisk on a vpool
                        (e.g. /mnt/vpool/test.raw = test.raw, /mnt/vpool/volumes/test.raw = volumes/test.raw )
     :type vdisk_name: str
     :param vpool_name: name of a existing vpool
     :type vpool_name: str
     :return: a vdisk object
     :rtype: ovs.dal.hybrids.vdisk.VDisk
     """
     vpool = VPoolList.get_vpool_by_name(vpool_name)
     if vpool:
         vdisk = VDiskList.get_by_devicename_and_vpool('/{0}'.format(vdisk_name), vpool)
         if vdisk:
             return vdisk
         else:
             raise VDiskNotFoundError("VDisk with name `{0}` not found!".format(vdisk_name))
     else:
         raise VPoolNotFoundError("vPool with name `{0}` cannot be found!".format(vpool_name))
开发者ID:openvstorage,项目名称:openvstorage-health-check,代码行数:22,代码来源:vdisk.py

示例9: _create_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _create_vpool(self):
     """
     Needed to actually run tests on
     This is not actually a test of "Add Vpool to OVS",
     so any failure here will be reported as a setUp error and no tests will run
     """
     self._debug('Creating vpool')
     backend_type = 'local'
     fields = ['storage_ip', 'vrouter_port']
     parameters = {'storagerouter_ip': IP,
                   'vpool_name': VPOOL_NAME,
                   'type': 'local',
                   'mountpoint_bfs': VPOOL_BFS,
                   'mountpoint_temp': VPOOL_TEMP,
                   'mountpoint_md': VPOOL_MD,
                   'mountpoint_readcache1': VPOOL_READCACHE1,
                   'mountpoint_readcache2': VPOOL_READCACHE2,
                   'mountpoint_writecache': VPOOL_WRITECACHE,
                   'mountpoint_foc': VPOOL_FOC,
                   'storage_ip': '127.0.0.1', #KVM
                   'vrouter_port': VPOOL_PORT
                   }
     StorageRouterController.add_vpool(parameters)
     attempt = 0
     while attempt < 10:
         vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
         if vpool is not None:
             self._debug('vpool %s created' % VPOOL_NAME)
             try:
                 self._get_shell_client()
                 self.shell_client('sudo chown %s %s' % (self.current_user_id, VPOOL_MOUNTPOINT))
                 self.shell_client('sudo chmod 775 %s' % (VPOOL_MOUNTPOINT))
                 os.listdir(VPOOL_MOUNTPOINT)
                 return vpool
             except Exception as ex:
                 #either it doesn't exist, or we don't have permission
                 self._debug('vpool not ready yet %s' % (str(ex)))
                 pass
         attempt += 1
         time.sleep(2)
     raise RuntimeError('Vpool %s was not modeled correctly or did not start.' % VPOOL_NAME)
开发者ID:BillTheBest,项目名称:openvstorage,代码行数:43,代码来源:ovs_common.py

示例10: update_vmachine_name

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
    def update_vmachine_name(instance_id, old_name, new_name):
        """
        Update a vMachine name: find vmachine by management center instance id, set new name
        :param instance_id: ID for the virtual machine known by management center
        :param old_name: Old name of the virtual machine
        :param new_name: New name for the virtual machine
        """
        vmachine = None
        for mgmt_center in MgmtCenterList.get_mgmtcenters():
            mgmt = Factory.get_mgmtcenter(mgmt_center = mgmt_center)
            try:
                machine_info = mgmt.get_vmachine_device_info(instance_id)
                file_name = machine_info['file_name']
                host_name = machine_info['host_name']
                vpool_name = machine_info['vpool_name']
                storage_router = StorageRouterList.get_by_name(host_name)
                machine_id = storage_router.machine_id
                device_name = '{0}/{1}'.format(machine_id, file_name)
                vp = VPoolList.get_vpool_by_name(vpool_name)
                vmachine = VMachineList.get_by_devicename_and_vpool(device_name, vp)
                if vmachine:
                    break
                vmachine = VMachineList.get_by_devicename_and_vpool(device_name, None)
                if vmachine:
                    break
            except Exception as ex:
                VMachineController._logger.info('Trying to get mgmt center failed for vmachine {0}. {1}'.format(old_name, ex))
        if not vmachine:
            VMachineController._logger.error('No vmachine found for name {0}'.format(old_name))
            return

        vpool = vmachine.vpool
        mutex = volatile_mutex('{0}_{1}'.format(old_name, vpool.guid if vpool is not None else 'none'))
        try:
            mutex.acquire(wait=5)
            vmachine.name = new_name
            vmachine.save()
        finally:
            mutex.release()
开发者ID:DarumasLegs,项目名称:framework,代码行数:41,代码来源:vmachine.py

示例11: _vpool_exists

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _vpool_exists(self):
     return VPoolList.get_vpool_by_name(VPOOL_NAME) is not None
开发者ID:JasperLue,项目名称:openvstorage,代码行数:4,代码来源:ovs_common.py

示例12: _get_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _get_vpool(self):
     self.vpool = VPoolList.get_vpool_by_name(VPOOL_NAME)
开发者ID:JasperLue,项目名称:openvstorage,代码行数:4,代码来源:ovs_common.py

示例13: _vpool_exists

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _vpool_exists(self):
     _ = self
     return VPoolList.get_vpool_by_name(OVSPluginTestCase.VPOOL_NAME) is not None
开发者ID:DarumasLegs,项目名称:framework,代码行数:5,代码来源:ovs_common.py

示例14: _get_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
 def _get_vpool(self):
     self.vpool = VPoolList.get_vpool_by_name(OVSPluginTestCase.VPOOL_NAME)
开发者ID:DarumasLegs,项目名称:framework,代码行数:4,代码来源:ovs_common.py

示例15: add_vpool

# 需要导入模块: from ovs.dal.lists.vpoollist import VPoolList [as 别名]
# 或者: from ovs.dal.lists.vpoollist.VPoolList import get_vpool_by_name [as 别名]
    def add_vpool(parameters):
        """
        Add a vPool to the machine this task is running on
        """

        parameters = {} if parameters is None else parameters
        ip = parameters['storagerouter_ip']
        vpool_name = parameters['vpool_name']

        if StorageRouterController._validate_ip(ip) is False:
            raise ValueError('The entered ip address is invalid')

        if not re.match('^[0-9a-z]+(\-+[0-9a-z]+)*$', vpool_name):
            raise ValueError('Invalid vpool_name given')

        client = SSHClient.load(ip)  # Make sure to ALWAYS reload the client, as Fabric seems to be singleton-ish
        unique_id = System.get_my_machine_id(client)

        storagerouter = None
        for current_storagerouter in StorageRouterList.get_storagerouters():
            if current_storagerouter.ip == ip and current_storagerouter.machine_id == unique_id:
                storagerouter = current_storagerouter
                break
        if storagerouter is None:
            raise RuntimeError('Could not find Storage Router with given ip address')

        vpool = VPoolList.get_vpool_by_name(vpool_name)
        storagedriver = None
        if vpool is not None:
            if vpool.backend_type.code == 'local':
                # Might be an issue, investigating whether it's on the same not or not
                if len(vpool.storagedrivers) == 1 and vpool.storagedrivers[0].storagerouter.machine_id != unique_id:
                    raise RuntimeError('A local vPool with name {0} already exists'.format(vpool_name))
            for vpool_storagedriver in vpool.storagedrivers:
                if vpool_storagedriver.storagerouter_guid == storagerouter.guid:
                    storagedriver = vpool_storagedriver  # The vPool is already added to this Storage Router and this might be a cleanup/recovery

            # Check whether there are running machines on this vPool
            machine_guids = []
            for vdisk in vpool.vdisks:
                if vdisk.vmachine_guid not in machine_guids:
                    machine_guids.append(vdisk.vmachine_guid)
                    if vdisk.vmachine.hypervisor_status in ['RUNNING', 'PAUSED']:
                        raise RuntimeError(
                            'At least one vMachine using this vPool is still running or paused. Make sure there are no active vMachines'
                        )

        nodes = {ip}  # Set comprehension
        if vpool is not None:
            for vpool_storagedriver in vpool.storagedrivers:
                nodes.add(vpool_storagedriver.storagerouter.ip)
        nodes = list(nodes)

        services = ['volumedriver_{0}'.format(vpool_name),
                    'failovercache_{0}'.format(vpool_name)]

        # Stop services
        for node in nodes:
            node_client = SSHClient.load(node)
            for service in services:
                System.exec_remote_python(node_client, """
from ovs.plugin.provider.service import Service
if Service.has_service('{0}'):
    Service.disable_service('{0}')
""".format(service))
                System.exec_remote_python(node_client, """
from ovs.plugin.provider.service import Service
if Service.has_service('{0}'):
    Service.stop_service('{0}')
""".format(service))

        # Keep in mind that if the Storage Driver exists, the vPool does as well
        client = SSHClient.load(ip)
        mountpoint_bfs = ''
        directories_to_create = []

        if vpool is None:
            vpool = VPool()
            supported_backends = System.read_remote_config(client, 'volumedriver.supported.backends').split(',')
            if 'rest' in supported_backends:
                supported_backends.remove('rest')  # REST is not supported for now
            backend_type = BackendTypeList.get_backend_type_by_code(parameters['type'])
            vpool.backend_type = backend_type
            connection_host = connection_port = connection_username = connection_password = None
            if vpool.backend_type.code in ['local', 'distributed']:
                vpool.metadata = {'backend_type': 'LOCAL'}
                mountpoint_bfs = parameters['mountpoint_bfs']
                directories_to_create.append(mountpoint_bfs)
                vpool.metadata['local_connection_path'] = mountpoint_bfs
            if vpool.backend_type.code == 'rest':
                connection_host = parameters['connection_host']
                connection_port = parameters['connection_port']
                rest_connection_timeout_secs = parameters['connection_timeout']
                vpool.metadata = {'rest_connection_host': connection_host,
                                  'rest_connection_port': connection_port,
                                  'buchla_connection_log_level': "0",
                                  'rest_connection_verbose_logging': rest_connection_timeout_secs,
                                  'rest_connection_metadata_format': "JSON",
                                  'backend_type': 'REST'}
            elif vpool.backend_type.code in ('ceph_s3', 'amazon_s3', 'swift_s3'):
#.........这里部分代码省略.........
开发者ID:mflu,项目名称:openvstorage_centos,代码行数:103,代码来源:storagerouter.py


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