Skip to content

Commit

Permalink
Merge 611a462 into 6d21790
Browse files Browse the repository at this point in the history
  • Loading branch information
pigmej committed Nov 18, 2015
2 parents 6d21790 + 611a462 commit da9ef28
Show file tree
Hide file tree
Showing 110 changed files with 5,413 additions and 3,869 deletions.
9 changes: 9 additions & 0 deletions .config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dblayer: riak
redis:
host: localhost
port: '6379'
solar_db:
mode: riak
host: localhost
port: '8087'
protocol: pbc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ celery*.log

*.dot
*.png
*.svg
resources_compiled.py

# bootstrap
Expand All @@ -45,3 +46,4 @@ solar/.coverage

# pytest cache
solar/.cache
.config.override
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
python: 2.7
env:
- PIP_ACCEL_CACHE=$HOME/.pip-accel-cache
- PIP_ACCEL_CACHE=$HOME/.pip-accel-cache SOLAR_CONFIG=$TRAVIS_BUILD_DIR/.config
cache:
directories:
- $HOME/.pip-accel-cache
Expand All @@ -10,8 +10,8 @@ install:
- pip-accel install coveralls
- pip-accel install -r solar/test-requirements.txt
script:
- cd solar && py.test --cov=solar -s solar && cd ..
- cd solar && py.test --cov=solar -s solar/test && cd ..
services:
- redis-server
- riak
after_success:
cd solar && coveralls
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM ubuntu:14.04

WORKDIR /

RUN apt-get update
# Install pip's dependency: setuptools:
RUN apt-get install -y python python-dev python-distribute python-pip
RUN pip install ansible

ADD bootstrap/playbooks/celery.yaml /celery.yaml
ADD solar /solar
ADD solard /solard
ADD resources /resources
ADD templates /templates
ADD run.sh /run.sh


RUN apt-get install -y libffi-dev libssl-dev
RUN pip install riak peewee
RUN pip install -U setuptools>=17.1
RUN cd /solar && python setup.py install
RUN cd /solard && python setup.py install
RUN ansible-playbook -v -i "localhost," -c local /celery.yaml --skip-tags slave

CMD ["/run.sh"]
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
solar-celery:
image: solarproject/solar-celery
# path inside of the container should be exactly the same as outside
# because solar uses absolute path to find resoruce actions files
volumes:
- /vagrant/.vagrant:/vagrant/.vagrant
- /vagrant/solar:/solar
- /vagrant/solard:/solard
- /vagrant/templates:/vagrant/templates
- /vagrant/resources:/vagrant/resources
environment:
- REDIS_HOST=10.0.0.2
- REDIS_PORT=6379
- RIAK_HOST=10.0.0.2
- RIAK_PORT=8087
# links are not used for configuration because we can rely on non-container
# based datastores
links:
- riak
- redis
riak:
image: tutum/riak
ports:
- 8087:8087
- 8098:8098
redis:
image: tutum/redis
ports:
- 6379:6379
environment:
- REDIS_PASS=**None**
19 changes: 5 additions & 14 deletions examples/bootstrap/example-bootstrap.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
from solar.core import validation
from solar.core.resource import virtual_resource as vr
from solar import errors

from solar.interfaces.db import get_db


db = get_db()
from solar.dblayer.model import ModelMeta


@click.group()
Expand All @@ -23,9 +19,7 @@ def main():


def setup_resources():
db.clear()

signals.Connections.clear()
ModelMeta.remove_all()

node2 = vr.create('node2', 'resources/ro_node/', {
'ip': '10.0.0.4',
Expand Down Expand Up @@ -61,7 +55,7 @@ def deploy():
setup_resources()

# run
resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource))
resources = resource.load_all()
resources = {r.name: r for r in resources}

for name in resources_to_run:
Expand All @@ -76,7 +70,7 @@ def deploy():

@click.command()
def undeploy():
resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource))
resources = resource.load_all()
resources = {r.name: r for r in resources}

for name in reversed(resources_to_run):
Expand All @@ -85,10 +79,7 @@ def undeploy():
except errors.SolarError as e:
print 'WARNING: %s' % str(e)

db.clear()

signals.Connections.clear()

ModelMeta.remove_all()

main.add_command(deploy)
main.add_command(undeploy)
Expand Down
16 changes: 5 additions & 11 deletions examples/compiled-resources/example-compiled-resources.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
from solar.core.resource import virtual_resource as vr
from solar.core import resource
from solar.core import signals

from solar.interfaces.db import get_db
from solar.dblayer.model import ModelMeta
from solar.core.resource_provider import GitProvider, RemoteZipProvider


import resources_compiled


Expand All @@ -34,9 +32,7 @@ def main():

@click.command()
def deploy():
db = get_db()
db.clear()

ModelMeta.remove_all()
signals.Connections.clear()

node1 = resources_compiled.RoNodeResource('node1', None, {})
Expand Down Expand Up @@ -75,18 +71,16 @@ def deploy():

@click.command()
def undeploy():
db = get_db()
ModelMeta.remove_all()

resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource))
resources = resource.load_all()
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()
ModelMeta.remove_all()


main.add_command(deploy)
Expand Down
8 changes: 2 additions & 6 deletions examples/hosts_file/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

from solar.core import signals
from solar.core.resource import virtual_resource as vr

from solar.interfaces.db import get_db


db = get_db()
from solar.dblayer.model import ModelMeta


def run():
db.clear()
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')]
Expand Down
6 changes: 2 additions & 4 deletions examples/library_ceph/ceph.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

from solar.core.resource import virtual_resource as vr
from solar.interfaces.db import get_db

from solar.dblayer.model import ModelMeta
import yaml

db = get_db()

STORAGE = {'objects_ceph': True,
'osd_pool_size': 2,
Expand Down Expand Up @@ -34,7 +32,7 @@


def deploy():
db.clear()
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'))
Expand Down
8 changes: 3 additions & 5 deletions examples/lxc/example-lxc.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from solar.core import signals
from solar.core.resource import virtual_resource as vr

from solar.interfaces.db import get_db

from solar.system_log import change
from solar.cli import orch
from solar.dblayer.model import ModelMeta


@click.group()
def main():
Expand Down Expand Up @@ -43,9 +43,7 @@ def lxc_template(idx):

@click.command()
def deploy():
db = get_db()
db.clear()
signals.Connections.clear()
ModelMeta.remove_all()

node1 = vr.create('nodes', 'templates/nodes.yaml', {})[0]
seed = vr.create('nodes', 'templates/seed_node.yaml', {})[0]
Expand Down
12 changes: 4 additions & 8 deletions examples/openstack/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
from solar.core import validation
from solar.core.resource import virtual_resource as vr
from solar import events as evapi

from solar.interfaces.db import get_db

from solar.dblayer.model import ModelMeta

PROFILE = False
#PROFILE = True
Expand All @@ -35,8 +33,6 @@
# Official puppet manifests, not fuel-library


db = get_db()


@click.group()
def main():
Expand Down Expand Up @@ -247,7 +243,7 @@ def setup_neutron(node, librarian, rabbitmq_service, openstack_rabbitmq_user, op
return {'neutron_puppet': neutron_puppet}

def setup_neutron_api(node, mariadb_service, admin_user, keystone_puppet, services_tenant, neutron_puppet):
# NEUTRON PLUGIN AND NEUTRON API (SERVER)
# NEUTRON PLUGIN AND NEUTRON API (SERVER)
neutron_plugins_ml2 = vr.create('neutron_plugins_ml2', 'resources/neutron_plugins_ml2_puppet', {})[0]
node.connect(neutron_plugins_ml2)

Expand Down Expand Up @@ -830,7 +826,7 @@ def create_compute(node):

@click.command()
def create_all():
db.clear()
ModelMeta.remove_all()
r = prepare_nodes(2)
r.update(create_controller('node0'))
r.update(create_compute('node1'))
Expand All @@ -856,7 +852,7 @@ def add_controller(node):

@click.command()
def clear():
db.clear()
ModelMeta.remove_all()


if __name__ == '__main__':
Expand Down
7 changes: 2 additions & 5 deletions examples/riak/riaks-template.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
import sys

from solar.core import resource
from solar.interfaces.db import get_db
from solar import template


db = get_db()
from solar.dblayer.model import ModelMeta


def setup_riak():
db.clear()

ModelMeta.remove_all()
nodes = template.nodes_from('templates/riak_nodes.yaml')

riak_services = nodes.on_each(
Expand Down
10 changes: 6 additions & 4 deletions examples/riak/riaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
from solar.core.resource import virtual_resource as vr
from solar import errors

from solar.interfaces.db import get_db
from solar.dblayer.model import ModelMeta

from solar.events.controls import React, Dep
from solar.events.api import add_event


db = get_db()
from solar.dblayer.solar_models import Resource


def setup_riak():
db.clear()

ModelMeta.remove_all()
resources = vr.create('nodes', 'templates/nodes.yaml', {'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
hosts_services = [x for x in resources if x.name.startswith('hosts_file')]

riak_services = []
ips = '10.0.0.%d'
Expand All @@ -44,6 +44,7 @@ def setup_riak():
r = vr.create('riak_service%d' % num,
'resources/riak_node',
{'riak_self_name': 'riak%d' % num,
'storage_backend': 'leveldb',
'riak_hostname': 'riak_server%d.solar' % num,
'riak_name': 'riak%d@riak_server%d.solar' % (num, num)})[0]
riak_services.append(r)
Expand All @@ -60,6 +61,7 @@ def setup_riak():
{'riak_hostname': 'hosts:name',
'ip': 'hosts:ip'})

Resource.save_all_lazy()
errors = resource.validate_resources()
for r, error in errors:
click.echo('ERROR: %s: %s' % (r.name, error))
Expand Down
9 changes: 2 additions & 7 deletions examples/solard/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
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()

from solar.dblayer.model import ModelMeta


def run():
db.clear()
ModelMeta.remove_all()

node = vr.create('node', 'resources/ro_node', {'name': 'first' + str(time.time()),
'ip': '10.0.0.3',
Expand Down
Loading

0 comments on commit da9ef28

Please sign in to comment.