From: Ryota MIBU Date: Mon, 6 Feb 2017 02:03:58 +0000 (+0000) Subject: bug fixes X-Git-Tag: danube.1.0~59 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F28079%2F1;p=joid.git bug fixes - not to create '2' file by using '[[]]' instead of '[]' - delete files which are needed only during build process - update createresource() to support maas v2 Change-Id: I182bb2e62909dc0e1cb8494297ecab3872a067e5 Signed-off-by: Ryota MIBU --- diff --git a/ci/02-deploybundle.sh b/ci/02-deploybundle.sh index afd5c8e9..e9757bd8 100755 --- a/ci/02-deploybundle.sh +++ b/ci/02-deploybundle.sh @@ -12,24 +12,16 @@ opnfvfeature=$5 opnfvdistro=$6 opnfvmodel=$7 -if [[ "$opnfvmodel" = "openstack" ]]; then - #copy and download charms - cp $opnfvsdn/fetch-charms.sh ./fetch-charms.sh -else - cp kubernetes/fetch-charms.sh ./fetch-charms.sh -fi - jujuver=`juju --version` maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'` -#modify the ubuntu series wants to deploy -sed -i -- "s|distro=trusty|distro=$opnfvdistro|g" ./fetch-charms.sh - -./fetch-charms.sh $opnfvdistro - if [[ "$opnfvmodel" = "openstack" ]]; then + #copy and download charms + ./opnfvsdn/fetch-charms.sh $opnfvdistro tar xvf common/scaleio.tar -C ./$opnfvdistro/ --strip=2 juju-scaleio/trusty/ osdomname='' +else + ./kubernetes/fetch-charms.sh $opnfvdistro fi #check whether charms are still executing the code even juju-deployer says installed. @@ -65,7 +57,7 @@ fi if [[ "$API_KEY" = "" ]]; then - if [ "$maasver" > "2" ]; then + if [[ "$maasver" > "2" ]]; then API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region apikey --username=ubuntu'` else API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region-admin apikey --username=ubuntu'` @@ -83,7 +75,7 @@ if [[ "$opnfvmodel" = "openstack" ]]; then osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` fi - if [ "$maasver" > "2" ]; then + if [[ "$maasver" > "2" ]]; then workmutiple=`maas maas nodes read | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '` else workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '` diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh index df47af6f..ce9d7312 100755 --- a/ci/03-maasdeploy.sh +++ b/ci/03-maasdeploy.sh @@ -112,16 +112,14 @@ fi # # make sure no password asked during the deployment. -echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init - -if [ -e /etc/sudoers.d/90-joid-init ]; then - sudo cp /etc/sudoers.d/90-joid-init 91-joid-init - sudo chown $USER:$USER 91-joid-init - sudo chmod 660 91-joid-init - sudo cat 90-joid-init >> 91-joid-init - sudo chown root:root 91-joid-init - sudo mv 91-joid-init /etc/sudoers.d/ +sudoer_file=/etc/sudoers.d/90-joid-init +sudoer_entry="$USER ALL=(ALL) NOPASSWD:ALL" +if [ -e $sudoer_file ]; then + if ! sudo grep -q "$sudoer_entry" $sudoer_file; then + sudo sed -i -e "1i$sudoer_entry" $sudoer_file + fi else + echo "$sudoer_entry" > 90-joid-init sudo chown root:root 90-joid-init sudo mv 90-joid-init /etc/sudoers.d/ fi @@ -147,6 +145,7 @@ if [ "$virtinstall" -eq 1 ]; then sudo virsh net-define default-net-org.xml sudo virsh net-destroy default sudo virsh net-start default + rm -f default-net-org.xml fi # @@ -338,6 +337,7 @@ addnodes(){ done fi sudo virsh -c qemu:///system define --file bootstrap + rm -f bootstrap maas $PROFILE machines create autodetect_nodegroup='yes' name='bootstrap' \ tags='bootstrap' hostname='bootstrap' power_type='virsh' mac_addresses=$bootstrapmac \ @@ -370,6 +370,7 @@ addnodes(){ sudo virsh -c qemu:///system define --file node1-control sudo virsh -c qemu:///system define --file node2-compute sudo virsh -c qemu:///system define --file node5-compute + rm -f node1-control node2-compute node5-compute maas $PROFILE machines create autodetect_nodegroup='yes' name='node1-control' \ @@ -563,7 +564,7 @@ fi # Add the cloud and controller credentials for MAAS for that lab. jujuver=`juju --version` -if [ "$jujuver" > "2" ]; then +if [[ "$jujuver" > "2" ]]; then addcloud addcredential fi diff --git a/ci/deploy.sh b/ci/deploy.sh index 99be542d..89dcfe0b 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -74,32 +74,43 @@ done #by default maas creates two VMs in case of three more VM needed. createresource() { - maas_ip=`grep " ip_address" deployconfig.yaml | cut -d " " -f 10` - apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2` - maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey} - - nodeexist=`maas maas nodes list hostname=node3-control` - - if [ $nodeexist != *node3* ]; then - sudo virt-install --connect qemu:///system --name node3-control --ram 8192 --cpu host --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node3-control - - sudo virt-install --connect qemu:///system --name node4-control --ram 8192 --cpu host --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node4-control - - node3controlmac=`grep "mac address" node3-control | head -1 | cut -d "'" -f 2` - node4controlmac=`grep "mac address" node4-control | head -1 | cut -d "'" -f 2` - - sudo virsh -c qemu:///system define --file node3-control - sudo virsh -c qemu:///system define --file node4-control - - controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node3-control' tags='control' hostname='node3-control' power_type='virsh' mac_addresses=$node3controlmac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node3-control' | grep system_id | cut -d '"' -f 4 ` - - maas maas tag update-nodes control add=$controlnodeid - - controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node4-control' tags='control' hostname='node4-control' power_type='virsh' mac_addresses=$node4controlmac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node4-control' | grep system_id | cut -d '"' -f 4 ` - - maas maas tag update-nodes control add=$controlnodeid - - fi + # TODO: make sure this function run with the same parameters used in 03-maasdeploy.sh + PROFILE=${PROFILE:-ubuntu} + MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //') + API_SERVER="http://$MAAS_IP/MAAS/api/2.0" + API_KEY=`sudo maas-region apikey --username=ubuntu` + maas login $PROFILE $API_SERVER $API_KEY + + for node in node3-control node4-control + do + node_id=$(maas $PROFILE machines read | \ + jq -r "select(.[].hostname == \"$node\")[0].system_id") + if [[ -z "$node_id" ]]; then + sudo virt-install --connect qemu:///system --name $node \ + --ram 8192 --cpu host --vcpus 4 \ + --disk size=120,format=qcow2,bus=virtio,io=native,pool=default \ + --network bridge=virbr0,model=virtio \ + --network bridge=virbr0,model=virtio \ + --boot network,hd,menu=off \ + --noautoconsole --vnc --print-xml | tee _node.xml + node_mac=$(grep "mac address" _node.xml | head -1 | cut -d "'" -f 2) + sudo virsh -c qemu:///system define --file _node.xml + rm -f _node.xml + + maas $PROFILE nodes new autodetect_nodegroup='yes' name=$node \ + tags='control' hostname=$name power_type='virsh' \ + mac_addresses=$node3controlmac \ + power_parameters_power_address="qemu+ssh://$USER@192.168.122.1/system" \ + architecture='amd64/generic' power_parameters_power_id='node3-control' + node_id=$(maas $PROFILE machines read | \ + jq -r "select(.[].hostname == \"$node\")[0].system_id") + fi + if [[ -z "$node_id" ]]; then + echo "Error: failed to create node $node ." + exit 1 + fi + maas $PROFILE tag update-nodes control add=$node_id || true + done } #copy the files and create extra resources needed for HA deployment @@ -153,16 +164,19 @@ deploy() { check_status() { retval=0 timeoutiter=0 + + echo -n "executing the reltionship within charms ." while [ $retval -eq 0 ]; do sleep 30 - juju status > status.txt - if [ "$(grep -c "executing" status.txt )" -ge 1 ]; then - echo " still executing the reltionship within charms ..." + if juju status | grep -q "executing"; then + echo -n '.' if [ $timeoutiter -ge 120 ]; then + echo 'timed out' retval=1 fi timeoutiter=$((timeoutiter+1)) else + echo 'done' retval=1 fi done