def pytest_configure(): if db.CURRENT_DB == 'redis_graph_db': db.DB = db.get_db(backend='fakeredis_graph_db') elif db.CURRENT_DB == 'redis_db': db.DB = db.get_db(backend='fakeredis_db') else: db.DB = db.get_db(backend=db.CURRENT_DB)
def __init__(self, profile, core_manager=None, config=None): self.config = config or {} self.uid = self.ID self.db = get_db() self.profile = profile from solar.core.extensions_manager import ExtensionsManager self.core = core_manager or ExtensionsManager(self.profile)
def undeploy(): db = get_db() resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) resources = {r.name: r for r in resources} actions.resource_action(resources['openstack_rabbitmq_user'], 'remove') actions.resource_action(resources['openstack_vhost'], 'remove') actions.resource_action(resources['rabbitmq_service1'], 'remove') db.clear() signals.Connections.clear()
def deploy(): db = get_db() db.clear() signals.Connections.clear() node1 = resources_compiled.RoNodeResource('node1', None, {}) node1.ip = '10.0.0.3' node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key' node1.ssh_user = '******' rabbitmq_service1 = resources_compiled.RabbitmqServiceResource( 'rabbitmq_service1', None, { 'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management' }) openstack_vhost = resource.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0] openstack_rabbitmq_user = resource.create( 'openstack_rabbitmq_user', 'resources/rabbitmq_user/', { 'user_name': 'openstack', 'password': '******' })[0] #### # connections #### # rabbitmq signals.connect(node1, rabbitmq_service1) signals.connect(rabbitmq_service1, openstack_vhost) signals.connect(rabbitmq_service1, openstack_rabbitmq_user) signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'}) errors = vr.validate_resources() if errors: for r, error in errors: print 'ERROR: %s: %s' % (r.name, error) sys.exit(1) # run actions.resource_action(rabbitmq_service1, 'run') actions.resource_action(openstack_vhost, 'run') actions.resource_action(openstack_rabbitmq_user, 'run') time.sleep(10)
def deploy(): db = get_db() db.clear() signals.Connections.clear() node1 = resources_compiled.RoNodeResource('node1', None, {}) node1.ip = '10.0.0.3' node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key' node1.ssh_user = '******' rabbitmq_service1 = resources_compiled.RabbitmqServiceResource('rabbitmq_service1', None, {'management_port': 15672, 'port': 5672, 'container_name': 'rabbitmq_service1', 'image': 'rabbitmq:3-management'}) openstack_vhost = resource.create('openstack_vhost', 'resources/rabbitmq_vhost/', {'vhost_name': 'openstack'})[0] openstack_rabbitmq_user = resource.create('openstack_rabbitmq_user', 'resources/rabbitmq_user/', {'user_name': 'openstack', 'password': '******'})[0] #### # connections #### # rabbitmq signals.connect(node1, rabbitmq_service1) signals.connect(rabbitmq_service1, openstack_vhost) signals.connect(rabbitmq_service1, openstack_rabbitmq_user) signals.connect(openstack_vhost, openstack_rabbitmq_user, {'vhost_name': 'vhost_name'}) errors = vr.validate_resources() if errors: for r, error in errors: print 'ERROR: %s: %s' % (r.name, error) sys.exit(1) # run actions.resource_action(rabbitmq_service1, 'run') actions.resource_action(openstack_vhost, 'run') actions.resource_action(openstack_rabbitmq_user, 'run') time.sleep(10)
import click import sys import time from solar.core import resource from solar.core import signals from solar.core.resource import virtual_resource as vr from solar.interfaces.db import get_db db = get_db() def run(): db.clear() 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_solard = vr.create('transports_for_solard', '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] solard_transport = vr.create('solard_transport', 'resources/transport_solard',
import cProfile import pstats pr = cProfile.Profile() pr.enable() # TODO # Resource for repository OR puppet apt-module in run.pp # add-apt-repository cloud-archive:juno # To discuss: install stuff in Docker container # NOTE # No copy of manifests, pull from upstream (implemented in the librarian resource) # Official puppet manifests, not fuel-library db = get_db() @click.group() def main(): pass 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 = {}
def fin(): db.get_db().clear()
def deploy(): db = get_db() db.clear() signals.Connections.clear() node1 = vr.create('nodes', 'templates/nodes.yml', {})[0] seed = vr.create('nodes', 'templates/seed_node.yml', {})[0] ssh_key = vr.create('ssh_key1', 'resources/ssh_key', { 'keys_dir': '/vagrant/.ssh', 'private_key': '/vagrant/.ssh/id_rsa', 'public_key': '/vagrant/.ssh/id_rsa.pub', 'passphrase': '', })[0] signals.connect(seed, ssh_key) cnets1 = vr.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', { 'networks': {'mgmt': { 'bridge': 'br-int53', 'bridge_address': '172.18.11.253/24' }} })[0] signals.connect(seed, cnets1) signals.connect(node1, cnets2) vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' })[0] vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' })[0] # seed node should be connected anyway, because we need to be able to ssh # into containers from any node signals.connect(seed, vxlan_mesh1) signals.connect(node1, vxlan_mesh2) lxc_infra1 = vr.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{}'.format(idx), 'resources/lxc_container', lxc_template(idx))[0] hosts_map[idx] = lxc_host_idx signals.connect(node1, lxc_host_idx, { 'ip': ['ansible_ssh_host', 'physical_host'], }) # this is a required to introduce depends on relationship between lxc infre # and lxc container signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'}) signals.connect(cnets2, lxc_host_idx) signals.connect(ssh_key, lxc_host_idx, { 'public_key': 'pub_key', 'private_key': 'user_key'}) # RABBIT rabbitmq_service1 = 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] signals.connect(hosts_map[28], rabbitmq_service1, { 'mgmt_ip': 'ip', 'user_key': 'ssh_key', 'user': '******'}) signals.connect(rabbitmq_service1, openstack_vhost) signals.connect(rabbitmq_service1, openstack_rabbitmq_user) signals.connect(openstack_vhost, openstack_rabbitmq_user, { 'vhost_name', }) print change.send_to_orchestration()
def fin(): from solar.core import signals db.get_db().clear() signals.Connections.clear()
def deploy(): db = get_db() db.clear() signals.Connections.clear() node1 = vr.create('nodes', 'templates/nodes.yaml', {})[0] seed = vr.create('nodes', 'templates/seed_node.yaml', {})[0] ssh_key = vr.create('ssh_key1', 'resources/ssh_key', { 'keys_dir': '/vagrant/.ssh', 'private_key': '/vagrant/.ssh/id_rsa', 'public_key': '/vagrant/.ssh/id_rsa.pub', 'passphrase': '', })[0] signals.connect(seed, ssh_key) cnets1 = vr.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', { 'networks': {'mgmt': { 'bridge': 'br-int53', 'bridge_address': '172.18.11.253/24' }} })[0] signals.connect(seed, cnets1) signals.connect(node1, cnets2) vxlan_mesh1 = vr.create('vxlan_mesh1', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' })[0] vxlan_mesh2 = vr.create('vxlan_mesh2', 'resources/vxlan_mesh', { 'id': 53, 'parent': 'eth1', 'master': 'br-int53' })[0] # seed node should be connected anyway, because we need to be able to ssh # into containers from any node signals.connect(seed, vxlan_mesh1) signals.connect(node1, vxlan_mesh2) lxc_infra1 = vr.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{}'.format(idx), 'resources/lxc_container', lxc_template(idx))[0] hosts_map[idx] = lxc_host_idx signals.connect(node1, lxc_host_idx, { 'ip': ['ansible_ssh_host', 'physical_host'], }) # this is a required to introduce depends on relationship between lxc infre # and lxc container signals.connect(lxc_infra1, lxc_host_idx, {'provides': 'requires'}) signals.connect(cnets2, lxc_host_idx) signals.connect(ssh_key, lxc_host_idx, { 'public_key': 'pub_key', 'private_key': 'user_key'}) # RABBIT rabbitmq_service1 = 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] signals.connect(hosts_map[28], rabbitmq_service1, { 'mgmt_ip': 'ip', 'user_key': 'ssh_key', 'user': '******'}) signals.connect(rabbitmq_service1, openstack_vhost) signals.connect(rabbitmq_service1, openstack_rabbitmq_user) signals.connect(openstack_vhost, openstack_rabbitmq_user, { 'vhost_name', }) print change.send_to_orchestration()