3 # Copyright 2020 Telefónica Investigación y Desarrollo S.A.U.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 #######################################################################################################
18 # PRE-REQUIREMENTS FOR THE ENVIRONMENT:
19 #######################################################################################################
20 # - There is at least one VIM available and reachable.
21 # - There is at least one OSM instance available and reachable.
22 # - The OSM instance(s) has (have) already at least one target added per VIM.
24 #######################################################################################################
25 # SOFTWARE PRE-REQUIREMENTS: (already covered for Vagrant)
26 #######################################################################################################
27 # - `authorized_keys` at `~/.ssh` with proper permissions
28 # - `id_rsa`, `id_rsa.pub` at `~/.ssh` with proper permissions
29 # - A functional `.gitconfig` file at `~` with proper permissions
30 # - `seedconfig.rc` and `patchconfig.rc` copied to `~/baseconfig`
31 # - `envprovisioning.sh` and `envconfig.rc` copied to `~/localconfig`
33 #######################################################################################################
34 # CONFIGURATION SEEDING
35 #######################################################################################################
37 # Folders where configuration is stored
38 BASE_CONFIG_FOLDER
=baseconfig
39 LOCAL_CONFIG_FOLDER
=localconfig
# Default path. It can be reset dinamically by `seedconfig.rc` or `envprovisioning.sh` if needed
42 if [ -f ${BASE_CONFIG_FOLDER}/seedconfig.rc
]
44 cat ${BASE_CONFIG_FOLDER}/seedconfig.rc
>> defaultenv.rc
45 source ${BASE_CONFIG_FOLDER}/seedconfig.rc
47 >&2 echo ################################################################################
48 >&2 echo ERROR
: Base configuration
file ${BASE_CONFIG_FOLDER}/seedconfig.rc is missing.
49 >&2 echo Please check README.md
for details.
50 >&2 echo Once fixed
, rebuild your environment. E.g.
for Vagrant
:
51 >&2 echo vagrant destroy
&& vagrant up
52 >&2 echo ################################################################################
56 # (OPTIONAL) Devops patch configuration
57 if [ -f ${BASE_CONFIG_FOLDER}/patchconfig.rc
]
59 cat ${BASE_CONFIG_FOLDER}/patchconfig.rc
>> defaultenv.rc
60 source ${BASE_CONFIG_FOLDER}/patchconfig.rc
63 # (OPTIONAL) Local environment provisioning (e.g. cloning of local repos)
64 if [ -f ${LOCAL_CONFIG_FOLDER}/envprovisioning.sh
]
66 source ${LOCAL_CONFIG_FOLDER}/envprovisioning.sh
69 # Local environment configuration: VIM(s), OSM(s), credentials, etc.
70 if [ -f ${LOCAL_CONFIG_FOLDER}/envconfig.rc
]
72 cat ${LOCAL_CONFIG_FOLDER}/envconfig.rc
>> defaultenv.rc
73 source ${LOCAL_CONFIG_FOLDER}/envconfig.rc
75 >&2 echo ################################################################################
76 >&2 echo WARNING
: Local configuration
file ${BASE_CONFIG_FOLDER}/envconfig.rc is missing.
77 >&2 echo Please check README.md
for details.
78 >&2 echo If it is an error
, once fixed
, rebuild your environment. E.g.
for Vagrant
:
79 >&2 echo vagrant destroy
&& vagrant up
80 >&2 echo Otherwise
, you should add manually the appropriate environment variables later.
81 >&2 echo ################################################################################
84 #------------------------------------------------------------------------------------------------------
87 sudo
sed -i "/osm-download.etsi.org/d" /etc
/apt
/sources.list
88 wget
-qO - https
://osm-download.etsi.org
/repository
/osm
/debian
/ReleaseSEVEN
/OSM
%20ETSI
%20Release
%20Key.gpg | sudo apt-key add
-
89 sudo add-apt-repository
-y "deb [arch=amd64] https://osm-download.etsi.org/repository/osm/debian/ReleaseSEVEN stable devops IM osmclient"
91 sudo apt-get
install -y python3-pip
92 sudo
-H python3
-m pip
install python-magic pyangbind verboselogs
93 sudo apt-get
install -y python3-osmclient
95 # Installs OpenStack client
96 ##For Train version, uncomment the following two lines:
97 ##sudo add-apt-repository -y cloud-archive:train
99 sudo apt-get
install -y python3-openstackclient
# Installs Queens by default
101 # Installs Robot and all dependencies required for the tests
103 sudo
-H python3
-m pip
install --ignore-installed haikunator requests pyvcloud progressbar pathlib robotframework robotframework-seleniumlibrary robotframework-requests robotframework-SSHLibrary
104 curl
-sS -o - https
://dl-ssl.google.com
/linux
/linux_signing_key.pub | sudo apt-key add
-
105 sudo add-apt-repository
-y "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main"
106 sudo apt-get
install -y google-chrome-stable chromium-chromedriver
107 ln -s ${ROBOT_DEVOPS_FOLDER} robot
109 # Clones Devops repo to retrieve all Robot tests from OSM community
110 ssh-keyscan
-p 29418 osm.etsi.org
>> ~
/.ssh
/known_hosts
111 if [ -n "${ETSIUSERNAME}" ] # If possible, uses ETSI's user name to make further contributions easier
113 git clone
"ssh://${ETSIUSERNAME}@osm.etsi.org:29418/osm/devops" && \
114 (cd "devops" && curl https
://osm.etsi.org
/gerrit
/tools
/hooks
/commit-msg
> .git
/hooks
/commit-msg
; chmod +x .git
/hooks
/commit-msg
)
116 git clone
"https://osm.etsi.org/gerrit/osm/devops"
119 # if applicable, adds additional patches to devops repo (refer to `patchconfig.rc`)
120 [ -n "${DEVOPS_PATCH}" ] && git
-C devops pull https
://osm.etsi.org
/gerrit
/osm
/devops
${DEVOPS_PATCH}
122 # Installs some additional packages to ease interactive troubleshooting
123 sudo apt-get
install -y osm-devops
124 sudo snap
install charm
--classic
127 # Copies VIM credentials in `clouds.yaml` (if applicable) to a proper location
128 if [ -f ${CLOUDS_PATH}/clouds.yaml
]; then
129 sudo mkdir
-p /etc
/openstack
130 sudo
cp ${CLOUDS_PATH}/clouds.yaml
/etc
/openstack
/
131 rm ${CLOUDS_PATH}/clouds.yaml
134 # Sets default environment to load automatically in `.bashrc`
135 cat defaultenv.rc
>> ~
/.bashrc