|
5 | 5 | # to you under the Apache License, Version 2.0 (the |
6 | 6 | # "License"); you may not use this file except in compliance |
7 | 7 | # with the License. You may obtain a copy of the License at |
8 | | -# |
| 8 | +# |
9 | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
10 | | -# |
| 10 | +# |
11 | 11 | # Unless required by applicable law or agreed to in writing, |
12 | 12 | # software distributed under the License is distributed on an |
13 | 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
@@ -29,7 +29,7 @@ def getSysConfigFactory(glbEnv): |
29 | 29 | return sysConfigDbFactory.getDb(glbEnv) |
30 | 30 | else: |
31 | 31 | raise CloudInternalException("Need to specify which mode are u running: Agent/Server/Db") |
32 | | - |
| 32 | + |
33 | 33 | class sysConfigAgentFactory: |
34 | 34 | @staticmethod |
35 | 35 | def getAgent(glbEnv): |
@@ -61,7 +61,7 @@ def getServer(glbEnv): |
61 | 61 | else: |
62 | 62 | print("Can't find the distribution version") |
63 | 63 | return sysConfig() |
64 | | - |
| 64 | + |
65 | 65 | class sysConfigDbFactory: |
66 | 66 | @staticmethod |
67 | 67 | def getDb(glbEnv): |
@@ -71,39 +71,39 @@ class sysConfig(object): |
71 | 71 | def __init__(self, env): |
72 | 72 | self.env = env |
73 | 73 | self.services = [] |
74 | | - |
| 74 | + |
75 | 75 | def registerService(self, service): |
76 | 76 | self.services.append(service(self)) |
77 | | - |
| 77 | + |
78 | 78 | def config(self): |
79 | 79 | if not self.check(): |
80 | 80 | return False |
81 | 81 |
|
82 | 82 | for service in self.services: |
83 | 83 | if not service.configration(): |
84 | 84 | raise CloudInternalException("Configuration failed for service %s" % service.serviceName) |
85 | | - |
| 85 | + |
86 | 86 | def restore(self): |
87 | 87 | for service in self.services: |
88 | 88 | service.backup() |
89 | | - |
| 89 | + |
90 | 90 | def check(self): |
91 | 91 | return True |
92 | | - |
| 92 | + |
93 | 93 | class sysConfigAgent(sysConfig): |
94 | 94 | def __init__(self, env): |
95 | 95 | super(sysConfigAgent, self).__init__(env) |
96 | 96 |
|
97 | 97 | def check(self): |
98 | 98 | if self.env.debug: |
99 | 99 | return True |
100 | | - |
| 100 | + |
101 | 101 | if self.env.agentMode == "myCloud": |
102 | 102 | if self.env.distribution.getVersion() != "Ubuntu": |
103 | 103 | raise CloudInternalException("Need to run myCloud agent on an Ubuntu machine\n") |
104 | 104 | elif self.env.distribution.getArch() != "x86_64": |
105 | 105 | raise CloudInternalException("Need to run myCloud agent on an 64bit machine\n") |
106 | | - #check free disk space on the local disk |
| 106 | + #check free disk space on the local disk |
107 | 107 | if os.path.exists("/var/lib/libvirt/images"): |
108 | 108 | size = -1 |
109 | 109 | try: |
@@ -127,18 +127,18 @@ def check(self): |
127 | 127 |
|
128 | 128 | if os.geteuid() != 0: |
129 | 129 | raise CloudInternalException("Need to execute with root permission\n") |
130 | | - |
| 130 | + |
131 | 131 | hostname = bash("hostname -f") |
132 | 132 | if not hostname.isSuccess(): |
133 | 133 | raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n") |
134 | 134 |
|
135 | 135 | kvmEnabled = self.svo.isKVMEnabled() |
136 | 136 | if not kvmEnabled: |
137 | 137 | raise CloudInternalException("Checking KVM...[Failed]\nPlease enable KVM on this machine\n") |
138 | | - |
| 138 | + |
139 | 139 | return True |
140 | 140 |
|
141 | | - |
| 141 | + |
142 | 142 | class sysConfigAgentRedhatBase(sysConfigAgent): |
143 | 143 | def __init__(self, env): |
144 | 144 | self.svo = serviceOpsRedhat() |
@@ -188,7 +188,7 @@ def __init__(self, glbEnv): |
188 | 188 | libvirtConfigRedhat(self), |
189 | 189 | firewallConfigAgent(self), |
190 | 190 | cloudAgentConfig(self)] |
191 | | - |
| 191 | + |
192 | 192 | #it covers RHEL7 |
193 | 193 | class sysConfigRedhat7(sysConfigAgentRedhat7Base): |
194 | 194 | def __init__(self, glbEnv): |
@@ -219,15 +219,15 @@ def check(self): |
219 | 219 | if not hostname.isSuccess(): |
220 | 220 | raise CloudInternalException("Checking hostname ... [Failed]\nPlease edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n") |
221 | 221 | return True |
222 | | - |
| 222 | + |
223 | 223 | class sysConfigServerRedhat(sysConfigServer): |
224 | 224 | def __init__(self, glbEnv): |
225 | 225 | super(sysConfigServerRedhat, self).__init__(glbEnv) |
226 | 226 | self.svo = serviceOpsRedhat() |
227 | | - self.services = [firewallConfigServer(self)] |
228 | | - |
| 227 | + self.services = [] |
| 228 | + |
229 | 229 | class sysConfigServerUbuntu(sysConfigServer): |
230 | 230 | def __init__(self, glbEnv): |
231 | 231 | super(sysConfigServerUbuntu, self).__init__(glbEnv) |
232 | 232 | self.svo = serviceOpsUbuntu() |
233 | | - self.services = [ubuntuFirewallConfigServer(self)] |
| 233 | + self.services = [] |