Change in vdsm[master]: pep8: Add non .py sources to PEP8_WHITELIST

dkuznets at redhat.com dkuznets at redhat.com
Wed May 21 11:52:06 UTC 2014


Dima Kuznetsov has uploaded a new change for review.

Change subject: pep8: Add non .py sources to PEP8_WHITELIST
......................................................................

pep8: Add non .py sources to PEP8_WHITELIST

Change-Id: Ic84d0acb47766ed3c433e06589114daca93083a5
Signed-off-by: Dima Kuznetsov <dkuznets at redhat.com>
---
M Makefile.am
M vds_bootstrap/setup
M vdsm/get-conf-item
M vdsm/set-conf-item
4 files changed, 91 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/27972/1

diff --git a/Makefile.am b/Makefile.am
index f72576c..ff1ea8e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,8 +62,16 @@
 	$(NULL)
 
 PEP8_WHITELIST = \
-	vdsm-tool/vdsm-tool \
+	contrib/profile-stats \
+	init/daemonAdapter \
+	vdsm/get-conf-item \
+	vdsm/set-conf-item \
 	vdsm/supervdsmServer \
+	vdsm/vdsm \
+	vdsm/vdsm-restore-net-config \
+	vdsm/storage/curl-img-wrap \
+	vdsm-tool/vdsm-tool \
+	vds_bootstrap/setup \
 	$(NULL)
 
 
diff --git a/vds_bootstrap/setup b/vds_bootstrap/setup
index 778dc12..972eb3e 100755
--- a/vds_bootstrap/setup
+++ b/vds_bootstrap/setup
@@ -14,31 +14,34 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 #
 # Refer to the README and COPYING files for full details of the license
 #
 
-import sys, getopt
+import sys
+import getopt
 import os
 import subprocess
-import logging, logging.config
+import logging
+import logging.config
 import traceback
 import string
 import re
 import tempfile
 from time import strftime
 
-SUPPORTED_PLATFORMS = [ "RedHatEnterpriseServer", "Fedora" ]
-HYPERVISOR_PLATFORMS = [ "RedHatEnterpriseVirtualizationHypervisor", "RedHatEnterpriseHypervisor", "oVirtNodeHypervisor" ]
+SUPPORTED_PLATFORMS = ["RedHatEnterpriseServer", "Fedora"]
+HYPERVISOR_PLATFORMS = ["RedHatEnterpriseVirtualizationHypervisor",
+                        "RedHatEnterpriseHypervisor", "oVirtNodeHypervisor"]
 HYPERVISOR_RELEASE_FILE = '/etc/rhev-hypervisor-release'
 REDHAT_RELEASE_FILE = '/etc/redhat-release'
 vdsm_reg_conf_file = '/etc/vdsm-reg/vdsm-reg.conf'
 
 try:
-    LOGDIR=os.environ["OVIRT_LOGDIR"]
+    LOGDIR = os.environ["OVIRT_LOGDIR"]
 except KeyError:
-    LOGDIR=tempfile.gettempdir()
+    LOGDIR = tempfile.gettempdir()
 logging.basicConfig(level=logging.DEBUG,
                     format='%(asctime)s %(levelname)-8s %(module)s '
                            '%(lineno)d %(message)s',
@@ -47,13 +50,16 @@
                              (LOGDIR, "setup", strftime("%Y%m%d%H%M%S")),
                     filemode='w')
 
+
 def printNlog(s):
     print s
     logging.debug(s)
 
+
 def releaseFileExists():
     """ -- According to lsb_release:
-           Read first line from HYPERVISOR_RELEASE_FILE, then try REDHAT_RELEASE_FILE and then return it.
+           Read first line from HYPERVISOR_RELEASE_FILE,
+           then try REDHAT_RELEASE_FILE and then return it.
     """
     if os.path.exists(HYPERVISOR_RELEASE_FILE):
         return True, HYPERVISOR_RELEASE_FILE
@@ -62,17 +68,18 @@
     else:
         return False, HYPERVISOR_RELEASE_FILE + ", " + REDHAT_RELEASE_FILE
 
+
 def get_id_line():
     line = ''
     RELEASE_FILE = None
 
     try:
-        fileExists, releaseFile =  releaseFileExists()
+        fileExists, releaseFile = releaseFileExists()
         RELEASE_FILE = releaseFile
         if (fileExists):
             release = open(releaseFile, "r")
             line = release.readline()
-            line = line.replace ("\n", "")
+            line = line.replace("\n", "")
             release.close
             logging.debug("get_id_line: read line %s.", line)
         else:
@@ -85,6 +92,7 @@
         logging.error(message + "\n" + traceback.format_exc())
 
     return line
+
 
 def lsb_release():
     """ -- According to lsb_release:
@@ -102,6 +110,7 @@
 
     logging.debug("lsb_release: return: %s.", res)
     return res
+
 
 def testPlatform():
     ''' testPlatform evaluates the platform version and returns
@@ -138,12 +147,18 @@
         logging.error(message + "\n" + traceback.format_exc())
         st = "FAIL"
 
-    printNlog("<BSTRAP component='%s' status='%s' message='%s'/>" % (component,st, message))
+    printNlog("<BSTRAP component='%s' status='%s' message='%s'/>" % (
+        component, st, message))
     sys.stdout.flush()
 
     return fReturn
 
-def runInstaller(bootstrap_interface_version, remote_nfs, orgName, systime, vds_config_str, url_rpm, vds_server, random_num, script, vds_complete, firewall_rules_file, engine_ssh_key, rebootAfterInstallation, installVirtualizationService, installGlusterService, bridgeName):
+
+def runInstaller(bootstrap_interface_version, remote_nfs, orgName, systime,
+                 vds_config_str, url_rpm, vds_server, random_num, script,
+                 vds_complete, firewall_rules_file, engine_ssh_key,
+                 rebootAfterInstallation, installVirtualizationService,
+                 installGlusterService, bridgeName):
     """ -- Run VDS bootstrap scripts
     """
     try:
@@ -174,19 +189,22 @@
                 else:
                     execfn += [random_num]
                 execfn.append(str(int(rebootAfterInstallation)))
-            logging.debug("trying to run %s script cmd = '%s'",script, string.join(execfn, " "))
+            logging.debug("trying to run %s script cmd = '%s'",
+                          script, string.join(execfn, " "))
             proc = subprocess.Popen(execfn)
             proc.communicate()
             if proc.returncode == 0:
                 return True
         else:
-            logging.debug("script %s doen not exist",script)
+            logging.debug("script %s doen not exist", script)
     except:
         logging.error(traceback.format_exc())
 
     return False
 
-def process_ovirt_platform(url_bs, engine_port, random_num, systime, engine_ssh_key):
+
+def process_ovirt_platform(url_bs, engine_port, random_num,
+                           systime, engine_ssh_key):
 
     """ update vdsm-reg.conf and restart vdsm-reg service """
     import time
@@ -199,13 +217,16 @@
         time_struct = time.strptime(systime, '%Y-%m-%dT%H:%M:%S')
         ticket = calendar.timegm(time_struct)
     except ValueError as ex:
-        logging.debug("setHostTime: Failed to parse ENGINE time. message= " + str(ex))
+        logging.debug(
+            "setHostTime: Failed to parse ENGINE time. message= " + str(ex))
         return 1
 
     if ticket is not None:
-        return_value = update_and_restart_vdsm_reg(url_bs, engine_port, engine_ssh_key, ticket)
+        return_value = update_and_restart_vdsm_reg(url_bs, engine_port,
+                                                   engine_ssh_key, ticket)
 
     return return_value
+
 
 def update_and_restart_vdsm_reg(url_bs, engine_port, engine_ssh_key, ticket):
     from urlparse import urlparse
@@ -213,7 +234,8 @@
     try:
         import deployUtil
     except:
-        printNlog("<BSTRAP component='INIT' status='FAIL' message='Error trying to deploy library.'/>")
+        printNlog("<BSTRAP component='INIT' status='FAIL' "
+                  "message='Error trying to deploy library.'/>")
         logging.error(traceback.format_exc())
         return False
 
@@ -223,7 +245,8 @@
     return_value = False
     if not os.path.exists(vdsm_reg_conf_file):
         message = "Error trying to configure registration service."
-        printNlog("<BSTRAP component='UPDATE_VDSM_REG_CONF' status='FAIL' message='%s'/>" % (message) )
+        printNlog("<BSTRAP component='UPDATE_VDSM_REG_CONF' "
+                  "status='FAIL' message='%s'/>" % (message))
         logging.debug("file %s does not exist", vdsm_reg_conf_file)
     else:
         vdc_url = urlparse(url_bs)
@@ -232,20 +255,25 @@
                 engine_port = str(vdc_url.port)
 
         if engine_port is not None:
-            deployUtil._updateFileLine(vdsm_reg_conf_file, "vdc_host_port", str(engine_port), True)
+            deployUtil._updateFileLine(vdsm_reg_conf_file, "vdc_host_port",
+                                       str(engine_port), True)
 
-        deployUtil._updateFileLine(vdsm_reg_conf_file, "vdc_host_name", str(vdc_url.hostname), True)
-        deployUtil._updateFileLine(vdsm_reg_conf_file, "ticket", str(ticket), True)
+        deployUtil._updateFileLine(vdsm_reg_conf_file, "vdc_host_name",
+                                   str(vdc_url.hostname), True)
+        deployUtil._updateFileLine(vdsm_reg_conf_file, "ticket",
+                                   str(ticket), True)
         deployUtil.ovirtfunctions.ovirt_store_config(vdsm_reg_conf_file)
 
         if handle_ssh_key(vdc_url.hostname, str(engine_port), engine_ssh_key):
-            out, err, return_code = deployUtil.setService('vdsm-reg', 'restart')
+            out, err, return_code = deployUtil.setService('vdsm-reg',
+                                                          'restart')
         else:
             return_code = None
 
         if not return_code:
             return_value = True
     return return_value
+
 
 def handle_ssh_key(host, port, engine_ssh_key):
     import deployUtil
@@ -262,20 +290,30 @@
         ssh_result = deployUtil.handleSSHKey(strKey)
 
     if ssh_result:
-        printNlog("<BSTRAP component='RHEV_INSTALL' status='OK' message='RHEV-H ACCESSIBLE'/>")
+        printNlog("<BSTRAP component='RHEV_INSTALL' status='OK' "
+                  "message='RHEV-H ACCESSIBLE'/>")
     else:
-        printNlog("<BSTRAP component='RHEV_INSTALL' status='FAIL' message='Host failed to download management server public-key.'/>")
+        printNlog(
+            "<BSTRAP component='RHEV_INSTALL' status='FAIL' "
+            "message='Host failed to download management server public-key.'/>"
+        )
 
     return ssh_result
 
+
 def main():
-    """Usage: vds_installer.py  [-c vds_config_str] [-v ver] [-m remote_nfs] [-r rev_num] [-O organizationName] [-t YYYY-MM-DDTHH:mm:SS_system_time] [-S engine-ssh-key] [-p engine_port] [-B bridge_name] [-V] [-g] <url_bs> <url_rpm> <vds_server> <random_num> <vds_complete>
+    """Usage:
+    vds_installer.py  [-c vds_config_str] [-v ver] [-m remote_nfs] [-r rev_num]
+    [-O organizationName] [-t YYYY-MM-DDTHH:mm:SS_system_time]
+    [-S engine-ssh-key] [-p engine_port] [-B bridge_name] [-V] [-g]
+    <url_bs> <url_rpm> <vds_server> <random_num> <vds_complete>
                     url_bs - components url
                     url_rpm - rpm download url
                     random_num - random number for temp. file names generation
                     vds_server - vds server for CSR usage
                     vds_complete - to run first vds_bootstrap script = false
-                                   to run second vds_bootstrap_complete script = true
+                                   to run second vds_bootstrap_complete
+                                   script = true
                     -v - interface version, default=2
                     -B - bridge name, default is installation specific
                     -V - don't install virutalization components on the host
@@ -283,7 +321,7 @@
     try:
         bootstrap_interface_version = 2
         remote_nfs = None
-        rev_num = None
+        # rev_num = None
         vds_config_str = None
         orgName = None
         systime = None
@@ -295,15 +333,15 @@
         installGlusterService = False
         bridgeName = None
         opts, args = getopt.getopt(sys.argv[1:], "c:m:r:O:t:p:bf:S:gB:Vv:")
-        for o,v in opts:
+        for o, v in opts:
             if o == "-v":
                 bootstrap_interface_version = int(v)
             if o == "-c":
                 vds_config_str = v
             if o == "-m":
                 remote_nfs = v
-            if o == "-r":
-                rev_num = v
+            # if o == "-r":
+            #    rev_num = v
             if o == "-O":
                 orgName = v
             if o == "-t":
@@ -377,9 +415,11 @@
                 try:
                     os.unlink(firewall_rules_file)
                 except:
-                    logging.warn("Failed to delete firewall conf file: %s" , firewall_rules_file)
+                    logging.warn("Failed to delete firewall conf file: %s",
+                                 firewall_rules_file)
         elif res == 1:
-            ret_value = process_ovirt_platform(url_bs, engine_port, random_num, systime, engine_ssh_key)
+            ret_value = process_ovirt_platform(url_bs, engine_port, random_num,
+                                               systime, engine_ssh_key)
             if ret_value is False:
                 printNlog("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
             return ret_value
@@ -400,4 +440,4 @@
     os.chdir(os.path.dirname(sys.argv[0]))
 
     # execute
-    sys.exit(not main()) # exit=0 is success
+    sys.exit(not main())  # exit=0 is success
diff --git a/vdsm/get-conf-item b/vdsm/get-conf-item
index 3ae4af5..3f5ffc8 100755
--- a/vdsm/get-conf-item
+++ b/vdsm/get-conf-item
@@ -5,14 +5,14 @@
 
 import sys
 try:
-   from vdsm.config import config
+    from vdsm.config import config
 except:
-   import ConfigParser
-   config = ConfigParser.ConfigParser()
+    import ConfigParser
+    config = ConfigParser.ConfigParser()
 
 (dummy, file, section, item, default) = sys.argv
 config.read(file)
 try:
-   print config.get(section, item)
+    print config.get(section, item)
 except:
-   print default
+    print default
diff --git a/vdsm/set-conf-item b/vdsm/set-conf-item
index 9c8203e..5530192 100755
--- a/vdsm/set-conf-item
+++ b/vdsm/set-conf-item
@@ -7,10 +7,10 @@
 
 import sys
 try:
-   from vdsm.config import config
+    from vdsm.config import config
 except:
-   import ConfigParser
-   config = ConfigParser.ConfigParser()
+    import ConfigParser
+    config = ConfigParser.ConfigParser()
 
 (dummy, fname, section, item, value) = sys.argv
 config.read(fname)


-- 
To view, visit http://gerrit.ovirt.org/27972
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic84d0acb47766ed3c433e06589114daca93083a5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets at redhat.com>


More information about the vdsm-patches mailing list