-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
191 lines (173 loc) · 8.26 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#! python
import os
import subprocess
import re
import fileinput
import zone_mgmt
import file_manip
import firewall
import yummy
#Call fmanip to append ipforwarding
ipforward_file = "/etc/sysctl.conf"
ipforward_append = "\nnet.ipv4.ip_forward=1"
file_manip.filebak(ipforward_file, ".bak").fbak()
file_manip.fileappend(ipforward_file, ipforward_append).fappend()
#Call method for enabling ipforwarding
class ip_forward_cmd:
subprocess.Popen(['sysctl', '-w', 'net.ipv4.ip_forward=1'])
#configure firewall zones
zone_mgmt.nmcli_con_enum().main()
#hard define the preferred route device.
#append gateway
gateway = zone_mgmt.nmcli_con_enum()
gateway.dev_enum()
gateway.dev_zone()
gateway_device = ",".join(gateway.ext_dev)
gateway_file = "/etc/sysconfig/network"
gateway_append = "\nGATEWAYDEV=" + gateway_device
file_manip.filebak(gateway_file, ".bak").fbak()
file_manip.fileappend(gateway_file, gateway_append).fappend()
#configure firewall
#GENERAL SERVICES
service_list = [
("internal", "tftp"),
("internal", "ftp"),
("internal", "dns"),
("internal", "nfs"),
("internal", "http"),
("external", "http"),
("internal", "https"),
("external", "https"),
("internal", "ssh"),
("external", "ssh"),
("internal", "proxy-dhcp"),
("internal", "ntp"),
]
print(service_list)
for x in service_list:
print(x[0], x[1])
firewall.firewall_service(x[0], x[1]).fw_service()
#GENERAL PORTS
port_list = [
#HDFS PORTS
("internal", 8020, "tcp"), # allow NameNodeMetaData : dfs.namenode.rpc-address
("internal", 8010, "tcp"), # allow DataNode : dfs.datanode.ipc.address
("internal", 8480, "tcp"), # allow DataNode : dfs.journalnode.http-address
("internal", 8481, "tcp"), # allow DataNode : dfs.journalnode.https-address
("internal", 8485, "tcp"), # allow DataNode : dfs.journalnode.rpc-address
("internal", 9000, "tcp"), # allow NameNodeMetaData
("internal", 50070, "tcp"), # allow NameNodeWebUI : namenode.http-address
("internal", 50075, "tcp"), # allow DataNode : dfs.datanode.http.address
("internal", 50475, "tcp"), # allow DataNode : dfs.datanode.https.address
("internal", 50470, "tcp"), # allow NameNodeWebUI : dfs.https.port
("internal", 50010, "tcp"), # allow DataNode : dfs.datanode.address
("internal", 50020, "tcp"), # allow DataNode :
("internal", 50100, "tcp"), # allow DataNode : dfs.namenode.backup.address
("internal", 50090, "tcp"), # allow SecondaryNameNode : dfs.namenode.secondary.http-address
("internal", 50105, "tcp"), # allow NameNode : dfs.namenode.backup.http-address
("internal", 50091, "tcp"), # allow SecondaryNameNode : dfs.namenode.secondary.https-address
#PUPPET PORTS
("internal", 8140,"tcp"), # allow puppetmaster
#AMBARI PORTS
####8080 is a conflict port!!!!
("internal", 8080, "tcp"), # allow Ambari Server : confirmed
("internal", "8440-8443", "tcp"), # allow Ambari Server : confirmed
("internal", 61310, "tcp"), # allow Ambari Metrics : hbase.master.info.port
("internal", 61300, "tcp"), # allow Ambari Metrics : hbase.master.port
("internal", 61330, "tcp"), # allow Ambari Metrics : hbase.regionserver.info.port
("internal", 61320, "tcp"), # allow Ambari Metrics : hbase.regionserver.port
("internal", 61388, "tcp"), # allow Ambari Metrics : hbase.zookeeper.leaderport
("internal", 61288, "tcp"), # allow Ambari Metrics : hbase.zookeeper.peerport
#KAFKA PORTS
("internal", 6667, "tcp"), # allow Kafka Broker : confirmed
("internal", 8671, "tcp"), # allow Kafka Metrics : confirmed
#YARN PORTS
("internal", 8025, "tcp"), # allow YARNResourceManager
("internal", 8141, "tcp"), # allow YARNRMAdmin
("internal", 8050, "tcp"), # allow YARNContainerManager
("internal", 45454, "tcp"), # allow YARNApplicationsManager
("internal", 8042, "tcp"), # allow YARNNodeManagerWebApp
("internal", 8088, "tcp"), # allow YARNResourceManagerWebApp
#YARN PORTS
("internal", 2181, "tcp"), # allow YARNResourceManager : yarn.resourcemanager.zk-address
("internal", 8025, "tcp"), # allow YARNResourceManager : yarn.resourcemanager.resource-tracker.address
("internal", 8141, "tcp"), # allow YARNRMAdmin : yarn.resourcemanager.admin.address
("internal", 8030, "tcp"), # allow YARNResourceManager : yarn.resourcemanager.scheduler.address
("internal", 10200, "tcp"), # allow YARNTimeline : yarn.timeline-service.address
("internal", 8050, "tcp"), # allow YARNContainerManager : yarn.resourcemanager.address
("internal", 45454, "tcp"), # allow YARNApplicationsManager : yarn.nodemanager.address
("internal", 8042, "tcp"), # allow YARNNodeManagerWebApp : yarn.nodemanager.webapp.address
("internal", 8088, "tcp"), # allow YARNResourceManagerWebApp : yarn.resourcemanager.webapp.address
("internal", 8188, "tcp"), # allow YARN : yarn.timeline-service.webapp.address
("internal", 8047, "tcp"), # allow YARN :yarn.sharedcache.admin.address
("internal", 8045, "tcp"), # allow YARN :yarn.sharedcache.client-server.address
("internal", 8190, "tcp"), # allow YARNTimeline :yarn.timeline-service.webapp.https.address
("internal", 8040, "tcp"), # allow YARNNodeManager : yarn.nodemanager.localizer.address
("internal", 8090, "tcp"), # allow YARNResourceManager : yarn.resourcemanager.webapp.https.address
("internal", 8046, "tcp"), # allow YARNSharedCache : yarn.sharedcache.uploader.server.address
("internal", 8788, "tcp"), # allow YARNSharedCache : yarn.sharedcache.webapp.address
#MAPREDUCE PORTS
("internal", 50030,"tcp"), # allow JobTrackerWebUI
("internal", 8021,"tcp"), # allow JobTracker
("internal", 50060,"tcp"), # allow TaskTrackerWebUI
("internal", 51111,"tcp"), # allow HistoryServerWebUI
("internal", 19888,"tcp"), # allow HistoryServerWebUI
#MAPREDUCE PORTS
("internal", 50030, "tcp"), # allow JobTrackerWebUI : mapreduce.jobtracker.http.address
("internal", 8021, "tcp"), # allow JobTracker : confirmed
("internal", 10033, "tcp"), # allow JobTracker : mapreduce.jobhistory.admin.address
("internal", 50060, "tcp"), # allow TaskTrackerWebUI/Shuffle : mapreduce.tasktracker.http.address
("internal", 51111, "tcp"), # allow HistoryServerWebUI
("internal", 19888, "tcp"), # allow HistoryServerWebUI : yarn.log.server.url / mapreduce.jobhistory.webapp.address
("internal", 13562, "tcp"), # allow MapRShuffle : mapreduce.shuffle.port
("internal", 10020, "tcp"), # allow JobHistory : mapreduce.jobhistory.address
#HBASE PORTS
("internal", 60000, "tcp"), # allow HMaster
("internal", 60010, "tcp"), # allow HMasterWebUI
("internal", 60020, "tcp"), # allow RegionServer
("internal", 60030, "tcp"), # allow RegionServer
("internal", 2888, "tcp"), # allow RegionServer : hbase.zookeeper.peerport
("internal", 3888, "tcp"), # allow RegionServer : hbase.zookeeper.leaderport
("internal", 2181, "tcp"), # allow RegionServer : hbase.zookeeper.property.clientPort
("internal", 16000, "tcp"), # allow HBase Server : hbase.master.port
("internal", 16010, "tcp"), # allow HBase Server : hbase.master.info.port
("internal", 16020, "tcp"), # allow HBase Server : hbase.regionserver.port
("internal", 16030, "tcp"), # allow HBase Server : hbase.regionserver.info.port
("internal", 16100, "tcp"), # allow HBase Server : hbase.status.multicast.address.port
#CONFLICT WITH AMBARI PORT!!!!!!
("internal", 8080, "tcp"), # allow HBase Server : hbase.rest.port
#TITAN PORT
("internal", 8182, "tcp"), # allow Titan
#GANGLIA PORTS
("internal", "8660-8663","tcp"), # allow GangliaServer
("internal", 8651,"tcp"), # allow GangliaServer
#POSTGRES PORT
("internal", 5432,"tcp"), # allow PostGres
#TIGERVNC
("internal",5904,"tcp"), # allow TigerVNC
("external",5904,"tcp"), # allow TigerVNC
];
print(port_list)
for x in port_list:
firewall.firewall_port(x[0], str(x[1]), x[2]).fw_port()
firewall.fw_reload()
#INSTALL/CONFIGURE VNCSERVER
arg=['tigervnc-server']
yummy.yummyintummy(arg).yuminstall()
src = '/lib/systemd/system/[email protected]'
dst = '/etc/systemd/system/vncserver@:4.service'
file_manip.filecp(src, dst).fcp()
file = "/etc/systemd/system/vncserver@:4.service"
file_manip.filebak(file, ".bak").fbak()
find = "<USER>"
replace = "ur.local"
file_manip.filereplace(file, find, replace).freplace()
file = "/etc/systemd/system/vncserver@:4.service"
find = "\"/usr/bin/vncserver %i\""
replace = "\"/usr/bin/vncserver %i -geometry 1280x1024\""
file_manip.filereplace(file, find, replace).freplace()
try:
subprocess.Popen(['systemctl', 'daemon-reload'])
subprocess.Popen(['systemctl', 'enable', 'vncserver@:4.service'])
except Exception:
print('Error:',x)