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

Python model.ModelMeta类代码示例

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

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



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

示例1: test_revert_create

def test_revert_create():
    res = DBResource.from_dict(
        "test1",
        {
            "name": "test1",
            "base_path": "x",
            "state": RESOURCE_STATE.created.name,
            "meta_inputs": {"a": {"value": None, "schema": "str"}},
        },
    )
    res.inputs["a"] = "9"
    res.save_lazy()
    ModelMeta.save_all_lazy()

    staged_log = change.stage_changes()
    assert len(staged_log) == 1
    logitem = staged_log[0]
    operations.move_to_commited(logitem.log_action)
    assert logitem.diff == [["add", "", [["a", "9"]]]]

    commited = CommitedResource.get("test1")
    assert commited.inputs == {"a": "9"}

    change.revert(logitem.uid)

    staged_log = change.stage_changes()
    assert len(staged_log) == 1
    for item in staged_log:
        operations.move_to_commited(item.log_action)
    assert resource.load_all() == []
开发者ID:aglarendil,项目名称:solar,代码行数:30,代码来源:test_system_log_api.py


示例2: test_update_action_after_commit

def test_update_action_after_commit():
    res = resource.load(create_resource('1').name)
    res.set_operational()
    res.update({'a': 10})
    ModelMeta.save_all_lazy()
    staged_log = change.staged_log()
    assert staged_log[0].action == 'update'
开发者ID:openstack,项目名称:solar,代码行数:7,代码来源:test_system_log_api.py


示例3: wait_finish

def wait_finish(uid, timeout):
    """Check if graph is finished

    Will return when no PENDING or INPROGRESS otherwise yields summary
    """
    start_time = time.time()

    while start_time + timeout >= time.time():
        dg = get_graph(uid)
        summary = Counter()
        summary.update({s.name: 0 for s in states})
        summary.update([task.status for task in dg.nodes()])
        yield summary
        if summary[states.PENDING.name] + summary[states.INPROGRESS.name] == 0:
            return
        else:
            # on db backends with snapshot isolation level and higher
            # updates wont be visible after start of transaction,
            # in order to report state correctly we will "refresh" transaction
            ModelMeta.session_end()
            ModelMeta.session_start()

    else:
        raise errors.ExecutionTimeout(
            'Run %s wasnt able to finish' % uid)
开发者ID:openstack,项目名称:solar,代码行数:25,代码来源:graph.py


示例4: test_discard_all_pending_changes_resources_created

def test_discard_all_pending_changes_resources_created():
    res1 = DBResource.from_dict(
        "test1",
        {
            "name": "test1",
            "base_path": "x",
            "state": RESOURCE_STATE.created.name,
            "meta_inputs": {"a": {"value": None, "schema": "str"}},
        },
    )
    res1.inputs["a"] = "9"
    res1.save_lazy()

    res2 = DBResource.from_dict(
        "test2",
        {
            "name": "test2",
            "base_path": "x",
            "state": RESOURCE_STATE.created.name,
            "meta_inputs": {"a": {"value": None, "schema": "str"}},
        },
    )
    res2.inputs["a"] = "0"
    res2.save_lazy()
    ModelMeta.save_all_lazy()

    staged_log = change.stage_changes()
    assert len(staged_log) == 2

    change.discard_all()
    staged_log = change.stage_changes()
    assert len(staged_log) == 0
    assert resource.load_all() == []
开发者ID:aglarendil,项目名称:solar,代码行数:33,代码来源:test_system_log_api.py


示例5: _end_start_session

 def _end_start_session(cls, uid, identity):
     """Because of isolated versions of data in concurrent sessions
     we need to ensure that session will be re-started at certain
     hooks during locking logic
     """
     ModelMeta.session_end()
     ModelMeta.session_start()
开发者ID:loles,项目名称:solar-1,代码行数:7,代码来源:locking.py


示例6: setup_resources

def setup_resources():
    ModelMeta.remove_all()

    node2 = vr.create('node2', 'resources/ro_node/', {
        'ip': '10.0.0.4',
        'ssh_key': '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key',
        'ssh_user': 'vagrant'
    })[0]

    solar_bootstrap2 = vr.create('solar_bootstrap2', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0]

    signals.connect(node2, solar_bootstrap2)

    has_errors = False
    for r in locals().values():
        if not isinstance(r, resource.Resource):
            continue

        print 'Validating {}'.format(r.name)
        errors = validation.validate_resource(r)
        if errors:
            has_errors = True
            print 'ERROR: %s: %s' % (r.name, errors)

    if has_errors:
        sys.exit(1)
开发者ID:aglarendil,项目名称:solar,代码行数:26,代码来源:example-bootstrap.py


示例7: create_plan_from_graph

def create_plan_from_graph(dg):
    dg.graph['uid'] = "{0}:{1}".format(dg.graph['name'], str(uuid.uuid4()))
    # FIXME change save_graph api to return new graph with Task objects
    # included
    save_graph(dg)
    ModelMeta.save_all_lazy()
    return get_graph(dg.graph['uid'])
开发者ID:openstack,项目名称:solar,代码行数:7,代码来源:graph.py


示例8: test_revert_create

def test_revert_create():
    res = DBResource.from_dict('test1',
                               {'name': 'test1',
                                'base_path': 'x',
                                'state': RESOURCE_STATE.created.name,
                                'meta_inputs': {'a': {'value': None,
                                                      'schema': 'str'}}})
    res.inputs['a'] = '9'
    res.save_lazy()
    ModelMeta.save_all_lazy()

    staged_log = change.stage_changes()
    assert len(staged_log) == 1
    logitem = staged_log[0]
    operations.move_to_commited(logitem.log_action)
    assert logitem.diff == [['add', '', [['a', '9']]]]

    commited = CommitedResource.get('test1')
    assert commited.inputs == {'a': '9'}

    change.revert(logitem.uid)

    staged_log = change.stage_changes()
    assert len(staged_log) == 1
    for item in staged_log:
        operations.move_to_commited(item.log_action)

    assert resource.load_all() == []
开发者ID:pigmej,项目名称:solar,代码行数:28,代码来源:test_system_log_api.py


示例9: test_concurrent_sequences_with_no_handler

def test_concurrent_sequences_with_no_handler(scale, clients):
    total_resources = scale * 3
    timeout = scale * 2
    scheduler_client = clients['scheduler']

    assert len(change.staged_log()) == total_resources
    ModelMeta.save_all_lazy()
    plan = change.send_to_orchestration()
    ModelMeta.save_all_lazy()
    scheduler_client.next({}, plan.graph['uid'])

    def wait_function(timeout):
        try:
            for summary in wait_finish(plan.graph['uid'], timeout):
                assert summary[states.ERROR.name] == 0
                time.sleep(0.5)
        except ExecutionTimeout:
            pass
        return summary
    waiter = gevent.spawn(wait_function, timeout)
    waiter.join(timeout=timeout)
    res = waiter.get(block=True)
    assert res[states.SUCCESS.name] == total_resources
    assert len(data.CL()) == total_resources
    clear_cache()
    assert len(change.staged_log()) == 0
开发者ID:openstack,项目名称:solar,代码行数:26,代码来源:test_complete_solar_workflow.py


示例10: test_discard_connection

def test_discard_connection():
    res1 = DBResource.from_dict('test1',
                                {'name': 'test1',
                                 'base_path': 'x',
                                 'state': RESOURCE_STATE.created.name,
                                 'meta_inputs': {'a': {'value': None,
                                                       'schema': 'str'}}})
    res1.inputs['a'] = '9'
    res1.save_lazy()

    res2 = DBResource.from_dict('test2',
                                {'name': 'test2',
                                 'base_path': 'x',
                                 'state': RESOURCE_STATE.created.name,
                                 'meta_inputs': {'a': {'value': None,
                                                       'schema': 'str'}}})
    res2.inputs['a'] = '0'
    res2.save_lazy()
    ModelMeta.save_all_lazy()

    staged_log = change.stage_changes()
    for item in staged_log:
        operations.move_to_commited(item.log_action)

    res1 = resource.load('test1')
    res2 = resource.load('test2')
    res1.connect(res2, {'a': 'a'})
    staged_log = change.stage_changes()
    assert len(staged_log) == 1
    assert res2.args == {'a': '9'}
    change.discard_all()
    assert res2.args == {'a': '0'}
    assert len(change.stage_changes()) == 0
开发者ID:pigmej,项目名称:solar,代码行数:33,代码来源:test_system_log_api.py


示例11: test_discard_all_pending_changes_resources_created

def test_discard_all_pending_changes_resources_created():
    res1 = DBResource.from_dict('test1',
                                {'name': 'test1',
                                 'base_path': 'x',
                                 'state': RESOURCE_STATE.created.name,
                                 'meta_inputs': {'a': {'value': None,
                                                       'schema': 'str'}}})
    res1.inputs['a'] = '9'
    res1.save_lazy()

    res2 = DBResource.from_dict('test2',
                                {'name': 'test2',
                                 'base_path': 'x',
                                 'state': RESOURCE_STATE.created.name,
                                 'meta_inputs': {'a': {'value': None,
                                                       'schema': 'str'}}})
    res2.inputs['a'] = '0'
    res2.save_lazy()
    ModelMeta.save_all_lazy()

    staged_log = change.stage_changes()
    assert len(staged_log) == 2

    change.discard_all()
    staged_log = change.stage_changes()
    assert len(staged_log) == 0
    assert resource.load_all() == []
开发者ID:pigmej,项目名称:solar,代码行数:27,代码来源:test_system_log_api.py


示例12: run

def run():
    ModelMeta.remove_all()

    resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2})

    node1, node2 = [x for x in resources if x.name.startswith('node')]
    hosts1, hosts2 = [x for x in resources
                      if x.name.startswith('hosts_file')]

    node1.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts1, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node1.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })

    node2.connect(hosts2, {
        'name': 'hosts:name',
        'ip': 'hosts:ip',
    })
开发者ID:Mirantis,项目名称:solar,代码行数:28,代码来源:hosts.py


示例13: test_discard_removed

def test_discard_removed():
    res1 = DBResource.from_dict(
        "test1",
        {
            "name": "test1",
            "base_path": "x",
            "state": RESOURCE_STATE.created.name,
            "meta_inputs": {"a": {"value": None, "schema": "str"}},
        },
    )
    res1.inputs["a"] = "9"
    res1.save_lazy()
    ModelMeta.save_all_lazy()
    staged_log = change.stage_changes()
    for item in staged_log:
        operations.move_to_commited(item.log_action)
    res1 = resource.load("test1")
    res1.remove()
    assert len(change.stage_changes()) == 1
    assert res1.to_be_removed()

    change.discard_all()

    assert len(change.stage_changes()) == 0
    assert not resource.load("test1").to_be_removed()
开发者ID:aglarendil,项目名称:solar,代码行数:25,代码来源:test_system_log_api.py


示例14: set_states

def set_states(uid, tasks):
    plan = get_graph(uid)
    for t in tasks:
        if t not in plan.node:
            raise Exception("No task %s in plan %s", t, uid)
        plan.node[t]['task'].status = states.NOOP.name
        plan.node[t]['task'].save_lazy()
    ModelMeta.save_all_lazy()
开发者ID:aglarendil,项目名称:solar,代码行数:8,代码来源:graph.py


示例15: undeploy

def undeploy():
    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    for name in reversed(resources_to_run):
        try:
            actions.resource_action(resources[name], 'remove')
        except errors.SolarError as e:
            print 'WARNING: %s' % str(e)

    ModelMeta.remove_all()
开发者ID:aglarendil,项目名称:solar,代码行数:11,代码来源:example-bootstrap.py


示例16: test_discard_update

def test_discard_update():
    res1 = create_resource('test1')
    res1.db_obj.inputs['a'] = '9'
    operations.commit_log_item(change.create_run(res1))
    res1.update({'a': '11'})
    ModelMeta.save_all_lazy()
    assert len(change.staged_log()) == 1
    assert res1.args == {'a': '11'}

    change.discard_single(change.staged_log()[0])
    assert res1.args == {'a': '9'}
开发者ID:openstack,项目名称:solar,代码行数:11,代码来源:test_system_log_api.py


示例17: undeploy

def undeploy():
    ModelMeta.remove_all()

    resources = resource.load_all()
    resources = {r.name: r for r in resources}

    actions.resource_action(resources['openstack_rabbitmq_user'], 'remove')
    actions.resource_action(resources['openstack_vhost'], 'remove')
    actions.resource_action(resources['rabbitmq_service1'], 'remove')

    ModelMeta.remove_all()
开发者ID:aglarendil,项目名称:solar,代码行数:11,代码来源:example-compiled-resources.py


示例18: test_childs_added_on_stage

def test_childs_added_on_stage():
    res_0, res_1 = [create_resource(str(n)) for n in range(2)]
    res_0.connect(res_1, {'a': 'a'})
    ModelMeta.save_all_lazy()
    created_log_items = stage_resources(res_0.name, 'run')
    assert len(created_log_items) == 1
    assert created_log_items[0].resource == res_0.name
    staged_log = change.staged_log()
    assert len(staged_log) == 2
    child_log_item = next(li for li in staged_log
                          if li.resource == res_1.name)
    assert child_log_item.action == 'run'
开发者ID:pigmej,项目名称:solar-1,代码行数:12,代码来源:test_system_log_api.py


示例19: test_discard_update

def test_discard_update():
    res1 = create_resource('test1')
    res1.inputs['a'] = '9'
    res1.save_lazy()
    operations.commit_log_item(change.create_run(res1.name))
    res1 = resource.load('test1')
    res1.update({'a': '11'})
    ModelMeta.save_all_lazy()
    assert len(change.staged_log()) == 1
    assert res1.args == {'a': '11'}

    change.discard_all()
    assert res1.args == {'a': '9'}
开发者ID:pigmej,项目名称:solar-1,代码行数:13,代码来源:test_system_log_api.py


示例20: tagged_resources

def tagged_resources():
    tags = ['n1', 'n2', 'n3']
    t1 = Resource.from_dict('t1',
                            {'name': 't1', 'tags': tags, 'base_path': 'x'})
    t1.save_lazy()
    t2 = Resource.from_dict('t2',
                            {'name': 't2', 'tags': tags, 'base_path': 'x'})
    t2.save_lazy()
    t3 = Resource.from_dict('t3',
                            {'name': 't3', 'tags': tags, 'base_path': 'x'})
    t3.save_lazy()
    ModelMeta.save_all_lazy()
    return [t1, t2, t3]
开发者ID:aglarendil,项目名称:solar,代码行数:13,代码来源:test_operations_with_tags.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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