Adds support for multi-region

Change-Id: Ib85fe7cb375692b04aca4c46f61ba7e1fbfa501b
Implements: blueprint multi-region
diff --git a/lib/glance b/lib/glance
index 4eb0ada..475bb48 100644
--- a/lib/glance
+++ b/lib/glance
@@ -164,36 +164,28 @@
 
 function create_glance_accounts {
     if is_service_enabled g-api; then
-        openstack user create \
-            --password "$SERVICE_PASSWORD" \
-            --project $SERVICE_TENANT_NAME \
-            glance
-        openstack role add \
-            --project $SERVICE_TENANT_NAME \
-            --user glance \
-            service
+
+        GLANCE_USER=$(get_or_create_user "glance" \
+            "$SERVICE_PASSWORD" $SERVICE_TENANT_NAME "glance@example.com")
+        get_or_add_user_role service $GLANCE_USER $SERVICE_TENANT_NAME
+
         # required for swift access
         if is_service_enabled s-proxy; then
-            openstack user create \
-                --password "$SERVICE_PASSWORD" \
-                --project $SERVICE_TENANT_NAME \
-                glance-swift
-            openstack role add \
-                --project $SERVICE_TENANT_NAME \
-                --user glance-swift \
-                ResellerAdmin
+
+            GLANCE_SWIFT_USER=$(get_or_create_user "glance-swift" \
+                "$SERVICE_PASSWORD" $SERVICE_TENANT_NAME "glance-swift@example.com")
+            get_or_add_user_role "ResellerAdmin" $GLANCE_SWIFT_USER $SERVICE_TENANT_NAME
         fi
+
         if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
-            openstack service create \
-                --type image \
-                --description "Glance Image Service" \
-                glance
-            openstack endpoint create \
-                --region RegionOne \
-                --publicurl "http://$GLANCE_HOSTPORT" \
-                --adminurl "http://$GLANCE_HOSTPORT" \
-                --internalurl "http://$GLANCE_HOSTPORT" \
-                glance
+
+            GLANCE_SERVICE=$(get_or_create_service "glance" \
+                "image" "Glance Image Service")
+            get_or_create_endpoint $GLANCE_SERVICE \
+                "$REGION_NAME" \
+                "http://$GLANCE_HOSTPORT" \
+                "http://$GLANCE_HOSTPORT" \
+                "http://$GLANCE_HOSTPORT"
         fi
     fi
 }