summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorjuraj.linkes <jlinkes@cisco.com>2017-02-14 15:45:41 +0100
committerjuraj.linkes <jlinkes@cisco.com>2017-03-13 16:13:57 +0100
commit27bc51931cd80724e5638709a7746496cd5151c2 (patch)
treeec2d0c04108b312ff0b2fa6d850aa4531aff006c /scripts
parent8f21ca2d5951be14464b3a99b9e792b3bd7a63b0 (diff)
Added draft of post apex deployment script
Change-Id: Ib4c4fdfbc9f24f4d6112c110a5fe12be61c40842 Signed-off-by: juraj.linkes <jlinkes@cisco.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/copy_keys.sh10
-rwxr-xr-xscripts/post_apex.sh87
2 files changed, 97 insertions, 0 deletions
diff --git a/scripts/copy_keys.sh b/scripts/copy_keys.sh
new file mode 100755
index 0000000..062e4a7
--- /dev/null
+++ b/scripts/copy_keys.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+if [[ $# -ne 1 ]]
+then
+ echo "Must have one argument which is the ip of the host to which the key will be copied"
+ exit 1
+fi
+scp -oStrictHostKeyChecking=no /home/stack/id_rsa_jumphost_root.pub heat-admin@$1:/home/heat-admin
+ssh -oStrictHostKeyChecking=no heat-admin@$1 'cat /home/heat-admin/id_rsa_jumphost_root.pub >> /home/heat-admin/.ssh/authorized_keys'
+ssh -oStrictHostKeyChecking=no heat-admin@$1 'cat /home/heat-admin/id_rsa_jumphost_root.pub | sudo tee -a /root/.ssh/authorized_keys'
+ssh -oStrictHostKeyChecking=no heat-admin@$1 'rm -f /home/heat-admin/id_rsa_jumphost_root.pub'
diff --git a/scripts/post_apex.sh b/scripts/post_apex.sh
new file mode 100755
index 0000000..c4ccf7d
--- /dev/null
+++ b/scripts/post_apex.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+overcloud_file_name=overcloudrc # change this if needed
+NODE_PATTERN=overcloud
+overcloudrc_path=/root/$overcloud_file_name
+undercloud_ip=`arp -a | grep $(virsh domiflist undercloud | grep default | awk '{print $5}') | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"`
+#echo $undercloud_ip
+
+# copy rc file to jumphost
+echo "Copying overcloud rc to jumphost to $overcloudrc_path"
+scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$undercloud_ip:/home/stack/overcloudrc $overcloudrc_path 2> /dev/null
+
+# copy jumphost root key to undercloud vm - needs $undercloud_ip
+echo "Copying root's public ssh key to undercloud vm"
+scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /root/.ssh/id_rsa.pub root@$undercloud_ip:/home/stack/id_rsa_jumphost_root.pub 2> /dev/null
+
+# copy key copying script to undercloud vm
+echo "Copying ssh setup script to undercloud vm"
+scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null `dirname $0`/copy_keys.sh root@$undercloud_ip:/home/stack 2> /dev/null
+
+#overcloud_dir="/root/.overcloud"
+#node_list_filename="$overcloud_dir/node_list"
+#mkdir -p $overcloud_dir
+sed -i "/$NODE_PATTERN/d" /etc/hosts
+OIFS="$IFS"
+IFS=$'\n'
+nova_list=`ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$undercloud_ip ". stackrc && nova list | tail -n+4 | head -n-1 | sed 's/ //g'" 2> /dev/null`
+node_list=($nova_list)
+IFS="$OIFS"
+echo
+for node in "${node_list[@]}"
+do
+ node_fields=`echo $node | cut -d "|" -f 3,7`
+ node_name=`echo $node_fields | cut -d "|" -f 1`
+ node_ip=`echo $node_fields | cut -d "=" -f 2`
+ echo "adding $node_name to /etc/hosts"
+ echo $node_ip $node_name >> /etc/hosts
+ echo "removing $node_ip from known hosts"
+ sed -i "/$node_ip/d" /root/.ssh/known_hosts
+ echo "Setting up ssh keys on $node_name for root"
+ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null stack@$undercloud_ip "/home/stack/copy_keys.sh $node_ip &" 2> /dev/null
+ echo "Copying overcloudrc to $node_name"
+ scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $overcloudrc_path heat-admin@$node_ip:. 2> /dev/null
+ ssh -oStrictHostKeyChecking=no heat-admin@$node_ip 'sudo cp /home/heat-admin/overcloudrc /root' 2> /dev/null
+ echo "Cloning fds repo on $node_name to /root/fds"
+ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $node_name 'git clone https://gerrit.opnfv.org/gerrit/p/fds.git /root/fds' 2> /dev/null
+ if [[ $node_name = *'controller'* ]]
+ then
+ echo "Setting debugs for nova and neutron on $node_name"
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/nova/nova.conf' 2> /dev/null
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/nova/nova.conf' 2> /dev/null
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/neutron/neutron.conf' 2> /dev/null
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/neutron/neutron.conf' 2> /dev/null
+ else
+ echo "Setting debugs for nova on $node_name"
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?debug *=.*$/debug=True/" /etc/nova/nova.conf' 2> /dev/null
+ ssh -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null heat-admin@$node_ip 'sudo sed -i "s/^\(# *\)\?verbose *=.*$/verbose=True/" /etc/nova/nova.conf' 2> /dev/null
+ fi
+done
+. $overcloudrc_path
+openstack flavor list | grep nfv > /dev/null
+echo
+if [[ ! $? -eq 0 ]]
+then
+ echo "Configuring flavor nfv"
+ openstack flavor create nfv --ram 768 --property hw:mem_page_size=large
+else
+ echo "Flavor nfv is already configured"
+fi
+
+openstack image list | grep cirros-0.3.4 > /dev/null
+echo
+if [[ ! $? -eq 0 ]]
+then
+ echo "Configuring image cirros-0.3.4"
+ image_loc=/root/cirros-0.3.4-x86_64-disk.img
+ if [[ ! -f $image_loc ]]
+ then
+ echo "Downloading cirros image to $image_loc"
+ wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -O $image_loc
+ fi
+ openstack image create --disk-format qcow2 --container-format bare --public --property hw_mem_page_size=large --file $image_loc cirros-0.3.4
+else
+ echo "Image cirros-0.3.4 is already configured"
+fi
+
+echo
+echo "Post-apex script is finished. If you want the nova and neutron debug configurations to take effect, you'll need to restart the services manually."