Merge branch 'master' into testable-resources

This commit is contained in:
Przemyslaw Kaminski 2015-07-07 11:34:34 +02:00
commit c59a66ca64
7 changed files with 141 additions and 33 deletions

View File

@ -1,55 +1,84 @@
# Setup development env # Setup development env
* Install virtualbox
* Install vagrant
* Setup environment
* Install [Vagrant](http://www.vagrantup.com/downloads.html)
* Setup environment:
``` ```
$ cd fuel-ng cd solar
$ vagrant up vagrant up
``` ```
* Login into vm, the code is available in /vagrant directory * Login into vm, the code is available in /vagrant directory
``` ```
$ vagrant ssh vagrant ssh
$ solar --help solar --help
```
* Launch standard deployment:
```
python example.py
```
* Get ssh details for running slave nodes (vagrant/vagrant):
```
vagrant ssh-config
```
* Get list of docker containers and attach to the foo container
```
sudo docker ps -a
sudo docker exec -it foo
``` ```
## Solar usage ## Solar usage
* discover nodes, with standard file based discovery
* To get data for the resource bar (raw and pretty-JSON):
``` ```
solar discover solar resource show --tag 'resources/bar'
solar resource show --use-json --tag 'resources/bar' | jq .
``` ```
* create profile (global config) * To clear all resources/connections:
``` ```
solar profile --create --id prf1 --tags env/test_env solar resource clear_all
solar connections clear_all
```
* assign nodes to profile with tags
* edit nodes files, in the future we want to provide
some cli in order to change the data
```
vim tmp/storage/nodes-id.yaml
``` ```
* add `env/test_env` in tags list * Some very simple cluster setup:
* assign resources to nodes
``` ```
# TODO Does not work without default values in golden templates cd /vagrant
solar assign -n "env/test_env && node/1" -r resource/mariadb
solar resource create node1 resources/ro_node/ '{"ip":"10.0.0.3", "ssh_key" : "/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key", "ssh_user":"vagrant"}'
solar resource create mariadb_service resources/mariadb_service '{"image": "mariadb", "root_password": "mariadb", "port": 3306}'
solar resource create keystone_db resources/mariadb_keystone_db/ '{"db_name": "keystone_db", "login_user": "root"}'
solar resource create keystone_db_user resources/mariadb_user/ '{"user_name": "keystone", "user_password": "keystone", "login_user": "root"}'
solar connect node1 mariadb_service
solar connect node1 keystone_db
solar connect mariadb_service keystone_db --mapping '{"root_password": "login_password", "port": "login_port"}'
solar connect mariadb_service keystone_db_user --mapping '{"root_password": "login_password", "port": "login_port"}'
solar connect keystone_db keystone_db_user
solar changes stage
solar changes commit
``` ```
You can fiddle with the above configuration like this:
```
solar resource update keystone_db_user '{"user_password": "new_keystone_password"}'
solar changes stage
solar changes commit
```
* Show the connections/graph:
```
solar connections show
solar connections graph
```
# Low level API # Low level API
## HAProxy deployment ## HAProxy deployment (not maintained)
``` ```
cd /vagrant cd /vagrant

View File

@ -75,6 +75,7 @@ def deploy():
admin_user = vr.create('admin_user', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_user'), {'user_name': 'admin', 'user_password': 'admin'})[0] admin_user = vr.create('admin_user', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_user'), {'user_name': 'admin', 'user_password': 'admin'})[0]
admin_role = vr.create('admin_role', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_role'), {'role_name': 'admin'})[0] admin_role = vr.create('admin_role', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_role'), {'role_name': 'admin'})[0]
keystone_service_endpoint = vr.create('keystone_service_endpoint', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_service_endpoint'), {'adminurl': 'http://{{ip}}:{{admin_port}}/v2.0', 'internalurl': 'http://{{ip}}:{{port}}/v2.0', 'publicurl': 'http://{{ip}}:{{port}}/v2.0', 'description': 'OpenStack Identity Service', 'type': 'identity'})[0] keystone_service_endpoint = vr.create('keystone_service_endpoint', GitProvider(GIT_KEYSTONE_RESOURCE_URL, 'keystone_service_endpoint'), {'adminurl': 'http://{{ip}}:{{admin_port}}/v2.0', 'internalurl': 'http://{{ip}}:{{port}}/v2.0', 'publicurl': 'http://{{ip}}:{{port}}/v2.0', 'description': 'OpenStack Identity Service', 'type': 'identity'})[0]
openrc = vr.create('openrc_file', 'resources/openrc_file', {})[0]
#### ####
@ -178,6 +179,9 @@ def deploy():
signals.connect(keystone_service1, glance_api_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port'}) signals.connect(keystone_service1, glance_api_endpoint, {'ip': 'keystone_host', 'admin_port': 'keystone_port'})
signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'admin_port'}) signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'admin_port'})
signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'port'}) signals.connect(haproxy_glance_api_config, glance_api_endpoint, {'listen_port': 'port'})
signals.connect(node1, openrc)
signals.connect(keystone_service1, openrc, {'ip': 'keystone_host', 'admin_port':'keystone_port'})
signals.connect(admin_user, openrc, {'user_name': 'user_name','user_password':'password', 'tenant_name': 'tenant'})
errors = vr.validate_resources() errors = vr.validate_resources()
@ -206,6 +210,7 @@ def deploy():
actions.resource_action(admin_user, 'run') actions.resource_action(admin_user, 'run')
actions.resource_action(admin_role, 'run') actions.resource_action(admin_role, 'run')
actions.resource_action(keystone_service_endpoint, 'run') actions.resource_action(keystone_service_endpoint, 'run')
actions.resource_action(openrc, 'run')
actions.resource_action(services_tenant, 'run') actions.resource_action(services_tenant, 'run')
actions.resource_action(glance_keystone_user, 'run') actions.resource_action(glance_keystone_user, 'run')
@ -280,6 +285,7 @@ def undeploy():
actions.resource_action(resources['glance_keystone_user'], 'remove') actions.resource_action(resources['glance_keystone_user'], 'remove')
actions.resource_action(resources['glance_keystone_tenant'], 'remove') actions.resource_action(resources['glance_keystone_tenant'], 'remove')
actions.resource_action(resources['openrc_file'], 'remove')
actions.resource_action(resources['keystone_service_endpoint'], 'remove') actions.resource_action(resources['keystone_service_endpoint'], 'remove')
actions.resource_action(resources['admin_role'], 'remove') actions.resource_action(resources['admin_role'], 'remove')
actions.resource_action(resources['admin_user'], 'remove') actions.resource_action(resources['admin_user'], 'remove')

View File

@ -0,0 +1,5 @@
- hosts: [ {{ ip }} ]
sudo: yes
tasks:
- file: path=/root/openrc state=absent

View File

@ -0,0 +1,10 @@
- hosts: [{{ ip }}]
sudo: yes
vars:
tenant: {{tenant}}
user_name: {{user_name}}
password: {{password}}
keystone_host: {{keystone_host}}
keystone_port: {{keystone_port}}
tasks:
- template: src={{resource_dir}}/templates/openrc.template dest=/root/openrc

View File

@ -0,0 +1,29 @@
id: nova_config
handler: ansible
version: 1.0.0
input:
keystone_host:
schema: str!
value:
keystone_port:
schema: int!
value:
tenant:
schema: str!
value:
user_name:
schema: str!
value:
password:
schema: str!
value:
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:

View File

@ -0,0 +1,9 @@
#!/bin/sh
export LC_ALL=C
export OS_NO_CACHE="true"
export OS_TENANT_NAME={{tenant}}
export OS_USERNAME={{user_name}}
export OS_PASSWORD={{password}}
export OS_AUTH_URL=http://{{keystone_host}}:{{keystone_port}}/v2.0
export OS_AUTH_STRATEGY=keystone
export OS_REGION_NAME='RegionOne'

View File

@ -23,6 +23,7 @@ import json
import networkx as nx import networkx as nx
import os import os
import pprint import pprint
import sys
import yaml import yaml
from solar import utils from solar import utils
@ -129,6 +130,14 @@ def init_changes():
def changes(): def changes():
pass pass
@changes.command()
def validate():
errors = vr.validate_resources()
if errors:
for r, error in errors:
print 'ERROR: %s: %s' % (r.name, error)
sys.exit(1)
@changes.command() @changes.command()
def stage(): def stage():
log = operations.stage_changes() log = operations.stage_changes()
@ -196,6 +205,11 @@ def init_cli_connections():
def connections(): def connections():
pass pass
@connections.command()
def clear_all():
click.echo('Clearing all connections')
signals.Connections.clear()
@connections.command() @connections.command()
def show(): def show():
def format_resource_input(resource_name, resource_input_name): def format_resource_input(resource_name, resource_input_name):
@ -261,15 +275,20 @@ def init_cli_resource():
pass pass
@resource.command() @resource.command()
@click.argument('resource_path') @click.argument('resource_name')
@click.argument('action_name') @click.argument('action_name')
def action(action_name, resource_path): def action(action_name, resource_name):
click.echo( click.echo(
'action {} for resource {}'.format(action_name, resource_path) 'action {} for resource {}'.format(action_name, resource_name)
) )
r = sresource.load(resource_path) r = sresource.load(resource_name)
actions.resource_action(r, action_name) actions.resource_action(r, action_name)
@resource.command()
def clear_all():
click.echo('Clearing all resources')
db.clear()
@resource.command() @resource.command()
@click.argument('name') @click.argument('name')
@click.argument('base_path') @click.argument('base_path')
@ -328,6 +347,7 @@ def init_cli_resource():
@click.argument('args') @click.argument('args')
def update(name, args): def update(name, args):
args = json.loads(args) args = json.loads(args)
click.echo('Updating resource {} with args {}'.format(name, args))
all = sresource.load_all() all = sresource.load_all()
r = all[name] r = all[name]
r.update(args) r.update(args)