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': '******' })[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)
def run(): ModelMeta.remove_all() resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {'count': 2}) nodes = [x for x in resources if x.name.startswith('node')] node1, node2 = nodes hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0] hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0] 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', })
def setup_base(node, librarian): # MARIADB mariadb_service = vr.create('mariadb_service1', 'resources/mariadb_service', { 'image': 'mariadb', 'port': 3306 })[0] node.connect(mariadb_service) # RABBIT rabbitmq_service = vr.create('rabbitmq_service1', 'resources/rabbitmq_service/', { 'management_port': 15672, 'port': 5672, })[0] openstack_vhost = vr.create('openstack_vhost', 'resources/rabbitmq_vhost/', { 'vhost_name': 'openstack' })[0] openstack_rabbitmq_user = vr.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', { 'user_name': 'openstack', 'password': '******' })[0] node.connect(rabbitmq_service) rabbitmq_service.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, rabbitmq_service.name, actions=('run', 'update')) rabbitmq_service.connect(openstack_vhost) rabbitmq_service.connect(openstack_rabbitmq_user) openstack_vhost.connect(openstack_rabbitmq_user, { 'vhost_name', }) return {'mariadb_service': mariadb_service, 'rabbitmq_service1': rabbitmq_service, 'openstack_vhost': openstack_vhost, 'openstack_rabbitmq_user': openstack_rabbitmq_user}
def deploy(): db.clear() resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 1}) first_node = next(x for x in resources if x.name.startswith('node')) library = vr.create('library1', 'resources/fuel_library', {})[0] first_node.connect(library) keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0] first_node.connect(keys) ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon', {'storage': STORAGE, 'keystone': KEYSTONE, 'network_scheme': NETWORK_SCHEMA, 'ceph_monitor_nodes': NETWORK_METADATA, 'ceph_primary_monitor_node': NETWORK_METADATA, 'role': 'controller', })[0] managed_apt = vr.create( 'managed_apt1', 'templates/mos_repos.yaml', {'node': first_node.name, 'index': 0})[-1] keys.connect(ceph_mon, {}) first_node.connect(ceph_mon, {'ip': ['ip', 'public_vip', 'management_vip']}) library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'}) managed_apt.connect(ceph_mon, {})
def run(): db.clear() resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {'count': 2}) nodes = [x for x in resources if x.name.startswith('node')] node1, node2 = nodes hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0] hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0] 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', })
def setup_base(node, librarian): # MARIADB mariadb_service = vr.create("mariadb_service1", "resources/mariadb_service", {"image": "mariadb", "port": 3306})[0] node.connect(mariadb_service) # RABBIT rabbitmq_service = vr.create( "rabbitmq_service1", "resources/rabbitmq_service/", {"management_port": 15672, "port": 5672} )[0] openstack_vhost = vr.create("openstack_vhost", "resources/rabbitmq_vhost/", {"vhost_name": "openstack"})[0] openstack_rabbitmq_user = vr.create( "openstack_rabbitmq_user", "resources/rabbitmq_user/", {"user_name": "openstack", "password": "******"}, )[0] node.connect(rabbitmq_service) rabbitmq_service.connect_with_events(librarian, {"module": "modules"}, {}) evapi.add_dep(librarian.name, rabbitmq_service.name, actions=("run", "update")) rabbitmq_service.connect(openstack_vhost) rabbitmq_service.connect(openstack_rabbitmq_user) openstack_vhost.connect(openstack_rabbitmq_user, {"vhost_name"}) return { "mariadb_service": mariadb_service, "rabbitmq_service1": rabbitmq_service, "openstack_vhost": openstack_vhost, "openstack_rabbitmq_user": openstack_rabbitmq_user, }
def prepare_nodes(nodes_count): resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {"count": nodes_count}) nodes = [x for x in resources if x.name.startswith('node')] resources = vr.create('nodes_network', 'templates/nodes_network.yaml', {"count": nodes_count}) nodes_sdn = [x for x in resources if x.name.startswith('node')] r = {} for node, node_sdn in zip(nodes, nodes_sdn): r[node.name] = node r[node_sdn.name] = node_sdn # LIBRARIAN librarian = vr.create('librarian_{}'.format(node.name), 'resources/librarian', {})[0] r[librarian.name] = librarian node.connect(librarian, {}) # NETWORKING # TODO(bogdando) node's IPs should be populated as br-mgmt IPs, but now are hardcoded in templates signals.connect(node, node_sdn) node_sdn.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, node_sdn.name, actions=('run', 'update')) signals.connect(node, node_sdn) node_sdn.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, node_sdn.name, actions=('run', 'update')) return r
def deploy(): db.clear() resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 2}) first_node, second_node = [x for x in resources if x.name.startswith('solar-dev')] library2 = vr.create('library2', 'resources/fuel_library', {'temp_directory': '/tmp/solar', 'puppet_modules': '/etc/fuel/modules', 'git':{'branch': 'master', 'repository': 'https://github.com/stackforge/fuel-library'}, 'librarian_puppet_simple': 'true'})[0] ceph_compute = vr.create('ceph_compute1', 'resources/ceph_compute', {'storage': STORAGE, 'keystone': KEYSTONE, 'network_scheme': NETWORK_SCHEMA, 'ceph_monitor_nodes': NETWORK_METADATA, 'ceph_primary_monitor_node': NETWORK_METADATA, 'role': 'compute', })[0] second_node.connect(ceph_compute, {}) library2.connect(ceph_compute, {'puppet_modules': 'puppet_modules'}) evapi.add_dep(second_node.name, ceph_compute.name, actions=('run',))
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', { # TODO(bogdando) these should come from the node network resource 'enable_tunneling': True, 'tunnel_types': ['gre'], 'local_ip': '10.1.0.13' # should be the IP addr of the br-mesh int. })[0] node.connect(neutron_agents_ml2) 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] 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', { # TODO(bogdando) these should come from the node network resource 'metadata_port': 8775, 'external_network_bridge': 'br-floating', })[0] 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', { 'sh2ared_secret': 'secret', })[0] node.connect(neutron_agents_metadata) neutron_server_puppet.connect(neutron_agents_metadata, { 'auth_host', 'auth_port', 'auth_password', 'auth_tenant', 'auth_user', }) return {'neutron_agents_ml2': neutron_agents_ml2, 'neutron_agents_dhcp': neutron_agents_dhcp, 'neutron_agents_metadata': neutron_agents_metadata}
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': '******' })[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)
def run(): db.clear() resources = vr.create('nodes', 'templates/nodes_with_transports.yaml', {'count': 2}) nodes = [x for x in resources if x.name.startswith('node')] node1, node2 = nodes hosts1 = vr.create('hosts_file1', 'resources/hosts_file', {})[0] hosts2 = vr.create('hosts_file2', 'resources/hosts_file', {})[0] signals.connect(node1, hosts1, { 'name': 'hosts:name', 'ip': 'hosts:ip', }) signals.connect(node2, hosts2, { 'name': 'hosts:name', 'ip': 'hosts:ip', }) signals.connect(node1, hosts2, { 'name': 'hosts:name', 'ip': 'hosts:ip', }) signals.connect(node2, hosts1, { 'name': 'hosts:name', 'ip': 'hosts:ip', })
def add_solard(i): solard_transport = vr.create('solard_transport%s' % i, 'resources/transport_solard', { 'solard_user': '******', 'solard_password': '******' })[0] transports = resource.load('transports%s' % i) ssh_transport = resource.load('ssh_transport%s' % i) transports_for_solard = vr.create('transports_for_solard%s' % i, 'resources/transports')[0] # install solard with ssh signals.connect(transports_for_solard, solard_transport, {}) signals.connect( ssh_transport, transports_for_solard, { 'ssh_key': 'transports:key', 'ssh_user': '******', 'ssh_port': 'transports:port', 'name': 'transports:name' }) # add solard to transports on this node signals.connect( solard_transport, transports, { 'solard_user': '******', 'solard_port': 'transports:port', 'solard_password': '******', 'name': 'transports:name' })
def setup_riak(nodes_num=None, hosts_mapping=False): if nodes_num is None: nodes_num = NODES db.clear() resources = vr.create("nodes", "templates/nodes.yaml", {"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")] riak_services = [] ips = "10.0.0.%d" for i in xrange(nodes_num): num = i + 1 r = vr.create( "riak_service%d" % num, "resources/riak_node", { "riak_self_name": "riak%d" % num, "riak_hostname": "riak_server%d.solar" % num, "riak_name": "riak%d@riak_server%d.solar" % (num, num), }, )[0] 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"}) if hosts_mapping: for riak in riak_services: for hosts_file in hosts_services: riak.connect_with_events(hosts_file, {"riak_hostname": "hosts:name", "ip": "hosts:ip"}) res_errors = resource.validate_resources() for r, error in res_errors: click.echo("ERROR: %s: %s" % (r.name, error)) has_errors = False if has_errors: click.echo("ERRORS") sys.exit(1) events = [] for x in xrange(nodes_num): i = x + 1 if hosts_mapping: events.append(Dep("hosts_file%d" % i, "run", "success", "riak_service%d" % i, "run")) if i >= 2: events.append(React("riak_service%d" % i, "run", "success", "riak_service%d" % i, "join")) events.append(React("riak_service%d" % i, "join", "success", "riak_service1", "commit")) for event in events: add_event(event) click.echo("Use solar changes process & orch") sys.exit(0)
def setup_cinder_volume(node, cinder_puppet): # CINDER VOLUME cinder_volume = vr.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] node.connect(cinder_volume_puppet) cinder_puppet.connect(cinder_volume_puppet) evapi.add_react(cinder_puppet.name, cinder_volume_puppet.name, actions=('update',)) cinder_volume.connect(cinder_volume_puppet, {'volume_name': 'volume_group'}) return {'cinder_volume_puppet': cinder_volume_puppet}
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.connect_with_events(librarian, {"module": "modules"}, {}) evapi.add_dep(librarian.name, neutron_puppet2.name, actions=("run", "update")) dep = evapi.Dep(librarian.name, "update", state="SUCESS", child=neutron_puppet2.name, child_action="run") evapi.add_event(dep) node.connect(neutron_puppet2) neutron_puppet.connect( neutron_puppet2, { "rabbit_host", "rabbit_port", "rabbit_user", "rabbit_password", "rabbit_virtual_host", "package_ensure", "core_plugin", }, ) # 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 ] 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", { # TODO(bogdando) these should come from the node network resource "enable_tunneling": True, "tunnel_types": ["gre"], "local_ip": "10.1.0.14", # Should be the IP addr of the br-mesh int. }, )[0] node.connect(neutron_agents_ml22) evapi.add_dep(neutron_puppet2.name, neutron_agents_ml22.name, actions=("run",)) evapi.add_dep(neutron_server_puppet.name, neutron_agents_ml22.name, actions=("run",)) return { "neutron_puppet2": neutron_puppet2, "neutron_plugins_ml22": neutron_plugins_ml22, "neutron_agents_ml22": neutron_agents_ml22, }
def setup_cinder_volume(node, cinder_puppet): # CINDER VOLUME cinder_volume = vr.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] node.connect(cinder_volume_puppet) cinder_puppet.connect(cinder_volume_puppet) evapi.add_react(cinder_puppet.name, cinder_volume_puppet.name, actions=("update",)) cinder_volume.connect(cinder_volume_puppet, {"volume_name": "volume_group"}) return {"cinder_volume_puppet": cinder_volume_puppet}
def run(): db.clear() resources = vr.create("nodes", "templates/nodes_with_transports.yaml", {"count": 2}) nodes = [x for x in resources if x.name.startswith("node")] node1, node2 = nodes hosts1 = vr.create("hosts_file1", "resources/hosts_file", {})[0] hosts2 = vr.create("hosts_file2", "resources/hosts_file", {})[0] 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"})
def create(cls, count, resource_path, name='{resource_path_name}-{num}', args=None): """Create a number of resources of the same type, with optional args. name -- optional resource name args -- an optional dict with create arguments. You can use "{num}" -- index of resource in the list "{resource_path_name}" -- name of resource from the `resource_path` argument """ args = args or {} created_resources = [] resource_path_name = os.path.split(resource_path)[-1] for num in range(count): kwargs = { 'num': num, 'resource_path_name': resource_path_name, } kwargs['name'] = name.format(**kwargs) args_fmt = cls.args_fmt(args, kwargs) r = vr.create(kwargs['name'], resource_path, args_fmt)[0] created_resources.append(r) return ResourceListTemplate(created_resources)
def test_create_resource(): node_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures', 'node') resources = vr.create('node1', node_path) assert len(resources) == 1 assert resources[0].name == 'node1'
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', {'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin'})[0] node.connect(neutron_puppet) neutron_puppet.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, neutron_puppet.name, actions=('run', 'update')) rabbitmq_service.connect(neutron_puppet, { 'ip': 'rabbit_host', 'port': 'rabbit_port' }) openstack_rabbitmq_user.connect(neutron_puppet, { 'user_name': 'rabbit_user', 'password': '******' }) openstack_vhost.connect(neutron_puppet, {'vhost_name': 'rabbit_virtual_host'}) return {'neutron_puppet': neutron_puppet}
def create(cls, count, resource_path, args={}): """Create a number of resources of the same type, with optional args. args -- an optional dict with create arguments. You can use "{num}" -- index of resource in the list "{resource_path_name}" -- name of resource from the `resource_path` argument """ created_resources = [] resource_path_name = os.path.split(resource_path)[-1] for num in range(count): kwargs = { 'num': num, 'resource_path_name': resource_path_name, } kwargs['name'] = '{resource_path_name}-{num}'.format(**kwargs) args_fmt = cls.args_fmt(args, kwargs) r = vr.create('{name}'.format(**kwargs), resource_path, args_fmt)[0] created_resources.append(r) return ResourceListTemplate(created_resources)
def setup_cinder_scheduler(node, cinder_puppet): # CINDER SCHEDULER cinder_scheduler_puppet = vr.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",)) return {"cinder_scheduler_puppet": cinder_scheduler_puppet}
def setup_cinder_scheduler(node, cinder_puppet): # CINDER SCHEDULER cinder_scheduler_puppet = vr.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',)) return {'cinder_scheduler_puppet': cinder_scheduler_puppet}
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] node.connect(nova_conductor_puppet) nova_puppet.connect(nova_conductor_puppet) evapi.add_dep(nova_api_puppet.name, nova_conductor_puppet.name, actions=('run',)) evapi.add_react(nova_puppet.name, nova_conductor_puppet.name, actions=('update',)) return {'nova_conductor': nova_conductor_puppet}
def setup_openrc(node, keystone_puppet, admin_user): # OPENRC openrc = vr.create("openrc_file", "resources/openrc_file", {})[0] node.connect(openrc) keystone_puppet.connect(openrc, {"ip": "keystone_host", "admin_port": "keystone_port"}) admin_user.connect(openrc, {"user_name": "user_name", "user_password": "******", "tenant_name": "tenant"}) return {"openrc_file": openrc}
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] node.connect(nova_conductor_puppet) nova_puppet.connect(nova_conductor_puppet) evapi.add_dep(nova_api_puppet.name, nova_conductor_puppet.name, actions=("run",)) evapi.add_react(nova_puppet.name, nova_conductor_puppet.name, actions=("update",)) return {"nova_conductor": nova_conductor_puppet}
def setup_openrc(node, keystone_puppet, admin_user): # OPENRC openrc = vr.create('openrc_file', 'resources/openrc_file', {})[0] node.connect(openrc) keystone_puppet.connect(openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'}) admin_user.connect(openrc, {'user_name': 'user_name','user_password':'******', 'tenant_name': 'tenant'}) return {'openrc_file' : openrc}
def test_update(tmpdir): # XXX: make helper for it base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource_fixtures") vr_node_tmpl_path = os.path.join(base_path, "nodes.yaml.tmpl") vr_update_tmpl_path = os.path.join(base_path, "update.yaml.tmpl") update_path = os.path.join(base_path, "update") node_resource_path = os.path.join(base_path, "node") with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_update_tmpl_path) as f: update_data = f.read().format(resource_path=update_path) vr_file = tmpdir.join("nodes.yaml") vr_file.write(vr_data) update_file = tmpdir.join("update.yaml") update_file.write(update_data) resources = vr.create("nodes", str(vr_file)) vr.create("updates", str(update_file)) assert resources[0].args["ip"] == "10.0.0.4"
def test_setting_location(tmpdir): # XXX: make helper for it base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource_fixtures") vr_node_tmpl_path = os.path.join(base_path, "nodes.yaml.tmpl") vr_location_tmpl_path = os.path.join(base_path, "with_location.yaml.tmpl") base_service_path = os.path.join(base_path, "base_service") node_resource_path = os.path.join(base_path, "node") with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_location_tmpl_path) as f: location_data = f.read().format(resource_path=base_service_path) vr_file = tmpdir.join("nodes.yaml") vr_file.write(vr_data) location_file = tmpdir.join("with_location.yaml") location_file.write(location_data) vr.create("nodes", str(vr_file)) resources = vr.create("updates", str(location_file)) assert "location=node1" in resources[0].tags
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", { # TODO(bogdando) these should come from the node network resource "enable_tunneling": True, "tunnel_types": ["gre"], "local_ip": "10.1.0.13", # should be the IP addr of the br-mesh int. }, )[0] node.connect(neutron_agents_ml2) 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] 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", { # TODO(bogdando) these should come from the node network resource "metadata_port": 8775, "external_network_bridge": "br-floating", }, )[0] 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", {"sh2ared_secret": "secret"} )[0] node.connect(neutron_agents_metadata) neutron_server_puppet.connect( neutron_agents_metadata, {"auth_host", "auth_port", "auth_password", "auth_tenant", "auth_user"} ) return { "neutron_agents_ml2": neutron_agents_ml2, "neutron_agents_dhcp": neutron_agents_dhcp, "neutron_agents_metadata": neutron_agents_metadata, }
def test_setting_location(tmpdir): # XXX: make helper for it base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_node_tmpl_path = os.path.join(base_path, 'nodes.yaml.tmpl') vr_location_tmpl_path = os.path.join(base_path, 'with_location.yaml.tmpl') base_service_path = os.path.join(base_path, 'base_service') node_resource_path = os.path.join(base_path, 'node') with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_location_tmpl_path) as f: location_data = f.read().format(resource_path=base_service_path) vr_file = tmpdir.join('nodes.yaml') vr_file.write(vr_data) location_file = tmpdir.join('with_location.yaml') location_file.write(location_data) vr.create('nodes', str(vr_file)) resources = vr.create('updates', str(location_file)) assert 'location=node1' in resources[0].tags
def test_create_virtual_resource(tmpdir): base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource_fixtures") vr_tmpl_path = os.path.join(base_path, "nodes.yaml.tmpl") node_resource_path = os.path.join(base_path, "node") with open(vr_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) vr_file = tmpdir.join("nodes.yaml") vr_file.write(vr_data) resources = vr.create("nodes", str(vr_file)) assert len(resources) == 2
def setup_cinder_api(node, cinder_puppet): # CINDER API cinder_api_puppet = vr.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"}) cinder_puppet.connect( cinder_api_puppet, {"keystone_host": "keystone_auth_host", "keystone_port": "keystone_auth_port"} ) evapi.add_react(cinder_puppet.name, cinder_api_puppet.name, actions=("update",)) return {"cinder_api_puppet": cinder_api_puppet}
def test_update(tmpdir): # XXX: make helper for it base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_node_tmpl_path = os.path.join(base_path, 'nodes.yaml.tmpl') vr_update_tmpl_path = os.path.join(base_path, 'update.yaml.tmpl') update_path = os.path.join(base_path, 'update') node_resource_path = os.path.join(base_path, 'node') with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_update_tmpl_path) as f: update_data = f.read().format(resource_path=update_path) vr_file = tmpdir.join('nodes.yaml') vr_file.write(vr_data) update_file = tmpdir.join('update.yaml') update_file.write(update_data) resources = vr.create('nodes', str(vr_file)) vr.create('updates', str(update_file)) assert resources[0].args['ip'] == '10.0.0.4'
def setup_cinder_api(node, cinder_puppet): # CINDER API cinder_api_puppet = vr.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'}) cinder_puppet.connect(cinder_api_puppet, { 'keystone_host': 'keystone_auth_host', 'keystone_port': 'keystone_auth_port'}) evapi.add_react(cinder_puppet.name, cinder_api_puppet.name, actions=('update',)) return {'cinder_api_puppet': cinder_api_puppet}
def test_create_virtual_resource(tmpdir): base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_tmpl_path = os.path.join(base_path, 'nodes.yaml.tmpl') node_resource_path = os.path.join(base_path, 'node') with open(vr_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) vr_file = tmpdir.join('nodes.yaml') vr_file.write(vr_data) resources = vr.create('nodes', str(vr_file)) assert len(resources) == 2
def test_update(tmpdir): # XXX: make helper for it base_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_node_tmpl_path = os.path.join(base_path, 'nodes.yaml.tmpl') vr_update_tmpl_path = os.path.join(base_path, 'update.yaml.tmpl') update_path = os.path.join(base_path, 'update') node_resource_path = os.path.join(base_path, 'node') with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_update_tmpl_path) as f: update_data = f.read().format(resource_path=update_path) vr_file = tmpdir.join('nodes.yaml') vr_file.write(vr_data) update_file = tmpdir.join('update.yaml') update_file.write(update_data) resources = vr.create('nodes', str(vr_file)) vr.create('updates', str(update_file)) assert resources[0].args['ip'] == '10.0.0.4'
def test_setting_location(tmpdir): # XXX: make helper for it base_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_node_tmpl_path = os.path.join(base_path, 'nodes.yaml.tmpl') vr_location_tmpl_path = os.path.join(base_path, 'with_location.yaml.tmpl') base_service_path = os.path.join(base_path, 'base_service') node_resource_path = os.path.join(base_path, 'node') with open(vr_node_tmpl_path) as f: vr_data = f.read().format(resource_path=node_resource_path) with open(vr_location_tmpl_path) as f: location_data = f.read().format(resource_path=base_service_path) vr_file = tmpdir.join('nodes.yaml') vr_file.write(vr_data) location_file = tmpdir.join('with_location.yaml') location_file.write(location_data) vr.create('nodes', str(vr_file)) resources = vr.create('updates', str(location_file)) assert 'location=node1' in resources[0].tags
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', { 'title' : 'scheduler', 'package_name': 'nova-scheduler', 'service_name': 'nova-scheduler', })[0] node.connect(nova_scheduler_puppet) evapi.add_dep(nova_puppet.name, nova_scheduler_puppet.name, actions=('run',)) evapi.add_dep(nova_api_puppet.name, nova_scheduler_puppet.name, actions=('run',)) evapi.add_react(nova_puppet.name, nova_scheduler_puppet.name, actions=('update',)) return {'nova_scheduler_puppet': nova_scheduler_puppet}
def create(args, base_path, name): args_parsed = {} click.echo('create {} {} {}'.format(name, base_path, args)) for arg in args: try: args_parsed.update(json.loads(arg)) except ValueError: k, v = arg.split('=') args_parsed.update({k: v}) resources = vr.create(name, base_path, args=args_parsed) for res in resources: click.echo(res.color_repr())
def test_create_virtual_resource_with_dict(tmpdir): base_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'resource_fixtures') vr_tmpl_path = os.path.join(base_path, 'resource_with_dict.yaml.tmpl') base_resource_path = os.path.join(base_path, 'base_service') with open(vr_tmpl_path) as f: vr_data = f.read().format(resource_path=base_resource_path) vr_file = tmpdir.join('base.yaml') vr_file.write(vr_data) resources = vr.create('base', str(vr_file)) assert len(resources) == 1 res = resources[0] assert res.args['servers'] == {'a': 1, 'b': 2}
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.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, neutron_puppet2.name, actions=('run', 'update')) dep = evapi.Dep(librarian.name, 'update', state='SUCESS', child=neutron_puppet2.name, child_action='run') evapi.add_event(dep) node.connect(neutron_puppet2) neutron_puppet.connect(neutron_puppet2, { 'rabbit_host', 'rabbit_port', 'rabbit_user', 'rabbit_password', 'rabbit_virtual_host', 'package_ensure', 'core_plugin', }) # 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] 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', { # TODO(bogdando) these should come from the node network resource 'enable_tunneling': True, 'tunnel_types': ['gre'], 'local_ip': '10.1.0.14' # Should be the IP addr of the br-mesh int. })[0] node.connect(neutron_agents_ml22) evapi.add_dep(neutron_puppet2.name, neutron_agents_ml22.name, actions=('run',)) evapi.add_dep(neutron_server_puppet.name, neutron_agents_ml22.name, actions=('run',)) return {'neutron_puppet2': neutron_puppet2, 'neutron_plugins_ml22': neutron_plugins_ml22, 'neutron_agents_ml22': neutron_agents_ml22}
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] node.connect(nova_api_puppet) nova_puppet.connect(nova_api_puppet, { 'keystone_tenant': 'admin_tenant_name', 'keystone_user': '******', 'keystone_password': '******', 'keystone_host': 'auth_host', 'keystone_port': 'auth_port'}) evapi.add_react(nova_puppet.name, nova_api_puppet.name, actions=('update',)) nova_api_puppet.connect(neutron_agents_metadata, {'ip': 'metadata_ip'}) return {'nova_api_puppet': nova_api_puppet}
def run(): ModelMeta.remove_all() node = vr.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] ssh_transport = vr.create( 'ssh_transport', 'resources/transport_ssh', { 'ssh_key': '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key', 'ssh_user': '******' })[0] solar_agent_transport = vr.create('solar_agent_transport', 'resources/transport_solar_agent', { 'solar_agent_user': '******', 'solar_agent_password': '******' })[0] transports_for_solar_agent.connect(solar_agent_transport, {}) ssh_transport.connect( transports_for_solar_agent, { 'ssh_key': 'transports:key', 'ssh_user': '******', 'ssh_port': 'transports:port', 'name': 'transports:name' }) # set transports_id transports.connect(node, {}) # it uses reverse mappings ssh_transport.connect( transports, { 'ssh_key': 'transports:key', 'ssh_user': '******', 'ssh_port': 'transports:port', 'name': 'transports:name' }) solar_agent_transport.connect( transports, { 'solar_agent_user': '******', 'solar_agent_port': 'transports:port', 'solar_agent_password': '******', 'name': 'transports:name' }) hosts = vr.create('hosts_file', 'resources/hosts_file', {})[0] node.connect(hosts, {'ip': 'hosts:ip', 'name': 'hosts:name'})
def setup_glance_registry(node, glance_api_puppet): # GLANCE REGISTRY glance_registry_puppet = vr.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',)) # API and registry should not listen same ports # should not use the same log destination and a pipeline, # so disconnect them and restore the defaults signals.disconnect_receiver_by_input(glance_registry_puppet, 'bind_port') signals.disconnect_receiver_by_input(glance_registry_puppet, 'log_file') signals.disconnect_receiver_by_input(glance_registry_puppet, 'pipeline') glance_registry_puppet.update({ 'bind_port': 9191, 'log_file': '/var/log/glance/registry.log', 'pipeline': 'keystone', }) return {'glance_registry_puppet': glance_registry_puppet}
def deploy(): ModelMeta.remove_all() resources = vr.create('nodes', 'templates/nodes.yaml', {'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] first_node.connect(library) keys = vr.create('ceph_key', 'resources/ceph_keys', {})[0] first_node.connect(keys) remote_file = vr.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', { 'storage': STORAGE, 'keystone': KEYSTONE, 'network_scheme': NETWORK_SCHEMA, 'ceph_monitor_nodes': NETWORK_METADATA, 'ceph_primary_monitor_node': NETWORK_METADATA, 'role': 'controller', })[0] managed_apt = vr.create('managed_apt1', 'templates/mos_repos.yaml', { 'node': first_node.name, 'index': 0 })[-1] keys.connect(ceph_mon, {}) first_node.connect(ceph_mon, {'ip': ['ip', 'public_vip', 'management_vip']}) library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'}) managed_apt.connect(ceph_mon, {})
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/', { 'user_name': 'glance', 'user_password': '******', 'login_user': '******' })[0] glance_db = vr.create('glance_db', 'resources/mariadb_db/', { 'db_name': 'glance', 'login_user': '******' })[0] glance_keystone_user = vr.create('glance_keystone_user', 'resources/keystone_user', { 'user_name': 'glance', 'user_password': '******' })[0] glance_keystone_role = vr.create('glance_keystone_role', 'resources/keystone_role', {'role_name': 'admin'})[0] glance_keystone_service_endpoint = vr.create( 'glance_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'glance', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', 'publicurl': 'http://{{public_ip}}:{{public_port}}', 'description': 'OpenStack Image Service', 'type': 'image' })[0] node.connect(glance_api_puppet) glance_api_puppet.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, glance_api_puppet.name, actions=('run', 'update')) node.connect(glance_db) node.connect(glance_db_user) admin_user.connect( glance_api_puppet, { 'user_name': 'keystone_user', 'user_password': '******', 'tenant_name': 'keystone_tenant' }) #? mariadb_service.connect( glance_db, { 'port': 'login_port', 'root_password': '******', 'root_user': '******', 'ip': 'db_host' }) mariadb_service.connect(glance_db_user, { 'port': 'login_port', 'root_password': '******' }) glance_db.connect(glance_db_user, {'db_name', 'db_host'}) glance_db_user.connect( glance_api_puppet, { 'user_name': 'db_user', 'db_name': 'db_name', 'user_password': '******', 'db_host': 'db_host' }) mariadb_service.connect(glance_api_puppet, { 'port': 'db_port', 'ip': 'db_host' }) keystone_puppet.connect(glance_api_puppet, { 'ip': 'keystone_host', 'admin_port': 'keystone_port' }) #or non admin port? services_tenant.connect(glance_keystone_user) glance_keystone_user.connect(glance_keystone_role) glance_keystone_user.connect( glance_api_puppet, { 'user_name': 'keystone_user', 'tenant_name': 'keystone_tenant', 'user_password': '******' }) mariadb_service.connect(glance_api_puppet, {'ip': 'ip'}) glance_api_puppet.connect( glance_keystone_service_endpoint, { 'ip': ['ip', 'keystone_host', 'admin_ip', 'internal_ip', 'public_ip'], 'bind_port': ['admin_port', 'internal_port', 'public_port'], }) keystone_puppet.connect(glance_keystone_service_endpoint, { 'admin_port': 'keystone_admin_port', 'admin_token': 'admin_token' }) # Update glance_api_service for cinder glance_api_puppet.connect(cinder_glance_puppet, { 'ip': 'glance_api_servers_host', 'bind_port': 'glance_api_servers_port' }) return { 'glance_api_puppet': glance_api_puppet, 'glance_db_user': glance_db_user, 'glance_db': glance_db, 'glance_keystone_user': glance_keystone_user, 'glance_keystone_role': glance_keystone_role, 'glance_keystone_service_endpoint': glance_keystone_service_endpoint }
def setup_nova_compute(node, librarian, nova_puppet, nova_api_puppet, neutron_server_puppet, neutron_keystone_service_endpoint, glance_api_puppet): # 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] # TODO (bogdando) figure out how to use it for multiple glance api servers nova_puppet2 = vr.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, { 'ensure_package', 'rabbit_host', 'rabbit_password', 'rabbit_port', 'rabbit_userid', 'rabbit_virtual_host', 'db_user', 'db_password', 'db_name', 'db_host', 'keystone_password', 'keystone_port', 'keystone_host', 'keystone_tenant', 'keystone_user', }) # TODO(bogdando): Make a connection for nova_puppet2.glance_api_servers = "glance_api_puppet.ip:glance_api_puppet.bind_port" node.connect(nova_puppet2) nova_puppet2.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, nova_puppet2.name, actions=('run', 'update')) dep = evapi.Dep(librarian.name, 'update', state='SUCESS', child=nova_puppet2.name, child_action='run') evapi.add_event(dep) node.connect(nova_compute_puppet) evapi.add_dep(nova_puppet2.name, nova_compute_puppet.name, actions=('run', )) evapi.add_dep(nova_api_puppet.name, nova_compute_puppet.name, actions=('run', )) evapi.add_react(nova_puppet2.name, nova_compute_puppet.name, actions=('run', 'update')) # 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] 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] 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', )) neutron_server_puppet.connect( nova_neutron_puppet, { 'auth_password': '******', 'auth_user': '******', 'auth_type': 'neutron_auth_strategy', 'auth_host': 'auth_host', 'auth_port': 'auth_port', 'auth_protocol': 'auth_protocol', }) neutron_keystone_service_endpoint.connect( nova_neutron_puppet, { 'internal_ip': 'neutron_endpoint_host', 'internal_port': 'neutron_endpoint_port', }) # Update glance_api_service for nova compute glance_api_puppet.connect(nova_puppet2, { 'ip': 'glance_api_servers_host', 'bind_port': 'glance_api_servers_port' }) # signals.connect(keystone_puppet, nova_network_puppet, {'ip': 'keystone_host', 'port': 'keystone_port'}) # signals.connect(keystone_puppet, nova_keystone_service_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port', 'admin_token': 'admin_token'}) # signals.connect(rabbitmq_service1, nova_network_puppet, {'ip': 'rabbitmq_host', 'port': 'rabbitmq_port'}) return { 'nova_compute_puppet': nova_compute_puppet, 'nova_puppet2': nova_puppet2, 'nova_compute_libvirt_puppet': nova_compute_libvirt_puppet, 'nova_neutron_puppet': nova_neutron_puppet, 'neutron_server_puppet': neutron_server_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/', { 'db_name': 'nova_db', 'login_user': '******' })[0] nova_db_user = vr.create('nova_db_user', 'resources/mariadb_user/', { 'user_name': 'nova', 'user_password': '******', 'login_user': '******' })[0] nova_keystone_user = vr.create('nova_keystone_user', 'resources/keystone_user', { 'user_name': 'nova', 'user_password': '******' })[0] nova_keystone_role = vr.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', { 'endpoint_name': 'nova', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2/%(tenant_id)s', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2/%(tenant_id)s', 'publicurl': 'http://{{public_ip}}:{{public_port}}/v2/%(tenant_id)s', 'description': 'OpenStack Compute Service', 'type': 'compute' })[0] node.connect(nova_puppet) nova_puppet.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, nova_puppet.name, actions=('run', 'update')) node.connect(nova_db) node.connect(nova_db_user) mariadb_service.connect( nova_db, { 'port': 'login_port', 'root_password': '******', 'root_user': '******', 'ip': 'db_host' }) mariadb_service.connect(nova_db_user, { 'port': 'login_port', 'root_password': '******' }) admin_user.connect( nova_puppet, { 'user_name': 'keystone_user', 'user_password': '******', 'tenant_name': 'keystone_tenant' }) #? openstack_vhost.connect(nova_puppet, {'vhost_name': 'rabbit_virtual_host'}) nova_db.connect(nova_db_user, {'db_name', 'db_host'}) services_tenant.connect(nova_keystone_user) nova_keystone_user.connect(nova_keystone_role) keystone_puppet.connect(nova_puppet, { 'ip': 'keystone_host', 'admin_port': 'keystone_port' }) nova_keystone_user.connect( nova_puppet, { 'user_name': 'keystone_user', 'tenant_name': 'keystone_tenant', 'user_password': '******' }) rabbitmq_service.connect(nova_puppet, { 'ip': 'rabbit_host', 'port': 'rabbit_port' }) openstack_rabbitmq_user.connect(nova_puppet, { 'user_name': 'rabbit_userid', 'password': '******' }) keystone_puppet.connect( nova_keystone_service_endpoint, { 'ip': 'keystone_host', 'admin_port': 'keystone_admin_port', 'admin_token': 'admin_token' }) mariadb_service.connect(nova_puppet, {'ip': 'db_host', 'port': 'db_port'}) nova_db_user.connect( nova_puppet, { 'user_name': 'db_user', 'db_name': 'db_name', 'user_password': '******' }) nova_puppet.connect( nova_keystone_service_endpoint, { 'ip': ['ip', 'keystone_host', 'public_ip', 'internal_ip', 'admin_ip'], 'port': ['admin_port', 'internal_port', 'public_port'], }) return { 'nova_puppet': nova_puppet, 'nova_db': nova_db, 'nova_db_user': nova_db_user, 'nova_keystone_user': nova_keystone_user, 'nova_keystone_role': nova_keystone_role, 'nova_keystone_service_endpoint': nova_keystone_service_endpoint }
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/', { 'db_name': 'cinder_db', 'login_user': '******' })[0] cinder_db_user = vr.create('cinder_db_user', 'resources/mariadb_user/', { 'user_name': 'cinder', 'user_password': '******', 'login_user': '******' })[0] cinder_keystone_user = vr.create('cinder_keystone_user', 'resources/keystone_user', { 'user_name': 'cinder', 'user_password': '******' })[0] cinder_keystone_role = vr.create('cinder_keystone_role', 'resources/keystone_role', {'role_name': 'admin'})[0] cinder_keystone_service_endpoint = vr.create( 'cinder_keystone_service_endpoint', 'resources/keystone_service_endpoint', { 'endpoint_name': 'cinder', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2/%(tenant_id)s', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2/%(tenant_id)s', 'publicurl': 'http://{{public_ip}}:{{public_port}}/v2/%(tenant_id)s', 'description': 'OpenStack Block Storage Service', 'type': 'volumev2' })[0] node.connect(cinder_puppet) cinder_puppet.connect_with_events(librarian, {'module': 'modules'}, {}) evapi.add_dep(librarian.name, cinder_puppet.name, actions=('run', 'update')) node.connect(cinder_db) node.connect(cinder_db_user) rabbitmq_service.connect(cinder_puppet, { 'ip': 'rabbit_host', 'port': 'rabbit_port' }) admin_user.connect( cinder_puppet, { 'user_name': 'keystone_user', 'user_password': '******', 'tenant_name': 'keystone_tenant' }) #? openstack_vhost.connect(cinder_puppet, {'vhost_name': 'rabbit_virtual_host'}) openstack_rabbitmq_user.connect(cinder_puppet, { 'user_name': 'rabbit_userid', 'password': '******' }) mariadb_service.connect( cinder_db, { 'port': 'login_port', 'root_password': '******', 'root_user': '******', 'ip': 'db_host' }) mariadb_service.connect(cinder_db_user, { 'port': 'login_port', 'root_password': '******' }) cinder_db.connect(cinder_db_user, {'db_name', 'db_host'}) cinder_db_user.connect( cinder_puppet, { 'user_name': 'db_user', 'db_name': 'db_name', 'user_password': '******' }) mariadb_service.connect(cinder_puppet, { 'port': 'db_port', 'ip': 'db_host' }) keystone_puppet.connect(cinder_puppet, { 'ip': 'keystone_host', 'admin_port': 'keystone_port' }) #or non admin port? services_tenant.connect(cinder_keystone_user) cinder_keystone_user.connect(cinder_keystone_role) cinder_keystone_user.connect( cinder_puppet, { 'user_name': 'keystone_user', 'tenant_name': 'keystone_tenant', 'user_password': '******' }) mariadb_service.connect(cinder_puppet, {'ip': 'ip'}) cinder_puppet.connect( cinder_keystone_service_endpoint, { 'ip': ['ip', 'keystone_host', 'admin_ip', 'internal_ip', 'public_ip'], 'port': ['admin_port', 'internal_port', 'public_port'], }) keystone_puppet.connect(cinder_keystone_service_endpoint, { 'admin_port': 'keystone_admin_port', 'admin_token': 'admin_token' }) # 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] node.connect(cinder_glance_puppet) evapi.add_dep(cinder_puppet.name, cinder_glance_puppet.name, actions=('run', )) return { 'cinder_puppet': cinder_puppet, 'cinder_db': cinder_db, 'cinder_db_user': cinder_db_user, 'cinder_keystone_user': cinder_keystone_user, 'cinder_keystone_role': cinder_keystone_role, 'cinder_keystone_service_endpoint': cinder_keystone_service_endpoint, 'cinder_glance_puppet': cinder_glance_puppet }