summaryrefslogtreecommitdiffstats
path: root/ci/generate-admin-rc.sh
blob: e1e6bc9f282627be6bb7f7c61530794dcae13416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
##############################################################################
# Copyright (c) 2016 EMC and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

cd $(dirname "$0")

if [ ! -d job ]
then
    mkdir job
fi

SSH_KEY=""
INSTALLER="$(./detect_installer.sh)"
case $INSTALLER in
    joid)
        OS_AUTH_URL=http://`juju status keystone | grep public | awk '{print $2}'`:5000/v2.0
        OS_USERNAME=admin
        OS_PASSWORD=openstack
        cat << EOF > job/openstack.rc
export OS_AUTH_URL=$OS_AUTH_URL
export OS_USERNAME=$OS_USERNAME
export OS_PASSWORD=$OS_PASSWORD
export OS_TENANT_NAME=admin
export OS_PROJECT_NAME=admin
EOF
        ;;
    fuel)
        INSTALLER_IP=$(sudo virsh domifaddr cfg01 | grep ipv4 | awk '{print $4}' | cut -d/ -f1)
        export BRANCH="${BRANCH:-master}"
        SSH_KEY="-s /var/lib/opnfv/mcp.rsa"
        ;;
    apex)
        INSTALLER_IP=$(sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1)
        ;;
    *)
        echo "Unknown installer ${INSTALLER}"
        exit 1
esac

if [ ! -z "${INSTALLER_IP}" ]
then
    CMD="./job/releng/utils/fetch_os_creds.sh -i $INSTALLER -a $INSTALLER_IP $SSH_KEY -d job/openstack.rc"
    echo $CMD
    $CMD

    echo export OS_PROJECT_NAME=admin >> job/openstack.rc
fi

grep "export" job/openstack.rc | sed "s/export //"  > job/admin.rc
echo "INSTALLER_TYPE=${INSTALLER}" >> job/admin.rc