Skip to content

Commit

Permalink
Though the user sets regoin_name in testbed.py, RegionName is hardcod…
Browse files Browse the repository at this point in the history
…ed to RegionOne

while creating endpoints.
Fixing it to use the user provided region name.

Change-Id: I79f2adf89218eeb478202c625c7e1702d4d9bdf6
Partial-Bug: 1483902
  • Loading branch information
cijohnson committed Feb 18, 2016
1 parent b1dd703 commit 699d343
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
3 changes: 2 additions & 1 deletion contrail_provisioning/config/quantum_in_keystone_setup.py
Expand Up @@ -243,7 +243,8 @@ def quant_set_user_admin_role(self):
def quant_set_endpoints(self):
# check if endpoint exists
try:
quant_ends = self.kshandle.endpoints.find(service_id=self.quant_svc_id)
quant_ends = self.kshandle.endpoints.find(region=self._args.region_name,
service_id=self.quant_svc_id)
if quant_ends:
# service tenant exists! possible that the openstack node is setup independently
# delete and recreate it
Expand Down
Expand Up @@ -199,7 +199,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $NOVA_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $NOVA_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $NOVA_SERVICE \
--publicurl 'http://'$CONTROLLER':8774/v1.1/$(tenant_id)s' \
--adminurl 'http://localhost:$(compute_port)s/v1.1/$(tenant_id)s' \
--internalurl 'http://'$CONTROLLER':8774/v1.1/$(tenant_id)s'
Expand All @@ -209,7 +209,7 @@ fi
EC2_SERVICE=$(get_service ec2 ec2 "EC2 Compatibility Layer")
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $EC2_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $EC2_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $EC2_SERVICE \
--publicurl http://localhost:8773/services/Cloud \
--adminurl http://localhost:8773/services/Admin \
--internalurl http://localhost:8773/services/Cloud
Expand All @@ -227,7 +227,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $GLANCE_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $GLANCE_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $GLANCE_SERVICE \
--publicurl http://$CONTROLLER:9292/v1 \
--adminurl http://localhost:9393/v1 \
--internalurl http://localhost:9393/v1
Expand All @@ -237,7 +237,7 @@ fi
KEYSTONE_SERVICE=$(get_service keystone identity "Keystone Identity Service")
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $KEYSTONE_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $KEYSTONE_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $KEYSTONE_SERVICE \
--publicurl 'http://'$CONTROLLER':5000/v2.0' \
--adminurl 'http://'$CONTROLLER':35357/v2.0' \
--internalurl 'http://'$CONTROLLER':35357/v2.0'
Expand All @@ -255,7 +255,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $CINDER_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $CINDER_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $CINDER_SERVICE \
--publicurl 'http://'$CONTROLLER':8776/v1/$(tenant_id)s' \
--adminurl 'http://localhost:9776/v1/$(tenant_id)s' \
--internalurl 'http://localhost:9776/v1/$(tenant_id)s'
Expand All @@ -277,7 +277,7 @@ if [[ -n "$ENABLE_SWIFT" ]]; then
--user-id $SWIFT_USER \
--role-id $ADMIN_ROLE
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
keystone endpoint-create --region RegionOne --service-id $SWIFT_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $SWIFT_SERVICE \
--publicurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s' \
--adminurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s' \
--internalurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s'
Expand All @@ -295,7 +295,7 @@ if [[ -n "$ENABLE_QUANTUM" ]]; then

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $QUANTUM_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $QUANTUM_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $QUANTUM_SERVICE \
--publicurl http://'$CONTROLLER':9696 \
--adminurl http://'$CONTROLLER':9696 \
--internalurl http://'$CONTROLLER':9696
Expand All @@ -316,7 +316,7 @@ if [[ -n "$ENABLE_HEAT" ]]; then

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $HEAT_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $HEAT_SERVICE \
keystone endpoint-create --region $REGION_NAME --service-id $HEAT_SERVICE \
--publicurl 'http://'$CONTROLLER':8004/v1/%(tenant_id)s' \
--adminurl 'http://'$CONTROLLER:'8004/v1/%(tenant_id)s' \
--internalurl 'http://'$CONTROLLER':8004/v1/%(tenant_id)s'
Expand Down
Expand Up @@ -184,7 +184,7 @@ function get_service_user() {
}

function endpoint_lookup() {
echo $(keystone endpoint-list | grep ' '$1' ' | awk '{print $2;}' )
echo $(keystone --os-region-name $OS_REGION_NAME endpoint-list | grep ' '$1' ' | awk '{print $2;}' )
}

NOVA_SERVICE=$(get_service nova compute "Nova Compute Service")
Expand All @@ -198,7 +198,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $NOVA_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $NOVA_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $NOVA_SERVICE \
--publicurl 'http://'$CONTROLLER':$(compute_port)s/v1.1/$(tenant_id)s' \
--adminurl 'http://'$CONTROLLER:'$(compute_port)s/v1.1/$(tenant_id)s' \
--internalurl 'http://'$CONTROLLER:'$(compute_port)s/v1.1/$(tenant_id)s'
Expand All @@ -208,7 +208,7 @@ fi
EC2_SERVICE=$(get_service ec2 ec2 "EC2 Compatibility Layer")
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $EC2_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $EC2_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $EC2_SERVICE \
--publicurl http://localhost:8773/services/Cloud \
--adminurl http://localhost:8773/services/Admin \
--internalurl http://localhost:8773/services/Cloud
Expand All @@ -226,7 +226,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $GLANCE_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $GLANCE_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $GLANCE_SERVICE \
--publicurl http://$CONTROLLER:9292/v1 \
--adminurl http://$CONTROLLER:9292/v1 \
--internalurl http://$CONTROLLER:9292/v1
Expand All @@ -236,7 +236,7 @@ fi
KEYSTONE_SERVICE=$(get_service keystone identity "Keystone Identity Service")
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $KEYSTONE_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $KEYSTONE_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $KEYSTONE_SERVICE \
--publicurl 'http://'$CONTROLLER':$(public_port)s/v2.0' \
--adminurl 'http://'$CONTROLLER':$(admin_port)s/v2.0' \
--internalurl 'http://'$CONTROLLER':$(admin_port)s/v2.0'
Expand Down Expand Up @@ -280,7 +280,7 @@ fi

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $CINDER_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $CINDER_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $CINDER_SERVICE \
--publicurl 'http://'$CONTROLLER':8776/'$CINDER_SERVICE_TYPE'/$(tenant_id)s' \
--adminurl 'http://'$CONTROLLER':8776/'$CINDER_SERVICE_TYPE'/$(tenant_id)s' \
--internalurl 'http://'$CONTROLLER':8776/'$CINDER_SERVICE_TYPE'/$(tenant_id)s'
Expand All @@ -302,7 +302,7 @@ if [[ -n "$ENABLE_SWIFT" ]]; then
--user-id $SWIFT_USER \
--role-id $ADMIN_ROLE
if [[ -n "$ENABLE_ENDPOINTS" ]]; then
keystone endpoint-create --region RegionOne --service-id $SWIFT_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $SWIFT_SERVICE \
--publicurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s' \
--adminurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s' \
--internalurl 'http://localhost:8080/v1/AUTH_$(tenant_id)s'
Expand All @@ -320,7 +320,7 @@ if [[ -n "$ENABLE_QUANTUM" ]]; then

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $QUANTUM_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $QUANTUM_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $QUANTUM_SERVICE \
--publicurl http://localhost:9696 \
--adminurl http://localhost:9696 \
--internalurl http://localhost:9696
Expand All @@ -341,7 +341,7 @@ if [[ -n "$ENABLE_HEAT" ]]; then

if [[ -n "$ENABLE_ENDPOINTS" ]]; then
if [ -z $(endpoint_lookup $HEAT_SERVICE) ]; then
keystone endpoint-create --region RegionOne --service-id $HEAT_SERVICE \
keystone endpoint-create --region $OS_REGION_NAME --service-id $HEAT_SERVICE \
--publicurl 'http://'$CONTROLLER':8004/v1/%(tenant_id)s' \
--adminurl 'http://'$CONTROLLER:'8004/v1/%(tenant_id)s' \
--internalurl 'http://'$CONTROLLER':8004/v1/%(tenant_id)s'
Expand Down
Expand Up @@ -113,6 +113,7 @@ if [ -d /var/log/keystone ]; then
fi

# Set up a keystonerc file with admin password
REGION_NAME=${REGION_NAME:-RegionOne}
OPENSTACK_INDEX=${OPENSTACK_INDEX:-0}
INTERNAL_VIP=${INTERNAL_VIP:-none}
if [ "$INTERNAL_VIP" != "none" ]; then
Expand All @@ -132,12 +133,14 @@ export OS_PASSWORD=$ADMIN_PASSWORD
export OS_TENANT_NAME=admin
export OS_AUTH_URL=${AUTH_PROTOCOL}://$controller_ip:5000/v2.0/
export OS_NO_CACHE=1
export OS_REGION_NAME=$REGION_NAME
EOF

cat > $CONF_DIR/keystonerc <<EOF
export OS_USERNAME=admin
export SERVICE_TOKEN=$SERVICE_TOKEN
export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT
export OS_REGION_NAME=$REGION_NAME
EOF

export ADMIN_PASSWORD
Expand Down
3 changes: 3 additions & 0 deletions contrail_provisioning/openstack/setup.py
Expand Up @@ -27,6 +27,7 @@ def __init__(self, args_str = None):
'keystone_ip': '127.0.0.1',
'keystone_auth_protocol':'http',
'keystone_admin_passwd': 'contrail123',
'region_name': 'RegionOne',
'nova_password': None,
'neutron_password': None,
'keystone_service_tenant_name': 'service',
Expand Down Expand Up @@ -70,6 +71,7 @@ def parse_args(self, args_str):
parser.add_argument("--haproxy", help = "Enable haproxy", action="store_true")
parser.add_argument("--keystone_ip", help = "IP Address of keystone node")
parser.add_argument("--keystone_admin_passwd", help = "Passwd of the admin tenant")
parser.add_argument("--region_name", help = "Region name of the openstack services")
parser.add_argument("--neutron_password", help="Password of neutron user")
parser.add_argument("--nova_password", help="Password of nova user")
parser.add_argument("--keystone_service_tenant_name",
Expand Down Expand Up @@ -103,6 +105,7 @@ def build_ctrl_details(self):
ctrl_infos.append('AUTH_PROTOCOL=%s' % self._args.keystone_auth_protocol)
ctrl_infos.append('QUANTUM_PROTOCOL=%s' % self._args.quantum_service_protocol)
ctrl_infos.append('ADMIN_TOKEN=%s' % self._args.keystone_admin_passwd)
ctrl_infos.append('REGION_NAME=%s' % self._args.region_name)
ctrl_infos.append('CONTROLLER=%s' % self._args.keystone_ip)
ctrl_infos.append('NEUTRON_PASSWORD=%s' % self._args.neutron_password)
ctrl_infos.append('NOVA_PASSWORD=%s' % self._args.nova_password)
Expand Down
22 changes: 14 additions & 8 deletions contrail_provisioning/storage/storagefs/setup.py
Expand Up @@ -3328,18 +3328,20 @@ def do_keystone_config(self):
--publicurl http://%s:8776/v2/%%\(tenant_id\)s \
--internalurl http://%s:8776/v2/%%\(tenant_id\)s \
--adminurl http://%s:8776/v2/%%\(tenant_id\)s \
--region RegionOne' %(v2_service,
--region %s' %(v2_service,
self._args.cinder_vip, self._args.cinder_vip,
self._args.cinder_vip), shell='/bin/bash')
self._args.cinder_vip, self._args.region_name),
shell='/bin/bash')
else:
local('source /etc/contrail/openstackrc && \
keystone endpoint-create --service-id %s \
--publicurl http://%s:8776/v2/%%\(tenant_id\)s \
--internalurl http://%s:8776/v2/%%\(tenant_id\)s \
--adminurl http://%s:8776/v2/%%\(tenant_id\)s \
--region RegionOne' %(v2_service,
--region %s' %(v2_service,
self._args.openstack_ip, self._args.openstack_ip,
self._args.openstack_ip), shell='/bin/bash')
self._args.openstack_ip, self._args.region_name),
shell='/bin/bash')

v1_config = local('source /etc/contrail/openstackrc && \
keystone service-list | grep -w volume | wc -l',
Expand All @@ -3357,18 +3359,20 @@ def do_keystone_config(self):
--publicurl http://%s:8776/v1/%%\(tenant_id\)s \
--internalurl http://%s:8776/v1/%%\(tenant_id\)s \
--adminurl http://%s:8776/v1/%%\(tenant_id\)s \
--region RegionOne' %(v1_service,
--region %s' %(v1_service,
self._args.cinder_vip, self._args.cinder_vip,
self._args.cinder_vip), shell='/bin/bash')
self._args.cinder_vip, self._args.region_name),
shell='/bin/bash')
else:
local('source /etc/contrail/openstackrc && \
keystone endpoint-create --service-id %s \
--publicurl http://%s:8776/v1/%%\(tenant_id\)s \
--internalurl http://%s:8776/v1/%%\(tenant_id\)s \
--adminurl http://%s:8776/v1/%%\(tenant_id\)s \
--region RegionOne' %(v1_service,
--region %s' %(v1_service,
self._args.openstack_ip, self._args.openstack_ip,
self._args.openstack_ip), shell='/bin/bash')
self._args.openstack_ip, self._args.region_name),
shell='/bin/bash')
#end do_keystone_config()

def find_cinder_version(self):
Expand Down Expand Up @@ -3577,6 +3581,7 @@ def _parse_args(self, args_str):

global_defaults = {
'service_dbpass' : 'c0ntrail123',
'region_name': 'RegionOne',
}

if args.conf_file:
Expand Down Expand Up @@ -3628,6 +3633,7 @@ def _parse_args(self, args_str):
parser.add_argument("--openstack-ip", help = "Openstack IP")
parser.add_argument("--orig-hostnames", help = "Actual Host names of storage nodes", nargs='+', type=str)
parser.add_argument("--service-dbpass", help = "Database password for openstack service db user.")
parser.add_argument("--region_name", help = "Region name of the cinder service")

self._args = parser.parse_args(remaining_argv)

Expand Down

0 comments on commit 699d343

Please sign in to comment.