Update devstack plugin and examples
The devstack plugin should only use the openstackclient to interact with OpenStack services via CLI. This patch fixes both the devstack plugin and the examples. Task: 5678 Task: 5680 Task: 5698 Story: 2001183 Change-Id: Id30ab0484edb350f0a424a0fc90c381357614b8e
This commit is contained in:
parent
bb9bb2d05b
commit
662485e2d2
@ -16,9 +16,8 @@ git clone https://github.com/openstack-dev/devstack.git $HOME/devstack
|
||||
|
||||
cat <<EOF > $HOME/devstack/localrc
|
||||
enable_plugin barbican https://review.openstack.org/openstack/barbican
|
||||
enable_plugin neutron-lbaas https://review.openstack.org/openstack/neutron-lbaas
|
||||
enable_plugin octavia https://review.openstack.org/openstack/octavia
|
||||
LIBS_FROM_GIT+=python-neutronclient
|
||||
LIBS_FROM_GIT+=python-octaviaclient
|
||||
|
||||
KEYSTONE_TOKEN_FORMAT=UUID
|
||||
|
||||
@ -41,10 +40,6 @@ ENABLED_SERVICES+=,placement-api,placement-client
|
||||
ENABLED_SERVICES+=,g-api,g-reg
|
||||
# Neutron
|
||||
ENABLED_SERVICES+=,q-svc,q-agt,q-dhcp,q-l3,q-meta,neutron
|
||||
# Enable LBaaS V2
|
||||
ENABLED_SERVICES+=,q-lbaasv2
|
||||
# Cinder (optional)
|
||||
#ENABLED_SERVICES+=,cinder,c-api,c-vol,c-sch
|
||||
# Tempest (optional)
|
||||
#ENABLED_SERVICES+=,tempest
|
||||
# Octavia
|
||||
|
@ -61,7 +61,7 @@ function build_octavia_worker_image {
|
||||
else
|
||||
export DIB_REPOREF_amphora_agent=$(git -c "$OCTAVIA_DIR" log -1 --pretty="format:%H")
|
||||
fi
|
||||
TOKEN=$(openstack token issue | grep ' id ' | get_field 2)
|
||||
TOKEN=$(openstack token issue -f value -c id)
|
||||
die_if_not_set $LINENO TOKEN "Keystone failed to get token."
|
||||
|
||||
octavia_dib_tracing_arg=
|
||||
@ -234,6 +234,7 @@ function octavia_configure {
|
||||
iniset $OCTAVIA_CONF oslo_messaging rpc_thread_pool_size 2
|
||||
iniset $OCTAVIA_CONF oslo_messaging topic octavia_prov
|
||||
|
||||
# TODO(nmagnezi): Remove this when neutron-lbaas gets deprecated
|
||||
# Setting neutron request_poll_timeout
|
||||
iniset $NEUTRON_CONF octavia request_poll_timeout 3000
|
||||
if [[ "$WSGI_MODE" == "uwsgi" ]]; then
|
||||
@ -314,16 +315,13 @@ function octavia_configure {
|
||||
|
||||
function create_mgmt_network_interface {
|
||||
if [ $OCTAVIA_MGMT_PORT_IP != 'auto' ]; then
|
||||
SUBNET_ID=$(neutron subnet-show lb-mgmt-subnet | awk '/ id / {print $4}')
|
||||
PORT_FIXED_IP="--fixed-ip subnet_id=$SUBNET_ID,ip_address=$OCTAVIA_MGMT_PORT_IP"
|
||||
SUBNET_ID=$(openstack subnet show lb-mgmt-subnet -f value -c id)
|
||||
PORT_FIXED_IP="--fixed-ip subnet=$SUBNET_ID,ip-address=$OCTAVIA_MGMT_PORT_IP"
|
||||
fi
|
||||
|
||||
# TODO(johnsom) Change this to OSC when security group is working
|
||||
id_and_mac=$(neutron port-create --name octavia-health-manager-$OCTAVIA_NODE-listen-port --security-group lb-health-mgr-sec-grp --device-owner Octavia:health-mgr --binding:host_id=$(hostname) lb-mgmt-net $PORT_FIXED_IP | awk '/ id | mac_address / {print $4}')
|
||||
MGMT_PORT_ID=$(openstack port create --security-group lb-health-mgr-sec-grp --device-owner Octavia:health-mgr --host=$(hostname) -c id -f value --network lb-mgmt-net $PORT_FIXED_IP octavia-health-manager-$OCTAVIA_NODE-listen-port)
|
||||
MGMT_PORT_MAC=$(openstack port show -c mac_address -f value $MGMT_PORT_ID)
|
||||
|
||||
id_and_mac=($id_and_mac)
|
||||
MGMT_PORT_ID=${id_and_mac[0]}
|
||||
MGMT_PORT_MAC=${id_and_mac[1]}
|
||||
# TODO(johnsom) This gets the IPv4 address, should be updated for IPv6
|
||||
MGMT_PORT_IP=$(openstack port show -f value -c fixed_ips $MGMT_PORT_ID | awk '{FS=",| "; gsub(",",""); gsub("'\''",""); for(i = 1; i <= NF; ++i) {if ($i ~ /^ip_address/) {n=index($i, "="); if (substr($i, n+1) ~ "\\.") print substr($i, n+1)}}}')
|
||||
if function_exists octavia_create_network_interface_device ; then
|
||||
@ -358,8 +356,8 @@ function create_mgmt_network_interface {
|
||||
|
||||
function build_mgmt_network {
|
||||
# Create network and attach a subnet
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network create lb-mgmt-net | awk '/ id / {print $4}')
|
||||
OCTAVIA_AMP_SUBNET_ID=$(openstack subnet create --subnet-range $OCTAVIA_MGMT_SUBNET --allocation-pool start=$OCTAVIA_MGMT_SUBNET_START,end=$OCTAVIA_MGMT_SUBNET_END --network lb-mgmt-net lb-mgmt-subnet | awk '/ id / {print $4}')
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network create lb-mgmt-net -f value -c id)
|
||||
OCTAVIA_AMP_SUBNET_ID=$(openstack subnet create --subnet-range $OCTAVIA_MGMT_SUBNET --allocation-pool start=$OCTAVIA_MGMT_SUBNET_START,end=$OCTAVIA_MGMT_SUBNET_END --network lb-mgmt-net lb-mgmt-subnet -f value -c id)
|
||||
|
||||
# Create security group and rules
|
||||
openstack security group create lb-mgmt-sec-grp
|
||||
@ -377,7 +375,7 @@ function build_mgmt_network {
|
||||
}
|
||||
|
||||
function configure_lb_mgmt_sec_grp {
|
||||
OCTAVIA_MGMT_SEC_GRP_ID=$(openstack security group list | awk ' / lb-mgmt-sec-grp / {print $2}')
|
||||
OCTAVIA_MGMT_SEC_GRP_ID=$(openstack security group show lb-mgmt-sec-grp -f value -c id)
|
||||
iniset ${OCTAVIA_CONF} controller_worker amp_secgroup_list ${OCTAVIA_MGMT_SEC_GRP_ID}
|
||||
}
|
||||
|
||||
@ -394,7 +392,7 @@ function configure_octavia_tempest {
|
||||
function create_amphora_flavor {
|
||||
# Pass even if it exists to avoid race condition on multinode
|
||||
openstack flavor create --id auto --ram 1024 --disk 2 --vcpus 1 --private m1.amphora -f value -c id || true
|
||||
amp_flavor_id=$(openstack flavor list --all -c ID -c Name | awk ' / m1.amphora / {print $2}')
|
||||
amp_flavor_id=$(openstack flavor show m1.amphora -f value -c id)
|
||||
iniset $OCTAVIA_CONF controller_worker amp_flavor_id $amp_flavor_id
|
||||
}
|
||||
|
||||
@ -477,7 +475,7 @@ function octavia_start {
|
||||
|
||||
iniset $OCTAVIA_CONF controller_worker amp_image_tag ${OCTAVIA_AMP_IMAGE_TAG}
|
||||
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network list | awk '/ lb-mgmt-net / {print $2}')
|
||||
OCTAVIA_AMP_NETWORK_ID=$(openstack network show lb-mgmt-net -f value -c id)
|
||||
|
||||
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list ${OCTAVIA_AMP_NETWORK_ID}
|
||||
|
||||
|
@ -9,7 +9,7 @@ RECLONE=True
|
||||
|
||||
enable_plugin octavia https://git.openstack.org/openstack/octavia
|
||||
|
||||
LIBS_FROM_GIT+=python-neutronclient
|
||||
LIBS_FROM_GIT+=python-octaviaclient
|
||||
DATABASE_PASSWORD=password
|
||||
ADMIN_PASSWORD=password
|
||||
SERVICE_PASSWORD=password
|
||||
@ -20,8 +20,6 @@ LOGFILE=$DEST/logs/stack.sh.log
|
||||
VERBOSE=True
|
||||
LOG_COLOR=True
|
||||
|
||||
ENABLED_SERVICES=
|
||||
|
||||
# Nova
|
||||
enable_service n-cpu
|
||||
|
||||
@ -53,8 +51,6 @@ DATABASE_TYPE=mysql
|
||||
Q_PLUGIN=ml2
|
||||
Q_ML2_TENANT_NETWORK_TYPE=vxlan
|
||||
|
||||
IMAGE_URLS+=",http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
|
||||
|
||||
LOGFILE=$DEST/logs/stack.sh.log
|
||||
|
||||
# Old log files are automatically removed after 7 days to keep things neat. Change
|
||||
|
@ -5,14 +5,13 @@
|
||||
|
||||
RECLONE=True
|
||||
|
||||
# Load the external LBaaS plugin.
|
||||
# Load the external Octavia plugin.
|
||||
|
||||
enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas
|
||||
enable_plugin neutron-lbaas-dashboard https://git.openstack.org/openstack/neutron-lbaas-dashboard
|
||||
enable_plugin octavia-dashboard https://git.openstack.org/openstack/octavia-dashboard
|
||||
enable_plugin octavia https://git.openstack.org/openstack/octavia
|
||||
enable_plugin barbican https://git.openstack.org/openstack/barbican
|
||||
|
||||
LIBS_FROM_GIT+=python-neutronclient
|
||||
LIBS_FROM_GIT+=python-octaviaclient
|
||||
DATABASE_PASSWORD=password
|
||||
ADMIN_PASSWORD=password
|
||||
SERVICE_PASSWORD=password
|
||||
@ -46,20 +45,14 @@ enable_service g-api
|
||||
enable_service g-reg
|
||||
|
||||
# Neutron
|
||||
enable_service neutron
|
||||
enable_service q-svc
|
||||
enable_service q-agt
|
||||
enable_service q-dhcp
|
||||
enable_service q-l3
|
||||
enable_service q-meta
|
||||
|
||||
# Cinder
|
||||
enable_service c-api
|
||||
enable_service c-vol
|
||||
enable_service c-sch
|
||||
|
||||
|
||||
# LBaaS V2 and Octavia
|
||||
enable_service q-lbaasv2
|
||||
# Octavia
|
||||
enable_service octavia
|
||||
enable_service o-cw
|
||||
enable_service o-hm
|
||||
@ -76,8 +69,6 @@ OCTAVIA_NODES=main:192.168.42.10,second:192.168.42.11
|
||||
Q_PLUGIN=ml2
|
||||
Q_ML2_TENANT_NETWORK_TYPE=vxlan
|
||||
|
||||
IMAGE_URLS+=",http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
|
||||
|
||||
LOGFILE=$DEST/logs/stack.sh.log
|
||||
|
||||
# Old log files are automatically removed after 7 days to keep things neat. Change
|
||||
|
@ -18,14 +18,13 @@
|
||||
|
||||
RECLONE=True
|
||||
|
||||
# Load the external LBaaS plugin.
|
||||
# Load the external Octavia plugin.
|
||||
|
||||
enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas
|
||||
enable_plugin neutron-lbaas-dashboard https://git.openstack.org/openstack/neutron-lbaas-dashboard
|
||||
enable_plugin octavia-dashboard https://git.openstack.org/openstack/octavia-dashboard
|
||||
enable_plugin octavia https://git.openstack.org/openstack/octavia
|
||||
enable_plugin barbican https://git.openstack.org/openstack/barbican
|
||||
|
||||
LIBS_FROM_GIT+=python-neutronclient
|
||||
LIBS_FROM_GIT+=python-octaviaclient
|
||||
DATABASE_PASSWORD=password
|
||||
ADMIN_PASSWORD=password
|
||||
SERVICE_PASSWORD=password
|
||||
@ -59,20 +58,14 @@ enable_service g-api
|
||||
enable_service g-reg
|
||||
|
||||
# Neutron
|
||||
enable_service neutron
|
||||
enable_service q-svc
|
||||
enable_service q-agt
|
||||
enable_service q-dhcp
|
||||
enable_service q-l3
|
||||
enable_service q-meta
|
||||
|
||||
# Cinder
|
||||
enable_service c-api
|
||||
enable_service c-vol
|
||||
enable_service c-sch
|
||||
|
||||
|
||||
# LBaaS V2 and Octavia
|
||||
enable_service q-lbaasv2
|
||||
# Octavia
|
||||
enable_service octavia
|
||||
enable_service o-cw
|
||||
enable_service o-hm
|
||||
@ -86,8 +79,6 @@ Q_PLUGIN=ml2
|
||||
Q_ML2_TENANT_NETWORK_TYPE=vxlan
|
||||
Q_DVR_MODE=dvr_snat
|
||||
|
||||
IMAGE_URLS+=",http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
|
||||
|
||||
LOGFILE=$DEST/logs/stack.sh.log
|
||||
|
||||
# Old log files are automatically removed after 7 days to keep things neat. Change
|
||||
|
@ -20,7 +20,7 @@ DEST=${DEST:-/opt/stack}
|
||||
# Polling functions
|
||||
function wait_for_loadbalancer_active() {
|
||||
lb_name=$1
|
||||
while [ $(neutron lbaas-loadbalancer-list | grep $lb_name | grep ACTIVE | wc --lines) == 0 ]; do
|
||||
while [ $(openstack loadbalancer show $lb_name -f value -c provisioning_status) != "ACTIVE" ]; do
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
@ -33,12 +33,12 @@ if is_service_enabled nova; then
|
||||
source ${TOP_DIR}/openrc demo demo
|
||||
|
||||
# Create an SSH key to use for the instances
|
||||
DEVSTACK_LBAAS_SSH_KEY_NAME=$(hostname)_DEVSTACK_LBAAS_SSH_KEY_RSA
|
||||
DEVSTACK_LBAAS_SSH_KEY_NAME=DEVSTACK_LBAAS_SSH_KEY_RSA
|
||||
DEVSTACK_LBAAS_SSH_KEY_DIR=${TOP_DIR}
|
||||
DEVSTACK_LBAAS_SSH_KEY=${DEVSTACK_LBAAS_SSH_KEY_DIR}/${DEVSTACK_LBAAS_SSH_KEY_NAME}
|
||||
rm -f ${DEVSTACK_LBAAS_SSH_KEY}.pub ${DEVSTACK_LBAAS_SSH_KEY}
|
||||
ssh-keygen -b 2048 -t rsa -f ${DEVSTACK_LBAAS_SSH_KEY} -N ""
|
||||
nova keypair-add --pub-key=${DEVSTACK_LBAAS_SSH_KEY}.pub ${DEVSTACK_LBAAS_SSH_KEY_NAME}
|
||||
openstack keypair create --public-key=${DEVSTACK_LBAAS_SSH_KEY}.pub ${DEVSTACK_LBAAS_SSH_KEY_NAME}
|
||||
|
||||
# Add tcp/22,80 and icmp to default security group
|
||||
openstack security group rule create --protocol tcp --dst-port 22:22 default
|
||||
@ -46,46 +46,56 @@ if is_service_enabled nova; then
|
||||
openstack security group rule create --protocol icmp default
|
||||
|
||||
# Boot some instances
|
||||
NOVA_BOOT_ARGS="--key-name ${DEVSTACK_LBAAS_SSH_KEY_NAME} --image $(openstack image list | awk '/ cirros-0.3.4-x86_64-disk / {print $2}') --flavor 1 --nic net-id=$(neutron net-list | awk '/ private / {print $2}')"
|
||||
NOVA_BOOT_ARGS="--key-name ${DEVSTACK_LBAAS_SSH_KEY_NAME} --image $(openstack image show cirros-0.3.5-x86_64-disk -f value -c id) --flavor 1 --nic net-id=$(openstack network show private -f value -c id)"
|
||||
|
||||
nova boot ${NOVA_BOOT_ARGS} node1
|
||||
nova boot ${NOVA_BOOT_ARGS} node2
|
||||
openstack server create ${NOVA_BOOT_ARGS} node1
|
||||
openstack server create ${NOVA_BOOT_ARGS} node2
|
||||
|
||||
echo "Waiting ${BOOT_DELAY} seconds for instances to boot"
|
||||
sleep ${BOOT_DELAY}
|
||||
|
||||
IP1=$(nova show node1 | grep "private network" | awk '/private network/ {ip = substr($5, 0, length($5)-1); if (ip ~ "\\.") print ip; else print $6}')
|
||||
IP2=$(nova show node2 | grep "private network" | awk '/private network/ {ip = substr($5, 0, length($5)-1); if (ip ~ "\\.") print ip; else print $6}')
|
||||
IP1=$(openstack server show node1 | awk '/private/ {ip = substr($4, 9, length($4)-9) ; if (ip ~ "\\.") print ip ; else print $5}')
|
||||
IP2=$(openstack server show node2 | awk '/private/ {ip = substr($4, 9, length($4)-9) ; if (ip ~ "\\.") print ip ; else print $5}')
|
||||
|
||||
touch ~/.ssh/known_hosts
|
||||
|
||||
ssh-keygen -R ${IP1}
|
||||
ssh-keygen -R ${IP2}
|
||||
|
||||
|
||||
# Get Neutron router namespace details
|
||||
NAMESPACE_NAME='qrouter-'$(openstack router show router1 -f value -c id)
|
||||
NAMESPACE_CMD_PREFIX='sudo ip netns exec'
|
||||
|
||||
# Run a simple web server on the instances
|
||||
chmod 0755 ${TOP_DIR}/webserver.sh
|
||||
scp -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no ${TOP_DIR}/webserver.sh cirros@${IP1}:webserver.sh
|
||||
scp -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no ${TOP_DIR}/webserver.sh cirros@${IP2}:webserver.sh
|
||||
|
||||
screen_process node1 "ssh -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no cirros@${IP1} ./webserver.sh"
|
||||
screen_process node2 "ssh -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no cirros@${IP2} ./webserver.sh"
|
||||
$NAMESPACE_CMD_PREFIX $NAMESPACE_NAME scp -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no ${TOP_DIR}/webserver.sh cirros@${IP1}:webserver.sh
|
||||
$NAMESPACE_CMD_PREFIX $NAMESPACE_NAME scp -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no ${TOP_DIR}/webserver.sh cirros@${IP2}:webserver.sh
|
||||
$NAMESPACE_CMD_PREFIX $NAMESPACE_NAME ssh -o UserKnownHostsFile=/dev/null -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no -q cirros@${IP1} "screen -d -m sh webserver.sh"
|
||||
$NAMESPACE_CMD_PREFIX $NAMESPACE_NAME ssh -o UserKnownHostsFile=/dev/null -i ${DEVSTACK_LBAAS_SSH_KEY} -o StrictHostKeyChecking=no -q cirros@${IP2} "screen -d -m sh webserver.sh"
|
||||
|
||||
fi
|
||||
|
||||
if is_service_enabled q-lbaasv2; then
|
||||
if is_service_enabled octavia; then
|
||||
|
||||
neutron lbaas-loadbalancer-create --name lb1 private-subnet
|
||||
SUBNET_ID=$(openstack subnet show private-subnet -f value -c id)
|
||||
openstack loadbalancer create --name lb1 --vip-subnet-id $SUBNET_ID
|
||||
wait_for_loadbalancer_active lb1
|
||||
|
||||
neutron lbaas-listener-create --loadbalancer lb1 --protocol HTTP --protocol-port 80 --name listener1
|
||||
openstack loadbalancer listener create lb1 --protocol HTTP --protocol-port 80 --name listener1
|
||||
wait_for_loadbalancer_active lb1
|
||||
|
||||
neutron lbaas-pool-create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1
|
||||
openstack loadbalancer pool create --lb-algorithm ROUND_ROBIN --listener listener1 --protocol HTTP --name pool1
|
||||
wait_for_loadbalancer_active lb1
|
||||
|
||||
neutron lbaas-member-create --subnet private-subnet --address ${IP1} --protocol-port 80 pool1
|
||||
openstack loadbalancer member create --subnet-id $SUBNET_ID --address ${IP1} --protocol-port 80 pool1
|
||||
wait_for_loadbalancer_active lb1
|
||||
|
||||
neutron lbaas-member-create --subnet private-subnet --address ${IP2} --protocol-port 80 pool1
|
||||
openstack loadbalancer member create --subnet-id $SUBNET_ID --address ${IP2} --protocol-port 80 pool1
|
||||
|
||||
fi
|
||||
|
||||
echo "How to test load balancing:"
|
||||
echo ""
|
||||
echo "${NAMESPACE_CMD_PREFIX} ${NAMESPACE_NAME} curl $(openstack loadbalancer show lb1 -f value -c vip_address)"
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user