DevStack: Adapt fixed_ips processing

Seems like python-openstackclient 4.0.0 changed the way fixed_ips from
ports are presented, so instead of:

ip_address='10.0.0.89', subnet_id='99dea948-27dd-413c-9e27-ebdd6ae33472'

we get:

[{u'subnet_id': u'99dea948-27dd-413c-9e27-ebdd6ae33472', u'ip_address':
u'10.0.0.89'}]

This obviously sucks as the latter isn't even JSON, but so is life. This
commit fixes that by using python to parse this.

Change-Id: I53f56160680555c70fc6d1d87796badf8d2d4e37
This commit is contained in:
Michał Dulko 2019-09-19 17:19:22 +02:00
parent f009598f40
commit 444096ea96
2 changed files with 7 additions and 5 deletions

View File

@ -15,6 +15,7 @@
function ovs_bind_for_kubelet() {
local port_id
local port_mac
local fixed_ips
local port_ips
local port_subnets
local prefix
@ -56,10 +57,9 @@ function ovs_bind_for_kubelet() {
-c gateway_ip -f value)
port_mac=$(openstack port show "$port_id" -c mac_address -f value)
port_ips=($(openstack port show "$port_id" -f value -c fixed_ips | \
awk -F"'" '{print $2}'))
port_subnets=($(openstack port show "$port_id" -f value -c fixed_ips | \
awk -F"'" '{print $4}'))
fixed_ips=$(openstack port show "$port_id" -f value -c fixed_ips)
port_ips=($(python -c "print ${fixed_ips}[0]['ip_address']"))
port_subnets=($(python -c "print ${fixed_ips}[0]['subnet_id']"))
sudo ovs-vsctl -- --may-exist add-port $OVS_BRIDGE "$ifname" \
-- set Interface "$ifname" type=internal \

View File

@ -221,6 +221,7 @@ function create_k8s_api_service {
local lb_name
local use_octavia
local project_id
local fixed_ips
project_id=$(get_or_create_project \
"$KURYR_NEUTRON_DEFAULT_PROJECT" default)
@ -230,7 +231,8 @@ function create_k8s_api_service {
subnet show "$KURYR_NEUTRON_DEFAULT_SERVICE_SUBNET" \
-c cidr -f value)
kubelet_iface_ip=$(openstack port show kubelet-"${HOSTNAME}" -c fixed_ips -f value | cut -d \' -f 2)
fixed_ips=$(openstack port show kubelet-"${HOSTNAME}" -c fixed_ips -f value)
kubelet_iface_ip=$(python -c "print ${fixed_ips}[0]['ip_address']")
k8s_api_clusterip=$(_cidr_range "$service_cidr" | cut -f1)