summaryrefslogtreecommitdiff
path: root/oam
diff options
context:
space:
mode:
authorbsdbc <[email protected]>2019-04-02 09:52:52 +0800
committerbsdbc <[email protected]>2019-04-02 09:52:52 +0800
commit4f1a03aeb9329361e7e7c316a4baeaea2dd49518 (patch)
tree47fe65efc58dd9c299828b82380f6b2d7fbb038b /oam
parent48f09fa63d5bfba5ab4d9b416e7f26cb5110c5f6 (diff)
init import
Diffstat (limited to 'oam')
-rw-r--r--oam/OAM安装文档.docbin0 -> 122880 bytes
-rw-r--r--oam/oam_install/A016/master/script/collector.zipbin0 -> 9625 bytes
-rw-r--r--oam/oam_install/A016/master/script/device_config231
-rw-r--r--oam/oam_install/A016/slave/collector.zipbin0 -> 8370 bytes
-rw-r--r--oam/oam_install/A016/slave/device_config231
-rw-r--r--oam/oam_install/OAM安装文档.docbin0 -> 122880 bytes
-rw-r--r--oam/oam_install/T102/script/collector.zipbin0 -> 9661 bytes
-rw-r--r--oam/oam_install/T102/script/device_config231
-rw-r--r--oam/oam_install/db/oam.db.A016bin0 -> 3526656 bytes
-rw-r--r--oam/oam_install/db/oam.db.T102bin0 -> 3526656 bytes
-rw-r--r--oam/oam_install/install.sh344
-rw-r--r--oam/oam_install/process/oam.zipbin0 -> 61190153 bytes
-rw-r--r--oam/oam_install/rpm/bc-1.06.95-13.el7.x86_64.rpmbin0 -> 117272 bytes
-rw-r--r--oam/oam_install/rpm/libsensors3-3.4.0-alt4.x86_64.rpmbin0 -> 25456 bytes
-rw-r--r--oam/oam_install/rpm/net-tools-2.0-0.22.20131004git.el7.x86_64.rpmbin0 -> 312764 bytes
-rw-r--r--oam/oam_install/rpm/sysstat-10.1.5-13.el7.x86_64.rpmbin0 -> 317864 bytes
16 files changed, 1037 insertions, 0 deletions
diff --git a/oam/OAM安装文档.doc b/oam/OAM安装文档.doc
new file mode 100644
index 0000000..829b92b
--- /dev/null
+++ b/oam/OAM安装文档.doc
Binary files differ
diff --git a/oam/oam_install/A016/master/script/collector.zip b/oam/oam_install/A016/master/script/collector.zip
new file mode 100644
index 0000000..fc8c004
--- /dev/null
+++ b/oam/oam_install/A016/master/script/collector.zip
Binary files differ
diff --git a/oam/oam_install/A016/master/script/device_config b/oam/oam_install/A016/master/script/device_config
new file mode 100644
index 0000000..5106aaa
--- /dev/null
+++ b/oam/oam_install/A016/master/script/device_config
@@ -0,0 +1,231 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+# created by zhangbin
+from sys import argv
+import json
+import os
+from pprint import pprint
+import shutil
+
+def update_route(data):
+ list = []
+ route_path = '/etc/sysconfig/static-routes'
+ requestOldParam = 'any net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' + \
+ data['interface']
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ result2 = os.system(
+ 'route del -net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ if (result2 != 0):
+ print(result)
+ return
+ # �޸������ļ����·����Ϣ
+ with open(route_path, 'r+') as f_route:
+ lines = f_route.readlines()
+ for line in reversed(lines):
+ if (requestOldParam in line):
+ list.append('any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface'] + '\n')
+ else:
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+def new_route(data):
+ # �����·��
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] +' '+data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ route_path = '/etc/sysconfig/static-routes'
+ # ����·����Ϣ��ӵ��ļ���
+ result = os.path.exists(route_path)
+ if (result == False):
+ with open(route_path, 'w') as f:
+ f.close()
+ with open(route_path, 'r+') as f:
+ strData = 'any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface']
+ f.seek(0, 2)
+ f.write('\n' + strData)
+
+
+def remove_route(data):
+ #ɾ��·����Ϣ
+ route_path = '/etc/sysconfig/static-routes'
+ list = []
+ requestParam='any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + data['interface']
+ result = os.system(
+ 'route del -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ with open(route_path, 'r+')as f_route:
+ lines = f_route.readlines()
+ for line in lines:
+ if (not requestParam in line):
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+# ����ת��
+def exchange_maskint(mask_int):
+ bin_arr = ['0' for i in range(32)]
+ for i in range(mask_int):
+ bin_arr[i] = '1'
+ tmpmask = [''.join(bin_arr[i * 8:i * 8 + 8]) for i in range(4)]
+ tmpmask = [str(int(tmpstr, 2)) for tmpstr in tmpmask]
+ return '.'.join(tmpmask)
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_route():
+ path = '/etc/sysconfig/static-routes'
+ list = []
+ if(os.path.exists(path)):
+ with open(path, 'a+') as f:
+ content=f.readlines()
+ for i in content:
+ if(not i.strip('\n')==''):
+ data=i.split(' ')
+ result = {}
+ result['destination_ip'] = data[2]
+ result['ip_mask'] = data[4]
+ result['gateway'] = data[6]
+ result['r_interface'] = data[7]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_single_route(data): # ����洢��list
+ path = '/etc/sysconfig/network-scripts/route-'
+ list = []
+ with open(path + data, 'a+') as f:
+ content = f.readline()
+ a = content.split()
+ b = a[0].split('/')
+ result = {}
+ result['destination_ip'] = b[0]
+ result['ip_mask'] = exchange_maskint(int(b[1]))
+ result['gateway'] = a[2]
+ result['r_interface'] = a[4]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ�������õ���Ϣ
+def query_all_config():
+ path = '/etc/sysconfig/network-scripts/'
+ list = []
+ for file in os.listdir(path):
+ if ('ifcfg-e' in file and not('.' in file)):
+ with open(path + file, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content.strip()):
+ if (not (content.strip().startswith('#'))):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ if(result):
+ if('IPADDR' in result.keys()):
+ if(not result['IPADDR'].strip()==''):
+ list.append(result)
+ return list
+'''
+def query_all_config():
+ networknames=get_networkName()
+ path = '/etc/sysconfig/network-scripts/ifcfg-'
+ list = []
+ for networkname in networknames:
+ with open(path + networkname, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ list.append(result)
+ return list
+'''
+#��ȡ������������
+def get_networkName():
+ result = os.popen("ifconfig | awk '/^[a-z]/{print $1}'").readlines()
+ list = []
+ for i in result:
+ if (i.strip("\n") == 'lo'):
+ break
+ list.append(i.strip("\n"))
+ return list
+
+# �޸�������Ϣ
+def modify_config(data):
+ path = '/etc/sysconfig/network-scripts/'
+ path2 = '/tmp/'
+ # list��ΪN������
+ list = data['request']
+ for i in range(len(list)):
+ dic = {}
+ if (not (':' in list[i]['DEVICE'])):
+ with open(path + 'ifcfg-' + list[i]['DEVICE'], 'r+') as f:
+ for line in f:
+ (key, value) = line.strip().split('=')
+ dic[key] = value
+ dic['HWADDR'] = list[i]['HWADDR']
+ dic['NETMASK'] = list[i]['NETMASK']
+ dic['GATEWAY'] = list[i]['GATEWAY']
+ dic['IPADDR'] = list[i]['IPADDR']
+ list2 = []
+ for key in dic:
+ list2.append(key + '=' + dic[key] + '\n')
+ with open(path2 + 'ifcfg-' + list[i]['DEVICE'], 'w+') as f2:
+ f2.writelines(list2)
+
+ if (os.path.exists(path + 'ifcfg-' + list[i]['DEVICE'])):
+ os.remove(path + 'ifcfg-' + list[i]['DEVICE'])
+ shutil.move(path2 + 'ifcfg-' + list[i]['DEVICE'], path)
+ # �޸�������Ϣ�� ��������
+ os.system('service network restart')
+
+
+if __name__ == '__main__':
+ path_manage = '/etc/sysconfig/network-scripts/ifcfg-unknown2'
+ data = json.loads(argv[1])[0]
+ if data['type'] == '1':
+ list=get_networkName()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '2':
+ update_route(data)
+ elif data['type'] == '3':
+ remove_route(data)
+ elif data['type'] == '4':
+ new_route(data)
+ elif data['type'] == '5':
+ list = query_route()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '6':
+ modify_config(data)
+ elif data['type'] == '7':
+ list = query_all_config()
+ if(list):
+ print(json.dumps(list))
+ exit(0)
diff --git a/oam/oam_install/A016/slave/collector.zip b/oam/oam_install/A016/slave/collector.zip
new file mode 100644
index 0000000..50091c7
--- /dev/null
+++ b/oam/oam_install/A016/slave/collector.zip
Binary files differ
diff --git a/oam/oam_install/A016/slave/device_config b/oam/oam_install/A016/slave/device_config
new file mode 100644
index 0000000..5106aaa
--- /dev/null
+++ b/oam/oam_install/A016/slave/device_config
@@ -0,0 +1,231 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+# created by zhangbin
+from sys import argv
+import json
+import os
+from pprint import pprint
+import shutil
+
+def update_route(data):
+ list = []
+ route_path = '/etc/sysconfig/static-routes'
+ requestOldParam = 'any net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' + \
+ data['interface']
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ result2 = os.system(
+ 'route del -net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ if (result2 != 0):
+ print(result)
+ return
+ # �޸������ļ����·����Ϣ
+ with open(route_path, 'r+') as f_route:
+ lines = f_route.readlines()
+ for line in reversed(lines):
+ if (requestOldParam in line):
+ list.append('any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface'] + '\n')
+ else:
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+def new_route(data):
+ # �����·��
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] +' '+data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ route_path = '/etc/sysconfig/static-routes'
+ # ����·����Ϣ��ӵ��ļ���
+ result = os.path.exists(route_path)
+ if (result == False):
+ with open(route_path, 'w') as f:
+ f.close()
+ with open(route_path, 'r+') as f:
+ strData = 'any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface']
+ f.seek(0, 2)
+ f.write('\n' + strData)
+
+
+def remove_route(data):
+ #ɾ��·����Ϣ
+ route_path = '/etc/sysconfig/static-routes'
+ list = []
+ requestParam='any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + data['interface']
+ result = os.system(
+ 'route del -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ with open(route_path, 'r+')as f_route:
+ lines = f_route.readlines()
+ for line in lines:
+ if (not requestParam in line):
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+# ����ת��
+def exchange_maskint(mask_int):
+ bin_arr = ['0' for i in range(32)]
+ for i in range(mask_int):
+ bin_arr[i] = '1'
+ tmpmask = [''.join(bin_arr[i * 8:i * 8 + 8]) for i in range(4)]
+ tmpmask = [str(int(tmpstr, 2)) for tmpstr in tmpmask]
+ return '.'.join(tmpmask)
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_route():
+ path = '/etc/sysconfig/static-routes'
+ list = []
+ if(os.path.exists(path)):
+ with open(path, 'a+') as f:
+ content=f.readlines()
+ for i in content:
+ if(not i.strip('\n')==''):
+ data=i.split(' ')
+ result = {}
+ result['destination_ip'] = data[2]
+ result['ip_mask'] = data[4]
+ result['gateway'] = data[6]
+ result['r_interface'] = data[7]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_single_route(data): # ����洢��list
+ path = '/etc/sysconfig/network-scripts/route-'
+ list = []
+ with open(path + data, 'a+') as f:
+ content = f.readline()
+ a = content.split()
+ b = a[0].split('/')
+ result = {}
+ result['destination_ip'] = b[0]
+ result['ip_mask'] = exchange_maskint(int(b[1]))
+ result['gateway'] = a[2]
+ result['r_interface'] = a[4]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ�������õ���Ϣ
+def query_all_config():
+ path = '/etc/sysconfig/network-scripts/'
+ list = []
+ for file in os.listdir(path):
+ if ('ifcfg-e' in file and not('.' in file)):
+ with open(path + file, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content.strip()):
+ if (not (content.strip().startswith('#'))):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ if(result):
+ if('IPADDR' in result.keys()):
+ if(not result['IPADDR'].strip()==''):
+ list.append(result)
+ return list
+'''
+def query_all_config():
+ networknames=get_networkName()
+ path = '/etc/sysconfig/network-scripts/ifcfg-'
+ list = []
+ for networkname in networknames:
+ with open(path + networkname, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ list.append(result)
+ return list
+'''
+#��ȡ������������
+def get_networkName():
+ result = os.popen("ifconfig | awk '/^[a-z]/{print $1}'").readlines()
+ list = []
+ for i in result:
+ if (i.strip("\n") == 'lo'):
+ break
+ list.append(i.strip("\n"))
+ return list
+
+# �޸�������Ϣ
+def modify_config(data):
+ path = '/etc/sysconfig/network-scripts/'
+ path2 = '/tmp/'
+ # list��ΪN������
+ list = data['request']
+ for i in range(len(list)):
+ dic = {}
+ if (not (':' in list[i]['DEVICE'])):
+ with open(path + 'ifcfg-' + list[i]['DEVICE'], 'r+') as f:
+ for line in f:
+ (key, value) = line.strip().split('=')
+ dic[key] = value
+ dic['HWADDR'] = list[i]['HWADDR']
+ dic['NETMASK'] = list[i]['NETMASK']
+ dic['GATEWAY'] = list[i]['GATEWAY']
+ dic['IPADDR'] = list[i]['IPADDR']
+ list2 = []
+ for key in dic:
+ list2.append(key + '=' + dic[key] + '\n')
+ with open(path2 + 'ifcfg-' + list[i]['DEVICE'], 'w+') as f2:
+ f2.writelines(list2)
+
+ if (os.path.exists(path + 'ifcfg-' + list[i]['DEVICE'])):
+ os.remove(path + 'ifcfg-' + list[i]['DEVICE'])
+ shutil.move(path2 + 'ifcfg-' + list[i]['DEVICE'], path)
+ # �޸�������Ϣ�� ��������
+ os.system('service network restart')
+
+
+if __name__ == '__main__':
+ path_manage = '/etc/sysconfig/network-scripts/ifcfg-unknown2'
+ data = json.loads(argv[1])[0]
+ if data['type'] == '1':
+ list=get_networkName()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '2':
+ update_route(data)
+ elif data['type'] == '3':
+ remove_route(data)
+ elif data['type'] == '4':
+ new_route(data)
+ elif data['type'] == '5':
+ list = query_route()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '6':
+ modify_config(data)
+ elif data['type'] == '7':
+ list = query_all_config()
+ if(list):
+ print(json.dumps(list))
+ exit(0)
diff --git a/oam/oam_install/OAM安装文档.doc b/oam/oam_install/OAM安装文档.doc
new file mode 100644
index 0000000..829b92b
--- /dev/null
+++ b/oam/oam_install/OAM安装文档.doc
Binary files differ
diff --git a/oam/oam_install/T102/script/collector.zip b/oam/oam_install/T102/script/collector.zip
new file mode 100644
index 0000000..803e439
--- /dev/null
+++ b/oam/oam_install/T102/script/collector.zip
Binary files differ
diff --git a/oam/oam_install/T102/script/device_config b/oam/oam_install/T102/script/device_config
new file mode 100644
index 0000000..5106aaa
--- /dev/null
+++ b/oam/oam_install/T102/script/device_config
@@ -0,0 +1,231 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+# created by zhangbin
+from sys import argv
+import json
+import os
+from pprint import pprint
+import shutil
+
+def update_route(data):
+ list = []
+ route_path = '/etc/sysconfig/static-routes'
+ requestOldParam = 'any net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' + \
+ data['interface']
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ result2 = os.system(
+ 'route del -net ' + data['destination_ip_old'] + ' netmask ' + data['ip_mask_old'] + ' gw ' + data['gateway_old'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ if (result2 != 0):
+ print(result)
+ return
+ # �޸������ļ����·����Ϣ
+ with open(route_path, 'r+') as f_route:
+ lines = f_route.readlines()
+ for line in reversed(lines):
+ if (requestOldParam in line):
+ list.append('any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface'] + '\n')
+ else:
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+def new_route(data):
+ # �����·��
+ result = os.system(
+ 'route add -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] +' '+data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ route_path = '/etc/sysconfig/static-routes'
+ # ����·����Ϣ��ӵ��ļ���
+ result = os.path.exists(route_path)
+ if (result == False):
+ with open(route_path, 'w') as f:
+ f.close()
+ with open(route_path, 'r+') as f:
+ strData = 'any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + \
+ data['interface']
+ f.seek(0, 2)
+ f.write('\n' + strData)
+
+
+def remove_route(data):
+ #ɾ��·����Ϣ
+ route_path = '/etc/sysconfig/static-routes'
+ list = []
+ requestParam='any net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' + data['interface']
+ result = os.system(
+ 'route del -net ' + data['destination_ip'] + ' netmask ' + data['ip_mask'] + ' gw ' + data['gateway'] + ' ' +
+ data['interface'])
+ # ��������쳣����ֹ����
+ if (result != 0):
+ print(result)
+ return
+ with open(route_path, 'r+')as f_route:
+ lines = f_route.readlines()
+ for line in lines:
+ if (not requestParam in line):
+ list.append(line)
+ f_route.seek(0)
+ f_route.truncate()
+ f_route.writelines(list)
+
+
+# ����ת��
+def exchange_maskint(mask_int):
+ bin_arr = ['0' for i in range(32)]
+ for i in range(mask_int):
+ bin_arr[i] = '1'
+ tmpmask = [''.join(bin_arr[i * 8:i * 8 + 8]) for i in range(4)]
+ tmpmask = [str(int(tmpstr, 2)) for tmpstr in tmpmask]
+ return '.'.join(tmpmask)
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_route():
+ path = '/etc/sysconfig/static-routes'
+ list = []
+ if(os.path.exists(path)):
+ with open(path, 'a+') as f:
+ content=f.readlines()
+ for i in content:
+ if(not i.strip('\n')==''):
+ data=i.split(' ')
+ result = {}
+ result['destination_ip'] = data[2]
+ result['ip_mask'] = data[4]
+ result['gateway'] = data[6]
+ result['r_interface'] = data[7]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ����·�ɵ���Ϣ
+def query_single_route(data): # ����洢��list
+ path = '/etc/sysconfig/network-scripts/route-'
+ list = []
+ with open(path + data, 'a+') as f:
+ content = f.readline()
+ a = content.split()
+ b = a[0].split('/')
+ result = {}
+ result['destination_ip'] = b[0]
+ result['ip_mask'] = exchange_maskint(int(b[1]))
+ result['gateway'] = a[2]
+ result['r_interface'] = a[4]
+ if(result):
+ list.append(result)
+ return list
+
+
+# ��ȡ�������õ���Ϣ
+def query_all_config():
+ path = '/etc/sysconfig/network-scripts/'
+ list = []
+ for file in os.listdir(path):
+ if ('ifcfg-e' in file and not('.' in file)):
+ with open(path + file, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content.strip()):
+ if (not (content.strip().startswith('#'))):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ if(result):
+ if('IPADDR' in result.keys()):
+ if(not result['IPADDR'].strip()==''):
+ list.append(result)
+ return list
+'''
+def query_all_config():
+ networknames=get_networkName()
+ path = '/etc/sysconfig/network-scripts/ifcfg-'
+ list = []
+ for networkname in networknames:
+ with open(path + networkname, 'a+') as f:
+ result = {}
+ content = f.readline()
+ while (content):
+ res = content.split('=')
+ result[res[0]] = res[1].rstrip('\n').rstrip()
+ content = f.readline()
+ list.append(result)
+ return list
+'''
+#��ȡ������������
+def get_networkName():
+ result = os.popen("ifconfig | awk '/^[a-z]/{print $1}'").readlines()
+ list = []
+ for i in result:
+ if (i.strip("\n") == 'lo'):
+ break
+ list.append(i.strip("\n"))
+ return list
+
+# �޸�������Ϣ
+def modify_config(data):
+ path = '/etc/sysconfig/network-scripts/'
+ path2 = '/tmp/'
+ # list��ΪN������
+ list = data['request']
+ for i in range(len(list)):
+ dic = {}
+ if (not (':' in list[i]['DEVICE'])):
+ with open(path + 'ifcfg-' + list[i]['DEVICE'], 'r+') as f:
+ for line in f:
+ (key, value) = line.strip().split('=')
+ dic[key] = value
+ dic['HWADDR'] = list[i]['HWADDR']
+ dic['NETMASK'] = list[i]['NETMASK']
+ dic['GATEWAY'] = list[i]['GATEWAY']
+ dic['IPADDR'] = list[i]['IPADDR']
+ list2 = []
+ for key in dic:
+ list2.append(key + '=' + dic[key] + '\n')
+ with open(path2 + 'ifcfg-' + list[i]['DEVICE'], 'w+') as f2:
+ f2.writelines(list2)
+
+ if (os.path.exists(path + 'ifcfg-' + list[i]['DEVICE'])):
+ os.remove(path + 'ifcfg-' + list[i]['DEVICE'])
+ shutil.move(path2 + 'ifcfg-' + list[i]['DEVICE'], path)
+ # �޸�������Ϣ�� ��������
+ os.system('service network restart')
+
+
+if __name__ == '__main__':
+ path_manage = '/etc/sysconfig/network-scripts/ifcfg-unknown2'
+ data = json.loads(argv[1])[0]
+ if data['type'] == '1':
+ list=get_networkName()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '2':
+ update_route(data)
+ elif data['type'] == '3':
+ remove_route(data)
+ elif data['type'] == '4':
+ new_route(data)
+ elif data['type'] == '5':
+ list = query_route()
+ if(list):
+ print(json.dumps(list))
+ elif data['type'] == '6':
+ modify_config(data)
+ elif data['type'] == '7':
+ list = query_all_config()
+ if(list):
+ print(json.dumps(list))
+ exit(0)
diff --git a/oam/oam_install/db/oam.db.A016 b/oam/oam_install/db/oam.db.A016
new file mode 100644
index 0000000..15aa37e
--- /dev/null
+++ b/oam/oam_install/db/oam.db.A016
Binary files differ
diff --git a/oam/oam_install/db/oam.db.T102 b/oam/oam_install/db/oam.db.T102
new file mode 100644
index 0000000..5c42d65
--- /dev/null
+++ b/oam/oam_install/db/oam.db.T102
Binary files differ
diff --git a/oam/oam_install/install.sh b/oam/oam_install/install.sh
new file mode 100644
index 0000000..13c6081
--- /dev/null
+++ b/oam/oam_install/install.sh
@@ -0,0 +1,344 @@
+#!/bin/bash
+#trap 'rm -rf /home/ceiec/oam;rm -rf /home/ceiec/collector;' EXIT
+#带颜色输出内容
+#$1 颜色 red green yellow 警告 red 成功 green 提示/输入 yellow
+#$2 输出语句
+#$3 -n y/n 是否换行输出
+function pinfo(){
+ LINE=""
+ if [[ "$#" -gt 2 ]]; then
+ #statements
+ if [[ "$3" = "n" ]]; then
+ #statements
+ LINE="-n"
+ fi
+ fi
+ case $1 in
+ "red")
+ echo -e $LINE "\e[1;31m "${2}"\e[0m"
+ ;;
+ "green")
+ echo -e $LINE "\e[1;32m "${2}"\e[0m"
+ ;;
+ "yellow")
+ echo -e $LINE "\e[1;33m "${2}"\e[0m"
+ ;;
+ "blue")
+ echo -e $LINE "\e[1;34m "${2}"\e[0m"
+ ;;
+ *)
+ echo $LINE $2
+ ;;
+ esac
+}
+
+READ_NOTNULL_TEMP=""
+function read_notNull(){
+ echo -n "$1"
+ stty erase '^H'
+ read READ_NOTNULL_TEMP
+ length=$#
+ if [[ length -gt 1 ]]; then #参数大于1个,验证输入是否正确
+ #statements
+ FLAG=0
+ while [[ true ]]; do
+ #statements
+ for i in "$@"; do
+ if [[ "$READ_NOTNULL_TEMP" = "$i" ]]; then
+ #statements
+ FLAG=1
+ break
+ fi
+ done
+ if [[ "$FLAG" = 1 ]]; then
+ #statements
+ break
+ else
+ echo "input failed,please input again!"
+ echo -n "$1"
+ read READ_NOTNULL_TEMP
+ fi
+ done
+
+
+ else
+ while [ -z "$READ_NOTNULL_TEMP" ]
+ do
+ echo "input is empty,please input again!"
+ echo -n "$1"
+ read READ_NOTNULL_TEMP
+ done
+ fi
+
+}
+
+
+function modify_file(){
+ if [ $# != 2 ]
+ then
+ echo "usage: modify_file [prop_name] [prop_value]"
+ exit 0
+ fi
+ prop_name="$1"
+ prop_value="$2"
+ echo "modify_file $PROP_FILE: $prop_name $prop_value"
+ if [ -z "$(cat $PROP_FILE |grep $prop_name)" ]
+ then
+ echo "" >> $PROP_FILE
+ echo "$prop_name=$prop_value" >> $PROP_FILE
+ else
+ sed -i "s|^$prop_name.*|$prop_name=$prop_value|" $PROP_FILE
+ fi
+}
+
+#当前目录
+temp=`dirname $0`
+CURDIR=`cd $temp;pwd`
+
+#设备类型
+DEVICE='ADC-A016'
+#java打包程序路径
+PROC_PATH=${CURDIR}"/process/oam.zip"
+#脚本及配置文件路径
+SCRIPT_HOME=${CURDIR}"/A016/master/script"
+#安装路径
+OAM_HOME="/home/ceiec"
+#配置文件路径
+CONFIG_FILE="/home/ceiec/oam/conf/config.properties"
+read_notNull 'please input device type[ASEM-T102/ADC-A016](t/a):' t a
+device_type="$READ_NOTNULL_TEMP"
+
+is_master="1"
+#安装类型标志 1 A106 master 2 A106 slave 3 T102
+role=-1
+DB_FILE="oam.db.A016"
+if [ "t" = "$device_type" ];then
+ DEVICE="ASEM-T102"
+ SCRIPT_HOME=${CURDIR}"/T102/script"
+ DB_FILE="oam.db.T102"
+ role=3
+else
+ role=1
+ read_notNull 'please input install as master or slave (m/s)' m s
+ flag="$READ_NOTNULL_TEMP"
+ #echo "$flag"
+ if [ "s" = "$flag" ];then
+ is_master="0"
+ role=2
+ fi
+fi
+#echo "is_master:$is_master"
+#安装java程序
+if [ "$is_master" = "1" ];then
+ pinfo green "install oam program..."
+ unzip $PROC_PATH -d $OAM_HOME >/dev/null
+ if [ $? = 1 ];then
+ pinfo red "install FAILD."
+ exit 0
+ fi
+ PROP_FILE="$CONFIG_FILE"
+ modify_file 'equipment_name' $DEVICE
+
+ cp ${CURDIR}"/db/$DB_FILE" ${OAM_HOME}"/oam/db/oam.db"
+ read_notNull 'start oam right now?(y/n)' y n
+ start="$READ_NOTNULL_TEMP"
+ if [ "$start" = 'y' ];then
+ pinfo green "now start program..."
+ bash ${OAM_HOME}"/oam/shell/startup.sh" >/dev/null 2>$1
+ if [ $? = 0 ];then
+ pinfo green "start SUCCESS"
+ else
+ pinfo red "start FAILD.check \"$OAM_HOME/oam/log/gloam.log\" for help..."
+ exit 0
+ fi
+ else
+ echo "please start program with \"$OAM_HOME/oam/shell/startup.sh\""
+ fi
+fi
+
+enter_password=""
+function readPasswd(){
+ enter_password=""
+ stty -echo cbreak erase '^H'
+ while true
+ do
+ character=$(dd if=/dev/tty bs=1 count=1 2> /dev/null)
+ case $character in
+ $(echo -e "\n"))
+ break
+ ;;
+ $(echo -e "\b"))
+ if [ -z "$enter_password" ]; then
+ echo -n -e "\b \b"
+ enter_password=$(echo "$password" | sed 's/.$//g')
+ fi
+ ;;
+ *)
+ enter_password=$enter_password$character
+ echo -n '*'
+ ;;
+ esac
+ done
+ stty -cbreak echo
+ echo ""
+}
+
+enter_info=""
+function readInfo_notNull(){
+ if [ $# != 1 ];then
+ echo "usage:readInfo_notNull [hint]"
+ exit 1
+ fi
+ hint="$1"
+ stty erase '^H'
+ read -p "$hint:" enter_info
+ while [ -z "enter_info" ];do
+ read -p "this parameter is must,please input again:" enter_info
+ done
+
+}
+NODE_ID=""
+function getNodeIdByIP(){
+ if [ $# != 1 ];then
+ echo "usage:getNodeIdByIP [node_ip]"
+ exit 1
+ fi
+ node_ip="$1"
+ NODE_ID=$(sqlite3 ${CURDIR}"/db/$DB_FILE" <<EOF |awk '{print $0}'
+ select id from node_table where ip="$node_ip";
+EOF
+)
+echo "NODE_ID=$NODE_ID"
+}
+
+#安装脚本程序方法
+function installScript(){
+ if [ $# != 1 ];then
+ echo "usage:installScript [script_dir]"
+ fi
+ script_dir=$1
+
+ read -p "please input script file home[default /home/ceiec]:" script_home
+ if [ -z "$script_home" ];then
+ script_home="/home/ceiec"
+ else
+ if [ ! -d "$script_home" ];then
+ mkdir -p "$script_home"
+ fi
+ fi
+
+ #echo "$script_home"
+ unzip ${script_dir}"/collector.zip" -d "$script_home" >/dev/null
+ if [ $? != 0 ];then
+ pinfo red "script file unzip FAILD"
+ exit 1
+ fi
+ cd ${script_home}"/collector"
+ #修改主机配置文件config
+ if [[ -f config ]];then
+ for i in 1 2 3 4
+ do
+ ipinfo=$(sqlite3 ${CURDIR}"/db/"${DB_FILE} <<EOF |awk -va="$i" 'NR==a{print $0}'
+ select ip||","||user||","||pwd from node_table;
+EOF
+)
+ #写入配置
+ PROP_FILE="$script_home/collector/config"
+ modify_file 'ip'${i} "$ipinfo"
+ if [ "t" = "$device_type" ];then
+ break
+ fi
+ done
+
+ #key src_dir
+ srcDir="$script_home"
+
+ #key dest_dir
+ destDir="$script_home"
+
+ #写入配置
+ PROP_FILE="$script_home/collector/config"
+ modify_file 'src_dir' "$srcDir"
+ modify_file 'dest_dir' "$destDir"
+ fi
+ #为脚本授权
+ chmod +x *.sh
+ if [ -f expect_scp ];then
+ chmod +x expect_scp
+ fi
+
+ #新建定时任务
+ if [ -z "$(grep "$script_home/collector/getSingleMacInfo.sh" /var/spool/cron/root | grep -v 'grep' 2>/dev/null)" ];then
+ echo "*/5 * * * * $script_home/collector/getSingleMacInfo.sh" >>/var/spool/cron/root
+ fi
+
+ if [[ -f ${script_home}"/collector/merge.sh" && -z "$(grep "$script_home/collector/merge.sh" /var/spool/cron/root |grep -v 'grep' 2>/dev/null)" ]];then
+ echo "*/1 * * * * $script_home/collector/merge.sh">>/var/spool/cron/root
+ fi
+
+ #处理configs目录下配置文件
+ cd ${script_home}"/collector/configs"
+ <<UNUSE
+ cpu="cpu_cpu.cfg"
+ disk="disk_disk.cfg"
+ mem="memory_memory.cfg"
+ net="net_net.cfg"
+ sys="systeminfo_servicessysinfo.cfg"
+UNUSE
+ #获取node_table的id
+ readInfo_notNull "please input the localhost"
+ #只针对ADC-A016
+ ip="$enter_info"
+ getNodeIdByIP "$ip"
+ while [ -z "$NODE_ID" ];do
+ #获取node_table的id
+ readInfo_notNull "this ip is not exist,please input the device ip again"
+ #只针对ADC-A016
+ ip="$enter_info"
+ getNodeIdByIP "$ip"
+
+ done
+ node_id="$NODE_ID"
+ for file in *
+ do
+ temp=$(awk 'NR==1{print $0}' $file|cut -d'=' -f2)
+ value=${node_id}${temp}
+ PROP_FILE=$(readlink -f "$file")
+ modify_file 'pubInfo' "$value"
+ done
+
+ #处理device_config 脚本
+ if [ ! -f '/usr/local/bin/device_config' ];then
+ cp $script_dir/device_config /usr/local/bin
+ if [ $? = 0 ];then
+ chmod +x /usr/local/bin/device_config
+ fi
+ fi
+
+
+
+}
+
+#安装脚本程序
+case $role in
+1 )
+ installScript "$SCRIPT_HOME"
+;;
+2 )
+ SCRIPT_HOME="${CURDIR}/A016/slave"
+ installScript "$SCRIPT_HOME"
+;;
+3 )
+ SCRIPT_HOME="${CURDIR}/T102/script"
+ installScript "$SCRIPT_HOME"
+;;
+
+* )
+ pinfo red "`basename $0` exec error "
+ exit 1
+;;
+esac
+
+
+
+
diff --git a/oam/oam_install/process/oam.zip b/oam/oam_install/process/oam.zip
new file mode 100644
index 0000000..49f4f8c
--- /dev/null
+++ b/oam/oam_install/process/oam.zip
Binary files differ
diff --git a/oam/oam_install/rpm/bc-1.06.95-13.el7.x86_64.rpm b/oam/oam_install/rpm/bc-1.06.95-13.el7.x86_64.rpm
new file mode 100644
index 0000000..132a501
--- /dev/null
+++ b/oam/oam_install/rpm/bc-1.06.95-13.el7.x86_64.rpm
Binary files differ
diff --git a/oam/oam_install/rpm/libsensors3-3.4.0-alt4.x86_64.rpm b/oam/oam_install/rpm/libsensors3-3.4.0-alt4.x86_64.rpm
new file mode 100644
index 0000000..4d9676d
--- /dev/null
+++ b/oam/oam_install/rpm/libsensors3-3.4.0-alt4.x86_64.rpm
Binary files differ
diff --git a/oam/oam_install/rpm/net-tools-2.0-0.22.20131004git.el7.x86_64.rpm b/oam/oam_install/rpm/net-tools-2.0-0.22.20131004git.el7.x86_64.rpm
new file mode 100644
index 0000000..6b9ae9b
--- /dev/null
+++ b/oam/oam_install/rpm/net-tools-2.0-0.22.20131004git.el7.x86_64.rpm
Binary files differ
diff --git a/oam/oam_install/rpm/sysstat-10.1.5-13.el7.x86_64.rpm b/oam/oam_install/rpm/sysstat-10.1.5-13.el7.x86_64.rpm
new file mode 100644
index 0000000..bed7109
--- /dev/null
+++ b/oam/oam_install/rpm/sysstat-10.1.5-13.el7.x86_64.rpm
Binary files differ