Created
March 6, 2019 11:44
-
-
Save gnuoy/f0e967e0f0f4d71c1e09fc378dfef2c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/clientsrc | |
. ~/novarc_auto | |
unset OS_DOMAIN_NAME | |
image_name="trusty" | |
image_name="bionic" | |
prefix="_$(date +'%d%m%y%H%M%S')" | |
vol_name="bootvol${prefix}" | |
server_name="server${prefix}" | |
echo "* Getting image id" | |
image_id=$(openstack image show -c id -f value ${image_name}) | |
echo "* Creating Volume image id" | |
openstack volume create --image ${image_id} --size 3 --bootable ${vol_name} | |
vol_id=$(openstack volume show -c id -f value ${vol_name}) | |
echo "* Waiting for volume create to complete" | |
while true; do | |
status=$(openstack volume show -c status -f value $vol_id) | |
if [[ $status == "available" ]]; then | |
break | |
fi | |
sleep 5 | |
done | |
echo "* Creating keypair" | |
openstack keypair show guests || openstack keypair create --public-key ~/.ssh/id_rsa_guests.pub guests | |
echo "* Creating server" | |
nova boot --flavor m1.small --block-device source=volume,id=${vol_id},dest=volume,size=10,shutdown=preserve,bootindex=0 --nic net-name=private --key-name guests ${server_name} | |
echo "* Waiting for server create to complete" | |
while true; do | |
status=$(openstack server show -c status -f value $server_name) | |
if [[ $status == "ACTIVE" ]]; then | |
break | |
fi | |
sleep 5 | |
done | |
echo "Complete" | |
echo "Server Name: ${server_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/novarc_auto | |
source ~/clientsrc | |
dom_id=$(openstack domain show admin_domain -c id -f value) | |
export OS_PROJECT_DOMAIN_ID=$dom_id | |
export OS_USER_DOMAIN_ID=$dom_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source /home/ubuntu/clientsrc | |
source ./masakari_rc | |
masakari segment-create --name seg1 --recovery-method auto --service-type COMPUTE | |
masakari segment-create --name seg2 --recovery-method auto --service-type COMPUTE | |
hypervisors=$(openstack hypervisor list --format value -c "Hypervisor Hostname" | paste -d" " -s) | |
segments=$(openstack segment list -f value -c uuid | paste -d" " -s) | |
echo $segments | |
counter=0 | |
for hyper in $hypervisors; do | |
hyper_nofqdn=$(echo $hyper | awk 'BEGIN{FS="."} {print $1}') | |
counter=$((counter+1)) | |
if [ $((counter%2)) -eq 0 ]; then | |
seg=$(echo $segments | awk '{print $1}') | |
else | |
seg=$(echo $segments | awk '{print $2}') | |
fi | |
masakari host-create --name $hyper_nofqdn --segment-id $seg --type COMPUTE --control-attributes SSH | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment