aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/bonding.py
diff options
context:
space:
mode:
authorliyuenan <liyuenan@huawei.com>2017-03-14 15:55:08 +0800
committerliyuenan <liyuenan@huawei.com>2017-03-14 15:55:08 +0800
commit2932812260b57e7f67cef655ee2e043bf66b4887 (patch)
tree8993dc1cb40a2fc36db9cac1c883370731770a69 /deploy/bonding.py
parent267fd18d744ab641338eb144e0b4cb768f323cac (diff)
Support bond created
JIRA: - You can add bond according to deploy/conf/network_cfg.yaml. Change-Id: I70f2f03581cf763dbaf7a8a47bdbd46b66620fcb Signed-off-by: liyuenan <liyuenan@huawei.com>
Diffstat (limited to 'deploy/bonding.py')
-rw-r--r--deploy/bonding.py41
1 files changed, 41 insertions, 0 deletions
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])