aboutsummaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorJustin chi <chigang@huawei.com>2017-03-27 10:15:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-03-27 10:15:49 +0000
commit4ef20a75da0cad69c05c8f4a91efb7e344f620a9 (patch)
tree366e6b150a3e1c1e6240be6410da47bc5653f22a /deploy
parent46fb076b06060a29bbae390e93bd03a3c441a094 (diff)
parent2932812260b57e7f67cef655ee2e043bf66b4887 (diff)
Merge "Support bond created"
Diffstat (limited to 'deploy')
-rw-r--r--deploy/adapters/cobbler/snippets/kickstart_post_install_network_config7
-rw-r--r--deploy/adapters/cobbler/snippets/preseed_post_install_network_config7
-rw-r--r--deploy/adapters/cobbler/snippets/preseed_software_ansible2
-rw-r--r--deploy/bonding.py41
-rw-r--r--deploy/conf/network_cfg.yaml18
-rwxr-xr-xdeploy/deploy_host.sh6
6 files changed, 74 insertions, 7 deletions
diff --git a/deploy/adapters/cobbler/snippets/kickstart_post_install_network_config b/deploy/adapters/cobbler/snippets/kickstart_post_install_network_config
index 2c089f92..1a5a7f66 100644
--- a/deploy/adapters/cobbler/snippets/kickstart_post_install_network_config
+++ b/deploy/adapters/cobbler/snippets/kickstart_post_install_network_config
@@ -426,9 +426,12 @@ declare -A used_logical_interfaces
used_logical_interfaces[$iname]=$iname
- #if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
+ #if $iface_type in ("slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
+ #if $ip == ""
+ #set $static = ""
+ #end if
echo "DEVICE=$iname" > $devfile
echo "ONBOOT=yes" >> $devfile
@@ -514,7 +517,7 @@ echo "GATEWAY=$if_gateway" >> $devfile
echo "NETMASK=$netmask" >> $devfile
#end if
#else
-echo "BOOTPROTO=dhcp" >> $devfile
+echo "BOOTPROTO=manual" >> $devfile
#if $len($name_servers) > 0
echo "PEERDNS=no" >> $devfile
#end if
diff --git a/deploy/adapters/cobbler/snippets/preseed_post_install_network_config b/deploy/adapters/cobbler/snippets/preseed_post_install_network_config
index a2abbf71..f15b6be2 100644
--- a/deploy/adapters/cobbler/snippets/preseed_post_install_network_config
+++ b/deploy/adapters/cobbler/snippets/preseed_post_install_network_config
@@ -434,15 +434,18 @@ echo "" >> /etc/network/interfaces
used_logical_interface_$iname=$iname
- #if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
+ #if $iface_type in ("slave","bridge_slave","bonded_bridge_slave")
#set $static = 1
#end if
+ #if $ip == ""
+ #set $static = ""
+ #end if
echo "auto $iname" >> /etc/network/interfaces
#if $static
echo "iface $iname inet static" >> /etc/network/interfaces
#else
-echo "iface $iname inet dhcp" >> /etc/network/interfaces
+echo "iface $iname inet manual" >> /etc/network/interfaces
#end if
#if $iface_type not in ("master","bond","bridge","bonded_bridge_slave")
diff --git a/deploy/adapters/cobbler/snippets/preseed_software_ansible b/deploy/adapters/cobbler/snippets/preseed_software_ansible
index cde79356..5516c893 100644
--- a/deploy/adapters/cobbler/snippets/preseed_software_ansible
+++ b/deploy/adapters/cobbler/snippets/preseed_software_ansible
@@ -1 +1 @@
-d-i pkgsel/include string ntp ssh openssh-server wget vim
+d-i pkgsel/include string ntp ssh openssh-server wget vim ifenslave
diff --git a/deploy/bonding.py b/deploy/bonding.py
new file mode 100644
index 00000000..27e76daa
--- /dev/null
+++ b/deploy/bonding.py
@@ -0,0 +1,41 @@
+import os
+import sys
+import yaml
+
+
+def exec_cmd(cmd):
+ print cmd
+ os.system(cmd)
+
+
+def create_bonding(network_info, rsa_file, compass_ip):
+ for bond in network_info['bond_mappings']:
+ bond_name = bond['name']
+ host_name = bond.get('host')
+ interfaces = bond.get('bond-slaves')
+ bond_mode = bond['bond-mode']
+ bond_miimon = bond['bond-miimon']
+ lacp_rate = bond['bond-lacp_rate']
+ xmit_hash_policy = bond['bond-xmit_hash_policy']
+ bond_mtu = bond['mtu']
+ if interfaces:
+ for host in host_name:
+ for interface in interfaces:
+ exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -i %s root@%s \
+ 'cobbler system edit --name=%s --interface=%s --interface-type=bond_slave --interface-master=%s'" # noqa
+ % (rsa_file, compass_ip, host, interface, bond_name)) # noqa
+
+ exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -i %s root@%s \
+ 'cobbler system edit --name=%s --interface=%s --interface-type=bond --bonding-opts=\"miimon=%s mode=%s lacp_rate=%s xmit_hash_policy=%s mtu=%s\"'" # noqa
+ % (rsa_file, compass_ip, host, bond_name, bond_miimon, bond_mode, lacp_rate, xmit_hash_policy, bond_mtu)) # noqa
+
+if __name__ == "__main__":
+ assert(len(sys.argv) == 4)
+ create_bonding(
+ yaml.load(
+ open(
+ sys.argv[1])),
+ sys.argv[2],
+ sys.argv[3])
diff --git a/deploy/conf/network_cfg.yaml b/deploy/conf/network_cfg.yaml
index 28224b66..5e704e80 100644
--- a/deploy/conf/network_cfg.yaml
+++ b/deploy/conf/network_cfg.yaml
@@ -9,7 +9,23 @@
---
nic_mappings: []
-bond_mappings: []
+
+bond_mappings:
+ - name: bond1
+ host:
+ - host1
+ - host2
+ - host3
+ - host4
+ - host5
+ bond-slaves:
+ - eth1
+ - eth2
+ bond-mode: 802.3ad
+ bond-miimon: 100
+ bond-lacp_rate: fast
+ bond-xmit_hash_policy: layer2
+ mtu: 9000
provider_net_mappings:
- name: br-prv
diff --git a/deploy/deploy_host.sh b/deploy/deploy_host.sh
index bf27b31a..8c863045 100755
--- a/deploy/deploy_host.sh
+++ b/deploy/deploy_host.sh
@@ -13,6 +13,10 @@ function rename_nics(){
python $COMPASS_DIR/deploy/rename_nics.py $DHA $rsa_file $MGMT_IP $OS_VERSION
}
+function add_bonding(){
+ python $COMPASS_DIR/deploy/bonding.py $NETWORK $rsa_file $MGMT_IP
+}
+
function deploy_host(){
export AYNC_TIMEOUT=20
ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/compass/bin/ansible_callbacks
@@ -22,7 +26,7 @@ function deploy_host(){
scp $ssh_args -r ${COMPASS_DIR}/deploy/adapters/ansible/ansible_modules/* root@${MGMT_IP}:/opt/ansible-modules
# avoid nodes reboot to fast, cobbler can not give response
- (sleep $AYNC_TIMEOUT; rename_nics; reboot_hosts) &
+ (sleep $AYNC_TIMEOUT; add_bonding; rename_nics; reboot_hosts) &
if [[ "$REDEPLOY_HOST" == true ]]; then
deploy_flag="redeploy"
else