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


Python fields.UnspecifiedDefault方法代码示例

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


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

示例1: fake_db_verification

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_verification(**updates):
    db_verification = {
        "id": "36ea41b2-c358-48a7-9117-70cb7617410a",
        "project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
        "provider_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
        "checkpoint_id": "09edcbdc-d1c2-49c1-a212-122627b20968",
        "parameters": '{}',
        "status": "SUCCESS"
    }
    for name, field in objects.Verification.fields.items():
        if name in db_verification:
            continue
        if field.nullable:
            db_verification[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_verification[name] = field.default
        else:
            raise Exception('fake_db_verification needs help with %s.' % name)

    if updates:
        db_verification.update(updates)

    return db_verification 
开发者ID:openstack,项目名称:karbor,代码行数:25,代码来源:fake_verification.py

示例2: __init__

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def __init__(self, nullable=False, default=ovoo_fields.UnspecifiedDefault,
                 read_only=False, minimum=0, maximum=None):
        super(IntegerFields, self).__init__(nullable=nullable,
                                            default=default,
                                            read_only=read_only)
        self.min = minimum
        self.max = maximum 
开发者ID:openstack,项目名称:designate,代码行数:9,代码来源:fields.py

示例3: _obj_primitive_field

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def _obj_primitive_field(cls, primitive, field,
                             default=obj_fields.UnspecifiedDefault):
        key = cls._obj_primitive_key(field)
        if default == obj_fields.UnspecifiedDefault:
            return primitive[key]
        else:
            return primitive.get(key, default) 
开发者ID:openstack,项目名称:oslo.versionedobjects,代码行数:9,代码来源:base.py

示例4: obj_set_defaults

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def obj_set_defaults(self, *attrs):
        if not attrs:
            attrs = [name for name, field in self.fields.items()
                     if field.default != obj_fields.UnspecifiedDefault]

        for attr in attrs:
            default = copy.deepcopy(self.fields[attr].default)
            if default is obj_fields.UnspecifiedDefault:
                raise exception.ObjectActionError(
                    action='set_defaults',
                    reason='No default set for field %s' % attr)
            if not self.obj_attr_is_set(attr):
                setattr(self, attr, default) 
开发者ID:openstack,项目名称:oslo.versionedobjects,代码行数:15,代码来源:base.py

示例5: fake_db_notification

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_notification(**updates):
    db_notification = {
        "type": "VM",
        "id": 1,
        "payload":
            {'event': 'STOPPED', 'host_status': 'NORMAL',
             'cluster_status': 'ONLINE'
             },
        "source_host_uuid": uuidsentinel.fake_host,
        "generated_time": NOW,
        "status": "running",
        "notification_uuid": uuidsentinel.fake_notification,
        "created_at": NOW,
        "updated_at": None,
        "deleted_at": None,
        "deleted": 0
    }

    for name, field in objects.Notification.fields.items():
        if name in db_notification:
            continue
        if field.nullable:
            db_notification[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_notification[name] = field.default
        else:
            raise Exception('fake_db_notification needs help with %s' % name)

    if updates:
        db_notification.update(updates)

    return db_notification 
开发者ID:openstack,项目名称:masakari,代码行数:34,代码来源:fake_engine.py

示例6: fake_db_service

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_service(**updates):
    NOW = timeutils.utcnow().replace(microsecond=0)
    db_service = {
        'created_at': NOW,
        'updated_at': None,
        'deleted_at': None,
        'deleted': False,
        'id': 123,
        'host': 'fake-host',
        'binary': 'fake-service',
        'topic': 'fake-service-topic',
        'report_count': 1,
        'disabled': False,
        'disabled_reason': None,
        'modified_at': NOW,
    }

    for name, field in objects.Service.fields.items():
        if name in db_service:
            continue
        if field.nullable:
            db_service[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_service[name] = field.default
        else:
            raise Exception('fake_db_service needs help with %s.' % name)

    if updates:
        db_service.update(updates)

    return db_service 
开发者ID:openstack,项目名称:karbor,代码行数:33,代码来源:fake_service.py

示例7: fake_db_restore

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_restore(**updates):
    db_restore = {
        "id": "36ea41b2-c358-48a7-9117-70cb7617410a",
        "project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
        "provider_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
        "checkpoint_id": "09edcbdc-d1c2-49c1-a212-122627b20968",
        "restore_target": "192.168.1.2/identity/",
        "parameters": '{}',
        "restore_auth": '{"type": "password", "username": "admin",'
                        '"password": "test" }',
        "status": "SUCCESS"
    }
    for name, field in objects.Restore.fields.items():
        if name in db_restore:
            continue
        if field.nullable:
            db_restore[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_restore[name] = field.default
        else:
            raise Exception('fake_db_restore needs help with %s.' % name)

    if updates:
        db_restore.update(updates)

    return db_restore 
开发者ID:openstack,项目名称:karbor,代码行数:28,代码来源:fake_restore.py

示例8: fake_db_plan

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_plan(**updates):
    for name, field in objects.Plan.fields.items():
        if name in db_plan:
            continue
        if field.nullable:
            db_plan[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_plan[name] = field.default
        else:
            raise Exception('fake_db_plan needs help with %s.' % name)

    if updates:
        db_plan.update(updates)

    return db_plan 
开发者ID:openstack,项目名称:karbor,代码行数:17,代码来源:fake_plan.py

示例9: fake_db_operation_log

# 需要导入模块: from oslo_versionedobjects import fields [as 别名]
# 或者: from oslo_versionedobjects.fields import UnspecifiedDefault [as 别名]
def fake_db_operation_log(**updates):
    db_operation_log = {
        "id": "36ea41b2-c358-48a7-9117-70cb7617410a",
        "project_id": "586cc6ce-e286-40bd-b2b5-dd32694d9944",
        "operation_type": "protect",
        "checkpoint_id": "dcb20606-ad71-40a3-80e4-ef0fafdad0c3",
        "plan_id": "cf56bd3e-97a7-4078-b6d5-f36246333fd9",
        "provider_id": "23902b02-5666-4ee6-8dfe-962ac09c3994",
        "scheduled_operation_id": "2220f8b1-975d-4621-a872-fa9afb43cb6c",
        "status": "failed",
        "error_info": "Could not access bank",
        "extra_info": "[entries:{'timestamp': '2015-08-27T09:50:51-05:00',"
                   "'message': 'Doing things'}]"
    }
    for name, field in objects.OperationLog.fields.items():
        if name in db_operation_log:
            continue
        if field.nullable:
            db_operation_log[name] = None
        elif field.default != fields.UnspecifiedDefault:
            db_operation_log[name] = field.default
        else:
            raise Exception('db_operation_log needs help with %s.' % name)

    if updates:
        db_operation_log.update(updates)

    return db_operation_log 
开发者ID:openstack,项目名称:karbor,代码行数:30,代码来源:fake_operation_log.py


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