From 73e27b83e5d2d5beeda815d8ae613f89f32a9efd Mon Sep 17 00:00:00 2001
From: Jesse Andrews <anotherjesse@gmail.com>
Date: Mon, 12 Sep 2011 17:55:00 -0700
Subject: [PATCH] move keystone initialization into stack.sh

---
 files/keystone_data.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
 stack.sh               |  4 +---
 2 files changed, 43 insertions(+), 3 deletions(-)
 create mode 100755 files/keystone_data.sh

diff --git a/files/keystone_data.sh b/files/keystone_data.sh
new file mode 100755
index 0000000000..9f73743e01
--- /dev/null
+++ b/files/keystone_data.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+BIN_DIR=${BIN_DIR:-.}
+# Tenants
+$BIN_DIR/keystone-manage $* tenant add admin
+$BIN_DIR/keystone-manage $* tenant add demo
+
+# Users
+$BIN_DIR/keystone-manage $* user add demo secrete demo
+$BIN_DIR/keystone-manage $* user add admin secrete admin
+
+# Roles
+$BIN_DIR/keystone-manage $* role add Admin
+$BIN_DIR/keystone-manage $* role add Member
+$BIN_DIR/keystone-manage $* role grant Admin admin
+
+#endpointTemplates
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://localhost:8080/v1/AUTH_%tenant_id% http://localhost:8080/ http://localhost:8080/v1/AUTH_%tenant_id% 1 1
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne nova_compat http://localhost:8774/v1.0/ http://localhost:8774/v1.0  http://localhost:8774/v1.0 1 1
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne nova http://localhost:8774/v1.1/%tenant_id% http://localhost:8774/v1.1/%tenant_id%  http://localhost:8774/v1.1/%tenant_id% 1 1
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne glance http://localhost:9292/v1.1/%tenant_id% http://localhost:9292/v1.1/%tenant_id% http://localhost:9292/v1.1/%tenant_id% 1 1
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne keystone http://localhost:8080/v2.0 http://localhost:8081/v2.0 http://localhost:8080/v2.0 1 1
+$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne identity http://localhost:5000/v2.0 http://localhost:5001/v2.0 http://localhost:5000/v2.0 1 1
+
+# Tokens
+$BIN_DIR/keystone-manage $* token add 999888777666 admin admin 2015-02-05T00:00
+
+#Tenant endpoints
+$BIN_DIR/keystone-manage $* endpoint add admin 1
+$BIN_DIR/keystone-manage $* endpoint add admin 2
+$BIN_DIR/keystone-manage $* endpoint add admin 3
+$BIN_DIR/keystone-manage $* endpoint add admin 4
+$BIN_DIR/keystone-manage $* endpoint add admin 5
+$BIN_DIR/keystone-manage $* endpoint add admin 6
+
+$BIN_DIR/keystone-manage $* endpoint add demo 1
+$BIN_DIR/keystone-manage $* endpoint add demo 2
+$BIN_DIR/keystone-manage $* endpoint add demo 3
+$BIN_DIR/keystone-manage $* endpoint add demo 4
+$BIN_DIR/keystone-manage $* endpoint add demo 5
+$BIN_DIR/keystone-manage $* endpoint add demo 6
+
+$BIN_DIR/keystone-manage $* credentials add admin EC2 'admin:admin' admin admin || echo "no support for adding credentials"
diff --git a/stack.sh b/stack.sh
index 84486cadd9..ad6a9798eb 100755
--- a/stack.sh
+++ b/stack.sh
@@ -174,10 +174,8 @@ rm -f $NOVA_DIR/nova.sqlite
 $NOVA_DIR/bin/nova-manage db sync
 
 # initialize keystone with default users/endpoints
-# FIXME(ja): move initial_data.sh into this script
 rm -f /opt/keystone/keystone.db
-curl -OL https://raw.github.com/cloudbuilders/deploy.sh/master/initial_data.sh
-BIN_DIR=$KEYSTONE_DIR/bin bash initial_data.sh
+BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
 
 # create a small network
 $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32