def deploy(filename): with open(filename) as f: config = yaml.load(f) workdir = config['workdir'] resource_save_path = os.path.join(workdir, config['resource-save-path']) # Clean stuff first db.clear() xs.Connections.clear() shutil.rmtree(resource_save_path, ignore_errors=True) os.makedirs(resource_save_path) # Create resources first for resource_definition in config['resources']: name = resource_definition['name'] model = os.path.join(workdir, resource_definition['model']) args = resource_definition.get('args', {}) log.debug('Creating %s %s %s %s', name, model, resource_save_path, args) xr.create(name, model, resource_save_path, args=args) # Create resource connections for connection in config['connections']: emitter = db.get_resource(connection['emitter']) receiver = db.get_resource(connection['receiver']) mapping = connection.get('mapping') log.debug('Connecting %s %s %s', emitter.name, receiver.name, mapping) xs.connect(emitter, receiver, mapping=mapping) # Run all tests if 'test-suite' in config: log.debug('Running tests from %s', config['test-suite']) test_suite = __import__(config['test-suite'], {}, {}, ['main']) test_suite.main()
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)