From da3fd7dcb6a080f66e1533c857bd55e36ce79eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 1 Feb 2016 14:09:43 +0100 Subject: [PATCH] Nodes are note created in examples now To be able test examples in different envs nodes can not be created in examples. Now before running an example nodes should be created manually. For fuel-devops nodes will be created automaticly in run.sh script --- examples/hosts_file/hosts.py | 16 +++------------- examples/openstack/openstack.py | 4 +--- examples/riak/riaks.py | 17 +++++++---------- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/examples/hosts_file/hosts.py b/examples/hosts_file/hosts.py index cca1ab9..aaefdbb 100755 --- a/examples/hosts_file/hosts.py +++ b/examples/hosts_file/hosts.py @@ -1,21 +1,11 @@ #!/usr/bin/python -import click -import sys -import time - -from solar.core import signals -from solar.core.resource import composer as cr -from solar.dblayer.model import ModelMeta +from solar.core.resource import resource as rs def run(): - ModelMeta.remove_all() - resources = cr.create('nodes', 'templates/nodes', {'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, node2 = rs.load_all(startswith='node')[:2] + hosts1, hosts2 = rs.load_all(startswith='hosts_file')[:2] node1.connect(hosts1, { 'name': 'hosts:name', diff --git a/examples/openstack/openstack.py b/examples/openstack/openstack.py index cae9467..e614922 100755 --- a/examples/openstack/openstack.py +++ b/examples/openstack/openstack.py @@ -40,8 +40,7 @@ def main(): def prepare_nodes(nodes_count): - resources = cr.create('nodes', 'templates/nodes', {"count": nodes_count}) - nodes = resources.like('node') + nodes = resource.load_all(startswith='node') resources = cr.create('nodes_network', 'templates/nodes_network', {"count": nodes_count}) nodes_sdn = resources.like('node') r = {} @@ -826,7 +825,6 @@ def create_compute(node): @click.command() def create_all(): - ModelMeta.remove_all() r = prepare_nodes(2) r.update(create_controller('node1')) r.update(create_compute('node2')) diff --git a/examples/riak/riaks.py b/examples/riak/riaks.py index 29393b2..e045116 100755 --- a/examples/riak/riaks.py +++ b/examples/riak/riaks.py @@ -18,6 +18,7 @@ from solar.core import resource from solar.core import signals from solar.core import validation from solar.core.resource import composer as cr +from solar.core.resource import resource as rs from solar import errors from solar.dblayer.model import ModelMeta @@ -29,13 +30,9 @@ from solar.dblayer.solar_models import Resource def setup_riak(): - - ModelMeta.remove_all() - resources = cr.create('nodes', 'templates/nodes', {'count': 3}) - nodes = resources.like('node') - - hosts_services = resources.like('hosts_file') - node1, node2, node3 = nodes + 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' @@ -73,9 +70,9 @@ def setup_riak(): 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'), + 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'),