dea67b8583b08da283a25499982e5426f314c00e
[integration.git] / deployment / aks / util / create_robot_config.sh
1 #!/bin/bash
2 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #         http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 OPENSTACK_RC=$1
17 OPENSTACK_PARAM=$2
18 BUILD_DIR=$3
19 INTEGRATION_TEMPLATE=$4
20
21 if [ "$OPENSTACK_RC" == "" ] 
22        then
23         echo "No OPENSTACK_RC file"
24         echo "Usage: create-robot-config.sh <openstack.rc>  <openstack_env_param>"
25   exit
26 fi 
27 if [ "$OPENSTACK_PARAM" == "" ] 
28         then
29         echo "No OPENSTACK_PARAM"
30         echo "Usage: create-robot-config.sh <openstack.rc>  <openstack_env_param>"
31   exit
32 fi
33
34 source $OPENSTACK_RC
35 source $OPENSTACK_PARAM
36
37 env
38
39 SO_ENCRYPTION_KEY=aa3871669d893c7fb8abbcda31b88b4f
40 export OS_PASSWORD_ENCRYPTED_FOR_ROBOT=$(echo -n "$OS_PASSWORD" | openssl aes-128-ecb -e -K "$SO_ENCRYPTION_KEY" -nosalt | xxd -c 256 -p)
41
42 #Use new encryption method
43 pushd .
44
45 cd $BUILD_DIR/integration/deployment/heat/onap-rke/scripts
46 javac Crypto.java
47 SO_ENCRYPTION_KEY=aa3871669d893c7fb8abbcda31b88b4f
48 export OS_PASSWORD_ENCRYPTED=$(java Crypto "$OS_PASSWORD" "$SO_ENCRYPTION_KEY")
49
50 cp $INTEGRATION_TEMPLATE ./integration-override.yaml
51 template="integration-override.yaml"
52 sed -ir -e "s/\${OS_PASSWORD_ENCRYPTED_FOR_ROBOT}/$OS_PASSWORD_ENCRYPTED_FOR_ROBOT/"  $template
53 sed -ir -e "s/\${OS_PASSWORD_ENCRYPTED}/$OS_PASSWORD_ENCRYPTED/"  $template
54
55 sed -ir -e "s/\${OS_PROJECT_ID}/$OS_PROJECT_ID/"  $template
56 sed -ir -e "s/\${OS_USERNAME}/$OS_USERNAME/"  $template
57 sed -ir -e "s/\${OS_USER_DOMAIN_NAME}/$OS_USER_DOMAIN_NAME/"  $template
58 sed -ir -e "s/\${OS_PROJECT_NAME}/$OS_PROJECT_NAME/"  $template
59 sed -ir -e "s/\${OS_USERNAME}/$OS_USERNAME/"  $template
60 sed -ir -e "s~\${OS_AUTH_URL}~$OS_AUTH_URL~"  $template
61
62
63 sed -ir -e "s/__docker_proxy__/$DOCKER_REPOSITORY/"  $template
64 sed -ir -e "s/__public_net_id__/$OS_PUBLIC_NETWORK_ID/"  $template
65 sed -ir -e "s~__oam_network_cidr__~$OS_OAM_NETWORK_CIDR~"  $template
66 sed -ir -e "s/__oam_network_prefix__/$OS_OAM_NETWORK_PREFIX/"  $template
67 sed -ir -e "s/__oam_network_id__/$OS_OAM_NETWORK_ID/"  $template
68 sed -ir -e "s/__oam_subnet_id__/$OS_OAM_NETWORK_SUBNET_ID/"  $template
69 sed -ir -e "s/__sec_group__/$OS_SEC_GROUP/"  $template
70
71 sed -ir -e "s/\${OS_UBUNTU_14_IMAGE}/$OS_UBUNTU_14_IMAGE/"  $template
72 sed -ir -e "s/\${OS_UBUNTU_16_IMAGE}/$OS_UBUNTU_16_IMAGE/"  $template
73
74 sed -ir -e "s/__nfs_ip_addr__/$NFS_IP_ADDR/"  $template
75 sed -ir -e "s/__k8s_01_vm_ip__/$K8S_01_VM_IP/"  $template
76
77 cat $template
78 cp $template  $BUILD_DIR/$template
79
80 popd