管理网络¶
运营方面的考虑,例如合规性,可能需要管理网络。例如,向 OpenStack-Ansible 管理的云中添加新的提供商网络。以下部分概述了完成这些任务的最常见的管理任务。
有关网络故障排除的更通用信息,请参阅《操作指南》中的 网络故障排除章节。
有关网络的更深入信息,请参阅 网络指南。
使用新的网络接口添加提供商桥接¶
在执行必要的 playbook 以完成配置之前,将每个提供商网络添加到您的云中,以便 OpenStack-Ansible 和操作系统识别它。
OpenStack-Ansible 配置¶
所有提供商网络都需要添加到 OpenStack-Ansible 配置中。
编辑文件 /etc/openstack_deploy/openstack_user_config.yml,并在 provider_networks 部分下添加一个新的块
container_bridge 设置定义了用于连接物理主机到容器的 veth 对的物理网络桥接。在容器内部,container_interface 设置定义了物理网络可用的名称。当 Neutron 代理部署在裸机上时,不需要 container_interface 设置。确保这两个设置在所有提供商网络中都是唯一定义的,并且网络接口在您的操作系统中正确配置。 group_binds 定义了需要将此网络附加到的位置,可以是容器或物理主机,最终取决于使用的网络堆栈。例如,Linuxbridge 与 OVS。配置 range 定义了 Neutron 物理分段 ID,主要通过 horizon 和 Neutron API 由最终用户在创建网络时自动使用。 net_name 配置也是如此,它定义了 Neutron 配置中的可寻址名称。此配置还需要在其他提供商网络中是唯一的。
有关更多信息,请参阅 配置部署 在 OpenStack-Ansible 部署指南中。
使用新配置更新节点¶
根据 group_binds 部分运行适当的 playbook。
例如,如果您更新需要更改所有节点上 linux bridge 代理的网络,假设您拥有名为 infra01、infra02 和 infra03 的 infra 节点,则运行
# openstack-ansible containers-deploy.yml --limit localhost,infra01,infra01-host_containers
# openstack-ansible containers-deploy.yml --limit localhost,infra02,infra02-host_containers
# openstack-ansible containers-deploy.yml --limit localhost,infra03,infra03-host_containers
然后更新 neutron 配置。
# openstack-ansible os-neutron-install.yml --limit localhost,infra01,infra01-host_containers
# openstack-ansible os-neutron-install.yml --limit localhost,infra02,infra02-host_containers
# openstack-ansible os-neutron-install.yml --limit localhost,infra03,infra03-host_containers
然后根据需要更新您的计算节点。
从 OpenStack 中删除提供商桥接¶
与添加提供商网络类似,删除过程使用相同的步骤,但顺序相反。在删除 OpenStack-Ansible 配置之前,需要删除 Neutron 端口。
取消分配所有 Neutron 浮动 IP
注意
将要删除的 Neutron 网络导出为单个 UUID。
export NETWORK_UUID=<uuid> for p in $( neutron port-list -c id --device_owner compute:nova --network_id=${NETWORK_UUID}| awk '/([A-Fa-f0-9]+-){3}/ {print $2}' ); do floatid=$( neutron floatingip-list -c id --port_id=$p | awk '/([A-Fa-z0-9]+-){3}/ { print $2 }' ) if [ -n "$floatid" ]; then echo "Disassociating floating IP $floatid from port $p" neutron floatingip-disassociate $floatid fi done
从实例中删除所有 Neutron 端口
export NETWORK_UUID=<uuid> for p in $( neutron port-list -c id -c device_id --device_owner compute:nova --network_id=${NETWORK_UUID}| awk '/([A-Fa-f0-9]+-){3}/ {print $2}' ); do echo "Removing Neutron compute port $p" neutron port-delete $p done
删除 Neutron 路由器端口和 DHCP 代理
export NETWORK_UUID=<uuid> for line in $( neutron port-list -c id -c device_id --device_owner network:router_interface --network_id=${NETWORK_UUID}| awk '/([A-Fa-f0-9]+-){3}/ {print $2 "+" $4}' ); do p=$( echo "$line"| cut -d'+' -f1 ); r=$( echo "$line"| cut -d'+' -f2 ) echo "Removing Neutron router port $p from $r" neutron router-interface-delete $r port=$p done for agent in $( neutron agent-list -c id --agent_type='DHCP Agent' --network_id=${NETWORK_UUID}| awk '/([A-Fa-f0-9]+-){3}/ {print $2}' ); do echo "Remove network $NETWORK_UUID from Neutron DHCP Agent $agent" neutron dhcp-agent-network-remove "${agent}" $NETWORK_UUID done
删除 Neutron 网络
export NETWORK_UUID=<uuid> neutron net-delete $NETWORK_UUID
从 OpenStack-Ansible 配置
/etc/openstack_deploy/openstack_user_config.yml的provider_networks配置中删除提供商网络,然后重新运行以下 playbook# openstack-ansible lxc-containers-create.yml --limit infra01:infra01-host_containers # openstack-ansible lxc-containers-create.yml --limit infra02:infra02-host_containers # openstack-ansible lxc-containers-create.yml --limit infra03:infra03-host_containers # openstack-ansible os-neutron-install.yml --tags neutron-config
重启一个网络代理容器¶
在某些情况下,配置或临时问题,需要重启一个或所有 neutron 代理容器。
这可以通过多个命令完成
重启仍然可访问容器的示例。
此示例将向内部命名为
neutron_agents_container_hostname_name的容器发出重启命令# ansible -m shell neutron_agents_container_hostname_name -a 'reboot'
一次重启一个容器,间隔 60 秒的示例
# ansible -m shell neutron_agents_container -a 'sleep 60; reboot' --forks 1
如果容器没有响应,可以从物理网络主机重启它
# ansible -m shell network_hosts -a 'for c in $(lxc-ls -1 |grep neutron_agents_container); do lxc-stop -n $c && lxc-start -d -n $c; done' --forks 1