Custom Search

func/minion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


 func/minion/modules/bridge.py  |    4 
 func/minion/modules/jboss.py   |   30 +++---
 func/minion/modules/service.py |   18 +--
 func/minion/modules/test.py    |   14 +--
 func/minion/modules/virt.py    |  185 ++++++++++++++++++++---------------------
 5 files changed, 126 insertions(+), 125 deletions(-)

New commits:
commit 2441779de383f87a441ae09abd1b8871a6479bba
Author: Seth Vidal <skvidal@xxxxxxxxxxxxxxxxx>
Date:   Thu Oct 14 12:08:06 2010 -0400

    - fix tab/space issues all over the place (do people still have editors that use tabs?)
    - pylint the code and look for indentation errors and/or other odd language-isms.

diff --git a/func/minion/modules/bridge.py b/func/minion/modules/bridge.py
index 2536bca..fe35281 100644
--- a/func/minion/modules/bridge.py
+++ b/func/minion/modules/bridge.py
@@ -98,8 +98,8 @@ class Bridge(func_module.FuncModule):
                 # exist, append the interface.
                 if not curbr in self.options.ignorebridges:
                     if vifpattern.match(elements[0]) and listvif == False:
-			continue
-		    retlist[curbr].append(elements[0])
+                        continue
+                    retlist[curbr].append(elements[0])
     
         return retlist
 
diff --git a/func/minion/modules/jboss.py b/func/minion/modules/jboss.py
index 20d64eb..e5d12c5 100644
--- a/func/minion/modules/jboss.py
+++ b/func/minion/modules/jboss.py
@@ -36,7 +36,7 @@ class JBoss(func_module.FuncModule):
         """  
         processo = process.ProcessModule()
         results = processo.info("ax") 
-		
+    
         logging = logger.Logger().logger
         output = []
         for items in results:
@@ -59,8 +59,8 @@ class JBoss(func_module.FuncModule):
                     output.append((int(items[0]),instance,address,[]))
 
         # Retrieve information about network (netstat -tupln)
-	net_status = networktest.NetworkTest()
-	results = net_status.netstat("-tupln")
+        net_status = networktest.NetworkTest()
+        results = net_status.netstat("-tupln")
 
         for string in results:
             address = None
@@ -73,7 +73,7 @@ class JBoss(func_module.FuncModule):
             except:
                 address_port = None
                 pid_name = None
-	    
+    
             if address_port != None:
                 try:
                     address = address_port.split(":")[0]
@@ -131,8 +131,8 @@ class JBoss(func_module.FuncModule):
             data = self.status()
         else:
             data = status
-	
-	port = int(port)	
+
+        port = int(port)
         founded = []
 
         for item in data:
@@ -187,7 +187,7 @@ class JBoss(func_module.FuncModule):
     def start(self):
         '''
            Start a jboss instance 
-	'''
+        '''
         logging = logger.Logger().logger
 
         address=self.options.jboss_address
@@ -196,26 +196,26 @@ class JBoss(func_module.FuncModule):
         jboss_run_path=self.options.jboss_home+"/bin/run.sh"
 
         status=self.status()
-		
+    
         if len(self.search_by_address(address=address, status=status)) != 0:
             return (-1,"Another instances listening on this address, ")
 
-       	if len(self.search_by_instance(instance=instance, status=status)) != 0:
+        if len(self.search_by_instance(instance=instance, status=status)) != 0:
             return (-1,"This instances is just instanced")
 
         launcher ="sh "+str(jboss_run_path)+" -c "+instance+" -b "+address+" &"
         logging.info(launcher)
 
-	comm = command.Command()
-	comm.run(launcher)
+        comm = command.Command()
+        comm.run(launcher)
         
-	return "OK, instance "+ instance +" started on address "+address
+        return "OK, instance "+ instance +" started on address "+address
 
 
     def stop(self):
         '''
             Stop a jboss instance, It suppose you are using 
-	    use standard JNDI port 1099. 
+            use standard JNDI port 1099. 
         '''
         logging = logger.Logger().logger
 
@@ -228,11 +228,11 @@ class JBoss(func_module.FuncModule):
         if len(data) == 0:
             return (-1, "Istance on "+ address +" not running")
     
-	launcher ="sh "+str(jboss_sd_path)+" -s jnp://"+address+":1099 &"
+        launcher ="sh "+str(jboss_sd_path)+" -s jnp://"+address+":1099 &"
         logging.info(launcher)
 
         comm = command.Command()
-	comm.run(launcher)
+        comm.run(launcher)
 
         return "OK, stopped instance listening address "+address
 
diff --git a/func/minion/modules/service.py b/func/minion/modules/service.py
index b17aac5..3380a8e 100644
--- a/func/minion/modules/service.py
+++ b/func/minion/modules/service.py
@@ -25,8 +25,8 @@ class Service(func_module.FuncModule):
     description = "Allows for service control via func."
 
     def __command(self, service_name, command):
-	
-	service_name = service_name.strip() # remove useless spaces
+    
+        service_name = service_name.strip() # remove useless spaces
 
         filename = os.path.join("/etc/rc.d/init.d/",service_name)
         if os.path.exists(filename):
@@ -92,14 +92,14 @@ class Service(func_module.FuncModule):
         results = []
         for line in data.split("\n"):
             if line.find("0:") != -1:
-               # regular services
-               tokens = line.split()
-               results.append((tokens[0],tokens[1:]))
+                # regular services
+                tokens = line.split()
+                results.append((tokens[0],tokens[1:]))
             elif line.find(":") != -1 and not line.endswith(":"):
-               # xinetd.d based services
-               tokens = line.split()
-               tokens[0] = tokens[0].replace(":","")
-               results.append((tokens[0],tokens[1]))
+                # xinetd.d based services
+                tokens = line.split()
+                tokens[0] = tokens[0].replace(":","")
+                results.append((tokens[0],tokens[1]))
         return results
 
     def get_running(self):
diff --git a/func/minion/modules/test.py b/func/minion/modules/test.py
index 3b0089d..71315b7 100644
--- a/func/minion/modules/test.py
+++ b/func/minion/modules/test.py
@@ -67,12 +67,12 @@ class Test(func_module.FuncModule):
         return self.config_items()
 
     def config_save(self):
-	"""
-	Saves the options config
-	"""
-	self.save_config()
+        """
+        Saves the options config
+        """
+        self.save_config()
         # lame, need to convert the object into a marshaable ds
-	return self.config_items()
+        return self.config_items()
 
     def config_set(self, key_name, value):
         setattr(self.options,key_name, value)
@@ -80,10 +80,10 @@ class Test(func_module.FuncModule):
         return self.config_items()
 
     def config_get(self, key_name):
-	return getattr(self.options, key_name)
+        return getattr(self.options, key_name)
 
     def config_get_test(self):
-	return self.options.testvalue
+        return self.options.testvalue
 
     def register_method_args(self):
         """
diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py
index b0d6061..a7a6161 100644
--- a/func/minion/modules/virt.py
+++ b/func/minion/modules/virt.py
@@ -72,7 +72,7 @@ class FuncLibvirtConnection(object):
 
         # this block of code borrowed from virt-manager:
         # get working domain's name
-        ids = conn.listDomainsID();
+        ids = conn.listDomainsID()
         for id in ids:
             vm = conn.lookupByID(id)
             vms.append(vm)
@@ -213,35 +213,35 @@ class Virt(func_module.FuncModule):
         return results
 
     def virttype(self):
-	return self.__get_conn().get_type()
+        return self.__get_conn().get_type()
 
     def autostart(self, vm):
-	self.conn = self.__get_conn()
-	if self.conn.get_type() == "Xen":
-	    autostart_args = [
-		"/bin/ln",
-		"-s",
-		"/etc/xen/%s" % vm,
-		"/etc/xen/auto"
-	    ]
+        self.conn = self.__get_conn()
+        if self.conn.get_type() == "Xen":
+            autostart_args = [
+            "/bin/ln",
+            "-s",
+            "/etc/xen/%s" % vm,
+            "/etc/xen/auto"
+            ]
         else:
             # When using KVM, we need to make sure the autostart
             # directory exists
-	    mkdir_args = [
-		"/bin/mkdir",
-		"-p",
-		"/etc/libvirt/qemu/autostart"
-	    ]
+            mkdir_args = [
+            "/bin/mkdir",
+            "-p",
+            "/etc/libvirt/qemu/autostart"
+            ]
             sub_process.call(mkdir_args,shell=False,close_fds=True)
 
             # We aren't using virsh autostart because we want
             # the command to work even when the VM isn't running
-	    autostart_args = [
-		"/bin/ln",
-		"-s",
-		"/etc/libvirt/qemu/%s.xml" % vm,
-		"/etc/libvirt/qemu/autostart/%s.xml" % vm
-	    ]
+            autostart_args = [
+            "/bin/ln",
+            "-s",
+            "/etc/libvirt/qemu/%s.xml" % vm,
+            "/etc/libvirt/qemu/autostart/%s.xml" % vm
+            ]
 
         return sub_process.call(autostart_args,shell=False,close_fds=True)
 
@@ -383,86 +383,87 @@ class Virt(func_module.FuncModule):
 
     def get_xml(self, vmid):
         """
-	Recieve a Vm id as input
+        Recieve a Vm id as input
         Return an xml describing vm config returned by a libvirt call
-	"""
-	conn = libvirt.openReadOnly(None)
-	if conn == None:
-		return (-1,'Failed to open connection to the hypervisor')
-	try:
-		domV = conn.lookupByName(vmid)
-	except:
-		return (-1,'Failed to find the main domain')
-	return domV.XMLDesc(0)
+        """
+        conn = libvirt.openReadOnly(None)
+        if conn == None:
+            return (-1,'Failed to open connection to the hypervisor')
+        try:
+            domV = conn.lookupByName(vmid)
+        except:
+            return (-1,'Failed to find the main domain')
+        return domV.XMLDesc(0)
 
 
     def get_graphics(self,vmid,xml='None'):
-	"""
-	Recieve a Vm id as input
-	Read machine informations from xml config,
-	return a key/val map containing only graphics properties
-	"""
-	out = {'autoport': 'None', 'keymap': 'None', 'type': 'vnc', 'port': 'None', 'listen': 'None'}
-	if(xml=='None'):
-	    xml = self.get_xml(vmid)
-	else:
-	    xml = "<domain>\n"+xml+"\n</domain>"
-	ssock = StringIO.StringIO(xml)
-	doc = minidom.parse(ssock)
-	for node in doc.getElementsByTagName("domain"):
-	    graphics = node.getAttribute("devices")
-	    L = node.getElementsByTagName("graphics")
-	    for node2 in L:
-		for k in node2.attributes.keys():
-		    out[k] = node2.getAttribute(k)
-	return out
+        """
+        Recieve a Vm id as input
+        Read machine informations from xml config,
+        return a key/val map containing only graphics properties
+        """
+        out = {'autoport': 'None', 'keymap': 'None', 'type': 'vnc', 'port': 'None', 'listen': 'None'}
+        if(xml=='None'):
+            xml = self.get_xml(vmid)
+        else:
+            xml = "<domain>\n"+xml+"\n</domain>"
+        ssock = StringIO.StringIO(xml)
+        doc = minidom.parse(ssock)
+        for node in doc.getElementsByTagName("domain"):
+            graphics = node.getAttribute("devices")
+            L = node.getElementsByTagName("graphics")
+            for node2 in L:
+                for k in node2.attributes.keys():
+                    out[k] = node2.getAttribute(k)
+        return out
 
 
     def set_graphics(self,vmid,xml):
-	"""
-	Recieve a Vm id and a piece of xml as input
-	Set vnc address and parameters of vm in xml config file
-	Return 0 if config has been correctly written
-	"""
-	try:
-	   conn = libvirt.openReadOnly(None)
-	   tmp = conn.getType()
-	except:
-	   return (-1,'Failed to open connection to the hypervisor')
-	strxml = self.get_graphics(vmid,xml)
-	str = "vfb = [ \"vncunused=1, "
-
-	for el in strxml:
-	    if(strxml[el] != 'None'):
-		if(el == 'port'):
-		    str = "%s%s=\'%s\', " % (str,"vncdisplay",(int(strxml[el])-5900))
-		else:
-		    str = "%s%s=\'%s\', " % (str,el,strxml[el])
-	str = "%s\" ]" % str.rstrip(' ').rstrip(',')
-
-	if(tmp == "Xen"):
-	    if os.path.exists("/etc/xen/%s" % vmid):
-		return os.system("sed -i 's/^vfb.*/%s/g' /etc/xen/%s" % (str,vmid))
-	    else:
-		return (-1,'Config file /etc/xen/%s not found' % vmid)
-	else:
-	    if os.path.exists("/etc/libvirt/qemu/%s.xml" % vmid):
-		xml = self.get_xml(vmid)
-		ssock = StringIO.StringIO(xml)
-		doc = minidom.parse(ssock)
-		for node in doc.getElementsByTagName("domain"):
-		    graphics = node.getAttribute("devices")
-		    L = node.getElementsByTagName("graphics")
-		    for node2 in L:
-			for el in strxml:
+        """
+        Recieve a Vm id and a piece of xml as input
+        Set vnc address and parameters of vm in xml config file
+        Return 0 if config has been correctly written
+        """
+        try:
+            conn = libvirt.openReadOnly(None)
+            tmp = conn.getType()
+        except:
+            return (-1,'Failed to open connection to the hypervisor')
+        strxml = self.get_graphics(vmid,xml)
+        str = "vfb = [ \"vncunused=1, "
+
+        for el in strxml:
+            if(strxml[el] != 'None'):
+                if(el == 'port'):
+                    str = "%s%s=\'%s\', " % (str,"vncdisplay",(int(strxml[el])-5900))
+                else:
+                    str = "%s%s=\'%s\', " % (str,el,strxml[el])
+        str = "%s\" ]" % str.rstrip(' ').rstrip(',')
+
+        if(tmp == "Xen"):
+            if os.path.exists("/etc/xen/%s" % vmid):
+                return os.system("sed -i 's/^vfb.*/%s/g' /etc/xen/%s" % (str,vmid))
+            else:
+                return (-1,'Config file /etc/xen/%s not found' % vmid)
+        else:
+            if os.path.exists("/etc/libvirt/qemu/%s.xml" % vmid):
+                xml = self.get_xml(vmid)
+                ssock = StringIO.StringIO(xml)
+                doc = minidom.parse(ssock)
+                for node in doc.getElementsByTagName("domain"):
+                    graphics = node.getAttribute("devices")
+                    L = node.getElementsByTagName("graphics")
+                    for node2 in L:
+                        for el in strxml:
                             if(strxml[el] != 'None'):
                                 node2.setAttribute(el,strxml[el])
-		output_xml = open("/etc/libvirt/qemu/%s.xml" % vmid, 'w')
-		output_xml.write(node.toxml())
-		return 0
-	    else:
-		return (-1,'Config file /etc/libvirt/qemu/%s.xml not found' % vmid)
-	return (-2,'Unmatched Condition in set_graphics method')
+            
+                output_xml = open("/etc/libvirt/qemu/%s.xml" % vmid, 'w')
+                output_xml.write(node.toxml())
+                return 0
+            else:
+                return (-1,'Config file /etc/libvirt/qemu/%s.xml not found' % vmid)
+        return (-2,'Unmatched Condition in set_graphics method')
 
     def set_vcpus(self, vmid, num):
         """


_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Home]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Red Hat 9 Bible]     [Fedora Bible]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

Powered by Linux

Google
  Web www.spinics.net