From bd241b3bdc1f7494cd8bb7fc120155c8b1cb305f Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Thu, 3 Aug 2017 11:48:13 +0800 Subject: Use PDF(POD descriptor file) and correct the mapping of nodes and roles JIRA: DAISY-42 JIRA: DAISY-56 In bare metal deployment, we can use PDF to get MAC addresses of nodes https://gerrit.opnfv.org/gerrit/#/c/38387/. Then we can use the MACs to help to distinguish the discovered nodes and assign roles to them, like virtual deployment in the link https://gerrit.opnfv.org/gerrit/#/c/38381/. Change-Id: Ib0f1a60b8935f528a828f716ccc916b767cfa6f9 Signed-off-by: Alex Yang --- ci/deploy/deploy.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'ci/deploy') diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index bfe0f6fa..a4f1e7a3 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -172,6 +172,40 @@ done BMDEPLOY_DAISY_SERVER_NET=$WORKSPACE/templates/physical_environment/networks/daisy.xml BMDEPLOY_DAISY_SERVER_VM=$WORKSPACE/templates/physical_environment/vms/daisy.xml +function update_dha_by_pdf() +{ + local pdf_yaml=securedlab/labs/$LAB_NAME/${POD_NAME}.yaml + local jinja2_template=securedlab/installers/daisy/pod_config.yaml.j2 + local generate_config=securedlab/utils/generate_config.py + if [ ! -f ${generate_config} ] || [ ! -f ${pdf_yaml} ] || [ ! -f ${jinja2_template} ]; then + return + fi + + local tmpfile=$(mktemp XXXXXXXX.yml) + python ${generate_config} -j ${jinja2_template} -y ${pdf_yaml} > ${tmpfile} + if [ $? -ne 0 ]; then + echo "Cannot generate config from POD Descriptor File, use original deploy.yml !" + return + fi + if [ -z $(awk "BEGIN{}(/daisy_ip/){print NR}" $tmpfile) ]; then + line=$(awk "BEGIN{}(/daisy_gateway/){print NR}" $tmpfile) + sed -i "${line}b\daisy_ip: $INSTALLER_IP" $tmpfile + fi + if [ $? -ne 0 ]; then + echo "Cannot write INSTALLER_IP to config file, use original deploy.yml !" + return + fi + cp ${tmpfile} ${DHA_CONF} + echo "====== Update deploy.yml from POD Descriptor File ======" + rm -f $tmpfile +} + +if [[ ! -z $INSTALLER_IP ]]; then + pushd ${WORKSPACE} + update_dha_by_pdf + popd +fi + PARAS_FROM_DEPLOY=`python $WORKSPACE/deploy/get_conf.py --dha $DHA_CONF` TARGET_HOSTS_NUM=`echo $PARAS_FROM_DEPLOY | cut -d " " -f 1` DAISY_IP=`echo $PARAS_FROM_DEPLOY | cut -d " " -f 2` -- cgit 1.2.3-korg