• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_id_from_href函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_LI("Creating a database instance for tenant '%s'"),
                 tenant_id)
        LOG.debug("req : '%s'\n\n", strutils.mask_password(req))
        LOG.debug("body : '%s'\n\n", strutils.mask_password(body))
        context = req.environ[wsgi.CONTEXT_KEY]
        context.notification = notification.DBaaSInstanceCreate(context,
                                                                request=req)
        datastore_args = body['instance'].get('datastore', {})
        datastore, datastore_version = (
            datastore_models.get_datastore_version(**datastore_args))
        image_id = datastore_version.image_id
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)

        configuration = self._configuration_parse(context, body)
        databases = populate_validated_databases(
            body['instance'].get('databases', []))
        database_names = [database.get('_name', '') for database in databases]
        users = None
        try:
            users = populate_users(body['instance'].get('users', []),
                                   database_names)
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)

        if 'volume' in body['instance']:
            volume_info = body['instance']['volume']
            volume_size = int(volume_info['size'])
            volume_type = volume_info.get('type')
        else:
            volume_size = None
            volume_type = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)
        else:
            backup_id = None

        availability_zone = body['instance'].get('availability_zone')
        nics = body['instance'].get('nics')

        slave_of_id = body['instance'].get('replica_of',
                                           # also check for older name
                                           body['instance'].get('slave_of'))
        replica_count = body['instance'].get('replica_count')
        instance = models.Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          datastore, datastore_version,
                                          volume_size, backup_id,
                                          availability_zone, nics,
                                          configuration, slave_of_id,
                                          replica_count=replica_count,
                                          volume_type=volume_type)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:60,代码来源:service.py


示例2: create

    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
        LOG.info(logging.mask_password(_("req : '%s'\n\n") % req))
        LOG.info(logging.mask_password(_("body : '%s'\n\n") % body))
        context = req.environ[wsgi.CONTEXT_KEY]
        datastore_args = body['instance'].get('datastore', {})
        datastore, datastore_version = (
            datastore_models.get_datastore_version(**datastore_args))
        image_id = datastore_version.image_id
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)

        configuration = self._configuration_parse(context, body)
        databases = populate_validated_databases(
            body['instance'].get('databases', []))
        database_names = [database.get('_name', '') for database in databases]
        users = None
        try:
            users = populate_users(body['instance'].get('users', []),
                                   database_names)
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)

        if 'volume' in body['instance']:
            volume_size = int(body['instance']['volume']['size'])
        else:
            volume_size = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)
        else:
            backup_id = None

        if 'availability_zone' in body['instance']:
            availability_zone = body['instance']['availability_zone']
        else:
            availability_zone = None

        if 'nics' in body['instance']:
            nics = body['instance']['nics']
        else:
            nics = None

        if 'slave_of' in body['instance']:
            slave_of_id = body['instance']['slave_of']
        else:
            slave_of_id = None

        instance = models.Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          datastore, datastore_version,
                                          volume_size, backup_id,
                                          availability_zone, nics,
                                          configuration, slave_of_id)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
开发者ID:B-Rich,项目名称:trove,代码行数:60,代码来源:service.py


示例3: create

    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)
        context = req.environ[wsgi.CONTEXT_KEY]
        # Set the service type to mysql if its not in the request
        service_type = body["instance"].get("service_type") or CONF.service_type
        service = models.ServiceImage.find_by(service_name=service_type)
        image_id = service["image_id"]
        name = body["instance"]["name"]
        flavor_ref = body["instance"]["flavorRef"]
        flavor_id = utils.get_id_from_href(flavor_ref)
        databases = populate_validated_databases(body["instance"].get("databases", []))
        users = None
        try:
            users = populate_users(body["instance"].get("users", []))
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)

        if "volume" in body["instance"]:
            volume_size = int(body["instance"]["volume"]["size"])
        else:
            volume_size = None

        if "restorePoint" in body["instance"]:
            backupRef = body["instance"]["restorePoint"]["backupRef"]
            backup_id = utils.get_id_from_href(backupRef)
        else:
            backup_id = None

        if "availability_zone" in body["instance"]:
            availability_zone = body["instance"]["availability_zone"]
        else:
            availability_zone = None

        instance = models.Instance.create(
            context,
            name,
            flavor_id,
            image_id,
            databases,
            users,
            service_type,
            volume_size,
            backup_id,
            availability_zone,
        )

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:51,代码来源:service.py


示例4: _create_resources

        def _create_resources():
            # parse the ID from the Ref
            instance_id = utils.get_id_from_href(instance)

            # verify that the instance exists and can perform actions
            from trove.instance.models import Instance
            instance_model = Instance.load(context, instance_id)
            instance_model.validate_can_perform_action()

            cls.verify_swift_auth_token(context)

            try:
                db_info = DBBackup.create(name=name,
                                          description=description,
                                          tenant_id=context.tenant,
                                          state=BackupState.NEW,
                                          instance_id=instance_id,
                                          deleted=False)
            except exception.InvalidModelError as ex:
                LOG.exception("Unable to create Backup record:")
                raise exception.BackupCreationError(str(ex))

            backup_info = {'id': db_info.id,
                           'name': name,
                           'description': description,
                           'instance_id': instance_id,
                           'backup_type': db_info.backup_type,
                           'checksum': db_info.checksum,
                           }
            api.API(context).create_backup(backup_info, instance_id)
            return db_info
开发者ID:mlowery,项目名称:trove,代码行数:31,代码来源:models.py


示例5: _parse_grow_item

    def _parse_grow_item(self, item):
        used_keys = []

        def _check_option(key, required=False, valid_values=None):
            if required and key not in item:
                raise exception.TroveError(
                    _("An instance with the options %(given)s is missing " "the MongoDB required option %(expected)s.")
                    % {"given": item.keys(), "expected": key}
                )
            value = item.get(key, None)
            if valid_values and value not in valid_values:
                raise exception.TroveError(
                    _("The value %(value)s for key %(key)s is invalid. " "Allowed values are %(valid)s.")
                    % {"value": value, "key": key, "valid": valid_values}
                )
            used_keys.append(key)
            return value

        flavor_id = utils.get_id_from_href(_check_option("flavorRef", required=True))
        volume_size = int(_check_option("volume", required=True)["size"])
        instance_type = _check_option("type", required=True, valid_values=["replica", "query_router"])
        name = _check_option("name")
        related_to = _check_option("related_to")

        unused_keys = list(set(item.keys()).difference(set(used_keys)))
        if unused_keys:
            raise exception.TroveError(_("The arguments %s are not supported by MongoDB.") % unused_keys)

        instance = {"flavor_id": flavor_id, "volume_size": volume_size, "instance_type": instance_type}
        if name:
            instance["name"] = name
        if related_to:
            instance["related_to"] = related_to
        return instance
开发者ID:magictour,项目名称:trove,代码行数:34,代码来源:api.py


示例6: action

 def action(self, context, req, action, param):
     if action == 'grow':
         context.notification = DBaaSClusterGrow(context, request=req)
         with StartNotification(context, cluster_id=self.id):
             instances = []
             for node in param:
                 instance = {
                     'flavor_id': utils.get_id_from_href(node['flavorRef'])
                 }
                 if 'name' in node:
                     instance['name'] = node['name']
                 if 'volume' in node:
                     instance['volume_size'] = int(node['volume']['size'])
                 if 'modules' in node:
                     instance['modules'] = node['modules']
                 if 'nics' in node:
                     instance['nics'] = node['nics']
                 if 'availability_zone' in node:
                     instance['availability_zone'] = (
                         node['availability_zone'])
                 instances.append(instance)
             return self.grow(instances)
     elif action == 'shrink':
         context.notification = DBaaSClusterShrink(context, request=req)
         with StartNotification(context, cluster_id=self.id):
             instance_ids = [instance['id'] for instance in param]
             return self.shrink(instance_ids)
     else:
         raise exception.BadRequest(_("Action %s not supported") % action)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:29,代码来源:models.py


示例7: create

    def create(self, req, body, tenant_id):
        # TODO(hub-cap): turn this into middleware
        LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)
        context = req.environ[wsgi.CONTEXT_KEY]
        # Set the service type to mysql if its not in the request
        service_type = (body['instance'].get('service_type') or
                        CONF.service_type)
        service = models.ServiceImage.find_by(service_name=service_type)
        image_id = service['image_id']
        name = body['instance']['name']
        flavor_ref = body['instance']['flavorRef']
        flavor_id = utils.get_id_from_href(flavor_ref)
        databases = populate_validated_databases(
            body['instance'].get('databases', []))
        database_names = [database.get('_name', '') for database in databases]
        users = None
        try:
            users = populate_users(body['instance'].get('users', []),
                                   database_names)
        except ValueError as ve:
            raise exception.BadRequest(msg=ve)

        if 'volume' in body['instance']:
            volume_size = int(body['instance']['volume']['size'])
        else:
            volume_size = None

        if 'restorePoint' in body['instance']:
            backupRef = body['instance']['restorePoint']['backupRef']
            backup_id = utils.get_id_from_href(backupRef)
        else:
            backup_id = None

        if 'availability_zone' in body['instance']:
            availability_zone = body['instance']['availability_zone']
        else:
            availability_zone = None

        instance = models.Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          service_type, volume_size,
                                          backup_id, availability_zone)

        view = views.InstanceDetailView(instance, req=req)
        return wsgi.Result(view.data(), 200)
开发者ID:ReVolly,项目名称:trove,代码行数:47,代码来源:service.py


示例8: _action_resize_flavor

 def _action_resize_flavor(self, context, req, instance, flavorRef):
     context.notification = notification.DBaaSInstanceResizeInstance(
         context, request=req)
     new_flavor_id = utils.get_id_from_href(flavorRef)
     with StartNotification(context, instance_id=instance.id,
                            new_flavor_id=new_flavor_id):
         instance.resize_flavor(new_flavor_id)
     return wsgi.Result(None, 202)
开发者ID:Hopebaytech,项目名称:trove,代码行数:8,代码来源:service.py


示例9: _parse_grow_item

    def _parse_grow_item(self, item):
        used_keys = []

        def _check_option(key, required=False, valid_values=None,
                          flatten_value=False):
            if required and key not in item:
                raise exception.TroveError(
                    _('An instance with the options %(given)s is missing '
                      'the MongoDB required option %(expected)s.')
                    % {'given': item.keys(), 'expected': key}
                )
            value = item.get(key, None)
            if value and flatten_value and isinstance(value, list):
                value = ','.join(value)
            if valid_values and value not in valid_values:
                raise exception.TroveError(
                    _("The value '%(value)s' for key '%(key)s' is invalid. "
                      "Allowed values are %(valid)s.")
                    % {'value': value, 'key': key, 'valid': valid_values}
                )
            used_keys.append(key)
            return value

        flavor_id = utils.get_id_from_href(_check_option('flavorRef',
                                                         required=True))
        volume_size = int(_check_option('volume', required=True)['size'])
        instance_type = _check_option('type', required=True,
                                      valid_values=['replica',
                                                    'query_router'],
                                      flatten_value=True)
        name = _check_option('name')
        related_to = _check_option('related_to')
        nics = _check_option('nics')
        availability_zone = _check_option('availability_zone')

        unused_keys = list(set(item.keys()).difference(set(used_keys)))
        if unused_keys:
            raise exception.TroveError(
                _('The arguments %s are not supported by MongoDB.')
                % unused_keys
            )

        instance = {'flavor_id': flavor_id,
                    'volume_size': volume_size,
                    'instance_type': instance_type}
        if name:
            instance['name'] = name
        if related_to:
            instance['related_to'] = related_to
        if nics:
            instance['nics'] = nics
        if availability_zone:
            instance['availability_zone'] = availability_zone
        return instance
开发者ID:Tesora,项目名称:tesora-trove,代码行数:54,代码来源:api.py


示例10: _action_grow_cluster

 def _action_grow_cluster(self, cluster, body):
     nodes = body["grow"]
     instances = []
     for node in nodes:
         instance = {"flavor_id": utils.get_id_from_href(node["flavorRef"])}
         if "name" in node:
             instance["name"] = node["name"]
         if "volume" in node:
             instance["volume_size"] = int(node["volume"]["size"])
         instances.append(instance)
     return cluster.grow(instances)
开发者ID:vmazur,项目名称:trove,代码行数:11,代码来源:api.py


示例11: _action_grow_cluster

 def _action_grow_cluster(self, cluster, body):
     nodes = body['grow']
     instances = []
     for node in nodes:
         instance = {
             'flavor_id': utils.get_id_from_href(node['flavorRef'])
         }
         if 'name' in node:
             instance['name'] = node['name']
         instances.append(instance)
     return cluster.grow(instances)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:11,代码来源:api.py


示例12: create

    def create(self, req, body, tenant_id):
        LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)

        context = req.environ[wsgi.CONTEXT_KEY]
        name = body['cluster']['name']
        datastore_args = body['cluster'].get('datastore', {})
        datastore, datastore_version = (
            datastore_models.get_datastore_version(**datastore_args))

        # TODO(saurabhs): add extended_properties to apischema
        extended_properties = body['cluster'].get('extended_properties', {})

        try:
            clusters_enabled = (CONF.get(datastore_version.manager)
                                .get('cluster_support'))
        except NoSuchOptError:
            clusters_enabled = False

        if not clusters_enabled:
            raise exception.ClusterDatastoreNotSupported(
                datastore=datastore.name,
                datastore_version=datastore_version.name)

        nodes = body['cluster']['instances']
        instances = []
        for node in nodes:
            flavor_id = utils.get_id_from_href(node['flavorRef'])
            volume_size = volume_type = nics = availability_zone = None
            if 'volume' in node:
                volume_size = int(node['volume']['size'])
                volume_type = node['volume'].get('volume_type')
            if 'nics' in node:
                nics = node['nics']
            if 'availability_zone' in node:
                availability_zone = node['availability_zone']

            instances.append({"flavor_id": flavor_id,
                              "volume_size": volume_size,
                              "volume_type": volume_type,
                              "nics": nics,
                              "availability_zone": availability_zone})

        context.notification = notification.DBaaSClusterCreate(context,
                                                               request=req)
        with StartNotification(context, name=name, datastore=datastore.name,
                               datastore_version=datastore_version.name):
            cluster = models.Cluster.create(context, name, datastore,
                                            datastore_version, instances,
                                            extended_properties)
        view = views.load_view(cluster, req=req, load_servers=False)
        return wsgi.Result(view.data(), 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:53,代码来源:service.py


示例13: _create_resources

        def _create_resources():
            # parse the ID from the Ref
            instance_id = utils.get_id_from_href(instance)

            # verify that the instance exists and can perform actions
            from trove.instance.models import Instance
            instance_model = Instance.load(context, instance_id)
            instance_model.validate_can_perform_action()
            cls.validate_can_perform_action(
                instance_model, 'backup_create')
            cls.verify_swift_auth_token(context)
            if instance_model.cluster_id is not None:
                raise exception.ClusterInstanceOperationNotSupported()

            ds = instance_model.datastore
            ds_version = instance_model.datastore_version
            parent = None
            if parent_id:
                # Look up the parent info or fail early if not found or if
                # the user does not have access to the parent.
                _parent = cls.get_by_id(context, parent_id)
                parent = {
                    'location': _parent.location,
                    'checksum': _parent.checksum,
                }
            try:
                db_info = DBBackup.create(name=name,
                                          description=description,
                                          tenant_id=context.tenant,
                                          state=BackupState.NEW,
                                          instance_id=instance_id,
                                          parent_id=parent_id,
                                          datastore_version_id=ds_version.id,
                                          deleted=False)
            except exception.InvalidModelError as ex:
                LOG.exception(_("Unable to create backup record for "
                                "instance: %s"), instance_id)
                raise exception.BackupCreationError(str(ex))

            backup_info = {'id': db_info.id,
                           'name': name,
                           'description': description,
                           'instance_id': instance_id,
                           'backup_type': db_info.backup_type,
                           'checksum': db_info.checksum,
                           'parent': parent,
                           'datastore': ds.name,
                           'datastore_version': ds_version.name,
                           }
            api.API(context).create_backup(backup_info, instance_id)
            return db_info
开发者ID:Hopebaytech,项目名称:trove,代码行数:51,代码来源:models.py


示例14: _action_grow_cluster

 def _action_grow_cluster(self, cluster, body):
     nodes = body['grow']
     instances = []
     for node in nodes:
         instance = {
             'flavor_id': utils.get_id_from_href(node['flavorRef'])
         }
         if 'name' in node:
             instance['name'] = node['name']
         if 'volume' in node:
             instance['volume_size'] = int(node['volume']['size'])
         if 'nics' in node:
             instance['nics'] = node['nics']
         if 'availability_zone' in node:
             instance['availability_zone'] = node['availability_zone']
         instances.append(instance)
     return cluster.grow(instances)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:17,代码来源:api.py


示例15: create

    def create(self, req, body, tenant_id):
        LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)

        context = req.environ[wsgi.CONTEXT_KEY]
        name = body["cluster"]["name"]
        datastore_args = body["cluster"].get("datastore", {})
        datastore, datastore_version = datastore_models.get_datastore_version(**datastore_args)

        try:
            clusters_enabled = CONF.get(datastore_version.manager).get("cluster_support")
        except NoSuchOptError:
            clusters_enabled = False

        if not clusters_enabled:
            raise exception.ClusterDatastoreNotSupported(
                datastore=datastore.name, datastore_version=datastore_version.name
            )

        nodes = body["cluster"]["instances"]
        instances = []
        for node in nodes:
            flavor_id = utils.get_id_from_href(node["flavorRef"])
            volume_size = nics = availability_zone = None
            if "volume" in node:
                volume_size = int(node["volume"]["size"])
            if "nics" in node:
                nics = node["nics"]
            if "availability_zone" in node:
                availability_zone = node["availability_zone"]

            instances.append(
                {
                    "flavor_id": flavor_id,
                    "volume_size": volume_size,
                    "nics": nics,
                    "availability_zone": availability_zone,
                }
            )

        cluster = models.Cluster.create(context, name, datastore, datastore_version, instances)
        view = views.load_view(cluster, req=req, load_servers=False)
        return wsgi.Result(view.data(), 200)
开发者ID:henrylv206,项目名称:trove,代码行数:44,代码来源:service.py


示例16: _create_resources

        def _create_resources():
            # parse the ID from the Ref
            instance_id = utils.get_id_from_href(instance)

            # verify that the instance exists and can perform actions
            from trove.instance.models import Instance

            instance_model = Instance.load(context, instance_id)
            instance_model.validate_can_perform_action()

            cls.verify_swift_auth_token(context)

            parent = None
            if parent_id:
                # Look up the parent info or fail early if not found or if
                # the user does not have access to the parent.
                _parent = cls.get_by_id(context, parent_id)
                parent = {"location": _parent.location, "checksum": _parent.checksum}
            try:
                db_info = DBBackup.create(
                    name=name,
                    description=description,
                    tenant_id=context.tenant,
                    state=BackupState.NEW,
                    instance_id=instance_id,
                    parent_id=parent_id,
                    deleted=False,
                )
            except exception.InvalidModelError as ex:
                LOG.exception("Unable to create Backup record:")
                raise exception.BackupCreationError(str(ex))

            backup_info = {
                "id": db_info.id,
                "name": name,
                "description": description,
                "instance_id": instance_id,
                "backup_type": db_info.backup_type,
                "checksum": db_info.checksum,
                "parent": parent,
            }
            api.API(context).create_backup(backup_info, instance_id)
            return db_info
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:43,代码来源:models.py


示例17: action

 def action(self, context, req, action, param):
     if action == "grow":
         context.notification = DBaaSClusterGrow(context, request=req)
         with StartNotification(context, cluster_id=self.id):
             instances = []
             for node in param:
                 instance = {"flavor_id": utils.get_id_from_href(node["flavorRef"])}
                 if "name" in node:
                     instance["name"] = node["name"]
                 if "volume" in node:
                     instance["volume_size"] = int(node["volume"]["size"])
                 instances.append(instance)
             return self.grow(instances)
     elif action == "shrink":
         context.notification = DBaaSClusterShrink(context, request=req)
         with StartNotification(context, cluster_id=self.id):
             instance_ids = [instance["id"] for instance in param]
             return self.shrink(instance_ids)
     else:
         raise exception.BadRequest(_("Action %s not supported") % action)
开发者ID:mmasaki,项目名称:trove,代码行数:20,代码来源:models.py


示例18: create

    def create(self, req, body, tenant_id):
        LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)

        context = req.environ[wsgi.CONTEXT_KEY]
        name = body['cluster']['name']
        datastore_args = body['cluster'].get('datastore', {})
        datastore, datastore_version = (
            datastore_models.get_datastore_version(**datastore_args))

        try:
            clusters_enabled = (CONF.get(datastore_version.manager)
                                .get('cluster_support'))
        except NoSuchOptError:
            clusters_enabled = False

        if not clusters_enabled:
            raise exception.ClusterDatastoreNotSupported(
                datastore=datastore.name,
                datastore_version=datastore_version.name)

        nodes = body['cluster']['instances']
        instances = []
        for node in nodes:
            flavor_id = utils.get_id_from_href(node['flavorRef'])
            if 'volume' in node:
                volume_size = int(node['volume']['size'])
            else:
                volume_size = None
            instances.append({"flavor_id": flavor_id,
                              "volume_size": volume_size})

        cluster = models.Cluster.create(context, name, datastore,
                                        datastore_version, instances)
        view = views.load_view(cluster, req=req, load_servers=False)
        return wsgi.Result(view.data(), 200)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:37,代码来源:service.py


示例19: _configuration_parse

 def _configuration_parse(self, context, body):
     if 'configuration' in body['instance']:
         configuration_ref = body['instance']['configuration']
         if configuration_ref:
             configuration_id = utils.get_id_from_href(configuration_ref)
             return configuration_id
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:6,代码来源:service.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.import_class函数代码示例发布时间:2022-05-27
下一篇:
Python utils.generate_uuid函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap