summaryrefslogtreecommitdiffstats
path: root/meta-openstack
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack')
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone/identity.sh70
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone/keystone.conf2
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone/openrc6
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone_2013.1.bb12
4 files changed, 89 insertions, 1 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-keystone/identity.sh b/meta-openstack/recipes-devtools/python/python-keystone/identity.sh
new file mode 100644
index 0000000..78d5099
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-keystone/identity.sh
@@ -0,0 +1,70 @@
1#!/bin/bash
2
3# Modify these variables as needed
4ADMIN_PASSWORD=${ADMIN_PASSWORD:-password}
5SERVICE_PASSWORD=${SERVICE_PASSWORD:-$ADMIN_PASSWORD}
6DEMO_PASSWORD=${DEMO_PASSWORD:-$ADMIN_PASSWORD}
7export OS_SERVICE_TOKEN="password"
8export OS_SERVICE_ENDPOINT="http://localhost:35357/v2.0"
9SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
10#
11MYSQL_USER=keystone
12MYSQL_DATABASE=keystone
13MYSQL_HOST=localhost
14MYSQL_PASSWORD=password
15#
16KEYSTONE_REGION=RegionOne
17KEYSTONE_HOST=localhost
18
19# Shortcut function to get a newly generated ID
20function get_field() {
21 while read data; do
22 if [ "$1" -lt 0 ]; then
23 field="(\$(NF$1))"
24 else
25 field="\$$(($1 + 1))"
26 fi
27 echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}"
28 done
29}
30
31# Tenants
32ADMIN_TENANT=$(keystone tenant-create --name=admin | grep " id " | get_field 2)
33DEMO_TENANT=$(keystone tenant-create --name=demo | grep " id " | get_field 2)
34SERVICE_TENANT=$(keystone tenant-create --name=$SERVICE_TENANT_NAME | grep " id " | get_field 2)
35
36# Users
37ADMIN_USER=$(keystone user-create --name=admin --pass="$ADMIN_PASSWORD" --email=admin@domain.com | grep " id " | get_field 2)
38DEMO_USER=$(keystone user-create --name=demo --pass="$DEMO_PASSWORD" --email=demo@domain.com --tenant-id=$DEMO_TENANT | grep " id " | get_field 2)
39NOVA_USER=$(keystone user-create --name=nova --pass="$SERVICE_PASSWORD" --tenant-id $SERVICE_TENANT --email=nova@domain.com | grep " id " | get_field 2)
40GLANCE_USER=$(keystone user-create --name=glance --pass="$SERVICE_PASSWORD" --tenant-id $SERVICE_TENANT --email=glance@domain.com | grep " id " | get_field 2)
41QUANTUM_USER=$(keystone user-create --name=quantum --pass="$SERVICE_PASSWORD" --tenant-id $SERVICE_TENANT --email=quantum@domain.com | grep " id " | get_field 2)
42CINDER_USER=$(keystone user-create --name=cinder --pass="$SERVICE_PASSWORD" --tenant-id $SERVICE_TENANT --email=cinder@domain.com | grep " id " | get_field 2)
43
44# Roles
45ADMIN_ROLE=$(keystone role-create --name=admin | grep " id " | get_field 2)
46MEMBER_ROLE=$(keystone role-create --name=Member | grep " id " | get_field 2)
47
48# Add Roles to Users in Tenants
49keystone user-role-add --user-id $ADMIN_USER --role-id $ADMIN_ROLE --tenant-id $ADMIN_TENANT
50keystone user-role-add --tenant-id $SERVICE_TENANT --user-id $NOVA_USER --role-id $ADMIN_ROLE
51keystone user-role-add --tenant-id $SERVICE_TENANT --user-id $GLANCE_USER --role-id $ADMIN_ROLE
52keystone user-role-add --tenant-id $SERVICE_TENANT --user-id $QUANTUM_USER --role-id $ADMIN_ROLE
53keystone user-role-add --tenant-id $SERVICE_TENANT --user-id $CINDER_USER --role-id $ADMIN_ROLE
54keystone user-role-add --tenant-id $DEMO_TENANT --user-id $DEMO_USER --role-id $MEMBER_ROLE
55
56# Create services
57COMPUTE_SERVICE=$(keystone service-create --name nova --type compute --description 'OpenStack Compute Service' | grep " id " | get_field 2)
58VOLUME_SERVICE=$(keystone service-create --name cinder --type volume --description 'OpenStack Volume Service' | grep " id " | get_field 2)
59IMAGE_SERVICE=$(keystone service-create --name glance --type image --description 'OpenStack Image Service' | grep " id " | get_field 2)
60IDENTITY_SERVICE=$(keystone service-create --name keystone --type identity --description 'OpenStack Identity' | grep " id " | get_field 2)
61EC2_SERVICE=$(keystone service-create --name ec2 --type ec2 --description 'OpenStack EC2 service' | grep " id " | get_field 2)
62NETWORK_SERVICE=$(keystone service-create --name quantum --type network --description 'OpenStack Networking service' | grep " id " | get_field 2)
63
64# Create endpoints
65keystone endpoint-create --region $KEYSTONE_REGION --service-id $COMPUTE_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':8774/v2/$(tenant_id)s' --adminurl 'http://'"$KEYSTONE_HOST"':8774/v2/$(tenant_id)s' --internalurl 'http://'"$KEYSTONE_HOST"':8774/v2/$(tenant_id)s'
66keystone endpoint-create --region $KEYSTONE_REGION --service-id $VOLUME_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':8776/v1/$(tenant_id)s' --adminurl 'http://'"$KEYSTONE_HOST"':8776/v1/$(tenant_id)s' --internalurl 'http://'"$KEYSTONE_HOST"':8776/v1/$(tenant_id)s'
67keystone endpoint-create --region $KEYSTONE_REGION --service-id $IMAGE_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':9292/v2' --adminurl 'http://'"$KEYSTONE_HOST"':9292/v2' --internalurl 'http://'"$KEYSTONE_HOST"':9292/v2'
68keystone endpoint-create --region $KEYSTONE_REGION --service-id $IDENTITY_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':5000/v2.0' --adminurl 'http://'"$KEYSTONE_HOST"':35357/v2.0' --internalurl 'http://'"$KEYSTONE_HOST"':5000/v2.0'
69keystone endpoint-create --region $KEYSTONE_REGION --service-id $EC2_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':8773/services/Cloud' --adminurl 'http://'"$KEYSTONE_HOST"':8773/services/Admin' --internalurl 'http://'"$KEYSTONE_HOST"':8773/services/Cloud'
70keystone endpoint-create --region $KEYSTONE_REGION --service-id $NETWORK_SERVICE --publicurl 'http://'"$KEYSTONE_HOST"':9696/' --adminurl 'http://'"$KEYSTONE_HOST"':9696/' --internalurl 'http://'"$KEYSTONE_HOST"':9696/'
diff --git a/meta-openstack/recipes-devtools/python/python-keystone/keystone.conf b/meta-openstack/recipes-devtools/python/python-keystone/keystone.conf
index c58f3d4..e25af40 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone/keystone.conf
+++ b/meta-openstack/recipes-devtools/python/python-keystone/keystone.conf
@@ -1,6 +1,6 @@
1[DEFAULT] 1[DEFAULT]
2# A "shared secret" between keystone and other openstack services 2# A "shared secret" between keystone and other openstack services
3# admin_token = ADMIN 3admin_token=password
4 4
5# The IP address of the network interface to listen on 5# The IP address of the network interface to listen on
6# bind_host = 0.0.0.0 6# bind_host = 0.0.0.0
diff --git a/meta-openstack/recipes-devtools/python/python-keystone/openrc b/meta-openstack/recipes-devtools/python/python-keystone/openrc
new file mode 100644
index 0000000..b189d0e
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-keystone/openrc
@@ -0,0 +1,6 @@
1export OS_TENANT_NAME=admin
2export OS_USERNAME=admin
3export OS_PASSWORD=password
4export OS_AUTH_URL="http://localhost:5000/v2.0/"
5export SERVICE_ENDPOINT="http://localhost:35357/v2.0"
6export SERVICE_TOKEN=password
diff --git a/meta-openstack/recipes-devtools/python/python-keystone_2013.1.bb b/meta-openstack/recipes-devtools/python/python-keystone_2013.1.bb
index efe6fec..5bc772f 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone_2013.1.bb
+++ b/meta-openstack/recipes-devtools/python/python-keystone_2013.1.bb
@@ -9,6 +9,8 @@ SRCNAME = "keystone"
9 9
10SRC_URI = "https://launchpad.net/keystone/grizzly/${PV}/+download/${SRCNAME}-${PV}.tar.gz \ 10SRC_URI = "https://launchpad.net/keystone/grizzly/${PV}/+download/${SRCNAME}-${PV}.tar.gz \
11 file://keystone.conf \ 11 file://keystone.conf \
12 file://identity.sh \
13 file://openrc \
12 " 14 "
13 15
14SRC_URI[md5sum] = "f82189cd7e3f0955e32c60e41f4120da" 16SRC_URI[md5sum] = "f82189cd7e3f0955e32c60e41f4120da"
@@ -18,13 +20,19 @@ S = "${WORKDIR}/${SRCNAME}-${PV}"
18 20
19inherit setuptools 21inherit setuptools
20 22
23SERVICE_TOKEN = "password"
24
21do_install_append() { 25do_install_append() {
22 26
23 KEYSTONE_CONF_DIR=${D}${sysconfdir}/keystone 27 KEYSTONE_CONF_DIR=${D}${sysconfdir}/keystone
24 28
25 install -d ${KEYSTONE_CONF_DIR} 29 install -d ${KEYSTONE_CONF_DIR}
26 30
31 sed -e "s:^admin_token=.*:admin_token=${SERVICE_TOKEN}:g" -i ${WORKDIR}/keystone.conf
32
27 install -m 600 ${WORKDIR}/keystone.conf ${KEYSTONE_CONF_DIR}/ 33 install -m 600 ${WORKDIR}/keystone.conf ${KEYSTONE_CONF_DIR}/
34 install -m 600 ${WORKDIR}/identity.sh ${KEYSTONE_CONF_DIR}/
35 install -m 600 ${WORKDIR}/openrc ${KEYSTONE_CONF_DIR}/
28 install -m 600 ${S}/etc/logging.conf.sample ${KEYSTONE_CONF_DIR}/logging.conf 36 install -m 600 ${S}/etc/logging.conf.sample ${KEYSTONE_CONF_DIR}/logging.conf
29 install -m 600 ${S}/etc/policy.json ${KEYSTONE_CONF_DIR}/policy.json 37 install -m 600 ${S}/etc/policy.json ${KEYSTONE_CONF_DIR}/policy.json
30 38
@@ -42,6 +50,10 @@ pkg_postinst_${PN} () {
42 sudo -u postgres createdb keystone 50 sudo -u postgres createdb keystone
43 keystone-manage db_sync 51 keystone-manage db_sync
44 keystone-manage pki_setup 52 keystone-manage pki_setup
53 # quick fix
54 echo "source /etc/keystone/openrc" > /home/root/.bashrc
55 sleep 1
56 bash /etc/keystone/identity.sh
45} 57}
46 58
47FILES_${PN} += "${sysconfdir}/${SRCNAME}/*" 59FILES_${PN} += "${sysconfdir}/${SRCNAME}/*"