Add ceph-network-info role to get the cluster network info and interface 61/37461/3
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>
Fri, 14 Jul 2017 04:46:31 +0000 (21:46 -0700)
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>
Mon, 17 Jul 2017 19:01:09 +0000 (12:01 -0700)
network info from ceph nodes.

JIRA: QTIP-254

Change-Id: Ibf37d60e4a15e4238df2f702eee47cb114808106
Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
resources/ansible_roles/ceph-network-info/meta/main.yml [new file with mode: 0644]
resources/ansible_roles/ceph-network-info/tasks/main.yml [new file with mode: 0644]
tests/data/external/sysinfo/ceph-network-info.log [new file with mode: 0644]

diff --git a/resources/ansible_roles/ceph-network-info/meta/main.yml b/resources/ansible_roles/ceph-network-info/meta/main.yml
new file mode 100644 (file)
index 0000000..4f5b88d
--- /dev/null
@@ -0,0 +1,14 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+---
+
+allow_duplicates: yes
+dependencies:
+  - { role: qtip-common, basename: ceph-network-info }
diff --git a/resources/ansible_roles/ceph-network-info/tasks/main.yml b/resources/ansible_roles/ceph-network-info/tasks/main.yml
new file mode 100644 (file)
index 0000000..7216d1a
--- /dev/null
@@ -0,0 +1,37 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+- name: get system network info
+  shell: netstat -nr |grep  "U" | awk '{printf "interface %s network %s mask  %s \n",$8,$1, $3 }' 
+  register: ceph_network_out
+
+- name: saving output to log
+  copy:
+    content: "{{ ceph_network_out.stdout }}"
+    dest: "{{ logfile }}"
+  delegate_to: localhost
+
+- fetch:
+    src: /etc/ceph/ceph.conf
+    dest: "{{ qtip_results }}/sysinfo-{{ inventory_hostname }}/"
+    flat: yes
+
+- name: collect ceph system info from ceph.conf
+  set_fact: {"{{ item }}":"{{ lookup('ini', '{{ item }} section=global default='' file={{ qtip_results }}/sysinfo-{{ inventory_hostname }}/ceph.conf')  }}"}
+  with_items:
+      - cluster_network
+  delegate_to: localhost
+
+- name: append 
+  lineinfile:
+      dest: "{{ logfile }}"
+      line: "cluster_network {{ cluster_network }}"
+      insertafter: EOF
+  delegate_to: localhost
diff --git a/tests/data/external/sysinfo/ceph-network-info.log b/tests/data/external/sysinfo/ceph-network-info.log
new file mode 100644 (file)
index 0000000..5856ff5
--- /dev/null
@@ -0,0 +1,7 @@
+interface eth2 network 0.0.0.0 mask  0.0.0.0 
+interface eth1 network 11.0.0.0 mask  255.255.255.0 
+interface eth3 network 12.0.0.0 mask  255.255.255.0 
+interface eth0 network 169.254.169.254 mask  255.255.255.255 
+interface eth0 network 192.0.2.0 mask  255.255.255.0 
+interface eth2 network 192.168.37.0 mask  255.255.255.0 
+cluster_network 12.0.0.22/24