Fix the agent path according to 7a0a9231c355fee42c67799abe111edcd79998bb

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/90785500
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/90785500
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/90785500

Branch: refs/heads/vpc
Commit: 90785500735874c8faaee43252399362778563cf
Parents: 1bad242
Author: Tomoe Sugihara <[email protected]>
Authored: Tue Jul 31 22:03:10 2012 +0530
Committer: Prasanna Santhanam <[email protected]>
Committed: Tue Jul 31 22:05:04 2012 +0530

----------------------------------------------------------------------
 python/lib/cloudutils/serviceConfig.py |  190 +++++++++++++-------------
 1 files changed, 95 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/90785500/python/lib/cloudutils/serviceConfig.py
----------------------------------------------------------------------
diff --git a/python/lib/cloudutils/serviceConfig.py 
b/python/lib/cloudutils/serviceConfig.py
index 539e26a..b4ada22 100755
--- a/python/lib/cloudutils/serviceConfig.py
+++ b/python/lib/cloudutils/serviceConfig.py
@@ -8,7 +8,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-# 
+#
 # Automatically generated by addcopyright.py at 04/03/2012
 from utilities import writeProgressBar, bash
 from cloudException import CloudRuntimeException, CloudInternalException, 
formatExceptionInfo
@@ -26,7 +26,7 @@ class serviceCfgBase(object):
         self.cfoHandlers = []
         self.syscfg = syscfg
         self.netMgrRunning = False
-    
+
     def configration(self):
         writeProgressBar("Configure " + self.serviceName + " ...", None)
         result = False
@@ -34,7 +34,7 @@ class serviceCfgBase(object):
             result = self.config()
             if result is None:
                 result = False
-                
+
             self.status = result
             writeProgressBar(None, result)
             return result
@@ -53,29 +53,29 @@ class serviceCfgBase(object):
                 raise CloudRuntimeException("Configure %s failed, Please check 
the /var/log/cloud/setupManagement.log for detail"%self.serviceName)
             else:
                 raise CloudRuntimeException("Configure %s failed, Please check 
the /var/log/cloud/setupAgent.log for detail"%self.serviceName)
-            
+
     def backup(self):
         if self.status is None:
             return True
-        
+
         writeProgressBar("Restore " + self.serviceName + " ...", None)
         result = False
         try:
             for cfo in self.cfoHandlers:
                 cfo.backup()
-                
+
             result = self.restore()
         except (CloudRuntimeException, CloudInternalException), e:
             logging.debug(e)
 
         writeProgressBar(None, result)
-            
+
     def config(self):
         return True
-    
+
     def restore(self):
         return True
-    
+
 class networkConfigBase:
     def __init__(self, syscfg):
         self.netcfg = networkConfig()
@@ -93,9 +93,9 @@ class networkConfigBase:
             if not self.netcfg.isBridge(br):
                 raise CloudInternalException("%s is not a bridge"%br)
             preCfged = True
-        
+
         return preCfged
-    
+
     def cfgNetwork(self, dev=None, brName=None):
         if dev is None:
             device = self.netcfg.getDefaultNetwork()
@@ -116,7 +116,7 @@ class networkConfigBase:
             enslavedDev = self.netcfg.getEnslavedDev(device.name, 1)
             if enslavedDev is None:
                 raise CloudInternalException("Failed to get enslaved devices 
on bridge:%s"%device.name)
-            
+
             brDevice = device
             device = self.netcfg.getDevInfo(enslavedDev)
             brName = brDevice.name
@@ -124,7 +124,7 @@ class networkConfigBase:
 
         self.brName = brName
         self.dev = device.name
-        
+
     def writeToCfgFile(self):
         pass
 
@@ -133,7 +133,7 @@ class networkConfigUbuntu(serviceCfgBase, 
networkConfigBase):
         super(networkConfigUbuntu, self).__init__(syscfg)
         networkConfigBase.__init__(self, syscfg)
         self.netCfgFile = "/etc/network/interfaces"
-        
+
     def getNetworkMethod(self, line):
         if line.find("static") != -1:
             return "static"
@@ -142,7 +142,7 @@ class networkConfigUbuntu(serviceCfgBase, 
networkConfigBase):
         else:
             logging.debug("Failed to find the network method from:%s"%line)
             raise CloudInternalException("Failed to find the network method 
from /etc/network/interfaces")
-    
+
     def addBridge(self, br, dev):
         bash("ifdown %s"%dev.name)
         for line in file(self.netCfgFile).readlines():
@@ -177,34 +177,34 @@ class networkConfigUbuntu(serviceCfgBase, 
networkConfigBase):
             raise CloudInternalException("Missing device configuration, Need 
to add your network configuration into /etc/network/interfaces at first")
         else:
             raise CloudInternalException("Missing bridge/device network 
configuration, need to add your network configuration into 
/etc/network/interfaces at first")
-            
+
     def config(self):
         try:
             if super(networkConfigUbuntu, self).isPreConfiged():
                 return True
-            
+
             self.netMgrRunning = 
self.syscfg.svo.isServiceRunning("network-manager")
             super(networkConfigUbuntu, self).cfgNetwork()
             if self.netMgrRunning:
                 self.syscfg.svo.stopService("network-manager")
                 self.syscfg.svo.disableService("network-manager")
-                
+
             if not bash("ifup %s"%self.brName).isSuccess():
                 raise CloudInternalException("Can't start 
network:%s"%self.brName, bash.getErrMsg(self))
-            
+
             self.syscfg.env.nics.append(self.brName)
             self.syscfg.env.nics.append(self.brName)
             self.syscfg.env.nics.append(self.brName)
             return True
         except:
             raise
-    
+
     def restore(self):
         try:
             if self.netMgrRunning:
                 self.syscfg.svo.enableService("network-manager")
                 self.syscfg.svo.startService("network-manager")
-                
+
             bash("/etc/init.d/networking stop")
             bash("/etc/init.d/networking start")
             return True
@@ -216,11 +216,11 @@ class networkConfigRedhat(serviceCfgBase, 
networkConfigBase):
     def __init__(self, syscfg):
         super(networkConfigRedhat, self).__init__(syscfg)
         networkConfigBase.__init__(self, syscfg)
-    
+
     def writeToCfgFile(self, brName, dev):
         self.devCfgFile = "/etc/sysconfig/network-scripts/ifcfg-%s"%dev.name
         self.brCfgFile = "/etc/sysconfig/network-scripts/ifcfg-%s"%brName
-        
+
         isDevExist = os.path.exists(self.devCfgFile)
         isBrExist = os.path.exists(self.brCfgFile)
         if isDevExist and isBrExist:
@@ -234,35 +234,35 @@ class networkConfigRedhat(serviceCfgBase, 
networkConfigBase):
             raise CloudInternalException("Missing device configuration, Need 
to add your network configuration into /etc/sysconfig/network-scripts at first")
         else:
             raise CloudInternalException("Missing bridge/device network 
configuration, need to add your network configuration into 
/etc/sysconfig/network-scripts at first")
-            
-    
+
+
     def addBridge(self, brName, dev):
         bash("ifdown %s"%dev.name)
-        
+
         if not os.path.exists(self.brCfgFile):
             shutil.copy(self.devCfgFile, self.brCfgFile)
-        
+
         #config device file at first: disable nm, set onboot=yes if not
         cfo = configFileOps(self.devCfgFile, self)
         cfo.addEntry("NM_CONTROLLED", "no")
         cfo.addEntry("ONBOOT", "yes")
         cfo.addEntry("BRIDGE", brName)
         cfo.save()
-        
+
         cfo = configFileOps(self.brCfgFile, self)
         cfo.addEntry("NM_CONTROLLED", "no")
         cfo.addEntry("ONBOOT", "yes")
         cfo.addEntry("DEVICE", brName)
         cfo.addEntry("TYPE", "Bridge")
         cfo.save()
-        
+
     def config(self):
         try:
             if super(networkConfigRedhat, self).isPreConfiged():
                 return True
-            
+
             super(networkConfigRedhat, self).cfgNetwork()
-            
+
             self.netMgrRunning = 
self.syscfg.svo.isServiceRunning("NetworkManager")
             if self.netMgrRunning:
                 self.syscfg.svo.stopService("NetworkManager")
@@ -274,14 +274,14 @@ class networkConfigRedhat(serviceCfgBase, 
networkConfigBase):
 
             if not bash("service network restart").isSuccess():
                 raise CloudInternalException("Can't restart network")
-            
+
             self.syscfg.env.nics.append(self.brName)
             self.syscfg.env.nics.append(self.brName)
             self.syscfg.env.nics.append(self.brName)
             return True
         except:
             raise
-        
+
     def restore(self):
         try:
             if self.netMgrRunning:
@@ -292,12 +292,12 @@ class networkConfigRedhat(serviceCfgBase, 
networkConfigBase):
         except:
             logging.debug(formatExceptionInfo())
             return False
-            
+
 class cgroupConfig(serviceCfgBase):
     def __init__(self, syscfg):
         super(cgroupConfig, self).__init__(syscfg)
         self.serviceName = "Cgroup"
-    
+
     def config(self):
         try:
             cfo = configFileOps("/etc/cgconfig.conf", self)
@@ -314,14 +314,14 @@ class cgroupConfig(serviceCfgBase):
             cfo = configFileOps("/etc/cgrules.conf", self)
             cfgline = "root:/usr/sbin/libvirtd  cpu virt/\n"
             cfo.add_lines(cfgline)
-            
+
             self.syscfg.svo.stopService("cgred", True)
             if not self.syscfg.svo.enableService("cgred"):
                 return False
             return True
         except:
             raise
-        
+
     def restore(self):
         try:
             self.syscfg.svo.stopService("cgconfig")
@@ -332,7 +332,7 @@ class cgroupConfig(serviceCfgBase):
         except:
             logging.debug(formatExceptionInfo())
             return False
-        
+
 class nfsConfig(serviceCfgBase):
     def __init__(self, syscfg):
         super(nfsConfig, self).__init__(syscfg)
@@ -342,24 +342,24 @@ class nfsConfig(serviceCfgBase):
         try:
             if not os.path.exists("/etc/nfsmount.conf"):
                 return True
-            
+
             cfo = configFileOps("/etc/nfsmount.conf")
             cfo.addEntry("AC", "False")
             cfo.save()
-            
+
             self.syscfg.svo.enableService("rpcbind")
             self.syscfg.svo.stopService("rpcbind")
             self.syscfg.svo.startService("rpcbind")
-            
+
             self.syscfg.svo.enableService("nfs")
             self.syscfg.svo.stopService("nfs")
             self.syscfg.svo.startService("nfs")
-            
+
             return True
         except:
             logging.debug(formatExceptionInfo())
             return False
-            
+
 class securityPolicyConfigUbuntu(serviceCfgBase):
     def __init__(self, syscfg):
         super(securityPolicyConfigUbuntu, self).__init__(syscfg)
@@ -371,7 +371,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
             if not cmd.isSuccess() or cmd.getStdout() == "":
                 self.spRunning = False
                 return True
-            
+
             if not bash("apparmor_status |grep libvirt").isSuccess():
                 return True
 
@@ -384,7 +384,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
         except:
             raise CloudRuntimeException("Failed to configure apparmor, please 
see the /var/log/cloud/setupAgent.log for detail, \
                                         or you can manually disable it before 
starting myCloud")
-    
+
     def restore(self):
         try:
             self.syscfg.svo.enableService("apparmor")
@@ -393,7 +393,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase):
         except:
             logging.debug(formatExceptionInfo())
             return False
-        
+
 class securityPolicyConfigRedhat(serviceCfgBase):
     def __init__(self, syscfg):
         super(securityPolicyConfigRedhat, self).__init__(syscfg)
@@ -401,10 +401,10 @@ class securityPolicyConfigRedhat(serviceCfgBase):
 
     def config(self):
         selinuxEnabled = True
-        
+
         if not bash("selinuxenabled").isSuccess():
             selinuxEnabled = False
-            
+
         if selinuxEnabled:
             try:
                 bash("setenforce 0")
@@ -416,7 +416,7 @@ class securityPolicyConfigRedhat(serviceCfgBase):
                                             or you can manually disable it 
before starting myCloud")
         else:
             return True
-    
+
     def restore(self):
         try:
             bash("setenforce 1")
@@ -429,7 +429,7 @@ class libvirtConfigRedhat(serviceCfgBase):
     def __init__(self, syscfg):
         super(libvirtConfigRedhat, self).__init__(syscfg)
         self.serviceName = "Libvirt"
-    
+
     def config(self):
         try:
             cfo = configFileOps("/etc/libvirt/libvirtd.conf", self)
@@ -438,14 +438,14 @@ class libvirtConfigRedhat(serviceCfgBase):
             cfo.addEntry("auth_tcp", "\"none\"")
             cfo.addEntry("listen_tls", "0")
             cfo.save()
-            
+
             cfo = configFileOps("/etc/sysconfig/libvirtd", self)
             cfo.addEntry("export CGROUP_DAEMON", "'cpu:/virt'")
             cfo.addEntry("LIBVIRTD_ARGS", "-l")
             cfo.save()
-            
+
             filename = "/etc/libvirt/qemu.conf"
-        
+
             cfo = configFileOps(filename, self)
             cfo.addEntry("cgroup_controllers", "[\"cpu\"]")
             cfo.addEntry("security_driver", "\"none\"")
@@ -453,23 +453,23 @@ class libvirtConfigRedhat(serviceCfgBase):
             cfo.addEntry("group", "\"root\"")
             cfo.addEntry("vnc_listen", "\"0.0.0.0\"")
             cfo.save()
-            
+
             self.syscfg.svo.stopService("libvirtd")
             if not self.syscfg.svo.startService("libvirtd"):
                 return False
-            
+
             return True
         except:
             raise
-        
+
     def restore(self):
         pass
-    
+
 class libvirtConfigUbuntu(serviceCfgBase):
     def __init__(self, syscfg):
         super(libvirtConfigUbuntu, self).__init__(syscfg)
         self.serviceName = "Libvirt"
-    
+
     def setupLiveMigration(self):
         cfo = configFileOps("/etc/libvirt/libvirtd.conf", self)
         cfo.addEntry("listen_tcp", "1")
@@ -477,20 +477,20 @@ class libvirtConfigUbuntu(serviceCfgBase):
         cfo.addEntry("auth_tcp", "\"none\"");
         cfo.addEntry("listen_tls", "0")
         cfo.save()
-        
+
         if os.path.exists("/etc/init/libvirt-bin.conf"):
             cfo = configFileOps("/etc/init/libvirt-bin.conf", self)
             cfo.replace_line("exec /usr/sbin/libvirtd","exec 
/usr/sbin/libvirtd -d -l")
         else:
             cfo = configFileOps("/etc/default/libvirt-bin", self)
             cfo.replace_or_add_line("libvirtd_opts=","libvirtd_opts='-l -d'")
-    
+
     def config(self):
         try:
             self.setupLiveMigration()
-            
+
             filename = "/etc/libvirt/qemu.conf"
-    
+
             cfo = configFileOps(filename, self)
             cfo.addEntry("security_driver", "\"none\"")
             cfo.addEntry("user", "\"root\"")
@@ -511,12 +511,12 @@ class libvirtConfigUbuntu(serviceCfgBase):
         except:
             logging.debug(formatExceptionInfo())
             return False
-    
+
 class firewallConfigUbuntu(serviceCfgBase):
     def __init__(self, syscfg):
         super(firewallConfigUbuntu, self).__init__(syscfg)
         self.serviceName = "Firewall"
-    
+
     def config(self):
         try:
             ports = "22 1798 16509".split()
@@ -529,43 +529,43 @@ class firewallConfigUbuntu(serviceCfgBase):
             return True
         except:
             raise
-    
+
     def restore(self):
         return True
-    
+
 class firewallConfigBase(serviceCfgBase):
     def __init__(self, syscfg):
         super(firewallConfigBase, self).__init__(syscfg)
-        self.serviceName = "Firewall" 
+        self.serviceName = "Firewall"
         self.rules = []
-    
+
     def allowPort(self, port):
         status = False
         try:
             status = bash("iptables-save|grep INPUT|grep -w 
%s"%port).isSuccess()
         except:
             pass
-        
-        if not status: 
+
+        if not status:
             redo = False
             result = True
             try:
                 result = bash("iptables -I INPUT -p tcp -m tcp --dport %s -j 
ACCEPT"%port).isSuccess()
             except:
                 redo = True
-            
+
             if not result or redo:
                 bash("sleep 30")
                 bash("iptables -I INPUT -p tcp -m tcp --dport %s -j 
ACCEPT"%port)
-        
+
     def config(self):
         try:
             for port in self.ports:
                 self.allowPort(port)
-                
+
             for rule in self.rules:
                 bash("iptables " + rule)
-            
+
             bash("iptables-save > /etc/sysconfig/iptables")
             self.syscfg.svo.stopService("iptables")
             self.syscfg.svo.startService("iptables")
@@ -575,7 +575,7 @@ class firewallConfigBase(serviceCfgBase):
 
     def restore(self):
         return True
- 
+
 class firewallConfigAgent(firewallConfigBase):
     def __init__(self, syscfg):
         super(firewallConfigAgent, self).__init__(syscfg)
@@ -595,10 +595,10 @@ class cloudAgentConfig(serviceCfgBase):
             self.serviceName = "myCloud"
         elif syscfg.env.agentMode == "Console":
             self.serviceName = "Console Proxy"
-    
+
     def configMyCloud(self):
         try:
-            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)  
+            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
             cfo.addEntry("host", self.syscfg.env.mgtSvr)
             cfo.addEntry("zone", self.syscfg.env.zone)
             cfo.addEntry("port", "443")
@@ -611,16 +611,16 @@ class cloudAgentConfig(serviceCfgBase):
             cfo.addEntry("mount.path", "/mnt")
             cfo.addEntry("resource", 
"com.cloud.storage.resource.LocalSecondaryStorageResource|com.cloud.agent.resource.computing.CloudZonesComputingResource")
             cfo.save()
-            
+
             #self.syscfg.svo.stopService("cloud-agent")
             #self.syscfg.svo.enableService("cloud-agent")
             return True
         except:
             raise
-    
+
     def configAgent(self):
         try:
-            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)  
+            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
             cfo.addEntry("host", self.syscfg.env.mgtSvr)
             cfo.addEntry("zone", self.syscfg.env.zone)
             cfo.addEntry("pod", self.syscfg.env.pod)
@@ -632,19 +632,19 @@ class cloudAgentConfig(serviceCfgBase):
             cfo.addEntry("guid", str(self.syscfg.env.uuid))
             if cfo.getEntry("local.storage.uuid") == "":
                 cfo.addEntry("local.storage.uuid", 
str(bash("uuidgen").getStdout()))
-            cfo.addEntry("resource", 
"com.cloud.agent.resource.computing.LibvirtComputingResource")
+            cfo.addEntry("resource", 
"com.cloud.hypervisor.kvm.resource.LibvirtComputingResource")
             cfo.save()
-            
+
             self.syscfg.svo.stopService("cloud-agent")
             bash("sleep 30")
             self.syscfg.svo.enableService("cloud-agent")
             return True
         except:
             raise
-        
+
     def configConsole(self):
         try:
-            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)  
+            cfo = configFileOps("/etc/cloud/agent/agent.properties", self)
             cfo.addEntry("host", self.syscfg.env.mgtSvr)
             cfo.addEntry("zone", self.syscfg.env.zone)
             cfo.addEntry("pod", self.syscfg.env.pod)
@@ -656,13 +656,13 @@ class cloudAgentConfig(serviceCfgBase):
             cfo.addEntry("guid", str(self.syscfg.env.uuid))
             cfo.addEntry("resource", 
"com.cloud.agent.resource.computing.consoleProxyResource")
             cfo.save()
-            
+
             self.syscfg.svo.stopService("cloud-agent")
             self.syscfg.svo.enableService("cloud-agent")
             return True
         except:
             raise
-        
+
     def config(self):
         if self.syscfg.env.agentMode == "Agent":
             return self.configAgent()
@@ -670,7 +670,7 @@ class cloudAgentConfig(serviceCfgBase):
             return self.configMyCloud()
         elif self.syscfg.env.agentMode == "console":
             return self.configConsole()
-            
+
     def restore(self):
         return True
 
@@ -688,10 +688,10 @@ class sudoersConfig(serviceCfgBase):
             return True
         except:
             raise
-        
+
     def restore(self):
         return True
-    
+
 class firewallConfigServer(firewallConfigBase):
     def __init__(self, syscfg):
         super(firewallConfigServer, self).__init__(syscfg)
@@ -708,18 +708,18 @@ class ubuntuFirewallConfigServer(firewallConfigServer):
             status = bash("iptables-save|grep INPUT|grep -w 
%s"%port).isSuccess()
         except:
             pass
-        
-        if not status: 
+
+        if not status:
             bash("ufw allow %s/tcp"%port)
-            
+
     def config(self):
         try:
             for port in self.ports:
                 self.allowPort(port)
-            
-            #FIXME: urgly make /root writable 
+
+            #FIXME: urgly make /root writable
             bash("sudo chmod 0777 /root")
-                
+
             return True
         except:
             raise

Reply via email to