From 25dc2685f5884dd8171f0d621bdf42253f62f7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Mon, 28 Dec 2015 15:22:52 +0100 Subject: [PATCH] Refactor VirtualResources - rename VirtualResource to Composer - rename event parameter depend_action to child_action - rename values parameter to input Closes-bug: #1526780 Change-Id: Ib974e14ff4bda44c2d7d991f62aa4a06dea160ea --- .gitignore | 2 + examples/bootstrap/example-bootstrap.py | 6 +- .../example-compiled-resources.py | 4 +- examples/hosts_file/hosts.py | 4 +- examples/librarian/librarian.yaml | 10 +- examples/library_ceph/ceph.py | 14 +- examples/lxc/example-lxc.py | 26 ++-- examples/openstack/openstack.py | 128 +++++++++--------- examples/openstack/rabbitmq_user.yaml | 6 +- examples/provisioning/provision.py | 6 +- examples/riak/haproxy_riak_config.yaml | 34 ++--- examples/riak/riak_cluster.yaml | 26 ++-- examples/riak/riak_service.yaml | 58 ++++---- examples/riak/riaks.py | 18 +-- examples/riak/riaks_big.py | 6 +- examples/solar_agent/example.py | 14 +- examples/torrent/example.py | 16 +-- templates/controller/1.0.0/controller.yaml | 12 +- templates/glance/1.0.0/glance.yaml | 2 +- templates/glance_base/1.0.0/glance_base.yaml | 4 +- templates/glance_db/1.0.0/glance_db.yaml | 4 +- .../1.0.0/glance_registry.yaml | 4 +- templates/haproxy/1.0.0/haproxy.yaml | 10 +- .../keystone_api/1.0.0/keystone_api.yaml | 2 +- .../keystone_base/1.0.0/keystone_base.yaml | 4 +- templates/mos_repos/1.0.0/mos_repos.yaml | 8 +- templates/nodes/1.0.0/nodes.yaml | 8 +- .../nodes_network/1.0.0/nodes_network.yaml | 2 +- .../1.0.0/nodes_with_transports.yaml | 8 +- .../1.0.0/not_provisioned_nodes.yaml | 12 +- .../openstack_base/1.0.0/openstack_base.yaml | 10 +- templates/seed_node/1.0.0/seed_node.yaml | 2 +- templates/sources/1.0.0/sources.yaml | 2 +- 33 files changed, 237 insertions(+), 235 deletions(-) diff --git a/.gitignore b/.gitignore index b5aeaf9..8e43ecd 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ solar/.cache .testrepository/ .solar_config_override + +.ropeproject diff --git a/examples/bootstrap/example-bootstrap.py b/examples/bootstrap/example-bootstrap.py index 20f474b..dc7b1fb 100755 --- a/examples/bootstrap/example-bootstrap.py +++ b/examples/bootstrap/example-bootstrap.py @@ -8,7 +8,7 @@ from solar.core import actions from solar.core import resource from solar.core import signals from solar.core import validation -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar import errors from solar.dblayer.model import ModelMeta @@ -21,13 +21,13 @@ def main(): def setup_resources(): ModelMeta.remove_all() - node2 = vr.create('node2', 'resources/ro_node/', { + node2 = cr.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] + solar_bootstrap2 = cr.create('solar_bootstrap2', 'resources/solar_bootstrap', {'master_ip': '10.0.0.2'})[0] signals.connect(node2, solar_bootstrap2) diff --git a/examples/compiled-resources/example-compiled-resources.py b/examples/compiled-resources/example-compiled-resources.py index e34ce02..ed0b830 100755 --- a/examples/compiled-resources/example-compiled-resources.py +++ b/examples/compiled-resources/example-compiled-resources.py @@ -16,7 +16,7 @@ import sys import time from solar.core import actions -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.core import resource from solar.core import signals from solar.dblayer.model import ModelMeta @@ -55,7 +55,7 @@ def deploy(): signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'}) - errors = vr.validate_resources() + errors = cr.validate_resources() if errors: for r, error in errors: print 'ERROR: %s: %s' % (r.name, error) diff --git a/examples/hosts_file/hosts.py b/examples/hosts_file/hosts.py index ecce195..8689b4b 100644 --- a/examples/hosts_file/hosts.py +++ b/examples/hosts_file/hosts.py @@ -3,14 +3,14 @@ import sys import time from solar.core import signals -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.dblayer.model import ModelMeta def run(): ModelMeta.remove_all() - resources = vr.create('nodes', 'templates/nodes', {'count': 2}) + 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 diff --git a/examples/librarian/librarian.yaml b/examples/librarian/librarian.yaml index 660c0f2..07ec82c 100644 --- a/examples/librarian/librarian.yaml +++ b/examples/librarian/librarian.yaml @@ -3,15 +3,15 @@ id: librarian_examples resources: - id: rabbitmq_service1 from: resources/rabbitmq_service - location: {{node}} - values: + location: #{node}# + input: management_port: 15672 port: 5672 - id: librarian - location: {{node}} + location: #{node}# from: resources/librarian - values: + input: modules: - rabbitmq_service1::module::NO_EVENTS @@ -19,4 +19,4 @@ events: - type: depends_on parent_action: librarian.run state: success - depend_action: rabbitmq_service1.run + child_action: rabbitmq_service1.run diff --git a/examples/library_ceph/ceph.py b/examples/library_ceph/ceph.py index f6f11d2..24e173d 100644 --- a/examples/library_ceph/ceph.py +++ b/examples/library_ceph/ceph.py @@ -1,5 +1,5 @@ -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.dblayer.model import ModelMeta import yaml @@ -33,24 +33,24 @@ NETWORK_METADATA = yaml.load(""" def deploy(): ModelMeta.remove_all() - resources = vr.create('nodes', 'templates/nodes', {'count': 2}) + resources = cr.create('nodes', 'templates/nodes', {'count': 2}) first_node, second_node = [x for x in resources if x.name.startswith('node')] first_transp = next(x for x in resources if x.name.startswith('transport')) - library = vr.create('library1', 'resources/fuel_library', {})[0] + library = cr.create('library1', 'resources/fuel_library', {})[0] first_node.connect(library) - keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0] + keys = cr.create('ceph_key', 'resources/ceph_keys', {})[0] first_node.connect(keys) - remote_file = vr.create('ceph_key2', 'resources/remote_file', + remote_file = cr.create('ceph_key2', 'resources/remote_file', {'dest': '/var/lib/astute/'})[0] second_node.connect(remote_file) keys.connect(remote_file, {'ip': 'remote_ip', 'path': 'remote_path'}) first_transp.connect(remote_file, {'transports': 'remote'}) - ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon', + ceph_mon = cr.create('ceph_mon1', 'resources/ceph_mon', {'storage': STORAGE, 'keystone': KEYSTONE, 'network_scheme': NETWORK_SCHEMA, @@ -59,7 +59,7 @@ def deploy(): 'role': 'controller', })[0] - managed_apt = vr.create( + managed_apt = cr.create( 'managed_apt1', 'templates/mos_repos', {'node': first_node.name, 'index': 0})[-1] diff --git a/examples/lxc/example-lxc.py b/examples/lxc/example-lxc.py index 43d9e1f..79f690d 100755 --- a/examples/lxc/example-lxc.py +++ b/examples/lxc/example-lxc.py @@ -10,7 +10,7 @@ import click from solar.core import signals -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.system_log import change from solar.cli import orch @@ -45,10 +45,10 @@ def lxc_template(idx): def deploy(): ModelMeta.remove_all() - node1 = vr.create('nodes', 'templates/nodes', {})[0] - seed = vr.create('nodes', 'templates/seed_node', {})[0] + node1 = cr.create('nodes', 'templates/nodes', {})[0] + seed = cr.create('nodes', 'templates/seed_node', {})[0] - ssh_key = vr.create('ssh_key1', 'resources/ssh_key', { + ssh_key = cr.create('ssh_key1', 'resources/ssh_key', { 'keys_dir': '/vagrant/.ssh', 'private_key': '/vagrant/.ssh/id_rsa', 'public_key': '/vagrant/.ssh/id_rsa.pub', @@ -56,14 +56,14 @@ def deploy(): })[0] signals.connect(seed, ssh_key) - cnets1 = vr.create('cnets1', 'resources/container_networks', { + cnets1 = cr.create('cnets1', 'resources/container_networks', { 'networks': {'mgmt': { 'bridge': 'br-int53', 'bridge_address': '172.18.11.254/24' }} })[0] - cnets2 = vr.create('cnets2', 'resources/container_networks', { + cnets2 = cr.create('cnets2', 'resources/container_networks', { 'networks': {'mgmt': { 'bridge': 'br-int53', @@ -73,12 +73,12 @@ def deploy(): signals.connect(seed, cnets1) signals.connect(node1, cnets2) - vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', { + vxlan_mesh1 = cr.create('vxlan_mesh1', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' })[0] - vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', { + vxlan_mesh2 = cr.create('vxlan_mesh2', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' @@ -88,14 +88,14 @@ def deploy(): signals.connect(seed, vxlan_mesh1) signals.connect(node1, vxlan_mesh2) - lxc_infra1 = vr.create('lxc_infra1', 'resources/lxc_host', {})[0] + lxc_infra1 = cr.create('lxc_infra1', 'resources/lxc_host', {})[0] signals.connect(node1, lxc_infra1) lxc_hosts = range(28, 35) hosts_map = {} for idx in lxc_hosts: - lxc_host_idx = vr.create( + lxc_host_idx = cr.create( 'lxc_host{}'.format(idx), 'resources/lxc_container', lxc_template(idx))[0] hosts_map[idx] = lxc_host_idx @@ -112,15 +112,15 @@ def deploy(): 'private_key': 'user_key'}) # RABBIT - rabbitmq_service1 = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', { + rabbitmq_service1 = cr.create('rabbitmq_service1', 'resources/rabbitmq_service/', { 'management_port': 15672, 'port': 5672, })[0] - openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', { + openstack_vhost = cr.create('openstack_vhost', 'resources/rabbitmq_vhost/', { 'vhost_name': 'openstack' })[0] - openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', { + openstack_rabbitmq_user = cr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', { 'user_name': 'openstack', 'password': 'openstack_password' })[0] diff --git a/examples/openstack/openstack.py b/examples/openstack/openstack.py index 502aa7a..699404f 100755 --- a/examples/openstack/openstack.py +++ b/examples/openstack/openstack.py @@ -6,7 +6,7 @@ import sys from solar.core import resource from solar.core import signals from solar.core import validation -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar import events as evapi from solar.dblayer.model import ModelMeta @@ -40,9 +40,9 @@ def main(): def prepare_nodes(nodes_count): - resources = vr.create('nodes', 'templates/nodes_with_transports', {"count": nodes_count}) + resources = cr.create('nodes', 'templates/nodes_with_transports', {"count": nodes_count}) nodes = [x for x in resources if x.name.startswith('node')] - resources = vr.create('nodes_network', 'templates/nodes_network', {"count": nodes_count}) + resources = cr.create('nodes_network', 'templates/nodes_network', {"count": nodes_count}) nodes_sdn = [x for x in resources if x.name.startswith('node')] r = {} @@ -51,7 +51,7 @@ def prepare_nodes(nodes_count): r[node_sdn.name] = node_sdn # LIBRARIAN - librarian = vr.create('librarian_{}'.format(node.name), 'resources/librarian', {})[0] + librarian = cr.create('librarian_{}'.format(node.name), 'resources/librarian', {})[0] r[librarian.name] = librarian node.connect(librarian, {}) @@ -70,7 +70,7 @@ def prepare_nodes(nodes_count): def setup_base(node, librarian): # MARIADB - mariadb_service = vr.create('mariadb_service1', 'resources/mariadb_service', { + mariadb_service = cr.create('mariadb_service1', 'resources/mariadb_service', { 'image': 'mariadb', 'port': 3306 })[0] @@ -78,15 +78,15 @@ def setup_base(node, librarian): node.connect(mariadb_service) # RABBIT - rabbitmq_service = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', { + rabbitmq_service = cr.create('rabbitmq_service1', 'resources/rabbitmq_service/', { 'management_port': 15672, 'port': 5672, })[0] - openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', { + openstack_vhost = cr.create('openstack_vhost', 'resources/rabbitmq_vhost/', { 'vhost_name': 'openstack' })[0] - openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', { + openstack_rabbitmq_user = cr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', { 'user_name': 'openstack', 'password': 'openstack_password' })[0] @@ -105,21 +105,21 @@ def setup_base(node, librarian): 'openstack_rabbitmq_user': openstack_rabbitmq_user} def setup_keystone(node, librarian, mariadb_service, openstack_rabbitmq_user): - keystone_puppet = vr.create('keystone_puppet', 'resources/keystone_puppet', {})[0] + keystone_puppet = cr.create('keystone_puppet', 'resources/keystone_puppet', {})[0] keystone_puppet.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, keystone_puppet.name, actions=('run', 'update')) evapi.add_dep(openstack_rabbitmq_user.name, keystone_puppet.name, actions=('run', 'update')) - keystone_db = vr.create('keystone_db', 'resources/mariadb_db/', { + keystone_db = cr.create('keystone_db', 'resources/mariadb_db/', { 'db_name': 'keystone_db', 'login_user': 'root' })[0] - keystone_db_user = vr.create('keystone_db_user', 'resources/mariadb_user/', { + keystone_db_user = cr.create('keystone_db_user', 'resources/mariadb_user/', { 'user_name': 'keystone', 'user_password': 'keystone', })[0] - keystone_service_endpoint = vr.create('keystone_service_endpoint', 'resources/keystone_service_endpoint', { + keystone_service_endpoint = cr.create('keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'keystone', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2.0', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2.0', @@ -128,20 +128,20 @@ def setup_keystone(node, librarian, mariadb_service, openstack_rabbitmq_user): 'type': 'identity' })[0] - admin_tenant = vr.create('admin_tenant', 'resources/keystone_tenant', { + admin_tenant = cr.create('admin_tenant', 'resources/keystone_tenant', { 'tenant_name': 'admin' })[0] - admin_user = vr.create('admin_user', 'resources/keystone_user', { + admin_user = cr.create('admin_user', 'resources/keystone_user', { 'user_name': 'admin', 'user_password': 'admin' })[0] - admin_role = vr.create('admin_role', 'resources/keystone_role', { + admin_role = cr.create('admin_role', 'resources/keystone_role', { 'role_name': 'admin' })[0] - services_tenant = vr.create('services_tenant', 'resources/keystone_tenant', { + services_tenant = cr.create('services_tenant', 'resources/keystone_tenant', { 'tenant_name': 'services' })[0] - admin_role_services = vr.create('admin_role_services', 'resources/keystone_role', { + admin_role_services = cr.create('admin_role_services', 'resources/keystone_role', { 'role_name': 'admin' })[0] @@ -212,7 +212,7 @@ def setup_keystone(node, librarian, mariadb_service, openstack_rabbitmq_user): def setup_openrc(node, keystone_puppet, admin_user): # OPENRC - openrc = vr.create('openrc_file', 'resources/openrc_file', {})[0] + openrc = cr.create('openrc_file', 'resources/openrc_file', {})[0] node.connect(openrc) keystone_puppet.connect(openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'}) @@ -222,7 +222,7 @@ def setup_openrc(node, keystone_puppet, admin_user): def setup_neutron(node, librarian, rabbitmq_service, openstack_rabbitmq_user, openstack_vhost): # NEUTRON # Deploy chain neutron -> (plugins) -> neutron_server -> ( agents ) - neutron_puppet = vr.create('neutron_puppet', 'resources/neutron_puppet', { + neutron_puppet = cr.create('neutron_puppet', 'resources/neutron_puppet', { 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin' })[0] @@ -244,29 +244,29 @@ def setup_neutron(node, librarian, rabbitmq_service, openstack_rabbitmq_user, op def setup_neutron_api(node, mariadb_service, admin_user, keystone_puppet, services_tenant, neutron_puppet): # NEUTRON PLUGIN AND NEUTRON API (SERVER) - neutron_plugins_ml2 = vr.create('neutron_plugins_ml2', 'resources/neutron_plugins_ml2_puppet', {})[0] + neutron_plugins_ml2 = cr.create('neutron_plugins_ml2', 'resources/neutron_plugins_ml2_puppet', {})[0] node.connect(neutron_plugins_ml2) - neutron_server_puppet = vr.create('neutron_server_puppet', 'resources/neutron_server_puppet', { + neutron_server_puppet = cr.create('neutron_server_puppet', 'resources/neutron_server_puppet', { 'sync_db': True, })[0] evapi.add_dep(neutron_puppet.name, neutron_server_puppet.name, actions=('run',)) evapi.add_dep(neutron_plugins_ml2.name, neutron_server_puppet.name, actions=('run',)) evapi.add_dep(neutron_puppet.name, neutron_plugins_ml2.name, actions=('run',)) - neutron_db = vr.create('neutron_db', 'resources/mariadb_db/', { + neutron_db = cr.create('neutron_db', 'resources/mariadb_db/', { 'db_name': 'neutron_db', 'login_user': 'root'})[0] - neutron_db_user = vr.create('neutron_db_user', 'resources/mariadb_user/', { + neutron_db_user = cr.create('neutron_db_user', 'resources/mariadb_user/', { 'user_name': 'neutron', 'user_password': 'neutron', 'login_user': 'root'})[0] - neutron_keystone_user = vr.create('neutron_keystone_user', 'resources/keystone_user', { + neutron_keystone_user = cr.create('neutron_keystone_user', 'resources/keystone_user', { 'user_name': 'neutron', 'user_password': 'neutron' })[0] - neutron_keystone_role = vr.create('neutron_keystone_role', 'resources/keystone_role', { + neutron_keystone_role = cr.create('neutron_keystone_role', 'resources/keystone_role', { 'role_name': 'admin' })[0] evapi.add_dep(neutron_keystone_role.name, neutron_server_puppet.name, actions=('run',)) - neutron_keystone_service_endpoint = vr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', { + neutron_keystone_service_endpoint = cr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'neutron', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', @@ -323,7 +323,7 @@ def setup_neutron_api(node, mariadb_service, admin_user, keystone_puppet, servic def setup_neutron_agent(node, neutron_server_puppet): # NEUTRON ML2 PLUGIN & ML2-OVS AGENT WITH GRE - neutron_agents_ml2 = vr.create('neutron_agents_ml2', 'resources/neutron_agents_ml2_ovs_puppet', { + neutron_agents_ml2 = cr.create('neutron_agents_ml2', 'resources/neutron_agents_ml2_ovs_puppet', { # TODO(bogdando) these should come from the node network resource 'enable_tunneling': True, 'tunnel_types': ['gre'], @@ -333,11 +333,11 @@ def setup_neutron_agent(node, neutron_server_puppet): evapi.add_dep(neutron_server_puppet.name, neutron_agents_ml2.name, actions=('run',)) # NEUTRON DHCP, L3, metadata agents - neutron_agents_dhcp = vr.create('neutron_agents_dhcp', 'resources/neutron_agents_dhcp_puppet', {})[0] + neutron_agents_dhcp = cr.create('neutron_agents_dhcp', 'resources/neutron_agents_dhcp_puppet', {})[0] node.connect(neutron_agents_dhcp) evapi.add_dep(neutron_server_puppet.name, neutron_agents_dhcp.name, actions=('run',)) - neutron_agents_l3 = vr.create('neutron_agents_l3', 'resources/neutron_agents_l3_puppet', { + neutron_agents_l3 = cr.create('neutron_agents_l3', 'resources/neutron_agents_l3_puppet', { # TODO(bogdando) these should come from the node network resource 'metadata_port': 8775, 'external_network_bridge': 'br-floating', @@ -345,7 +345,7 @@ def setup_neutron_agent(node, neutron_server_puppet): node.connect(neutron_agents_l3) evapi.add_dep(neutron_server_puppet.name, neutron_agents_l3.name, actions=('run',)) - neutron_agents_metadata = vr.create('neutron_agents_metadata', 'resources/neutron_agents_metadata_puppet', { + neutron_agents_metadata = cr.create('neutron_agents_metadata', 'resources/neutron_agents_metadata_puppet', { 'sh2ared_secret': 'secret', })[0] node.connect(neutron_agents_metadata) @@ -361,7 +361,7 @@ def setup_neutron_compute(node, librarian, neutron_puppet, neutron_server_puppet # NEUTRON FOR COMPUTE (node1) # Deploy chain neutron -> (plugins) -> ( agents ) name = node.name - neutron_puppet2 = vr.create('neutron_puppet_{}'.format(name), 'resources/neutron_puppet', {})[0] + neutron_puppet2 = cr.create('neutron_puppet_{}'.format(name), 'resources/neutron_puppet', {})[0] neutron_puppet2.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, neutron_puppet2.name, actions=('run', 'update')) @@ -378,12 +378,12 @@ def setup_neutron_compute(node, librarian, neutron_puppet, neutron_server_puppet }) # NEUTRON OVS PLUGIN & AGENT WITH GRE FOR COMPUTE (node1) - neutron_plugins_ml22 = vr.create('neutron_plugins_ml_{}'.format(name), 'resources/neutron_plugins_ml2_puppet', {})[0] + neutron_plugins_ml22 = cr.create('neutron_plugins_ml_{}'.format(name), 'resources/neutron_plugins_ml2_puppet', {})[0] node.connect(neutron_plugins_ml22) evapi.add_dep(neutron_puppet2.name, neutron_plugins_ml22.name, actions=('run',)) evapi.add_dep(neutron_server_puppet.name, neutron_plugins_ml22.name, actions=('run',)) - neutron_agents_ml22 = vr.create('neutron_agents_ml_{}'.format(name), 'resources/neutron_agents_ml2_ovs_puppet', { + neutron_agents_ml22 = cr.create('neutron_agents_ml_{}'.format(name), 'resources/neutron_agents_ml2_ovs_puppet', { # TODO(bogdando) these should come from the node network resource 'enable_tunneling': True, 'tunnel_types': ['gre'], @@ -399,16 +399,16 @@ def setup_neutron_compute(node, librarian, neutron_puppet, neutron_server_puppet def setup_cinder(node, librarian, rabbitmq_service, mariadb_service, keystone_puppet, admin_user, openstack_vhost, openstack_rabbitmq_user, services_tenant): # CINDER - cinder_puppet = vr.create('cinder_puppet', 'resources/cinder_puppet', {})[0] - cinder_db = vr.create('cinder_db', 'resources/mariadb_db/', { + cinder_puppet = cr.create('cinder_puppet', 'resources/cinder_puppet', {})[0] + cinder_db = cr.create('cinder_db', 'resources/mariadb_db/', { 'db_name': 'cinder_db', 'login_user': 'root'})[0] - cinder_db_user = vr.create('cinder_db_user', 'resources/mariadb_user/', { + cinder_db_user = cr.create('cinder_db_user', 'resources/mariadb_user/', { 'user_name': 'cinder', 'user_password': 'cinder', 'login_user': 'root'})[0] - cinder_keystone_user = vr.create('cinder_keystone_user', 'resources/keystone_user', { + cinder_keystone_user = cr.create('cinder_keystone_user', 'resources/keystone_user', { 'user_name': 'cinder', 'user_password': 'cinder'})[0] - cinder_keystone_role = vr.create('cinder_keystone_role', 'resources/keystone_role', { + cinder_keystone_role = cr.create('cinder_keystone_role', 'resources/keystone_role', { 'role_name': 'admin'})[0] - cinder_keystone_service_endpoint = vr.create( + cinder_keystone_service_endpoint = cr.create( 'cinder_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'cinder', @@ -454,7 +454,7 @@ def setup_cinder(node, librarian, rabbitmq_service, mariadb_service, keystone_pu # CINDER GLANCE # Deploy chain: cinder_puppet -> cinder_glance -> ( cinder_api, cinder_scheduler, cinder_volume ) - cinder_glance_puppet = vr.create('cinder_glance_puppet', 'resources/cinder_glance_puppet', {})[0] + cinder_glance_puppet = cr.create('cinder_glance_puppet', 'resources/cinder_glance_puppet', {})[0] node.connect(cinder_glance_puppet) evapi.add_dep(cinder_puppet.name, cinder_glance_puppet.name, actions=('run',)) @@ -468,7 +468,7 @@ def setup_cinder(node, librarian, rabbitmq_service, mariadb_service, keystone_pu def setup_cinder_api(node, cinder_puppet): # CINDER API - cinder_api_puppet = vr.create('cinder_api_puppet', 'resources/cinder_api_puppet', {})[0] + cinder_api_puppet = cr.create('cinder_api_puppet', 'resources/cinder_api_puppet', {})[0] node.connect(cinder_api_puppet) cinder_puppet.connect(cinder_api_puppet, { 'keystone_password', 'keystone_tenant', 'keystone_user'}) @@ -480,7 +480,7 @@ def setup_cinder_api(node, cinder_puppet): def setup_cinder_scheduler(node, cinder_puppet): # CINDER SCHEDULER - cinder_scheduler_puppet = vr.create('cinder_scheduler_puppet', 'resources/cinder_scheduler_puppet', {})[0] + cinder_scheduler_puppet = cr.create('cinder_scheduler_puppet', 'resources/cinder_scheduler_puppet', {})[0] node.connect(cinder_scheduler_puppet) cinder_puppet.connect(cinder_scheduler_puppet) evapi.add_react(cinder_puppet.name, cinder_scheduler_puppet.name, actions=('update',)) @@ -488,11 +488,11 @@ def setup_cinder_scheduler(node, cinder_puppet): def setup_cinder_volume(node, cinder_puppet): # CINDER VOLUME - cinder_volume = vr.create('cinder_volume_{}'.format(node.name), 'resources/volume_group', + cinder_volume = cr.create('cinder_volume_{}'.format(node.name), 'resources/volume_group', {'path': '/root/cinder.img', 'volume_name': 'cinder-volume'})[0] node.connect(cinder_volume) - cinder_volume_puppet = vr.create('cinder_volume_puppet', 'resources/cinder_volume_puppet', {})[0] + cinder_volume_puppet = cr.create('cinder_volume_puppet', 'resources/cinder_volume_puppet', {})[0] node.connect(cinder_volume_puppet) cinder_puppet.connect(cinder_volume_puppet) evapi.add_react(cinder_puppet.name, cinder_volume_puppet.name, actions=('update',)) @@ -501,20 +501,20 @@ def setup_cinder_volume(node, cinder_puppet): def setup_nova(node, librarian, mariadb_service, rabbitmq_service, admin_user, openstack_vhost, services_tenant, keystone_puppet, openstack_rabbitmq_user): # NOVA - nova_puppet = vr.create('nova_puppet', 'resources/nova_puppet', {})[0] - nova_db = vr.create('nova_db', 'resources/mariadb_db/', { + nova_puppet = cr.create('nova_puppet', 'resources/nova_puppet', {})[0] + nova_db = cr.create('nova_db', 'resources/mariadb_db/', { 'db_name': 'nova_db', 'login_user': 'root'})[0] - nova_db_user = vr.create('nova_db_user', 'resources/mariadb_user/', { + nova_db_user = cr.create('nova_db_user', 'resources/mariadb_user/', { 'user_name': 'nova', 'user_password': 'nova', 'login_user': 'root'})[0] - nova_keystone_user = vr.create('nova_keystone_user', 'resources/keystone_user', { + nova_keystone_user = cr.create('nova_keystone_user', 'resources/keystone_user', { 'user_name': 'nova', 'user_password': 'nova'})[0] - nova_keystone_role = vr.create('nova_keystone_role', 'resources/keystone_role', { + nova_keystone_role = cr.create('nova_keystone_role', 'resources/keystone_role', { 'role_name': 'admin'})[0] - nova_keystone_service_endpoint = vr.create('nova_keystone_service_endpoint', 'resources/keystone_service_endpoint', { + nova_keystone_service_endpoint = cr.create('nova_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'nova', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2/%(tenant_id)s', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2/%(tenant_id)s', @@ -577,7 +577,7 @@ def setup_nova(node, librarian, mariadb_service, rabbitmq_service, admin_user, o def setup_nova_api(node, nova_puppet, neutron_agents_metadata): # NOVA API - nova_api_puppet = vr.create('nova_api_puppet', 'resources/nova_api_puppet', {})[0] + nova_api_puppet = cr.create('nova_api_puppet', 'resources/nova_api_puppet', {})[0] node.connect(nova_api_puppet) nova_puppet.connect(nova_api_puppet, { 'keystone_tenant': 'admin_tenant_name', @@ -591,7 +591,7 @@ def setup_nova_api(node, nova_puppet, neutron_agents_metadata): def setup_nova_conductor(node, nova_puppet, nova_api_puppet): # NOVA CONDUCTOR - nova_conductor_puppet = vr.create('nova_conductor_puppet', 'resources/nova_conductor_puppet', {})[0] + nova_conductor_puppet = cr.create('nova_conductor_puppet', 'resources/nova_conductor_puppet', {})[0] node.connect(nova_conductor_puppet) nova_puppet.connect(nova_conductor_puppet) evapi.add_dep(nova_api_puppet.name, nova_conductor_puppet.name, actions=('run',)) @@ -602,7 +602,7 @@ def setup_nova_scheduler(node, nova_puppet, nova_api_puppet): # NOVA SCHEDULER # NOTE(bogdando) Generic service is used. Package and service names for Ubuntu case # come from https://github.com/openstack/puppet-nova/blob/5.1.0/manifests/params.pp - nova_scheduler_puppet = vr.create('nova_scheduler_puppet', 'resources/nova_generic_service_puppet', { + nova_scheduler_puppet = cr.create('nova_scheduler_puppet', 'resources/nova_generic_service_puppet', { 'title' : 'scheduler', 'package_name': 'nova-scheduler', 'service_name': 'nova-scheduler', })[0] node.connect(nova_scheduler_puppet) @@ -615,9 +615,9 @@ def setup_nova_compute(node, librarian, nova_puppet, nova_api_puppet, neutron_se # NOVA COMPUTE # Deploy chain (nova, node_networking(TODO)) -> (nova_compute_libvirt, nova_neutron) -> nova_compute name = node.name - nova_compute_puppet = vr.create('nova_compute_puppet_{}'.format(name), 'resources/nova_compute_puppet', {})[0] + nova_compute_puppet = cr.create('nova_compute_puppet_{}'.format(name), 'resources/nova_compute_puppet', {})[0] # TODO (bogdando) figure out how to use it for multiple glance api servers - nova_puppet2 = vr.create('nova_puppet_{}'.format(name), 'resources/nova_puppet', { + nova_puppet2 = cr.create('nova_puppet_{}'.format(name), 'resources/nova_puppet', { 'glance_api_servers': '{{glance_api_servers_host}}:{{glance_api_servers_port}}' })[0] nova_puppet.connect(nova_puppet2, { @@ -643,13 +643,13 @@ def setup_nova_compute(node, librarian, nova_puppet, nova_api_puppet, neutron_se # NOVA COMPUTE LIBVIRT, NOVA_NEUTRON # NOTE(bogdando): changes nova config, so should notify nova compute service - nova_compute_libvirt_puppet = vr.create('nova_compute_libvirt_puppet_{}'.format(name), 'resources/nova_compute_libvirt_puppet', {})[0] + nova_compute_libvirt_puppet = cr.create('nova_compute_libvirt_puppet_{}'.format(name), 'resources/nova_compute_libvirt_puppet', {})[0] node.connect(nova_compute_libvirt_puppet) evapi.add_dep(nova_puppet2.name, nova_compute_libvirt_puppet.name, actions=('run',)) evapi.add_dep(nova_api_puppet.name, nova_compute_libvirt_puppet.name, actions=('run',)) # compute configuration for neutron, use http auth/endpoint protocols, keystone v2 auth hardcoded for the resource - nova_neutron_puppet = vr.create('nova_neutron_puppet_{}'.format(name), 'resources/nova_neutron_puppet', {})[0] + nova_neutron_puppet = cr.create('nova_neutron_puppet_{}'.format(name), 'resources/nova_neutron_puppet', {})[0] node.connect(nova_neutron_puppet) evapi.add_dep(nova_puppet2.name, nova_neutron_puppet.name, actions=('run',)) evapi.add_dep(nova_api_puppet.name, nova_neutron_puppet.name, actions=('run',)) @@ -681,16 +681,16 @@ def setup_nova_compute(node, librarian, nova_puppet, nova_api_puppet, neutron_se def setup_glance_api(node, librarian, mariadb_service, admin_user, keystone_puppet, services_tenant, cinder_glance_puppet): # GLANCE (base and API) - glance_api_puppet = vr.create('glance_api_puppet', 'resources/glance_puppet', {})[0] - glance_db_user = vr.create('glance_db_user', 'resources/mariadb_user/', { + glance_api_puppet = cr.create('glance_api_puppet', 'resources/glance_puppet', {})[0] + glance_db_user = cr.create('glance_db_user', 'resources/mariadb_user/', { 'user_name': 'glance', 'user_password': 'glance', 'login_user': 'root'})[0] - glance_db = vr.create('glance_db', 'resources/mariadb_db/', { + glance_db = cr.create('glance_db', 'resources/mariadb_db/', { 'db_name': 'glance', 'login_user': 'root'})[0] - glance_keystone_user = vr.create('glance_keystone_user', 'resources/keystone_user', { + glance_keystone_user = cr.create('glance_keystone_user', 'resources/keystone_user', { 'user_name': 'glance', 'user_password': 'glance123'})[0] - glance_keystone_role = vr.create('glance_keystone_role', 'resources/keystone_role', { + glance_keystone_role = cr.create('glance_keystone_role', 'resources/keystone_role', { 'role_name': 'admin'})[0] - glance_keystone_service_endpoint = vr.create( + glance_keystone_service_endpoint = cr.create( 'glance_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'glance', @@ -750,7 +750,7 @@ def setup_glance_api(node, librarian, mariadb_service, admin_user, keystone_pupp def setup_glance_registry(node, glance_api_puppet): # GLANCE REGISTRY - glance_registry_puppet = vr.create('glance_registry_puppet', 'resources/glance_registry_puppet', {})[0] + glance_registry_puppet = cr.create('glance_registry_puppet', 'resources/glance_registry_puppet', {})[0] node.connect(glance_registry_puppet) glance_api_puppet.connect(glance_registry_puppet) evapi.add_react(glance_api_puppet.name, glance_registry_puppet.name, actions=('update',)) diff --git a/examples/openstack/rabbitmq_user.yaml b/examples/openstack/rabbitmq_user.yaml index 2ec6433..fd20b55 100644 --- a/examples/openstack/rabbitmq_user.yaml +++ b/examples/openstack/rabbitmq_user.yaml @@ -4,14 +4,14 @@ resources: - id: rabbit_user from: resources/rabbitmq_user location: {{node}} - values: + input: user_name: {{user_name}} password: {{password}} vhost_name: {{vhost_res}}::vhost_name updates: - id: {{for}} - values: + input: {{for_user}}: rabbit_user::user_name {{for_password}}: rabbit_user::password @@ -19,4 +19,4 @@ events: - type: depends_on parent_action: rabbit_user.run state: success - depend_action: {{for}}.update + child_action: {{for}}.update diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index 14c88c6..2abd712 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import requests -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.events.api import add_event from solar.events.controls import React @@ -40,7 +40,7 @@ requests.post(bareon_sync) nodes_list = requests.get(discovery_service).json() # Create slave node resources -node_resources = vr.create('nodes', 'templates/not_provisioned_nodes', +node_resources = cr.create('nodes', 'templates/not_provisioned_nodes', {'nodes': nodes_list}) # Get master node @@ -63,7 +63,7 @@ for node in nodes_list: } ) - dnsmasq = vr.create('dnsmasq_{0}'.format(node.node_id), + dnsmasq = cr.create('dnsmasq_{0}'.format(node.node_id), 'resources/dnsmasq', {})[0] master_node.connect(dnsmasq) node_resource.connect(dnsmasq, {'admin_mac': 'exclude_mac_pxe'}) diff --git a/examples/riak/haproxy_riak_config.yaml b/examples/riak/haproxy_riak_config.yaml index 2a04469..34c49bb 100644 --- a/examples/riak/haproxy_riak_config.yaml +++ b/examples/riak/haproxy_riak_config.yaml @@ -4,38 +4,38 @@ resources: - id: haproxy_riak_config_http from: resources/haproxy_service_config tags: ['service=riak', 'protocol=http'] - values: - listen_port: {{http_listen_port}} + input: + listen_port: #{http_listen_port}# protocol: 'http' name: 'riak_haproxy_http' backends:server: - {% for riak in riaks %} - - {{riak}}::riak_hostname - {% endfor %} + #% for riak in riaks %# + - #{riak}#::riak_hostname + #% endfor %# backends:port: - {% for riak in riaks %} - - {{riak}}::riak_port_http - {% endfor %} + #% for riak in riaks %# + - #{riak}#::riak_port_http + #% endfor %# - id: haproxy_riak_config_pb from: resources/haproxy_service_config tags: ['service=riak', 'protocol=tcp'] - values: - listen_port: {{pb_listen_port}} + input: + listen_port: #{pb_listen_port}# protocol: 'tcp' name: 'riak_haproxy_pb' backends:server: - {% for riak in riaks %} - - {{riak}}::riak_hostname - {% endfor %} + #% for riak in riaks %# + - #{riak}#::riak_hostname + #% endfor %# backends:port: - {% for riak in riaks %} - - {{riak}}::riak_port_pb - {% endfor %} + #% for riak in riaks %# + - #{riak}#::riak_port_pb + #% endfor %# updates: - with_tags: ['resource=haproxy_config'] - values: + input: config:protocol: - haproxy_riak_config_http::protocol - haproxy_riak_config_pb::protocol diff --git a/examples/riak/riak_cluster.yaml b/examples/riak/riak_cluster.yaml index 277ab22..5b14533 100644 --- a/examples/riak/riak_cluster.yaml +++ b/examples/riak/riak_cluster.yaml @@ -3,49 +3,49 @@ id: riak_cluster resources: - id: riak_service1 from: examples/riak/riak_service.yaml - values: - node: {{nodes[0]}} + input: + node: #{nodes[0]}# index: 1 join_to: '' - id: riak_service2 from: examples/riak/riak_service.yaml - values: - node: {{nodes[1]}} + input: + node: #{nodes[1]}# index: 2 join_to: riak_service1 - id: riak_service3 from: examples/riak/riak_service.yaml - values: - node: {{nodes[2]}} + input: + node: #{nodes[2]}# index: 3 join_to: riak_service1 - id: haproxy_riak_config from: examples/riak/haproxy_riak_config.yaml - values: + input: http_listen_port: 8098 pb_listen_port: 8087 riaks: ['riak_service1', 'riak_service2', 'riak_service3'] - id: haproxy1 from: templates/haproxy - values: - node: {{nodes[0]}} + input: + node: #{nodes[0]}# service_configs: ['haproxy_riak_config_pb', 'haproxy_riak_config_http'] index: 1 - id: haproxy2 from: templates/haproxy - values: - node: {{nodes[1]}} + input: + node: #{nodes[1]}# service_configs: ['haproxy_riak_config_pb', 'haproxy_riak_config_http'] index: 2 - id: haproxy3 from: templates/haproxy - values: - node: {{nodes[2]}} + input: + node: #{nodes[2]}# service_configs: ['haproxy_riak_config_pb', 'haproxy_riak_config_http'] index: 3 diff --git a/examples/riak/riak_service.yaml b/examples/riak/riak_service.yaml index ad2c983..e047488 100644 --- a/examples/riak/riak_service.yaml +++ b/examples/riak/riak_service.yaml @@ -1,61 +1,61 @@ id: riak_service resources: - - id: riak_service{{index}} + - id: riak_service#{index}# from: resources/riak_node - location: {{node}} - values: - riak_self_name: riak{{index}} - riak_hostname: riak_server{{index}}.solar - riak_name: riak{{index}}@riak_server{{index}}.solar - {% if join_to %} - join_to: {{join_to}}::riak_name - {% endif %} - ip: {{node}}::ip + location: #{node}# + input: + riak_self_name: riak#{index}# + riak_hostname: riak_server#{index}#.solar + riak_name: riak#{index}#@riak_server#{index}#.solar + #% if join_to %# + join_to: #{join_to}#::riak_name + #% endif %# + ip: #{node}#::ip updates: - with_tags: 'resource=hosts_file' - values: + input: hosts:name: - - riak_service{{index}}::riak_hostname::NO_EVENTS + - riak_service#{index}#::riak_hostname::NO_EVENTS hosts:ip: - - riak_service{{index}}::ip::NO_EVENTS + - riak_service#{index}#::ip::NO_EVENTS - with_tags: 'resource=haproxy_service_config & service=riak & protocol=http' - values: + input: backends:server: - - riak_service{{index}}::riak_hostname + - riak_service#{index}#::riak_hostname backends:port: - - riak_service{{index}}::riak_port_http + - riak_service#{index}#::riak_port_http - with_tags: 'resource=haproxy_service_config & service=riak & protocol=tcp' - values: + input: backends:server: - - riak_service{{index}}::riak_hostname + - riak_service#{index}#::riak_hostname backends:port: - - riak_service{{index}}::riak_port_pb + - riak_service#{index}#::riak_port_pb events: - type: depends_on parent: - with_tags: 'resource=hosts_file & location={{node}}' + with_tags: 'resource=hosts_file & location=#{node}#' action: run state: success - depend_action: riak_service{{index}}.run + child_action: riak_service#{index}#.run -{% if join_to %} +#% if join_to %# - type: react_on - parent_action: riak_service{{index}}.run + parent_action: riak_service#{index}#.run state: success - depend_action: riak_service{{index}}.join + child_action: riak_service#{index}#.join - type: react_on - parent_action: riak_service{{index}}.leave + parent_action: riak_service#{index}#.leave state: success - depend_action: riak_service{{index}}.join + child_action: riak_service#{index}#.join - type: react_on - parent_action: riak_service{{index}}.join + parent_action: riak_service#{index}#.join state: success - depend_action: {{join_to}}.commit -{% endif %} + child_action: #{join_to}#.commit +#% endif %# diff --git a/examples/riak/riaks.py b/examples/riak/riaks.py index afe3c52..40e890f 100755 --- a/examples/riak/riaks.py +++ b/examples/riak/riaks.py @@ -17,7 +17,7 @@ import sys from solar.core import resource from solar.core import signals from solar.core import validation -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar import errors from solar.dblayer.model import ModelMeta @@ -31,7 +31,7 @@ from solar.dblayer.solar_models import Resource def setup_riak(): ModelMeta.remove_all() - resources = vr.create('nodes', 'templates/nodes', {'count': 3}) + resources = cr.create('nodes', 'templates/nodes', {'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 @@ -41,7 +41,7 @@ def setup_riak(): ips = '10.0.0.%d' for i in xrange(3): num = i + 1 - r = vr.create('riak_service%d' % num, + r = cr.create('riak_service%d' % num, 'resources/riak_node', {'riak_self_name': 'riak%d' % num, 'storage_backend': 'leveldb', @@ -113,18 +113,18 @@ def setup_haproxies(): hpsc_pb = [] for i in xrange(3): num = i + 1 - hps.append(vr.create('haproxy_service%d' % num, + hps.append(cr.create('haproxy_service%d' % num, 'resources/haproxy_service', {})[0]) - hpc.append(vr.create('haproxy_config%d' % num, + hpc.append(cr.create('haproxy_config%d' % num, 'resources/haproxy_config', {})[0]) - hpsc_http.append(vr.create('haproxy_service_config_http%d' % num, + hpsc_http.append(cr.create('haproxy_service_config_http%d' % num, 'resources/haproxy_service_config', {'listen_port': 8098, 'protocol': 'http', 'name': 'riak_haproxy_http%d' % num})[0]) - hpsc_pb.append(vr.create('haproxy_service_config_pb%d' % num, + hpsc_pb.append(cr.create('haproxy_service_config_pb%d' % num, 'resources/haproxy_service_config', {'listen_port': 8087, 'protocol': 'tcp', @@ -208,12 +208,12 @@ def setup_haproxies(): @click.command() @click.argument('i', type=int, required=True) def add_solar_agent(i): - solar_agent_transport = vr.create('solar_agent_transport%s' % i, 'resources/transport_solar_agent', + 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 = vr.create('transports_for_solar_agent%s' % i, 'resources/transports')[0] + 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, {}) diff --git a/examples/riak/riaks_big.py b/examples/riak/riaks_big.py index 9525f3d..679be4d 100755 --- a/examples/riak/riaks_big.py +++ b/examples/riak/riaks_big.py @@ -8,7 +8,7 @@ import sys from solar.core import resource from solar.core import signals from solar.core import validation -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar import errors from solar.interfaces.db import get_db @@ -28,7 +28,7 @@ def setup_riak(nodes_num=None, hosts_mapping=False): nodes_num = NODES db.clear() - resources = vr.create('nodes', 'templates/nodes', {'count': nodes_num}) + resources = cr.create('nodes', 'templates/nodes', {'count': nodes_num}) nodes = [x for x in resources if x.name.startswith('node')] hosts_services = [x for x in resources if x.name.startswith('hosts_file')] @@ -36,7 +36,7 @@ def setup_riak(nodes_num=None, hosts_mapping=False): ips = '10.0.0.%d' for i in xrange(nodes_num): num = i + 1 - r = vr.create('riak_service%d' % num, + r = cr.create('riak_service%d' % num, 'resources/riak_node', {'riak_self_name': 'riak%d' % num, 'riak_hostname': 'riak_server%d.solar' % num, diff --git a/examples/solar_agent/example.py b/examples/solar_agent/example.py index 3bc248c..08114b6 100644 --- a/examples/solar_agent/example.py +++ b/examples/solar_agent/example.py @@ -4,26 +4,26 @@ import time from solar.core import resource from solar.core import signals -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar.dblayer.model import ModelMeta def run(): ModelMeta.remove_all() - node = vr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()), + node = cr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()), 'ip': '10.0.0.3', 'node_id': 'node1', })[0] - transports = vr.create('transports_node1', 'resources/transports')[0] - transports_for_solar_agent = vr.create('transports_for_solar_agent', 'resources/transports')[0] + transports = cr.create('transports_node1', 'resources/transports')[0] + transports_for_solar_agent = cr.create('transports_for_solar_agent', 'resources/transports')[0] - ssh_transport = vr.create('ssh_transport', 'resources/transport_ssh', + ssh_transport = cr.create('ssh_transport', 'resources/transport_ssh', {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': 'vagrant'})[0] - solar_agent_transport = vr.create('solar_agent_transport', 'resources/transport_solar_agent', + solar_agent_transport = cr.create('solar_agent_transport', 'resources/transport_solar_agent', {'solar_agent_user': 'vagrant', 'solar_agent_password': 'password'})[0] @@ -46,7 +46,7 @@ def run(): 'name': 'transports:name'}) - hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0] + hosts = cr.create('hosts_file', 'resources/hosts_file', {})[0] node.connect(hosts, { 'ip': 'hosts:ip', 'name': 'hosts:name' diff --git a/examples/torrent/example.py b/examples/torrent/example.py index 5043baa..2c09233 100644 --- a/examples/torrent/example.py +++ b/examples/torrent/example.py @@ -1,6 +1,6 @@ import time -from solar.core.resource import virtual_resource as vr +from solar.core.resource import composer as cr from solar import errors from solar.dblayer.model import ModelMeta @@ -8,14 +8,14 @@ from solar.dblayer.model import ModelMeta def run(): ModelMeta.remove_all() - node = vr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()), + node = cr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()), 'ip': '10.0.0.3', 'node_id': 'node1', })[0] - transports = vr.create('transports_node1', 'resources/transports')[0] + transports = cr.create('transports_node1', 'resources/transports')[0] - ssh_transport = vr.create('ssh_transport', 'resources/transport_ssh', + ssh_transport = cr.create('ssh_transport', 'resources/transport_ssh', {'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': 'vagrant'})[0] @@ -27,17 +27,17 @@ def run(): 'ssh_port': 'transports:port', 'name': 'transports:name'}) - hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0] + hosts = cr.create('hosts_file', 'resources/hosts_file', {})[0] # let's add torrent transport for hosts file deployment (useless in real life) - torrent_transport = vr.create('torrent_transport', + torrent_transport = cr.create('torrent_transport', 'resources/transport_torrent', {'trackers': ['udp://open.demonii.com:1337', 'udp://tracker.openbittorrent.com:80']})[0] # you could use any trackers as you want - transports_for_torrent = vr.create( + transports_for_torrent = cr.create( 'transports_for_torrent', 'resources/transports')[0] transports_for_torrent.connect(torrent_transport, {}) @@ -48,7 +48,7 @@ def run(): 'name': 'transports:name'}, events={}) - transports_for_hosts = vr.create( + transports_for_hosts = cr.create( 'transports_for_hosts', 'resources/transports')[0] torrent_transport.connect(transports_for_hosts, {'trackers': 'transports:trackers', diff --git a/templates/controller/1.0.0/controller.yaml b/templates/controller/1.0.0/controller.yaml index 5d34bc6..20e34c6 100644 --- a/templates/controller/1.0.0/controller.yaml +++ b/templates/controller/1.0.0/controller.yaml @@ -3,7 +3,7 @@ id: primary_controller resources: - id: mariadb_service from: resources/mariadb_service - values: + input: port: 3306 root_password: mariadb image: mariadb @@ -13,14 +13,14 @@ resources: - id: rabbitmq_service from: resources/rabbitmq_service - values: + input: ip: '#{ip}#' ssh_user: '#{ssh_user}#' ssh_key: '#{ssh_key}#' - id: keystone_base from: templates/keystone_base - values: + input: login_user: root login_password: 'mariadb_service::root_password' login_port: 'mariadb_service::port' @@ -34,7 +34,7 @@ resources: - id: keystone_api_1 from: templates/keystone_api - values: + input: idx: 1 db_password: 'keystone_db_user::user_password' db_user: 'keystone_db_user::user_name' @@ -50,7 +50,7 @@ resources: - id: openstack_base from: templates/openstack_base - values: + input: ip: '#{ip}#' ssh_user: '#{ssh_user}#' ssh_key: '#{ssh_key}#' @@ -61,7 +61,7 @@ resources: - id: openrc_file from: resources/openrc_file - values: + input: keystone_host: 'keystone_service_1::ip' keystone_port: 'keystone_service_1::admin_port' tenant: 'admin_user::tenant_name' diff --git a/templates/glance/1.0.0/glance.yaml b/templates/glance/1.0.0/glance.yaml index 475b20a..021db28 100644 --- a/templates/glance/1.0.0/glance.yaml +++ b/templates/glance/1.0.0/glance.yaml @@ -3,7 +3,7 @@ id: glance_#{idx}# resources: - id: glance_base_#{ idx }# from: templates/glance_db - values: + input: idx: '#{ idx }#' db_name: '#{ db_name }#' diff --git a/templates/glance_base/1.0.0/glance_base.yaml b/templates/glance_base/1.0.0/glance_base.yaml index ab11e60..1cc4639 100644 --- a/templates/glance_base/1.0.0/glance_base.yaml +++ b/templates/glance_base/1.0.0/glance_base.yaml @@ -3,7 +3,7 @@ id: glance_base resources: - id: glance_db from: resources/mariadb_db - values: + input: db_name: #{db_name}# login_user: '#{login_user}#' login_password: '#{login_password}#' @@ -14,7 +14,7 @@ resources: - id: glance_db_user from: resources/mariadb_user - values: + input: user_password: '#{user_password}#' user_name: '#{user_name}#' db_name: 'keystone_db::db_name' diff --git a/templates/glance_db/1.0.0/glance_db.yaml b/templates/glance_db/1.0.0/glance_db.yaml index 6f750fe..b64f14c 100644 --- a/templates/glance_db/1.0.0/glance_db.yaml +++ b/templates/glance_db/1.0.0/glance_db.yaml @@ -3,7 +3,7 @@ id: glance_db_#{ idx }# resources: - id: glance_db_db_#{ idx }# from: resources/mariadb_db - values: + input: db_name: '#{ db_name }#' login_user: '#{ db_login_user }#' login_password: '#{ db_login_password }#' @@ -15,7 +15,7 @@ resources: - id: glance_db_user from: resources/mariadb_user - values: + input: user_password: '#{ db_password }#' user_name: '#{ db_user }#' diff --git a/templates/glance_registry/1.0.0/glance_registry.yaml b/templates/glance_registry/1.0.0/glance_registry.yaml index c5bbff8..5d30cb0 100644 --- a/templates/glance_registry/1.0.0/glance_registry.yaml +++ b/templates/glance_registry/1.0.0/glance_registry.yaml @@ -3,7 +3,7 @@ id: glance_register_#{idx}# resources: - id: glance_config_#{idx}# from: resources/glance_config - values: + input: keystone_admin_port: '#{keystone_admin_port}#' keystone_ip: '#{keystone_ip}#' mysql_password: '#{mysql_password}#' @@ -17,7 +17,7 @@ resources: - id: glance_registry_#{idx}# from: resources/glance_registry_service - values: + input: ip: 'keystone_config_#{idx}#::ip' ssh_user: 'keystone_config_#{idx}#::ssh_user' ssh_key: 'keystone_config_#{idx}#::ssh_key' diff --git a/templates/haproxy/1.0.0/haproxy.yaml b/templates/haproxy/1.0.0/haproxy.yaml index 15037f2..77920fc 100644 --- a/templates/haproxy/1.0.0/haproxy.yaml +++ b/templates/haproxy/1.0.0/haproxy.yaml @@ -4,7 +4,7 @@ resources: - id: haproxy_config#{index}# from: resources/haproxy_config location: #{node}# - values: + input: ip: '#{node}#::ip' config:protocol: #% for config in service_configs %# @@ -26,21 +26,21 @@ resources: - id: haproxy_service#{index}# location: #{node}# from: resources/haproxy_service - values: + input: ip: '#{node}#::ip' events: - type: depends_on parent_action: 'haproxy_service#{index}#.run' state: 'success' - depend_action: 'haproxy_config#{index}#.run' + child_action: 'haproxy_config#{index}#.run' - type: react_on parent_action: 'haproxy_config#{index}#.run' state: 'success' - depend_action: 'haproxy_service#{index}#.apply_config' + child_action: 'haproxy_service#{index}#.apply_config' - type: react_on parent_action: 'haproxy_config#{index}#.update' state: 'success' - depend_action: 'haproxy_service#{index}#.apply_config' + child_action: 'haproxy_service#{index}#.apply_config' diff --git a/templates/keystone_api/1.0.0/keystone_api.yaml b/templates/keystone_api/1.0.0/keystone_api.yaml index 4b89448..f831bdc 100644 --- a/templates/keystone_api/1.0.0/keystone_api.yaml +++ b/templates/keystone_api/1.0.0/keystone_api.yaml @@ -3,7 +3,7 @@ id: keystone_api_#{idx}# resources: - id: keystone_service_#{idx}# from: resources/keystone_puppet - values: + input: admin_token: '#{admin_token}#' db_host: '#{db_host}#' db_name: '#{db_name}#' diff --git a/templates/keystone_base/1.0.0/keystone_base.yaml b/templates/keystone_base/1.0.0/keystone_base.yaml index d7fa4f4..a7bee92 100644 --- a/templates/keystone_base/1.0.0/keystone_base.yaml +++ b/templates/keystone_base/1.0.0/keystone_base.yaml @@ -3,7 +3,7 @@ id: keystone_base resources: - id: keystone_db from: resources/mariadb_db - values: + input: db_name: '#{db_name}#' db_host: '#{db_host}#' login_user: '#{login_user}#' @@ -15,7 +15,7 @@ resources: - id: keystone_db_user from: resources/mariadb_user - values: + input: user_password: '#{user_password}#' user_name: '#{user_name}#' db_name: 'keystone_db::db_name' diff --git a/templates/mos_repos/1.0.0/mos_repos.yaml b/templates/mos_repos/1.0.0/mos_repos.yaml index f440940..1326a41 100644 --- a/templates/mos_repos/1.0.0/mos_repos.yaml +++ b/templates/mos_repos/1.0.0/mos_repos.yaml @@ -3,7 +3,7 @@ resources: - id: mos_holdback_#{index}# from: resources/apt_repo location: #{node}# - values: + input: name: mos-holdback package: '*' repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0/ mos8.0-holdback main restricted @@ -12,7 +12,7 @@ resources: - id: mos_security_#{index}# from: resources/apt_repo location: #{node}# - values: + input: name: mos package: '*' repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0/ mos8.0-security main restricted @@ -21,7 +21,7 @@ resources: - id: mos_updates_#{index}# from: resources/apt_repo location: #{node}# - values: + input: name: mos_update package: '*' repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/8.0/ mos8.0-updates main restricted @@ -30,7 +30,7 @@ resources: - id: managed_apt_#{index}# from: resources/managed_apt location: #{node}# - values: + input: names: - mos_holdback_#{index}#::name - mos_security_#{index}#::name diff --git a/templates/nodes/1.0.0/nodes.yaml b/templates/nodes/1.0.0/nodes.yaml index 4f21eba..dd8beef 100644 --- a/templates/nodes/1.0.0/nodes.yaml +++ b/templates/nodes/1.0.0/nodes.yaml @@ -4,17 +4,17 @@ resources: #% set j = i +1 %# - id: ssh_transport#{j}# from: resources/transport_ssh - values: + input: ssh_user: 'vagrant' ssh_key: '/vagrant/.vagrant/machines/solar-dev#{j}#/virtualbox/private_key' - id: rsync#{j}# from: resources/transport_rsync - values: + input: user: vagrant key: /vagrant/.vagrant/machines/solar-dev#{j}#/virtualbox/private_key - id: transports#{j}# from: resources/transports - values: + input: transports: - key: ssh_transport#{j}#::ssh_key user: ssh_transport#{j}#::ssh_user @@ -26,7 +26,7 @@ resources: port: rsync#{j}#::port - id: node#{j}# from: resources/ro_node - values: + input: name: node#{j}# ip: '10.0.0.#{i + 3}#' transports_id: transports#{j}#::transports_id diff --git a/templates/nodes_network/1.0.0/nodes_network.yaml b/templates/nodes_network/1.0.0/nodes_network.yaml index 3245210..8be7ee7 100644 --- a/templates/nodes_network/1.0.0/nodes_network.yaml +++ b/templates/nodes_network/1.0.0/nodes_network.yaml @@ -6,7 +6,7 @@ resources: #% for i in range(count|int) %# - id: node#{i}#_sdn from: resources/node_network_puppet - values: + input: use_ovs: true network_scheme: version: '1.1' diff --git a/templates/nodes_with_transports/1.0.0/nodes_with_transports.yaml b/templates/nodes_with_transports/1.0.0/nodes_with_transports.yaml index 6279649..a7b0fdd 100644 --- a/templates/nodes_with_transports/1.0.0/nodes_with_transports.yaml +++ b/templates/nodes_with_transports/1.0.0/nodes_with_transports.yaml @@ -3,17 +3,17 @@ resources: #% for i in range(count|int) %# - id: ssh_transport#{i}# from: resources/transport_ssh - values: + input: ssh_user: 'vagrant' ssh_key: '/vagrant/.vagrant/machines/solar-dev#{i + 1}#/virtualbox/private_key' - id: rsync#{i}# from: resources/transport_rsync - values: + input: user: vagrant key: /vagrant/.vagrant/machines/solar-dev#{i + 1}#/virtualbox/private_key - id: transports#{i}# from: resources/transports - values: + input: transports: - key: ssh_transport#{i}#::ssh_key user: ssh_transport#{i}#::ssh_user @@ -25,7 +25,7 @@ resources: port: rsync#{i}#::port - id: node#{i}# from: resources/ro_node - values: + input: ip: '10.0.0.#{i + 3}#' transports_id: transports#{i}#::transports_id name: node#{i}# diff --git a/templates/not_provisioned_nodes/1.0.0/not_provisioned_nodes.yaml b/templates/not_provisioned_nodes/1.0.0/not_provisioned_nodes.yaml index 96e1110..db86a7e 100644 --- a/templates/not_provisioned_nodes/1.0.0/not_provisioned_nodes.yaml +++ b/templates/not_provisioned_nodes/1.0.0/not_provisioned_nodes.yaml @@ -4,19 +4,19 @@ resources: #% set id = node.id | replace(':', '_') %# - id: ssh_transport#{ id }# from: resources/transport_ssh - values: + input: ssh_user: 'root' ssh_key: '/vagrant/tmp/keys/ssh_private' - id: transports#{id}# from: resources/transports - values: + input: transports:key: ssh_transport#{id}#::ssh_key transports:user: ssh_transport#{id}#::ssh_user transports:port: ssh_transport#{id}#::ssh_port transports:name: ssh_transport#{id}#::name - id: node_#{id}# from: resources/not_provisioned_node - values: + input: ip: #{node.ip}# transports_id: transports#{id}#::transports_id name: node_#{id}# @@ -25,19 +25,19 @@ resources: - id: ssh_transport_master from: resources/transport_ssh - values: + input: ssh_user: 'vagrant' ssh_key: '/vagrant/.vagrant/machines/solar-dev/virtualbox/private_key' - id: transports_master from: resources/transports - values: + input: transports:key: ssh_transport_master::ssh_key transports:user: ssh_transport_master::ssh_user transports:port: ssh_transport_master::ssh_port transports:name: ssh_transport_master::name - id: node_master from: resources/ro_node - values: + input: name: node_master ip: '10.0.2.15' transports_id: transports_master::transports_id diff --git a/templates/openstack_base/1.0.0/openstack_base.yaml b/templates/openstack_base/1.0.0/openstack_base.yaml index 307d4cd..28465e9 100644 --- a/templates/openstack_base/1.0.0/openstack_base.yaml +++ b/templates/openstack_base/1.0.0/openstack_base.yaml @@ -3,7 +3,7 @@ id: openstack_base resources: - id: admin_tenant from: resources/keystone_tenant - values: + input: tenant_name: admin keystone_port: '#{keystone_admin_port}#' keystone_host: '#{keystone_ip}#' @@ -14,7 +14,7 @@ resources: - id: admin_user from: resources/keystone_user - values: + input: user_name: 'admin' user_password: 'admin' tenant_name: 'admin_tenant::tenant_name' @@ -27,7 +27,7 @@ resources: - id: admin_role from: resources/keystone_role - values: + input: role_name: 'admin' user_name: 'admin_user::user_name' tenant_name: 'admin_user::tenant_name' @@ -40,7 +40,7 @@ resources: - id: keystone_service_endpoint from: resources/keystone_service_endpoint - values: + input: #% raw %# adminurl: 'http://#{admin_ip}#:#{admin_port}#/v2.0' internalurl: 'http://#{internal_ip}#:#{internal_port}#/v2.0' @@ -64,7 +64,7 @@ resources: - id: service_tenant from: resources/keystone_tenant - values: + input: tenant_name: services keystone_port: '#{keystone_admin_port}#' keystone_host: '#{keystone_ip}#' diff --git a/templates/seed_node/1.0.0/seed_node.yaml b/templates/seed_node/1.0.0/seed_node.yaml index 81663b7..acfb8e1 100644 --- a/templates/seed_node/1.0.0/seed_node.yaml +++ b/templates/seed_node/1.0.0/seed_node.yaml @@ -2,7 +2,7 @@ id: seed_node resources: - id: seed_node from: resources/ro_node - values: + input: ip: '10.0.0.2' ssh_key: '/vagrant/.vagrant/machines/solar-dev/virtualbox/private_key' ssh_user: 'vagrant' diff --git a/templates/sources/1.0.0/sources.yaml b/templates/sources/1.0.0/sources.yaml index 47ecb94..1022366 100644 --- a/templates/sources/1.0.0/sources.yaml +++ b/templates/sources/1.0.0/sources.yaml @@ -3,6 +3,6 @@ resources: - id: sources#{index}# from: resources/sources location: #{node}# - values: + input: sources: - {src: /tmp/sources_test, dst: /tmp/sources_test}