#!/bin/sh
source /opt/local/bin/os-utils.sh

create_or_get_user glance $1
get_or_add_user_project_role admin glance service
create_or_get_service glance image "OpenStack Image service"
create_or_get_endpoint image public http://$2:9292
create_or_get_endpoint image internal http://$2:9292
create_or_get_endpoint image admin http://$2:9292

openstack user create --domain default --password $1 glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image service" image
openstack endpoint create --region RegionOne image public http://$2:9292
openstack endpoint create --region RegionOne image internal http://$2:9292
openstack endpoint create --region RegionOne image admin http://$2:9292

--- 
+++ 
@@ -1,6 +1,9 @@
-openstack user create --domain default --password $1 glance
-openstack role add --project service --user glance admin
-openstack service create --name glance --description "OpenStack Image service" image
-openstack endpoint create --region RegionOne image public http://$2:9292
-openstack endpoint create --region RegionOne image internal http://$2:9292
-openstack endpoint create --region RegionOne image admin http://$2:9292
+#!/bin/sh
+source /opt/local/bin/os-utils.sh
+
+create_or_get_user glance $1
+get_or_add_user_project_role admin glance service
+create_or_get_service glance image "OpenStack Image service"
+create_or_get_endpoint image public http://$2:9292
+create_or_get_endpoint image internal http://$2:9292
+create_or_get_endpoint image admin http://$2:9292
Use utils to create glance service and endpoint
