本文整理汇总了Python中solar.core.resource.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _update_inputs_connections
def _update_inputs_connections(res_obj, args, old_connections, new_connections): # NOQA
removed = []
for item in old_connections:
if item not in new_connections:
removed.append(item)
added = []
for item in new_connections:
if item not in old_connections:
added.append(item)
for emitter, _, receiver, _ in removed:
emmiter_obj = resource.load(emitter)
receiver_obj = resource.load(receiver)
emmiter_obj.disconnect(receiver_obj)
for emitter, emitter_input, receiver, receiver_input in added:
emmiter_obj = resource.load(emitter)
receiver_obj = resource.load(receiver)
emmiter_obj.connect(receiver_obj, {emitter_input: receiver_input})
if removed or added:
# TODO without save we will get error
# that some values can not be updated
# even if connection was removed
receiver_obj.db_obj.save()
if args:
res_obj.update(args)
开发者ID:openstack,项目名称:solar,代码行数:29,代码来源:change.py
示例2: backtrack
def backtrack(resource, input, values, real_values):
r = sresource.load(resource)
db_obj = r.db_obj
def single(resource, name, get_val=False):
db_obj = sresource.load(resource).db_obj
se = db_obj.inputs._single_edge(name)
se = tuple(se)
if not se:
if get_val:
return dict(resource=resource, name=name, value=db_obj.inputs[name])
else:
return dict(resource=resource, name=name)
l = []
for (rname, rinput), _, meta in se:
l.append(dict(resource=resource, name=name))
val = single(rname, rinput, get_val)
if meta and isinstance(val, dict):
val["meta"] = meta
l.append(val)
return l
inps = {}
if input:
inps[input] = single(resource, input, values)
else:
for _inp in db_obj.inputs:
inps[_inp] = single(resource, _inp, values)
for name, values in inps.iteritems():
click.echo(yaml.safe_dump({name: values}, default_flow_style=False))
if real_values:
click.echo("! Real value: %r\n" % sresource.load(resource).db_obj.inputs[name])
开发者ID:pigmej,项目名称:solar,代码行数:34,代码来源:inputs.py
示例3: add_solar_agent
def add_solar_agent(i):
solar_agent_transport = cr.create(
"solar_agent_transport%s" % i,
"resources/transport_solar_agent",
{"solar_agent_user": "vagrant", "solar_agent_password": "password"},
)[0]
transports = resource.load("transports%s" % i)
ssh_transport = resource.load("ssh_transport%s" % i)
transports_for_solar_agent = cr.create("transports_for_solar_agent%s" % i, "resources/transports")[0]
# install solar_agent with ssh
signals.connect(transports_for_solar_agent, solar_agent_transport, {})
signals.connect(
ssh_transport,
transports_for_solar_agent,
{"key": "transports:key", "user": "transports:user", "port": "transports:port", "name": "transports:name"},
)
# add solar_agent to transports on this node
signals.connect(
solar_agent_transport,
transports,
{
"solar_agent_user": "transports:user",
"solar_agent_port": "transports:port",
"solar_agent_password": "transports:password",
"name": "transports:name",
},
)
开发者ID:openstack,项目名称:solar-resources,代码行数:30,代码来源:riaks.py
示例4: test_connections_recreated_after_load
def test_connections_recreated_after_load(self):
"""
Create resource in some process. Then in other process load it.
All connections should remain the same.
"""
sample_meta_dir = self.make_resource_meta("""
id: sample
handler: ansible
version: 1.0.0
input:
value:
schema: int
value: 0
""")
def creating_process():
sample1 = self.create_resource(
'sample1', sample_meta_dir, {'value': 1}
)
sample2 = self.create_resource(
'sample2', sample_meta_dir, {}
)
signals.connect(sample1, sample2)
self.assertEqual(sample1.args['value'], sample2.args['value'])
creating_process()
signals.CLIENTS = {}
sample1 = resource.load('sample1')
sample2 = resource.load('sample2')
sample1.update({'value': 2})
self.assertEqual(sample1.args['value'], sample2.args['value'])
开发者ID:CGenie,项目名称:solar,代码行数:34,代码来源:test_resource.py
示例5: create_master
def create_master():
master = source.master()
try:
resource.load('nodemaster')
except solar.dblayer.model.DBLayerNotFound:
cr.create('master', 'f2s/fuel_node',
{'index': master[0], 'ip': master[1]}, tags=['nodemaster'])
开发者ID:Mirantis,项目名称:f2s,代码行数:7,代码来源:fsclient.py
示例6: disconnect
def disconnect(receiver, emitter):
click.echo('Disconnect {} from {}'.format(emitter, receiver))
emitter = sresource.load(emitter)
receiver = sresource.load(receiver)
click.echo(emitter)
click.echo(receiver)
signals.disconnect(emitter, receiver)
show_emitter_connections(emitter)
开发者ID:rustyrobot,项目名称:solar,代码行数:9,代码来源:main.py
示例7: disconnect
def disconnect(receiver, emitter):
click.echo('Disconnect {} from {}'.format(emitter, receiver))
emitter = sresource.load(emitter)
receiver = sresource.load(receiver)
click.echo(emitter)
click.echo(receiver)
signals.disconnect(emitter, receiver)
clients = signals.Connections.read_clients()
show_emitter_connections(emitter.name, clients[emitter.name])
开发者ID:sand8080,项目名称:solar,代码行数:10,代码来源:main.py
示例8: _revert_remove
def _revert_remove(logitem):
"""Resource should be created with all previous connections
"""
commited = orm.DBCommitedState.load(logitem.res)
args = dictdiffer.revert(logitem.diff, commited.inputs)
connections = dictdiffer.revert(logitem.signals_diff, sorted(commited.connections))
resource.Resource(logitem.res, logitem.base_path, args=args, tags=commited.tags)
for emitter, emitter_input, receiver, receiver_input in connections:
emmiter_obj = resource.load(emitter)
receiver_obj = resource.load(receiver)
signals.connect(emmiter_obj, receiver_obj, {emitter_input: receiver_input})
开发者ID:rustyrobot,项目名称:solar,代码行数:11,代码来源:change.py
示例9: connect
def connect(mapping, receiver, emitter):
mapping_parsed = {}
click.echo('Connect {} to {}'.format(emitter, receiver))
emitter = sresource.load(emitter)
receiver = sresource.load(receiver)
try:
mapping_parsed.update(json.loads(mapping))
except ValueError:
for m in mapping.split():
k, v = m.split('->')
mapping_parsed.update({k: v})
signals.connect(emitter, receiver, mapping=mapping_parsed)
show_emitter_connections(emitter)
开发者ID:torgartor21,项目名称:solar,代码行数:15,代码来源:main.py
示例10: _revert_remove
def _revert_remove(logitem):
"""Resource should be created with all previous connections"""
commited = CommitedResource.get(logitem.resource)
args = dictdiffer.revert(logitem.diff, commited.inputs)
connections = dictdiffer.revert(
logitem.connections_diff, sorted(commited.connections))
resource.Resource(logitem.resource, logitem.base_path,
args=_get_args_to_update(args, connections),
tags=commited.tags)
for emitter, emitter_input, receiver, receiver_input in connections:
emmiter_obj = resource.load(emitter)
receiver_obj = resource.load(receiver)
signals.connect(emmiter_obj, receiver_obj, {
emitter_input: receiver_input})
开发者ID:openstack,项目名称:solar,代码行数:15,代码来源:change.py
示例11: fuel_data
def fuel_data(nobj):
uid = str(nobj.data['id'])
env_id = nobj.data['cluster']
node = resource.load('node{}'.format(uid))
res = resource.Resource('fuel_data{}'.format(uid), 'f2s/fuel_data',
{'uid': uid,
'env': env_id}, tags=['node%s' % nobj.data['id']])
events = [
evapi.React(res.name, 'run', 'success',
'pre_deployment_start', 'run'),
evapi.React(res.name, 'update', 'success',
'pre_deployment_start', 'run')]
evapi.add_events(res.name, events)
node = resource.load('node{}'.format(uid))
node.connect(res, {})
开发者ID:Mirantis,项目名称:f2s,代码行数:15,代码来源:fsclient.py
示例12: populate_log_item
def populate_log_item(log_item, diff=None):
if diff is None:
diff = Diff.create_from_resource(resource.load(log_item.resource))
log_item.diff = diff.diff
log_item.connections_diff = diff.connections
log_item.base_path = diff.path
return log_item
开发者ID:openstack,项目名称:solar,代码行数:7,代码来源:change.py
示例13: test_save
def test_save(self):
r = orm.DBResource(id='test1', name='test1', base_path='x')
r.save()
rr = resource.load(r.id)
self.assertEqual(r, rr.db_obj)
开发者ID:torgartor21,项目名称:solar,代码行数:7,代码来源:test_orm.py
示例14: _discard_update
def _discard_update(item):
resource_obj = resource.load(item.res)
old_connections = resource_obj.connections
new_connections = dictdiffer.revert(item.signals_diff, sorted(old_connections))
args = dictdiffer.revert(item.diff, resource_obj.args)
_update_inputs_connections(
resource_obj, args, old_connections, new_connections)
开发者ID:rustyrobot,项目名称:solar,代码行数:7,代码来源:change.py
示例15: test
def test(r):
if isinstance(r, basestring):
r = resource.load(r)
log.debug('Trying {}'.format(r.name))
script_path = os.path.join(r.db_obj.base_path, 'test.py')
if not os.path.exists(script_path):
log.warning('resource {} has no tests'.format(r.name))
return {}
log.debug('File {} found'.format(script_path))
with open(script_path) as f:
module = imp.load_module(
'{}_test'.format(r.name),
f,
script_path,
('', 'r', imp.PY_SOURCE)
)
try:
module.test(r)
return {
r.name: {
'status': 'ok',
},
}
except Exception:
return {
r.name: {
'status': 'error',
'message': traceback.format_exc(),
}
}
开发者ID:aglarendil,项目名称:solar,代码行数:35,代码来源:testing.py
示例16: disconnect
def disconnect(receiver, emitter, input):
if not input:
click.echo('Disconnect {} from {}'.format(emitter, receiver))
else:
click.echo('Disconnect {} from {} only {}'.format(
emitter,
receiver,
input
))
emitter = sresource.load(emitter)
receiver = sresource.load(receiver)
click.echo(emitter)
click.echo(receiver)
emitter.disconnect(receiver, input)
show_emitter_connections(emitter)
开发者ID:openstack,项目名称:solar,代码行数:16,代码来源:main.py
示例17: effective_input_value
def effective_input_value(resource, input_name):
r = sresource.load(resource)
inp = r.resource_inputs()[input_name]
click.echo(yaml.safe_dump(backtrack_single(inp), default_flow_style=False))
click.echo('-' * 20)
val = inp.backtrack_value()
click.echo(val)
click.echo('-' * 20)
开发者ID:pombredanne,项目名称:solar,代码行数:8,代码来源:resource.py
示例18: receivers
def receivers(self):
from solar.core import resource
for receiver_name, receiver_input in signals.Connections.receivers(
self._attached_to_name,
self.name
):
yield resource.load(receiver_name).args[receiver_input]
开发者ID:CGenie,项目名称:solar,代码行数:8,代码来源:observer.py
示例19: emitter
def emitter(self):
from solar.core import resource
emitter = signals.Connections.emitter(self._attached_to_name, self.name)
if emitter is not None:
emitter_name, emitter_input_name = emitter
return resource.load(emitter_name).args[emitter_input_name]
开发者ID:CGenie,项目名称:solar,代码行数:8,代码来源:observer.py
示例20: tag
def tag(add, tag_name, resource_name):
click.echo('Tag {} with {} {}'.format(resource_name, tag_name, add))
r = sresource.load(resource_name)
if add:
r.add_tag(tag_name)
else:
r.remove_tag(tag_name)
r.save()
开发者ID:sand8080,项目名称:solar,代码行数:8,代码来源:main.py
注:本文中的solar.core.resource.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论