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


Python remote.create_cinder_client函数代码示例

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


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

示例1: test_create_with_catalog_all_opts

 def test_create_with_catalog_all_opts(self):
     cfg.CONF.set_override('cinder_service_type', 'volume')
     cfg.CONF.set_override('os_region_name', 'RegionTwo')
     client = remote.create_cinder_client(
         TroveContext(service_catalog=self.service_catalog))
     self.assertEqual(self.volume_public_url_region_two,
                      client.client.management_url)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:7,代码来源:test_remote.py

示例2: load

 def load(context):
     client = create_cinder_client(context)
     rdstorages = client.rdstorage.list()
     for rdstorage in rdstorages:
         LOG.debug("rdstorage=" + str(rdstorage))
     return [StorageDevice(storage_info)
             for storage_info in rdstorages]
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:7,代码来源:models.py

示例3: get_volume_mountpoint

 def get_volume_mountpoint(self):
     volume = create_cinder_client(self.context).volumes.get(volume_id)
     mountpoint = volume.attachments[0]['device']
     if mountpoint[0] is not "/":
         return "/%s" % mountpoint
     else:
         return mountpoint
开发者ID:adamfokken,项目名称:trove,代码行数:7,代码来源:models.py

示例4: _create_server_volume_heat

    def _create_server_volume_heat(self, flavor, image_id, security_groups, service_type, volume_size):
        client = create_heat_client(self.context)
        novaclient = create_nova_client(self.context)
        cinderclient = create_cinder_client(self.context)
        heat_template = template.HeatTemplate().template()
        parameters = {
            "KeyName": "heatkey",
            "Flavor": flavor["name"],
            "VolumeSize": volume_size,
            "ServiceType": "mysql",
            "InstanceId": self.id,
        }
        stack_name = "trove-%s" % self.id
        stack = client.stacks.create(stack_name=stack_name, template=heat_template, parameters=parameters)
        stack = client.stacks.get(stack_name)

        utils.poll_until(
            lambda: client.stacks.get(stack_name),
            lambda stack: stack.stack_status in ["CREATE_COMPLETE", "CREATE_FAILED"],
            sleep_time=2,
            time_out=HEAT_TIME_OUT,
        )

        resource = client.resources.get(stack.id, "BaseInstance")
        server = novaclient.servers.get(resource.physical_resource_id)

        resource = client.resources.get(stack.id, "DataVolume")
        volume = cinderclient.volumes.get(resource.physical_resource_id)
        volume_info = self._build_volume(volume)

        self.update_db(compute_instance_id=server.id, volume_id=volume.id)

        return server, volume_info
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:33,代码来源:models.py

示例5: test_create_with_conf_override_trailing_slash

 def test_create_with_conf_override_trailing_slash(self):
     cinder_url_from_conf = 'http://example.com/'
     tenant_from_ctx = 'abc'
     cfg.CONF.set_override('cinder_url', cinder_url_from_conf)
     client = remote.create_cinder_client(
         TroveContext(tenant=tenant_from_ctx))
     self.assertEqual('%s%s' % (cinder_url_from_conf, tenant_from_ctx),
                      client.client.management_url)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:8,代码来源:test_remote.py

示例6: test_create_with_conf_override

    def test_create_with_conf_override(self):
        cinder_url_from_conf = 'http://example.com'
        tenant_from_ctx = uuid.uuid4().hex
        cfg.CONF.set_override('cinder_url', cinder_url_from_conf)

        client = remote.create_cinder_client(
            TroveContext(tenant=tenant_from_ctx))
        self.assertEqual('%s/%s' % (cinder_url_from_conf, tenant_from_ctx),
                         client.client.management_url)
开发者ID:magictour,项目名称:trove,代码行数:9,代码来源:test_remote.py

示例7: load

 def load(cls, context, id, include_deleted=False):
     instance = load_mgmt_instance(cls, context, id, include_deleted)
     client = remote.create_cinder_client(context)
     try:
         instance.volume = client.volumes.get(instance.volume_id)
     except Exception:
         instance.volume = None
         # Populate the volume_used attribute from the guest agent.
     instance_models.load_guest_info(instance, context, id)
     instance.root_history = mysql_models.RootHistory.load(context=context, instance_id=id)
     return instance
开发者ID:zjtheone,项目名称:trove,代码行数:11,代码来源:models.py

示例8: _create_server_volume_heat

    def _create_server_volume_heat(self, flavor, image_id,
                                   datastore_manager,
                                   volume_size, availability_zone):
        LOG.debug(_("begin _create_server_volume_heat for id: %s") % self.id)
        client = create_heat_client(self.context)
        novaclient = create_nova_client(self.context)

        template_obj = template.load_heat_template(datastore_manager)
        heat_template_unicode = template_obj.render()
        try:
            heat_template = heat_template_unicode.encode('ascii')
        except UnicodeEncodeError:
            LOG.error(_("heat template ascii encode issue"))
            raise TroveError("heat template ascii encode issue")

        parameters = {"Flavor": flavor["name"],
                      "VolumeSize": volume_size,
                      "InstanceId": self.id,
                      "ImageId": image_id,
                      "DatastoreManager": datastore_manager,
                      "AvailabilityZone": availability_zone}
        stack_name = 'trove-%s' % self.id
        client.stacks.create(stack_name=stack_name,
                             template=heat_template,
                             parameters=parameters)
        stack = client.stacks.get(stack_name)

        utils.poll_until(
            lambda: client.stacks.get(stack_name),
            lambda stack: stack.stack_status in ['CREATE_COMPLETE',
                                                 'CREATE_FAILED'],
            sleep_time=2,
            time_out=HEAT_TIME_OUT)

        resource = client.resources.get(stack.id, 'BaseInstance')
        server = novaclient.servers.get(resource.physical_resource_id)

        if CONF.trove_volume_support:
            cinderclient = create_cinder_client(self.context)
            resource = client.resources.get(stack.id, 'DataVolume')
            volume = cinderclient.volumes.get(resource.physical_resource_id)
            volume_info = self._build_volume(volume)
            self.update_db(compute_instance_id=server.id, volume_id=volume.id)
        else:
            volume_info = self._build_volume_info(volume_size)
            self.update_db(compute_instance_id=server.id)

        LOG.debug(_("end _create_server_volume_heat for id: %s") % self.id)
        return server, volume_info
开发者ID:abansal,项目名称:trove,代码行数:49,代码来源:models.py

示例9: allowed_datastore_version_volume_types

    def allowed_datastore_version_volume_types(cls, context,
                                               datastore_name,
                                               datastore_version_name):
        """
        List all allowed volume types for a given datastore and
        datastore version. If datastore version metadata is
        provided, then the valid volume types in that list are
        allowed. If datastore version metadata is not provided
        then all volume types known to cinder are allowed.
        """
        if datastore_name and datastore_version_name:
            # first obtain the list in the dsvmetadata
            datastore_version_id = cls._datastore_version_find(
                datastore_name, datastore_version_name)

            metadata = cls.list_datastore_version_volume_type_associations(
                datastore_version_id)

            # then get the list from cinder
            cinder_volume_types = remote.create_cinder_client(
                context).volume_types.list()

            # if there's metadata: intersect,
            # else, whatever cinder has.
            if (metadata.count() != 0):
                # the volume types from metadata first
                volume_types = tuple(f.value for f in metadata)

                # Cinder volume type names are unique, intersect
                ds_volume_types = (f for f in cinder_volume_types
                                   if ((f.name in volume_types) or
                                       (f.id in volume_types)))
                allowed_volume_types = tuple(
                    volume_type_model(volume_type=item)
                    for item in ds_volume_types)
            else:
                allowed_volume_types = tuple(
                    volume_type_model(volume_type=item)
                    for item in cinder_volume_types)

            return allowed_volume_types
        else:
            msg = _("Specify the datastore_name and datastore_version_name.")
            raise exception.BadRequest(msg)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:44,代码来源:models.py

示例10: _create_volume

    def _create_volume(self, volume_size):
        LOG.info("Entering create_volume")
        LOG.debug(_("Starting to create the volume for the instance"))

        volume_client = create_cinder_client(self.context)
        volume_desc = ("mysql volume for %s" % self.id)
        volume_ref = volume_client.volumes.create(
            volume_size, name="mysql-%s" % self.id, description=volume_desc)

        # Record the volume ID in case something goes wrong.
        self.update_db(volume_id=volume_ref.id)

        utils.poll_until(
            lambda: volume_client.volumes.get(volume_ref.id),
            lambda v_ref: v_ref.status in ['available', 'error'],
            sleep_time=2,
            time_out=VOLUME_TIME_OUT)

        v_ref = volume_client.volumes.get(volume_ref.id)
        if v_ref.status in ['error']:
            raise VolumeCreationFailure()
        LOG.debug(_("Created volume %s") % v_ref)
        # The mapping is in the format:
        # <id>:[<type>]:[<size(GB)>]:[<delete_on_terminate>]
        # setting the delete_on_terminate instance to true=1
        mapping = "%s:%s:%s:%s" % (v_ref.id, '', v_ref.size, 1)
        bdm = CONF.block_device_mapping
        block_device = {bdm: mapping}
        volumes = [{'id': v_ref.id,
                    'size': v_ref.size}]
        LOG.debug("block_device = %s" % block_device)
        LOG.debug("volume = %s" % volumes)

        device_path = CONF.device_path
        mount_point = CONF.mount_point
        LOG.debug(_("device_path = %s") % device_path)
        LOG.debug(_("mount_point = %s") % mount_point)

        volume_info = {'block_device': block_device,
                       'device_path': device_path,
                       'mount_point': mount_point,
                       'volumes': volumes}
        return volume_info
开发者ID:hub-cap,项目名称:trove,代码行数:43,代码来源:models.py

示例11: __init__

    def __init__(self, volume_type=None, context=None, volume_type_id=None):
        """
        Initialize the volume type either from the volume_type parameter, or
        by querying cinder using the context provided.
        """

        if volume_type and not (volume_type_id or context):
            self.volume_type = volume_type
        elif volume_type_id and context:
            try:
                client = create_cinder_client(context)
                self.volume_type = client.volume_types.get(volume_type_id)
            except cinder_exception.NotFound:
                raise trove_exception.NotFound(uuid=volume_type_id)
            except cinder_exception.ClientException as ce:
                raise trove_exception.TroveError(str(ce))

            return
        else:
            raise trove_exception.InvalidModelError(
                errors="An invalid set of arguments were provided.")
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:21,代码来源:models.py

示例12: _create_volume

    def _create_volume(self, volume_size):
        LOG.info("Entering create_volume")
        LOG.debug(_("begin _create_volume for id: %s") % self.id)
        volume_client = create_cinder_client(self.context)
        volume_desc = ("mysql volume for %s" % self.id)
        volume_ref = volume_client.volumes.create(
            volume_size, name="mysql-%s" % self.id, description=volume_desc)

        # Record the volume ID in case something goes wrong.
        self.update_db(volume_id=volume_ref.id)

        utils.poll_until(
            lambda: volume_client.volumes.get(volume_ref.id),
            lambda v_ref: v_ref.status in ['available', 'error'],
            sleep_time=2,
            time_out=VOLUME_TIME_OUT)

        v_ref = volume_client.volumes.get(volume_ref.id)
        if v_ref.status in ['error']:
            raise VolumeCreationFailure()
        LOG.debug(_("end _create_volume for id: %s") % self.id)
        return self._build_volume(v_ref)
开发者ID:adamfokken,项目名称:trove,代码行数:22,代码来源:models.py

示例13: _create_volume

    def _create_volume(self, volume_size):
        LOG.info("Entering create_volume")
        LOG.debug(_("Starting to create the volume for the instance"))

        volume_client = create_cinder_client(self.context)
        volume_desc = "mysql volume for %s" % self.id
        volume_ref = volume_client.volumes.create(volume_size, name="mysql-%s" % self.id, description=volume_desc)

        # Record the volume ID in case something goes wrong.
        self.update_db(volume_id=volume_ref.id)

        utils.poll_until(
            lambda: volume_client.volumes.get(volume_ref.id),
            lambda v_ref: v_ref.status in ["available", "error"],
            sleep_time=2,
            time_out=VOLUME_TIME_OUT,
        )

        v_ref = volume_client.volumes.get(volume_ref.id)
        if v_ref.status in ["error"]:
            raise VolumeCreationFailure()
        return self._build_volume(v_ref)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:22,代码来源:models.py

示例14: volume_client

 def volume_client(self):
     if not self._volume_client:
         self._volume_client = create_cinder_client(self.context)
     return self._volume_client
开发者ID:cretta,项目名称:trove,代码行数:4,代码来源:models.py

示例15: get_client

 def get_client(cls, context):
     return remote.create_cinder_client(context)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:2,代码来源:models.py


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