From ded8f0fe02422588e8696e4d405abb7d9b5cc384 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Wed, 15 Jul 2015 15:44:05 +0200 Subject: [PATCH 1/4] Add keystone endpoint for ... keystone --- example-puppet.py | 64 ++++++++++++++----- resources/keystone_puppet/README.md | 6 ++ .../actions/run.yaml | 2 +- resources/keystone_service_endpoint/meta.yaml | 3 + 4 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 resources/keystone_puppet/README.md diff --git a/example-puppet.py b/example-puppet.py index 2d596671..232a3f6e 100644 --- a/example-puppet.py +++ b/example-puppet.py @@ -48,6 +48,8 @@ def deploy(): #keystone_puppet = vr.create('keystone_puppet', GitProvider(GIT_PUPPET_LIBS_URL, path='keystone'), {})[0] keystone_puppet = vr.create('keystone_puppet', 'resources/keystone_puppet', {})[0] + keystone_service_endpoint = vr.create('keystone_service_endpoint', 'resources/keystone_service_endpoint', {'endpoint_name': 'keystone', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}/v2.0', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}/v2.0', 'publicurl': 'http://{{public_ip}}:{{public_port}}/v2.0', 'description': 'OpenStack Identity Service', 'type': 'identity'})[0] + # # TODO: vhost cannot be specified in neutron Puppet manifests so this user has to be admin anyways # neutron_puppet = vr.create('neutron_puppet', GitProvider(GIT_PUPPET_LIBS_URL, path='neutron'), {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0] neutron_puppet = vr.create('neutron_puppet', 'resources/neutron_puppet', {'rabbitmq_user': 'guest', 'rabbitmq_password': 'guest'})[0] @@ -60,7 +62,7 @@ def deploy(): neutron_keystone_user = vr.create('neutron_keystone_user', 'resources/keystone_user', {'user_name': 'neutron', 'user_password': 'neutron'})[0] neutron_keystone_role = vr.create('neutron_keystone_role', 'resources/keystone_role', {'role_name': 'neutron'})[0] - neutron_keystone_service_endpoint = vr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', {'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', 'publicurl': 'http://{{public_ip}}:{{public_port}}', 'description': 'OpenStack Network Service', 'type': 'network'})[0] + neutron_keystone_service_endpoint = vr.create('neutron_keystone_service_endpoint', 'resources/keystone_service_endpoint', {'endpoint_name': 'neutron', 'adminurl': 'http://{{admin_ip}}:{{admin_port}}', 'internalurl': 'http://{{internal_ip}}:{{internal_port}}', 'publicurl': 'http://{{public_ip}}:{{public_port}}', 'description': 'OpenStack Network Service', 'type': 'network'})[0] # #cinder_puppet = vr.create('cinder_puppet', GitProvider(GIT_PUPPET_LIBS_URL, 'cinder'), {})[0] # cinder_puppet = vr.create('cinder_puppet', 'resources/cinder_puppet', {})[0] @@ -96,6 +98,12 @@ def deploy(): signals.connect(mariadb_service1, keystone_db_user, {'port': 'login_port', 'root_password': 'login_password'}) signals.connect(keystone_db, keystone_db_user, {'db_name': 'db_name'}) + signals.connect(node1, keystone_service_endpoint) + signals.connect(keystone_puppet, keystone_service_endpoint, {'admin_token': 'admin_token', 'admin_port': 'keystone_admin_port', 'ip': 'keystone_host'}) + signals.connect(keystone_puppet, keystone_service_endpoint, {'admin_port': 'admin_port', 'ip': 'admin_ip'}) + signals.connect(keystone_puppet, keystone_service_endpoint, {'port': 'internal_port', 'ip': 'internal_ip'}) + signals.connect(keystone_puppet, keystone_service_endpoint, {'port': 'public_port', 'ip': 'public_ip'}) + signals.connect(keystone_puppet, admin_tenant) signals.connect(keystone_puppet, admin_tenant, {'admin_port': 'keystone_port', 'ip': 'keystone_host'}) signals.connect(admin_tenant, admin_user) @@ -173,6 +181,8 @@ def deploy(): actions.resource_action(admin_user, 'run') actions.resource_action(admin_role, 'run') + actions.resource_action(keystone_service_endpoint, 'run') + actions.resource_action(services_tenant, 'run') actions.resource_action(neutron_keystone_user, 'run') actions.resource_action(neutron_keystone_role, 'run') @@ -198,9 +208,31 @@ def deploy(): def undeploy(): db = get_db() + to_remove = [ + 'neutron_keystone_service_endpoint', + 'neutron_puppet', + 'neutron_keystone_role', + 'neutron_keystone_user', + 'services_tenant', + 'keystone_service_endpoint', + 'admin_role', + 'admin_user', + 'admin_tenant', + 'keystone_puppet', + 'keystone_db_user', + 'keystone_db', + 'mariadb_service1', + 'openstack_rabbitmq_user', + 'openstack_vhost', + 'rabbitmq_service1', + ] + resources = map(resource.wrap_resource, db.get_list(collection=db.COLLECTIONS.resource)) resources = {r.name: r for r in resources} + for name in to_remove: + actions.resource_action(resources[name], 'remove') + #actions.resource_action(resources['nova_keystone_service_endpoint'], 'remove' ) # actions.resource_action(resources['nova_network_puppet'], 'remove' ) @@ -209,29 +241,29 @@ def undeploy(): # actions.resource_action(resources['cinder_puppet'], 'remove' ) - actions.resource_action(resources['neutron_keystone_service_endpoint'], 'remove' ) - actions.resource_action(resources['neutron_puppet'], 'remove' ) + # actions.resource_action(resources['neutron_keystone_service_endpoint'], 'remove' ) + # actions.resource_action(resources['neutron_puppet'], 'remove' ) # actions.resource_action(resources['cinder_keystone_role'], 'remove') # actions.resource_action(resources['cinder_keystone_user'], 'remove') - actions.resource_action(resources['neutron_keystone_role'], 'remove') - actions.resource_action(resources['neutron_keystone_user'], 'remove') - actions.resource_action(resources['services_tenant'], 'remove') + # actions.resource_action(resources['neutron_keystone_role'], 'remove') + # actions.resource_action(resources['neutron_keystone_user'], 'remove') + # actions.resource_action(resources['services_tenant'], 'remove') - actions.resource_action(resources['admin_role'], 'remove') - actions.resource_action(resources['admin_user'], 'remove') - actions.resource_action(resources['admin_tenant'], 'remove') + # actions.resource_action(resources['admin_role'], 'remove') + # actions.resource_action(resources['admin_user'], 'remove') + # actions.resource_action(resources['admin_tenant'], 'remove') - actions.resource_action(resources['keystone_puppet'], 'remove') - actions.resource_action(resources['keystone_db_user'], 'remove') - actions.resource_action(resources['keystone_db'], 'remove') + # actions.resource_action(resources['keystone_puppet'], 'remove') + # actions.resource_action(resources['keystone_db_user'], 'remove') + # actions.resource_action(resources['keystone_db'], 'remove') - actions.resource_action(resources['mariadb_service1'], 'remove') + # actions.resource_action(resources['mariadb_service1'], 'remove') - actions.resource_action(resources['openstack_rabbitmq_user'], 'remove') - actions.resource_action(resources['openstack_vhost'], 'remove') - actions.resource_action(resources['rabbitmq_service1'], 'remove') + # actions.resource_action(resources['openstack_rabbitmq_user'], 'remove') + # actions.resource_action(resources['openstack_vhost'], 'remove') + # actions.resource_action(resources['rabbitmq_service1'], 'remove') db.clear() diff --git a/resources/keystone_puppet/README.md b/resources/keystone_puppet/README.md new file mode 100644 index 00000000..1db48d72 --- /dev/null +++ b/resources/keystone_puppet/README.md @@ -0,0 +1,6 @@ +# `keystone_puppet` resource + +This resource implements inputs for the official OpenStack Keystone Puppet manifests +from https://github.com/openstack/puppet-keystone (`stable/juno` branch). + +Basic tests are present that test HTTP connectivity to the service. diff --git a/resources/keystone_service_endpoint/actions/run.yaml b/resources/keystone_service_endpoint/actions/run.yaml index 71ebf614..fbd9649d 100644 --- a/resources/keystone_service_endpoint/actions/run.yaml +++ b/resources/keystone_service_endpoint/actions/run.yaml @@ -4,7 +4,7 @@ - name: keystone service and endpoint keystone_service: token: {{admin_token}} - name: {{resource_name}} + name: {{endpoint_name}} type: {{type}} description: {{description}} publicurl: {{publicurl}} diff --git a/resources/keystone_service_endpoint/meta.yaml b/resources/keystone_service_endpoint/meta.yaml index 3af6d0e3..7c0212f7 100644 --- a/resources/keystone_service_endpoint/meta.yaml +++ b/resources/keystone_service_endpoint/meta.yaml @@ -12,6 +12,9 @@ input: schema: str! value: + endpoint_name: + schema: str! + value: type: schema: str! value: From 761fc047256ed6d1869bf2145861bfffe15c5169 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Thu, 16 Jul 2015 08:48:07 +0200 Subject: [PATCH 2/4] README update --- README.md | 72 +++++++++++++++++-------------------------------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 46f1e621..ba5a02f4 100644 --- a/README.md +++ b/README.md @@ -90,23 +90,19 @@ solar connections graph --start-with mariadb_service --end-with keystone_db solar resource validate ``` +* Disconnect +``` +solar disconnect rs/mariadb_nova_data rs/node1 +``` + +* Tag a resource: +``` +solar resource tag rs/node1 test-tags # Remove tags +python cli.py resource tag rs/node1 test-tag --delete +``` + # Low level API -## HAProxy deployment (not maintained) - -``` -cd /vagrant -python cli.py deploy haproxy_deployment/haproxy-deployment.yaml -``` - -or from Python shell: - -``` -from x import deployment - -deployment.deploy('/vagrant/haproxy_deployment/haproxy-deployment.yaml') -``` - ## Usage: Creating resources: @@ -181,42 +177,18 @@ node1.ssh_key = '/vagrant/.vagrant/machines/solar-dev1/virtualbox/private_key' node1.ssh_user = 'vagrant' ``` -## CLI - -You can do the above from the command-line client: +## HAProxy deployment (not maintained) ``` cd /vagrant - -python cli.py resource create node1 x/resources/ro_node/ rs/ '{"ip":"10.0.0.3", "ssh_key" : "/vagrant/tmp/keys/ssh_private", "ssh_user":"vagrant"}' - -python cli.py resource create node2 x/resources/ro_node/ rs/ '{"ip":"10.0.0.4", "ssh_key" : "/vagrant/tmp/keys/ssh_private", "ssh_user":"vagrant"}' - -python cli.py resource create mariadb_keystone_data x/resources/data_container/ rs/ '{"image": "mariadb", "export_volumes" : ["/var/lib/mysql"], "ip": "", "ssh_user": "", "ssh_key": ""}' - -python cli.py resource create mariadb_nova_data x/resources/data_container/ rs/ '{"image" : "mariadb", "export_volumes" : ["/var/lib/mysql"], "ip": "", "ssh_user": "", "ssh_key": ""}' - -# View resourcespython cli.py resource show rs/mariadb_keystone_data -# Show all resources at location rs/ -python cli.py resource show rs/ --all - -# Show resources with specific tagspython cli.py resources show rs/ --tag test - -# Connect resourcespython cli.py connect rs/node2 rs/mariadb_keystone_data -python cli.py connect rs/node1 rs/mariadb_nova_data -# Test updatepython cli.py update rs/node2 '{"ip": "1.1.1.1"}' -python cli.py resource show rs/mariadb_keystone_data # --> IP is 1.1.1.1 - -# View connections -python cli.py connections show - -# Outputs graph to 'graph.png' file, please note that arrows don't have "normal" pointers, but just the line is thicker -# please see http://networkx.lanl.gov/_modules/networkx/drawing/nx_pylab.html -python cli.py connections graph - -# Disconnect -python cli.py disconnect rs/mariadb_nova_data rs/node1 - -# Tag a resource: -python cli.py resource tag rs/node1 test-tags# Remove tagspython cli.py resource tag rs/node1 test-tag --delete +python cli.py deploy haproxy_deployment/haproxy-deployment.yaml ``` + +or from Python shell: + +``` +from x import deployment + +deployment.deploy('/vagrant/haproxy_deployment/haproxy-deployment.yaml') +``` + From 6b7af5f867f412984cbef607b64ad9af4dbfe258 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Thu, 16 Jul 2015 09:04:59 +0200 Subject: [PATCH 3/4] Add some README's to couple of resources --- resources/haproxy_config/README.md | 11 +++++++++++ resources/haproxy_service/README.md | 8 ++++++++ resources/haproxy_service_config/README.md | 5 +++++ resources/keystone_service/README.md | 11 +++++++++++ 4 files changed, 35 insertions(+) create mode 100644 resources/haproxy_config/README.md create mode 100644 resources/haproxy_service/README.md create mode 100644 resources/haproxy_service_config/README.md create mode 100644 resources/keystone_service/README.md diff --git a/resources/haproxy_config/README.md b/resources/haproxy_config/README.md new file mode 100644 index 00000000..c0ee178a --- /dev/null +++ b/resources/haproxy_config/README.md @@ -0,0 +1,11 @@ +# `haproxy_config` resource + +This resource represents configuration for the `haproxy_service` resource. +Each service represented by Haproxy is connected to this resource via +`haproxy_service_config` resource. This is because in Haproxy there is no +support for something like `/etc/haproxy/conf.d` directory where you put +each config in a separate file, but instead you must collect all configuration +in one file. + +So this resource renders this file from data provided by collecting individual +`haproxy_service_config` data. diff --git a/resources/haproxy_service/README.md b/resources/haproxy_service/README.md new file mode 100644 index 00000000..348cd1e4 --- /dev/null +++ b/resources/haproxy_service/README.md @@ -0,0 +1,8 @@ +# `haproxy_service` resource + +This resource sets up a Docker container with Haproxy code. It requires +config to be provided by the `haproxy_config` resource (mounted under +`/etc/haproxy`). + +About container philosophy, see the `README.md` file in `keystone_service` +resource. diff --git a/resources/haproxy_service_config/README.md b/resources/haproxy_service_config/README.md new file mode 100644 index 00000000..fdbf60d4 --- /dev/null +++ b/resources/haproxy_service_config/README.md @@ -0,0 +1,5 @@ +# `haproxy_service_config` resource + +This resource represents config for a single service handled by Haproxy. +It connects into `haproxy_config`. It collects all services which are to +be load-balanced by Haproxy. diff --git a/resources/keystone_service/README.md b/resources/keystone_service/README.md new file mode 100644 index 00000000..aac0b259 --- /dev/null +++ b/resources/keystone_service/README.md @@ -0,0 +1,11 @@ +# `keystone_service` resource + +This resource sets up a Docker container with Keystone code. It requires +config to be provided by the `keystone_config` resource (mounted under +`/etc/keystone`). + +Basically, the philosophy behind containers in Solar is to have stateless +containers with service code and mount stateful resources with config, +volumes, etc. to that container. Upgrade of code then would be just about +replacing the stateless container with new one and remounting state to that +new container. From cb75932c0050126386adcedca83c661fc6338ee8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Thu, 16 Jul 2015 09:21:21 +0200 Subject: [PATCH 4/4] README.md: fix deprecated rs/ dirs and cli.py --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ba5a02f4..5c8190d5 100644 --- a/README.md +++ b/README.md @@ -92,13 +92,13 @@ solar resource validate * Disconnect ``` -solar disconnect rs/mariadb_nova_data rs/node1 +solar disconnect mariadb_service node1 ``` * Tag a resource: ``` -solar resource tag rs/node1 test-tags # Remove tags -python cli.py resource tag rs/node1 test-tag --delete +solar resource tag node1 test-tags # Remove tags +solar resource tag node1 test-tag --delete ``` # Low level API @@ -181,13 +181,13 @@ node1.ssh_user = 'vagrant' ``` cd /vagrant -python cli.py deploy haproxy_deployment/haproxy-deployment.yaml +solar deploy haproxy_deployment/haproxy-deployment.yaml ``` or from Python shell: ``` -from x import deployment +from solar.core import deployment deployment.deploy('/vagrant/haproxy_deployment/haproxy-deployment.yaml') ```