In another "things from the man page"
The return status is 0 unless local is used outside a function, an
invalid name is supplied, or name is a readonly variable.
Thus if anything fails in "cmd" of "local foo=$( cmd )" we don't
notice.
Change-Id: I22b10d5d39f014b6c92d2e101b167cbacf81afca
| ... | ... |
@@ -684,9 +684,10 @@ function policy_add {
|
| 684 | 684 |
# Gets or creates a domain |
| 685 | 685 |
# Usage: get_or_create_domain <name> <description> |
| 686 | 686 |
function get_or_create_domain {
|
| 687 |
+ local domain_id |
|
| 687 | 688 |
local os_url="$KEYSTONE_SERVICE_URI_V3" |
| 688 | 689 |
# Gets domain id |
| 689 |
- local domain_id=$( |
|
| 690 |
+ domain_id=$( |
|
| 690 | 691 |
# Gets domain id |
| 691 | 692 |
openstack --os-token=$OS_TOKEN --os-url=$os_url \ |
| 692 | 693 |
--os-identity-api-version=3 domain show $1 \ |
| ... | ... |
@@ -705,8 +706,9 @@ function get_or_create_domain {
|
| 705 | 705 |
function get_or_create_group {
|
| 706 | 706 |
local desc="${3:-}"
|
| 707 | 707 |
local os_url="$KEYSTONE_SERVICE_URI_V3" |
| 708 |
+ local group_id |
|
| 708 | 709 |
# Gets group id |
| 709 |
- local group_id=$( |
|
| 710 |
+ group_id=$( |
|
| 710 | 711 |
# Creates new group with --or-show |
| 711 | 712 |
openstack --os-token=$OS_TOKEN --os-url=$os_url \ |
| 712 | 713 |
--os-identity-api-version=3 group create $1 \ |
| ... | ... |
@@ -719,13 +721,14 @@ function get_or_create_group {
|
| 719 | 719 |
# Gets or creates user |
| 720 | 720 |
# Usage: get_or_create_user <username> <password> <domain> [<email>] |
| 721 | 721 |
function get_or_create_user {
|
| 722 |
+ local user_id |
|
| 722 | 723 |
if [[ ! -z "$4" ]]; then |
| 723 | 724 |
local email="--email=$4" |
| 724 | 725 |
else |
| 725 | 726 |
local email="" |
| 726 | 727 |
fi |
| 727 | 728 |
# Gets user id |
| 728 |
- local user_id=$( |
|
| 729 |
+ user_id=$( |
|
| 729 | 730 |
# Creates new user with --or-show |
| 730 | 731 |
openstack user create \ |
| 731 | 732 |
$1 \ |
| ... | ... |
@@ -743,7 +746,8 @@ function get_or_create_user {
|
| 743 | 743 |
# Gets or creates project |
| 744 | 744 |
# Usage: get_or_create_project <name> <domain> |
| 745 | 745 |
function get_or_create_project {
|
| 746 |
- local project_id=$( |
|
| 746 |
+ local project_id |
|
| 747 |
+ project_id=$( |
|
| 747 | 748 |
# Creates new project with --or-show |
| 748 | 749 |
openstack --os-url=$KEYSTONE_SERVICE_URI_V3 \ |
| 749 | 750 |
--os-identity-api-version=3 \ |
| ... | ... |
@@ -757,7 +761,8 @@ function get_or_create_project {
|
| 757 | 757 |
# Gets or creates role |
| 758 | 758 |
# Usage: get_or_create_role <name> |
| 759 | 759 |
function get_or_create_role {
|
| 760 |
- local role_id=$( |
|
| 760 |
+ local role_id |
|
| 761 |
+ role_id=$( |
|
| 761 | 762 |
# Creates role with --or-show |
| 762 | 763 |
openstack role create $1 \ |
| 763 | 764 |
--os-url=$KEYSTONE_SERVICE_URI_V3 \ |
| ... | ... |
@@ -770,8 +775,9 @@ function get_or_create_role {
|
| 770 | 770 |
# Gets or adds user role to project |
| 771 | 771 |
# Usage: get_or_add_user_project_role <role> <user> <project> |
| 772 | 772 |
function get_or_add_user_project_role {
|
| 773 |
+ local user_role_id |
|
| 773 | 774 |
# Gets user role id |
| 774 |
- local user_role_id=$(openstack role list \ |
|
| 775 |
+ user_role_id=$(openstack role list \ |
|
| 775 | 776 |
--user $2 \ |
| 776 | 777 |
--os-url=$KEYSTONE_SERVICE_URI_V3 \ |
| 777 | 778 |
--os-identity-api-version=3 \ |
| ... | ... |
@@ -795,8 +801,9 @@ function get_or_add_user_project_role {
|
| 795 | 795 |
# Gets or adds group role to project |
| 796 | 796 |
# Usage: get_or_add_group_project_role <role> <group> <project> |
| 797 | 797 |
function get_or_add_group_project_role {
|
| 798 |
+ local group_role_id |
|
| 798 | 799 |
# Gets group role id |
| 799 |
- local group_role_id=$(openstack role list \ |
|
| 800 |
+ group_role_id=$(openstack role list \ |
|
| 800 | 801 |
--os-url=$KEYSTONE_SERVICE_URI_V3 \ |
| 801 | 802 |
--os-identity-api-version=3 \ |
| 802 | 803 |
--group $2 \ |
| ... | ... |
@@ -822,8 +829,9 @@ function get_or_add_group_project_role {
|
| 822 | 822 |
# Gets or creates service |
| 823 | 823 |
# Usage: get_or_create_service <name> <type> <description> |
| 824 | 824 |
function get_or_create_service {
|
| 825 |
+ local service_id |
|
| 825 | 826 |
# Gets service id |
| 826 |
- local service_id=$( |
|
| 827 |
+ service_id=$( |
|
| 827 | 828 |
# Gets service id |
| 828 | 829 |
openstack service show $2 -f value -c id 2>/dev/null || |
| 829 | 830 |
# Creates new service if not exists |
| ... | ... |
@@ -841,7 +849,8 @@ function get_or_create_service {
|
| 841 | 841 |
# Create an endpoint with a specific interface |
| 842 | 842 |
# Usage: _get_or_create_endpoint_with_interface <service> <interface> <url> <region> |
| 843 | 843 |
function _get_or_create_endpoint_with_interface {
|
| 844 |
- local endpoint_id=$(openstack endpoint list \ |
|
| 844 |
+ local endpoint_id |
|
| 845 |
+ endpoint_id=$(openstack endpoint list \ |
|
| 845 | 846 |
--os-url $KEYSTONE_SERVICE_URI_V3 \ |
| 846 | 847 |
--os-identity-api-version=3 \ |
| 847 | 848 |
--service $1 \ |