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

Python utils.generate_uuid函数代码示例

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

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



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

示例1: setUp

 def setUp(self):
     super(OrderingTests, self).setUp()
     util.init_db()
     now = utils.utcnow()
     self.context, self.instance_id = _prep_conf(now)
     info = {
         'tenant_id': self.context.tenant,
         'state': BACKUP_STATE,
         'instance_id': self.instance_id,
         'size': 2.0,
         'deleted': False
     }
     four = now - datetime.timedelta(days=4)
     one = now - datetime.timedelta(days=1)
     three = now - datetime.timedelta(days=3)
     two = now - datetime.timedelta(days=2)
     # Create backups out of order, save/create set the 'updated' field,
     # so we need to use the db_api directly.
     models.DBBackup().db_api.save(
         models.DBBackup(name='four', updated=four,
                         id=utils.generate_uuid(), **info))
     models.DBBackup().db_api.save(
         models.DBBackup(name='one', updated=one,
                         id=utils.generate_uuid(), **info))
     models.DBBackup().db_api.save(
         models.DBBackup(name='three', updated=three,
                         id=utils.generate_uuid(), **info))
     models.DBBackup().db_api.save(
         models.DBBackup(name='two', updated=two,
                         id=utils.generate_uuid(), **info))
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:30,代码来源:test_backup_models.py


示例2: test_cluster_root_create

 def test_cluster_root_create(self, root_create, root_history_create):
     context = Mock()
     uuid = utils.generate_uuid()
     user = "root"
     password = "rootpassword"
     cluster_instances = [utils.generate_uuid(), utils.generate_uuid()]
     common_models.ClusterRoot.create(context, uuid, user, password, cluster_instances)
     root_create.assert_called_with(context, uuid, user, password, cluster_instances_list=None)
     self.assertEqual(2, root_history_create.call_count)
     calls = [call(context, cluster_instances[0], user), call(context, cluster_instances[1], user)]
     root_history_create.assert_has_calls(calls)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:11,代码来源:test_models.py


示例3: _create_backup

 def _create_backup(self, name='fake backup'):
     new_id = utils.generate_uuid()
     backup = bkup_models.DBBackup.create(
         id=new_id,
         name=name,
         description='This is a fake backup object.',
         tenant_id=utils.generate_uuid(),
         state=state.BackupState.NEW,
         instance_id=self.instance_id)
     backup.save()
     return new_id
开发者ID:arisu1000,项目名称:trove,代码行数:11,代码来源:test_methods.py


示例4: test_get_cluster_instance_id

 def test_get_cluster_instance_id(self, mock_find_all):
     tenant_id = Mock()
     cluster_id = Mock()
     db_inst_1 = Mock()
     db_inst_1.id.return_value = utils.generate_uuid()
     db_inst_2 = Mock()
     db_inst_2.id.return_value = utils.generate_uuid()
     cluster_instances = [db_inst_1, db_inst_2]
     mock_find_all.return_value.all.return_value = cluster_instances
     ret = self.controller._get_cluster_instance_id(tenant_id, cluster_id)
     self.assertTrue(db_inst_1.id, ret[0])
     self.assertTrue(cluster_instances, ret[1])
开发者ID:Hopebaytech,项目名称:trove,代码行数:12,代码来源:test_common_extensions.py


示例5: test_log_save_fresh

 def test_log_save_fresh(self):
     self.cleanup_swift()
     f = '/tmp/' + generate_uuid() + '.log'
     f2 = self.instances.log_save(instance_info.id, log='error',
                                  publish=True, filename=f)
     assert_equal(f, f2)
     copied = '/tmp/' + generate_uuid() + '.log'
     logfile = MySQLGuestLog.datastore_logs['error'][2]
     # TODO(atomic77) How to tell what user the tests should use on GA?
     self.server.scp(logfile, copied, user='fedora',
                     dest_is_remote=False)
     self.compare_files(f, copied)
     utils.execute_with_timeout("rm", f)
     utils.execute_with_timeout("rm", copied)
开发者ID:Tesora-Release,项目名称:tesora-trove,代码行数:14,代码来源:guest_log.py


示例6: add_shard

    def add_shard(self):

        if self.db_info.task_status != ClusterTasks.NONE:
            current_task = self.db_info.task_status.name
            msg = _("This action cannot be performed on the cluster while "
                    "the current cluster task is '%s'.") % current_task
            LOG.error(msg)
            raise exception.UnprocessableEntity(msg)

        db_insts = inst_models.DBInstance.find_all(cluster_id=self.id,
                                                   type='member').all()
        num_unique_shards = len(set([db_inst.shard_id for db_inst
                                     in db_insts]))
        if num_unique_shards == 0:
            msg = _("This action cannot be performed on the cluster as no "
                    "reference shard exists.")
            LOG.error(msg)
            raise exception.UnprocessableEntity(msg)

        arbitrary_shard_id = db_insts[0].shard_id
        members_in_shard = [db_inst for db_inst in db_insts
                            if db_inst.shard_id == arbitrary_shard_id]
        num_members_per_shard = len(members_in_shard)
        a_member = inst_models.load_any_instance(self.context,
                                                 members_in_shard[0].id)
        deltas = {'instances': num_members_per_shard}
        volume_size = a_member.volume_size
        if volume_size:
            deltas['volumes'] = volume_size * num_members_per_shard
        check_quotas(self.context.tenant, deltas)
        new_replica_set_name = "rs" + str(num_unique_shards + 1)
        new_shard_id = utils.generate_uuid()
        dsv_manager = (datastore_models.DatastoreVersion.
                       load_by_uuid(db_insts[0].datastore_version_id).manager)
        manager = task_api.load(self.context, dsv_manager)
        key = manager.get_key(a_member)
        member_config = {"id": self.id,
                         "shard_id": new_shard_id,
                         "instance_type": "member",
                         "replica_set_name": new_replica_set_name,
                         "key": key}
        for i in range(1, num_members_per_shard + 1):
            instance_name = "%s-%s-%s" % (self.name, new_replica_set_name,
                                          str(i))
            inst_models.Instance.create(self.context, instance_name,
                                        a_member.flavor_id,
                                        a_member.datastore_version.image_id,
                                        [], [], a_member.datastore,
                                        a_member.datastore_version,
                                        volume_size, None,
                                        availability_zone=None,
                                        nics=None,
                                        configuration_id=None,
                                        cluster_config=member_config)

        self.update_db(task_status=ClusterTasks.ADDING_SHARD)
        manager.mongodb_add_shard_cluster(
            self.id,
            new_shard_id,
            new_replica_set_name)
开发者ID:fabian4,项目名称:trove,代码行数:60,代码来源:api.py


示例7: test_instance_root_index

 def test_instance_root_index(self, mock_cluster_root_load):
     req = Mock()
     req.environ = {'trove.context': self.context}
     tenant_id = Mock()
     instance_id = utils.generate_uuid()
     self.controller.instance_root_index(req, tenant_id, instance_id)
     mock_cluster_root_load.assert_called_with(self.context, instance_id)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:7,代码来源:test_common_extensions.py


示例8: run_backup_create_instance_not_found

 def run_backup_create_instance_not_found(
         self, expected_exception=exceptions.NotFound,
         expected_http_code=404):
     self.assert_raises(
         expected_exception, expected_http_code,
         self.auth_client.backups.create,
         self.BACKUP_NAME, generate_uuid(), self.BACKUP_DESC)
开发者ID:melvinj1123,项目名称:trove,代码行数:7,代码来源:backup_runners.py


示例9: test_root_index_instance

 def test_root_index_instance(self, mock_instance_root_index):
     req = Mock()
     tenant_id = Mock()
     uuid = utils.generate_uuid()
     is_cluster = False
     self.controller.root_index(req, tenant_id, uuid, is_cluster)
     mock_instance_root_index.assert_called_with(req, tenant_id, uuid)
开发者ID:Hopebaytech,项目名称:trove,代码行数:7,代码来源:test_common_extensions.py


示例10: _create_shard_instances

 def _create_shard_instances(self, instances, replica_set_name=None, key=None):
     """Create the instances for a new shard in the cluster."""
     shard_id = utils.generate_uuid()
     if not replica_set_name:
         replica_set_name = self._gen_replica_set_name()
     cluster_config = {"shard_id": shard_id, "instance_type": "member", "replica_set_name": replica_set_name}
     return self._create_instances(instances, cluster_config, replica_set_name, key=key)
开发者ID:magictour,项目名称:trove,代码行数:7,代码来源:api.py


示例11: create_or_update_datastore_configuration_parameter

def create_or_update_datastore_configuration_parameter(name,
                                                       datastore_version_id,
                                                       restart_required,
                                                       data_type,
                                                       max_size,
                                                       min_size):
    get_db_api().configure_db(CONF)
    datastore_version = dstore_models.DatastoreVersion.load_by_uuid(
        datastore_version_id)
    try:
        config = DatastoreConfigurationParameters.load_parameter_by_name(
            datastore_version_id, name, show_deleted=True)
        config.restart_required = restart_required
        config.max_size = max_size
        config.min_size = min_size
        config.data_type = data_type
        get_db_api().save(config)
    except exception.NotFound:
        config = DBDatastoreConfigurationParameters(
            id=utils.generate_uuid(),
            name=name,
            datastore_version_id=datastore_version.id,
            restart_required=restart_required,
            data_type=data_type,
            max_size=max_size,
            min_size=min_size,
            deleted=False,
        )
        get_db_api().save(config)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:29,代码来源:models.py


示例12: _create

    def _create(self, req, body, tenant_id, instance_type):
        """return a SimpleInstance"""
        LOG.info(_("Creating database instance for tenant '%s'") % tenant_id)
        LOG.info(_("req : '%s'\n\n") % req)
        LOG.info(_("body : '%s'\n\n") % body)
        
 
        context, name, flavor_id,image_id, databases, users,\
            service_type, volume_size,backup_id, instance_type,\
            extend,master_id,template_config_id = self._get_create_param(req, body, instance_type)
            
        
#             @classmethod
#             def create(cls, context, name, flavor_id, image_id, databases, 
#                        users, service_type, volume_size, backup_id, instance_type, 
#                        extend=None, master_id=None):
        
        instance = pacth_inst_models.KSC_Instance.create(context, name, flavor_id,
                                          image_id, databases, users,
                                          service_type, volume_size,
                                          backup_id, instance_type,
                                          template_config_id,
                                          extend=extend, master_id=master_id)
        
        if instance_type in [InstanceType.HA, InstanceType.SG, InstanceType.RR]:
            vinst_id = utils.generate_uuid()
            InstanceVip.fake_allocate(context, instance.id, attached_virtual_instid = vinst_id)
        
        return instance   
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:29,代码来源:service.py


示例13: setUp

 def setUp(self):
     # See LP bug #1255178
     bkup_models.DBBackup.save = OLD_DBB_SAVE
     super(ConductorMethodTests, self).setUp()
     util.init_db()
     self.cond_mgr = conductor_manager.Manager()
     self.instance_id = utils.generate_uuid()
开发者ID:arisu1000,项目名称:trove,代码行数:7,代码来源:test_methods.py


示例14: run_attach_non_dynamic_group_to_non_existent_inst

 def run_attach_non_dynamic_group_to_non_existent_inst(
         self, expected_exception=exceptions.NotFound,
         expected_http_code=404):
     if self.non_dynamic_group_id:
         self.assert_instance_modify_failure(
             generate_uuid(), self.non_dynamic_group_id,
             expected_exception, expected_http_code)
开发者ID:Hopebaytech,项目名称:trove,代码行数:7,代码来源:configuration_runners.py


示例15: test_root_create_cluster

 def test_root_create_cluster(self, mock_cluster_root_create):
     req = Mock()
     body = Mock()
     tenant_id = Mock()
     uuid = utils.generate_uuid()
     is_cluster = True
     self.controller.root_create(req, body, tenant_id, uuid, is_cluster)
     mock_cluster_root_create.assert_called_with(req, body, tenant_id, uuid)
开发者ID:Hopebaytech,项目名称:trove,代码行数:8,代码来源:test_common_extensions.py


示例16: _create_iss

 def _create_iss(self):
     new_id = utils.generate_uuid()
     iss = t_models.InstanceServiceStatus(
         id=new_id,
         instance_id=self.instance_id,
         status=ServiceStatuses.NEW)
     iss.save()
     return new_id
开发者ID:arisu1000,项目名称:trove,代码行数:8,代码来源:test_methods.py


示例17: test_backup_instance_id_nomatch

 def test_backup_instance_id_nomatch(self):
     new_iid = utils.generate_uuid()
     bkup_id = self._create_backup('nomatch')
     old_name = self._get_backup(bkup_id).name
     self.cond_mgr.update_backup(None, new_iid, bkup_id,
                                 name="remains unchanged")
     bkup = self._get_backup(bkup_id)
     self.assertEqual(old_name, bkup.name)
开发者ID:arisu1000,项目名称:trove,代码行数:8,代码来源:test_methods.py


示例18: test_report_root_double_create

 def test_report_root_double_create(self):
     uuid = utils.generate_uuid()
     history = mysql_models.RootHistory(uuid, "root").save()
     mysql_models.RootHistory.load = Mock(return_value=history)
     report = mysql_models.RootHistory.create(None, uuid, "root")
     self.assertTrue(mysql_models.RootHistory.load.called)
     self.assertEqual(history.user, report.user)
     self.assertEqual(history.id, report.id)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:8,代码来源:test_models.py


示例19: test_instance_root_index

 def test_instance_root_index(self, mock_cluster_root_load):
     context = Mock()
     req = Mock()
     req.environ = Mock()
     req.environ.__getitem__ = Mock(return_value=context)
     tenant_id = Mock()
     instance_id = utils.generate_uuid()
     self.controller.instance_root_index(req, tenant_id, instance_id)
     mock_cluster_root_load.assert_called_with(context, instance_id)
开发者ID:Hopebaytech,项目名称:trove,代码行数:9,代码来源:test_common_extensions.py


示例20: __init__

 def __init__(self, tenant_id, resource, hard_limit,
              id=utils.generate_uuid(), created=utils.utcnow(),
              update=utils.utcnow()):
     self.tenant_id = tenant_id
     self.resource = resource
     self.hard_limit = hard_limit
     self.id = id
     self.created = created
     self.update = update
开发者ID:Hopebaytech,项目名称:trove,代码行数:9,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_id_from_href函数代码示例发布时间:2022-05-27
下一篇:
Python utils.generate_random_password函数代码示例发布时间: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