From 915da0db707a1b3ac80152cbdc1b34e1ebc1e929 Mon Sep 17 00:00:00 2001
From: Thomas Goirand <thomas@goirand.fr>
Date: Thu, 22 Nov 2012 17:13:42 +0000
Subject: [PATCH] Added service and endpoint creation in cinder-api.

---
 debian/cinder-api.config.in   | 11 ++++++++++
 debian/cinder-api.postinst.in | 15 +++++++++++++
 debian/cinder-api.templates   | 40 +++++++++++++++++++++++++++++++++++
 debian/control                |  2 +-
 debian/po/POTFILES.in         |  1 +
 debian/rules                  |  4 +++-
 6 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 debian/cinder-api.config.in
 create mode 100644 debian/cinder-api.postinst.in
 create mode 100644 debian/cinder-api.templates

diff --git a/debian/cinder-api.config.in b/debian/cinder-api.config.in
new file mode 100644
index 000000000..d07143787
--- /dev/null
+++ b/debian/cinder-api.config.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+#PKGOS-INCLUDE#
+
+pkgos_register_endpoint_config glance
+
+exit 0
diff --git a/debian/cinder-api.postinst.in b/debian/cinder-api.postinst.in
new file mode 100644
index 000000000..0e6aaf60f
--- /dev/null
+++ b/debian/cinder-api.postinst.in
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+#PKGOS-INCLUDE#
+
+if [ "$1" = "configure" ] ; then
+	. /usr/share/debconf/confmodule
+	pkgos_register_endpoint_postinst glance glance image "Glance Image Service" 9292 /v1
+	db_stop
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/cinder-api.templates b/debian/cinder-api.templates
new file mode 100644
index 000000000..eee1e7475
--- /dev/null
+++ b/debian/cinder-api.templates
@@ -0,0 +1,40 @@
+Template: cinder/register-endpoint
+Type: boolean
+Default: false
+_Description: Register Cinder in the keystone endpoint catalog?
+ Each Openstack services (each API) should be registered in order to be
+ accessible. This is done using "keystone service-create" and "keystone
+ endpoint-create". Select if you want to run these commands now.
+ .
+ Note that you will need to have an up and running keystone server on which to
+ connect using the Keystone auth token.
+
+Template: cinder/keystone-ip
+Type: string
+_Description: Keystone IP address:
+ Enter the IP address of your keystone server, so that cinder-api can
+ contact Keystone to do the Cinder service and endpoint creation.
+
+Template: cinder/keystone-auth-token
+Type: string
+_Description: Keystone Auth Token:
+ To configure its endpoint in Keystone, cinder-api needs the Keystone auth
+ token.
+
+Template: cinder/endpoint-ip
+Type: string
+_Description: Cinder endpoint IP address:
+ Enter the IP address that will be used to contact Cinder (eg: the Cinder
+ endpoint IP address).
+ .
+ This IP address should be accessible from the clients that will use this
+ service, so if you are installing a public cloud, this should be a public
+ IP address.
+
+Template: cinder/region-name
+Type: string
+Default: regionOne
+_Description: Name of the region to register:
+ Openstack can be used using availability zones, with each region representing
+ a location. Please enter the zone that you wish to use when registering the
+ endpoint.
diff --git a/debian/control b/debian/control
index 51a3989e5..695c609d9 100644
--- a/debian/control
+++ b/debian/control
@@ -99,7 +99,7 @@ Description: Openstack block storage as a service - common files
 Package: cinder-api
 Architecture: all
 Pre-Depends: dpkg (>= 1.15.6~)
-Depends: cinder-common (= ${binary:Version}), ${python:Depends}, ${misc:Depends}
+Depends: debconf, cinder-common (= ${binary:Version}), ${python:Depends}, ${misc:Depends}, python-keystoneclient
 Description: Openstack block storage as a service - API server
  Cinder is a block storage as service system for the Openstack cloud computing
  software suite. It is a direct replacement for nova-volume as a separate
diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in
index 2e389bb07..552b85003 100644
--- a/debian/po/POTFILES.in
+++ b/debian/po/POTFILES.in
@@ -1 +1,2 @@
 [type: gettext/rfc822deb] cinder-common.templates
+[type: gettext/rfc822deb] cinder-api.templates
diff --git a/debian/rules b/debian/rules
index 09f3bbaf3..a34e85a6a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,7 +12,7 @@ endif
 
 override_dh_clean:
 	dh_clean
-	rm -f cinder-common.config cinder-common.postinst
+	rm -f debian/cinder-common.config debian/cinder-common.postinst debian/cinder-api.config debian/cinder-api.postinst
 
 override_dh_installchangelogs:
 	dh_installchangelogs debian/CHANGELOG
@@ -39,3 +39,5 @@ override_dh_auto_build:
 
 	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-common.config
 	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-common.postinst
+	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-api.config
+	/usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func cinder-api.postinst
-- 
2.45.2