sriov計算節點轉ovs計算節點指令碼
因為有時候需要更改計算節點的功能,批量將sriov計算節點轉成ovs計算節點。
就把手動修改的命令一條條排列組成指令碼,然後用ansible工具批量執行下面的將sriov計算節點,轉ovs計算節點的指令碼。
# cat sriov2ovs.bash # 關閉物理網絡卡sriov vf的配置 echo '0' > /sys/class/net/ens1f0/device/sriov_numvfs sed -i '/sriov_numvfs/d' /etc/rc.d/rc.local # stop neutron-sriov-nic-agent服務,並disable掉,因為要啟用neutron ovs服務 systemctl disable neutron-sriov-nic-agent systemctl stop neutron-sriov-nic-agent # 刪除nova.conf sriov直通白名單配置 sed -i '/passthrough_whitelist/d' /etc/nova/nova.conf systemctl restart openstack-nova-compute # 物理網絡卡配置 # configure bond (cat <<HERE TYPE=Ethernet BOOTPROTO=none NAME=ens1f0 DEVICE=ens1f0 ONBOOT=yes MASTER=bond1 SLAVE=yes HERE )> /etc/sysconfig/network-scripts/ifcfg-ens1f0 (cat <<HERE TYPE=Ethernet BOOTPROTO=none NAME=ens1f1 DEVICE=ens1f1 ONBOOT=yes MASTER=bond1 SLAVE=yes HERE )> /etc/sysconfig/network-scripts/ifcfg-ens1f1 (cat <<HERE BOOTPROTO=none DEVICE=bond1 ONBOOT=yes ## MTU=1500 TYPE=Bond BONDING_OPTS="mode=active-backup miimon=100" HERE )> /etc/sysconfig/network-scripts/ifcfg-bond1 # 修改對資料包源地址的校驗配置 sed -i '/net\.ipv4\.conf\.all\.rp_filter/d' /etc/rc.d/rc.local sed -i '/net\.ipv4\.conf\.default\.rp_filter/d' /etc/rc.d/rc.local sed -i '$a\net.ipv4.conf.all.rp_filter=0' /etc/sysctl.conf sed -i '$a\net.ipv4.conf.default.rp_filter=0' /etc/sysctl.conf sysctl -p # 安裝neutron-openvswitch等服務 yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch openvswitch # 配置openvswitch_agent.ini檔案,配置物理網絡卡到網橋的對映,並重啟網路相關服務 # neutron.conf # /etc/neutron/plugins/ml2/openvswitch_agent.ini (cat <<HERE [DEFAULT] [agent] extensions = qos [ovs] integration_bridge = br-int bridge_mappings = physnet1:br-prv [securitygroup] enable_ipset = true enable_security_group = true firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver HERE )> /etc/neutron/plugins/ml2/openvswitch_agent.ini systemctl enableopenvswitch.service systemctl restartopenvswitch.service systemctl statusopenvswitch.service # 增加之前配置物理網絡卡到網橋的對映的網橋和網絡卡連線 ovs-vsctl add-br br-prv ovs-vsctl add-port br-prv bond1 systemctl enable neutron-openvswitch-agent.service systemctl restart neutron-openvswitch-agent.service