Open matelakat opened 7 years ago
Having n network nodes, something like this would work:
Some pseudo code:
for source_agent in agents:
source_routers = get_routers_on_agent(source_agent)
for target_agent in agents:
target_routers = get_routers_on_agent(target_agent)
routers_to_move = source_routers && target_routers
move_routers(routers_to_move, source_agent, target_agent)
for the agents i'd propose to set the description to the name of the AZ, e.g:
neutron agent-update --description "rot_2" <agent>
To find out which router has instances in which AZ, we have to check the networks, having an interface on that router:
neutron port-list --network-id <network_id> -c device_owner -f value | grep compute
results an entry per instance port compute:AZ, like:
compute:rot_2
If we find routers, where we have networks attached with instances in multiple AZs, the script should output a warning and do nothing. A dry-run, what the script will do is required.
@tpatzig what shall be the value for
This should give us all the information:
for router in `neutron router-list -c id -f value`; do
echo "--------------------------------------------"
echo "router: $router"
for network in `neutron router-port-list $router --device_owner network:router_interface -c network_id -f value`; do
echo "network: $network"
neutron port-list --network-id $network -c device_owner -f value | grep compute | uniq -c
done
done
The first iteration if the tool is ready. It will print out some log messages stating what should be done. 2 scenarios are not clear:
To run the first iteration:
git clone https://github.com/matelakat/cookbook-openstack-network
cd cookbook-openstack-network/
git fetch origin router-optimizer-0 && git checkout FETCH_HEAD && python files/default/router-optimizer.py 2>&1 | tee -a router-optimizer.log
The code for the first iteration is here:
https://github.com/matelakat/cookbook-openstack-network/tree/router-optimizer-0
We know which network nodes live close to which AZs. We also know which routers belong to which AZs, We want to use this information to move routers to network nodes that are close to compute nodes.
neutron-ha-tool can:
--l3-agent-evacuate
)--router-list-file
)--target-agent-id
)The idea is to re-use neutron-ha-tool for this job.
QnA