forked from rm-you/devstack_deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile
More file actions
76 lines (66 loc) · 3.89 KB
/
profile
File metadata and controls
76 lines (66 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Fix permissions on current tty so screens can attach
sudo chmod go+rw `tty`
# Add environment variables for auth/endpoints
source /opt/stack/devstack/openrc admin admin
export BARBICAN_ENDPOINT="http://localhost:9311"
# Set some utility variables
PROJECT_ID=$(openstack token issue | awk '/ project_id / {print $4}')
export PROJECT_ID="${PROJECT_ID:0:8}-${PROJECT_ID:8:4}-${PROJECT_ID:12:4}-${PROJECT_ID:16:4}-${PROJECT_ID:20}"
export DEFAULT_NETWORK=$(neutron subnet-list | awk '/ private-subnet / {print $2}')
export DEFAULT_NETWORK_IPV6=$(neutron subnet-list | awk '/ ipv6-private-subnet / {print $2}')
# Make pretty-printing json easy
alias json="python -mjson.tool"
# Make sshing to amps easy
alias ossh="ssh -i /etc/octavia/.ssh/octavia_ssh_key -l ubuntu"
# Run this to generate nova VMs as a test backend
function gen_backend() {
ssh-keygen -f /opt/stack/.ssh/id_rsa -t rsa -N '' -q
nova keypair-add default --pub-key ~/.ssh/id_rsa.pub
neutron security-group-create member
nova secgroup-add-rule member tcp 22 22 0.0.0.0/0
nova secgroup-add-rule member tcp 22 22 0::/0
nova secgroup-add-rule member tcp 80 80 0.0.0.0/0
nova secgroup-add-rule member tcp 80 80 0::/0
nova secgroup-add-rule member icmp -1 -1 0.0.0.0/0
nova secgroup-add-rule member icmp -1 -1 0::/0
PRIVATE_NETWORK=$(neutron net-list | awk '/ private / {print $2}')
nova boot --image cirros-0.3.0-x86_64-disk --flavor 2 --nic net-id=$PRIVATE_NETWORK member1 --security-groups member --key-name default
nova boot --image cirros-0.3.0-x86_64-disk --flavor 2 --nic net-id=$PRIVATE_NETWORK member2 --security-groups member --key-name default --poll
sleep 15
export MEMBER1_IP=$(nova show member1 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ "\\.") print a; else print $6}')
export MEMBER2_IP=$(nova show member2 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ ":") print a; else print $6}')
ssh -o StrictHostKeyChecking=no cirros@$MEMBER1_IP "(while true; do echo -e 'HTTP/1.0 200 OK\r\n\r\nIt Works: member1' | sudo nc -l -p 80 ; done)&"
ssh -o StrictHostKeyChecking=no cirros@$MEMBER2_IP "(while true; do echo -e 'HTTP/1.0 200 OK\r\n\r\nIt Works: member2' | sudo nc -l -p 80 ; done)&"
sleep 5
curl $MEMBER1_IP
curl -g "[$MEMBER2_IP]"
}
# Create a LB with Neutron-LBaaS
function create_lb() {
neutron lbaas-loadbalancer-create $DEFAULT_NETWORK --name lb1
watch neutron lbaas-loadbalancer-show lb1
}
function create_lb_ipv6() {
neutron lbaas-loadbalancer-create $DEFAULT_NETWORK_IPV6 --name lb1
watch neutron lbaas-loadbalancer-show lb1
}
# Create a Listener with Neutron-LBaaS
function create_listener() {
neutron lbaas-listener-create --loadbalancer lb1 --protocol-port 443 --protocol TERMINATED_HTTPS --name listener1 --default-tls-container=$DEFAULT_TLS_CONTAINER
watch neutron lbaas-loadbalancer-show lb1
}
# Create a Pool with Neutron-LBaaS
function create_pool() {
neutron lbaas-pool-create --name pool1 --protocol HTTP --listener listener1 --lb-algorithm ROUND_ROBIN
watch neutron lbaas-loadbalancer-show lb1
}
# Create Members with Neutron-LBaaS
function create_members() {
# Get member ips again because we might be in a different shell
export MEMBER1_IP=$(nova show member1 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ "\\.") print a; else print $6}')
neutron lbaas-member-create pool1 --address $MEMBER1_IP --protocol-port 80 --subnet $(neutron subnet-list | awk '/ private-subnet / {print $2}')
# Get the second memberIP while we're waiting anyway
export MEMBER2_IP=$(nova show member2 | awk '/private network/ {a = substr($5, 0, length($5)-1); if (a ~ ":") print a; else print $6}')
watch neutron lbaas-loadbalancer-show lb1 # TODO: Make a proper wait, right now just assumes you will ctrl-c when ready
neutron lbaas-member-create pool1 --address $MEMBER2_IP --protocol-port 80 --subnet $(neutron subnet-list | awk '/ ipv6-private-subnet / {print $2}')
}