本文整理汇总了Python中solar.dblayer.solar_models.Resource.save_all_lazy方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.save_all_lazy方法的具体用法?Python Resource.save_all_lazy怎么用?Python Resource.save_all_lazy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solar.dblayer.solar_models.Resource
的用法示例。
在下文中一共展示了Resource.save_all_lazy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nested_two_listdict
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import save_all_lazy [as 别名]
def test_nested_two_listdict(rk):
k1 = next(rk)
k2 = next(rk)
k3 = next(rk)
r1 = create_resource(k1, {'name': 'first',
'inputs': {'config': [{"backends": [{}],
'something': 0}]}})
r2 = create_resource(k2, {'name': 'second',
'inputs': {"backends": [{"host": "second_host",
"port": 2}],
'something': 1}})
r3 = create_resource(k3, {'name': 'third',
'inputs': {"backends": [{"host": "third_host",
"port": 3}],
'something': 2}})
r2.connect(r1, {'backends': 'config:backends',
'something': 'config:something'})
r3.connect(r1, {'backends': 'config:backends',
'something': 'config:something'})
Resource.save_all_lazy()
for sc in r1.inputs['config']:
assert 'something' in sc
assert 'backends' in sc
assert isinstance(sc['backends'], list)
assert isinstance(sc['something'], int)
示例2: test_nested_simple_listdict
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import save_all_lazy [as 别名]
def test_nested_simple_listdict(rk):
k1 = next(rk)
k2 = next(rk)
k3 = next(rk)
k4 = next(rk)
k5 = next(rk)
r1 = create_resource(k1, {'name': 'first',
'inputs': {'config': [{"backends": [{}],
'listen_port': 1}]}})
r2 = create_resource(k2, {'name': 'second', 'inputs': {'backend': {}}})
r3 = create_resource(k3, {'name': 'third', 'inputs': {'backend': {}}})
r5 = create_resource(k5, {'name': 'fifth',
'inputs': {"port": 5,
"host": "fifth_host"}})
r4 = create_resource(k4, {'name': 'fourth',
'inputs': {"port": 4,
"host": "fourth_host"}})
r4.connect(r2, {'port': "backend:port", 'host': 'backend:host'})
r5.connect(r3, {'port': "backend:port", 'host': 'backend:host'})
assert r2.inputs['backend'] == {'host': 'fourth_host', 'port': 4}
assert r3.inputs['backend'] == {'host': 'fifth_host', 'port': 5}
r2.connect(r1, {'backend': 'config:backends'})
r3.connect(r1, {'backend': 'config:backends'})
Resource.save_all_lazy()
backends = next(x['backends'] for x in r1.inputs['config']
if 'backends' in x)
assert len(backends) == 2
示例3: test_connect_other_list
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import save_all_lazy [as 别名]
def test_connect_other_list(rk):
k1 = next(rk)
k2 = next(rk)
r1 = create_resource(k1, {'name': 'first',
'inputs': {'config': {"trackers": []}}})
r2 = create_resource(k2, {'name': 'second',
'inputs': {"trackers": ["t1", "t2"]}})
r2.connect(r1, {'trackers': 'config:trackers'})
Resource.save_all_lazy()
assert r1.inputs['config']['trackers'] == ["t1", "t2"]
示例4: setup_riak
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import save_all_lazy [as 别名]
def setup_riak():
ModelMeta.remove_all()
resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 3})
nodes = [x for x in resources if x.name.startswith('node')]
hosts_services = [x for x in resources if x.name.startswith('hosts_file')]
node1, node2, node3 = nodes
hosts_services = [x for x in resources if x.name.startswith('hosts_file')]
riak_services = []
ips = '10.0.0.%d'
for i in xrange(3):
num = i + 1
r = vr.create('riak_service%d' % num,
'resources/riak_node',
{'riak_self_name': 'riak%d' % num,
'storage_backend': 'leveldb',
'riak_hostname': 'riak_server%d.solar' % num})[0]
r.connect(r, {'riak_self_name': 'riak_name',
'riak_hostname': 'riak_name'})
riak_services.append(r)
for i, riak in enumerate(riak_services):
nodes[i].connect(riak)
for i, riak in enumerate(riak_services[1:]):
riak_services[0].connect(riak, {'riak_name': 'join_to'})
for riak in riak_services:
for hosts_file in hosts_services:
riak.connect_with_events(hosts_file,
{'riak_hostname': 'hosts:name',
'ip': 'hosts:ip'})
Resource.save_all_lazy()
errors = resource.validate_resources()
for r, error in errors:
click.echo('ERROR: %s: %s' % (r.name, error))
has_errors = False
if errors:
click.echo("ERRORS")
sys.exit(1)
events = [
Dep('hosts_file1', 'run', 'success', 'riak_service1', 'run'),
Dep('hosts_file2', 'run', 'success', 'riak_service2', 'run'),
Dep('hosts_file3', 'run', 'success', 'riak_service3', 'run'),
React('riak_service2', 'run', 'success', 'riak_service2', 'join'),
React('riak_service3', 'run', 'success', 'riak_service3', 'join'),
# Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
# Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),
# React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
# React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),
React('riak_service2', 'leave', 'success', 'riak_service2', 'join'),
React('riak_service3', 'leave', 'success', 'riak_service3', 'join'),
# React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
# React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),
# Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
# Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),
React('riak_service3', 'join', 'success', 'riak_service1', 'commit'),
React('riak_service2', 'join', 'success', 'riak_service1', 'commit')
]
for event in events:
add_event(event)
click.echo('Use solar changes process & orch')
sys.exit(0)
示例5: setup_riak
# 需要导入模块: from solar.dblayer.solar_models import Resource [as 别名]
# 或者: from solar.dblayer.solar_models.Resource import save_all_lazy [as 别名]
def setup_riak():
nodes = rs.load_all(startswith="node")
hosts_services = rs.load_all(startswith="hosts_file")
node1, node2, node3 = nodes[:3]
riak_services = []
ips = "10.0.0.%d"
for i in xrange(3):
num = i + 1
r = cr.create(
"riak_service%d" % num,
"resources/riak_node",
{
"riak_self_name": "riak%d" % num,
"storage_backend": "leveldb",
"riak_hostname": "riak_server%d.solar" % num,
},
)[0]
r.connect(r, {"riak_self_name": "riak_name", "riak_hostname": "riak_name"})
riak_services.append(r)
for i, riak in enumerate(riak_services):
nodes[i].connect(riak)
for i, riak in enumerate(riak_services[1:]):
riak_services[0].connect(riak, {"riak_name": "join_to"})
for riak in riak_services:
for hosts_file in hosts_services:
riak.connect_with_events(hosts_file, {"riak_hostname": "hosts:name", "ip": "hosts:ip"})
Resource.save_all_lazy()
errors = resource.validate_resources()
for r, error in errors:
click.echo("ERROR: %s: %s" % (r.name, error))
has_errors = False
if errors:
click.echo("ERRORS")
sys.exit(1)
events = [
Dep("hosts_file_node_node1", "run", "success", "riak_service1", "run"),
Dep("hosts_file_node_node2", "run", "success", "riak_service2", "run"),
Dep("hosts_file_node_node3", "run", "success", "riak_service3", "run"),
React("riak_service2", "run", "success", "riak_service2", "join"),
React("riak_service3", "run", "success", "riak_service3", "join"),
# Dep('riak_service1', 'run', 'success', 'riak_service2', 'join'),
# Dep('riak_service1', 'run', 'success', 'riak_service3', 'join'),
# React('riak_service2', 'join', 'error', 'riak_service2', 'leave'),
# React('riak_service3', 'join', 'error', 'riak_service3', 'leave'),
React("riak_service2", "leave", "success", "riak_service2", "join"),
React("riak_service3", "leave", "success", "riak_service3", "join"),
# React('riak_service2', 'leave', 'success', 'riak_service1', 'commit_leave'),
# React('riak_service3', 'leave', 'success', 'riak_service1', 'commit_leave'),
# Dep('riak_service1', 'commit_leave', 'success', 'riak_service2', 'join'),
# Dep('riak_service1', 'commit_leave', 'success', 'riak_service3', 'join'),
React("riak_service3", "join", "success", "riak_service1", "commit"),
React("riak_service2", "join", "success", "riak_service1", "commit"),
]
for event in events:
add_event(event)
click.echo("Use solar changes process & orch")
sys.exit(0)