55# to you under the Apache License, Version 2.0 (the
66# "License"); you may not use this file except in compliance
77# with the License. You may obtain a copy of the License at
8- #
8+ #
99# http://www.apache.org/licenses/LICENSE-2.0
10- #
10+ #
1111# Unless required by applicable law or agreed to in writing,
1212# software distributed under the License is distributed on an
1313# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -29,7 +29,7 @@ def getSysConfigFactory(glbEnv):
2929 return sysConfigDbFactory .getDb (glbEnv )
3030 else :
3131 raise CloudInternalException ("Need to specify which mode are u running: Agent/Server/Db" )
32-
32+
3333class sysConfigAgentFactory :
3434 @staticmethod
3535 def getAgent (glbEnv ):
@@ -61,7 +61,7 @@ def getServer(glbEnv):
6161 else :
6262 print ("Can't find the distribution version" )
6363 return sysConfig ()
64-
64+
6565class sysConfigDbFactory :
6666 @staticmethod
6767 def getDb (glbEnv ):
@@ -71,39 +71,39 @@ class sysConfig(object):
7171 def __init__ (self , env ):
7272 self .env = env
7373 self .services = []
74-
74+
7575 def registerService (self , service ):
7676 self .services .append (service (self ))
77-
77+
7878 def config (self ):
7979 if not self .check ():
8080 return False
8181
8282 for service in self .services :
8383 if not service .configration ():
8484 raise CloudInternalException ("Configuration failed for service %s" % service .serviceName )
85-
85+
8686 def restore (self ):
8787 for service in self .services :
8888 service .backup ()
89-
89+
9090 def check (self ):
9191 return True
92-
92+
9393class sysConfigAgent (sysConfig ):
9494 def __init__ (self , env ):
9595 super (sysConfigAgent , self ).__init__ (env )
9696
9797 def check (self ):
9898 if self .env .debug :
9999 return True
100-
100+
101101 if self .env .agentMode == "myCloud" :
102102 if self .env .distribution .getVersion () != "Ubuntu" :
103103 raise CloudInternalException ("Need to run myCloud agent on an Ubuntu machine\n " )
104104 elif self .env .distribution .getArch () != "x86_64" :
105105 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
107107 if os .path .exists ("/var/lib/libvirt/images" ):
108108 size = - 1
109109 try :
@@ -127,18 +127,18 @@ def check(self):
127127
128128 if os .geteuid () != 0 :
129129 raise CloudInternalException ("Need to execute with root permission\n " )
130-
130+
131131 hostname = bash ("hostname -f" )
132132 if not hostname .isSuccess ():
133133 raise CloudInternalException ("Checking hostname ... [Failed]\n Please edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n " )
134134
135135 kvmEnabled = self .svo .isKVMEnabled ()
136136 if not kvmEnabled :
137137 raise CloudInternalException ("Checking KVM...[Failed]\n Please enable KVM on this machine\n " )
138-
138+
139139 return True
140140
141-
141+
142142class sysConfigAgentRedhatBase (sysConfigAgent ):
143143 def __init__ (self , env ):
144144 self .svo = serviceOpsRedhat ()
@@ -188,7 +188,7 @@ def __init__(self, glbEnv):
188188 libvirtConfigRedhat (self ),
189189 firewallConfigAgent (self ),
190190 cloudAgentConfig (self )]
191-
191+
192192#it covers RHEL7
193193class sysConfigRedhat7 (sysConfigAgentRedhat7Base ):
194194 def __init__ (self , glbEnv ):
@@ -219,15 +219,15 @@ def check(self):
219219 if not hostname .isSuccess ():
220220 raise CloudInternalException ("Checking hostname ... [Failed]\n Please edit /etc/hosts, add a Fully Qualified Domain Name as your hostname\n " )
221221 return True
222-
222+
223223class sysConfigServerRedhat (sysConfigServer ):
224224 def __init__ (self , glbEnv ):
225225 super (sysConfigServerRedhat , self ).__init__ (glbEnv )
226226 self .svo = serviceOpsRedhat ()
227- self .services = [firewallConfigServer ( self ) ]
228-
227+ self .services = []
228+
229229class sysConfigServerUbuntu (sysConfigServer ):
230230 def __init__ (self , glbEnv ):
231231 super (sysConfigServerUbuntu , self ).__init__ (glbEnv )
232232 self .svo = serviceOpsUbuntu ()
233- self .services = [ubuntuFirewallConfigServer ( self ) ]
233+ self .services = []
0 commit comments