Commit d984846d authored by Iustin Pop's avatar Iustin Pop
Browse files

Merge branch 'devel-2.0' into devel-2.1

* devel-2.0:
  Fix indentation in hv_kvm
  Implement BuildHooksEnv for NoHooksLU
  Clarifiy some more wide pylint disables
  Fix two bugs in seldom-used codepaths
  Update pylintrc
  Add targetted pylint disables
  Partial cherry-pick of 6c881c52 from the 2.1 branch
  Add a release script
  Fix a typo in the doc string

Conflicts:
	lib/cli.py
	lib/cmdlib.py
	lib/hypervisor/hv_kvm.py
	lib/jstore.py
	lib/locking.py
	lib/mcpu.py
	lib/rapi/rlib2.py

Many of the conflicts were on code removed from 2.1, so the resolving was
trivial.
parents fa05c92d 146afafb
#!/bin/bash
# Copyright (C) 2009 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# 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.
# This is a test script to ease development and testing on test clusters.
# It should not be used to update production environments.
# Usage: release v2.0.5
# Alternative: URL=file:///my/git/repo release e5823b7e2cd8a3...
# It will clone the given repository from the default or passed URL,
# checkout the given reference (a tag or branch) and then create a
# release archive; you will need to copy the archive and delete the
# temporary directory at the end
set -e
: ${URL:=git://git.ganeti.org/ganeti.git}
TAG="$1"
TMPDIR=`mktemp -d`
cd $TMPDIR
echo "Cloning the repository under $TMPDIR ..."
git clone -q "$URL" dist
cd dist
git checkout $TAG
./autogen.sh
./configure
VERSION=$(sed -n -e '/^PACKAGE_VERSION =/ s/^PACKAGE_VERSION = // p' Makefile)
make distcheck
fakeroot make dist
tar tzvf ganeti-$VERSION.tar.gz
sha1sum ganeti-$VERSION.tar.gz
echo "The archive is at $PWD/ganeti-$VERSION.tar.gz"
echo "Please copy it and remove the temporary directory when done."
...@@ -20,3 +20,5 @@ ...@@ -20,3 +20,5 @@
# empty file for package definition # empty file for package definition
"""Ganeti python modules"""
...@@ -1206,6 +1206,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info): ...@@ -1206,6 +1206,7 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
# we need the children open in case the device itself has to # we need the children open in case the device itself has to
# be assembled # be assembled
try: try:
# pylint: disable-msg=E1103
crdev.Open() crdev.Open()
except errors.BlockDeviceError, err: except errors.BlockDeviceError, err:
_Fail("Can't make child '%s' read-write: %s", child, err) _Fail("Can't make child '%s' read-write: %s", child, err)
...@@ -1340,6 +1341,7 @@ def BlockdevAssemble(disk, owner, as_primary): ...@@ -1340,6 +1341,7 @@ def BlockdevAssemble(disk, owner, as_primary):
try: try:
result = _RecursiveAssembleBD(disk, owner, as_primary) result = _RecursiveAssembleBD(disk, owner, as_primary)
if isinstance(result, bdev.BlockDev): if isinstance(result, bdev.BlockDev):
# pylint: disable-msg=E1103
result = result.dev_path result = result.dev_path
except errors.BlockDeviceError, err: except errors.BlockDeviceError, err:
_Fail("Error while assembling disk: %s", err, exc=True) _Fail("Error while assembling disk: %s", err, exc=True)
...@@ -2627,7 +2629,9 @@ class HooksRunner(object): ...@@ -2627,7 +2629,9 @@ class HooksRunner(object):
""" """
if hooks_base_dir is None: if hooks_base_dir is None:
hooks_base_dir = constants.HOOKS_BASE_DIR hooks_base_dir = constants.HOOKS_BASE_DIR
self._BASE_DIR = hooks_base_dir # yeah, _BASE_DIR is not valid for attributes, we use it like a
# constant
self._BASE_DIR = hooks_base_dir # pylint: disable-msg=C0103
@staticmethod @staticmethod
def ExecHook(script, env): def ExecHook(script, env):
......
...@@ -783,7 +783,7 @@ class DRBD8Status(object): ...@@ -783,7 +783,7 @@ class DRBD8Status(object):
self.est_time = None self.est_time = None
class BaseDRBD(BlockDev): class BaseDRBD(BlockDev): # pylint: disable-msg=W0223
"""Base DRBD class. """Base DRBD class.
This class contains a few bits of common functionality between the This class contains a few bits of common functionality between the
......
...@@ -1531,8 +1531,8 @@ def GenerateTable(headers, fields, separator, data, ...@@ -1531,8 +1531,8 @@ def GenerateTable(headers, fields, separator, data,
if unitfields is None: if unitfields is None:
unitfields = [] unitfields = []
numfields = utils.FieldSet(*numfields) numfields = utils.FieldSet(*numfields) # pylint: disable-msg=W0142
unitfields = utils.FieldSet(*unitfields) unitfields = utils.FieldSet(*unitfields) # pylint: disable-msg=W0142
format_fields = [] format_fields = []
for field in fields: for field in fields:
......
...@@ -21,7 +21,10 @@ ...@@ -21,7 +21,10 @@
"""Module implementing the master-side code.""" """Module implementing the master-side code."""
# pylint: disable-msg=W0613,W0201 # pylint: disable-msg=W0201
# W0201 since most LU attributes are defined in CheckPrereq or similar
# functions
import os import os
import os.path import os.path
...@@ -87,9 +90,9 @@ class LogicalUnit(object): ...@@ -87,9 +90,9 @@ class LogicalUnit(object):
self.recalculate_locks = {} self.recalculate_locks = {}
self.__ssh = None self.__ssh = None
# logging # logging
self.LogWarning = processor.LogWarning self.LogWarning = processor.LogWarning # pylint: disable-msg=C0103
self.LogInfo = processor.LogInfo self.LogInfo = processor.LogInfo # pylint: disable-msg=C0103
self.LogStep = processor.LogStep self.LogStep = processor.LogStep # pylint: disable-msg=C0103
# support for dry-run # support for dry-run
self.dry_run_result = None self.dry_run_result = None
...@@ -347,7 +350,7 @@ class LogicalUnit(object): ...@@ -347,7 +350,7 @@ class LogicalUnit(object):
del self.recalculate_locks[locking.LEVEL_NODE] del self.recalculate_locks[locking.LEVEL_NODE]
class NoHooksLU(LogicalUnit): class NoHooksLU(LogicalUnit): # pylint: disable-msg=W0223
"""Simple LU which runs no hooks. """Simple LU which runs no hooks.
This LU is intended as a parent for other LogicalUnits which will This LU is intended as a parent for other LogicalUnits which will
...@@ -357,6 +360,14 @@ class NoHooksLU(LogicalUnit): ...@@ -357,6 +360,14 @@ class NoHooksLU(LogicalUnit):
HPATH = None HPATH = None
HTYPE = None HTYPE = None
def BuildHooksEnv(self):
"""Empty BuildHooksEnv for NoHooksLu.
This just raises an error.
"""
assert False, "BuildHooksEnv called for NoHooksLUs"
class Tasklet: class Tasklet:
"""Tasklet base class. """Tasklet base class.
...@@ -6536,7 +6547,8 @@ class TLReplaceDisks(Tasklet): ...@@ -6536,7 +6547,8 @@ class TLReplaceDisks(Tasklet):
if len(ial.nodes) != ial.required_nodes: if len(ial.nodes) != ial.required_nodes:
raise errors.OpPrereqError("iallocator '%s' returned invalid number" raise errors.OpPrereqError("iallocator '%s' returned invalid number"
" of nodes (%s), required %s" % " of nodes (%s), required %s" %
(len(ial.nodes), ial.required_nodes), (iallocator_name,
len(ial.nodes), ial.required_nodes),
errors.ECODE_FAULT) errors.ECODE_FAULT)
remote_node_name = ial.nodes[0] remote_node_name = ial.nodes[0]
...@@ -8232,7 +8244,7 @@ class LURemoveExport(NoHooksLU): ...@@ -8232,7 +8244,7 @@ class LURemoveExport(NoHooksLU):
" Domain Name.") " Domain Name.")
class TagsLU(NoHooksLU): class TagsLU(NoHooksLU): # pylint: disable-msg=W0223
"""Generic tags LU. """Generic tags LU.
This is an abstract class which is the parent of all the other tags LUs. This is an abstract class which is the parent of all the other tags LUs.
......
...@@ -384,7 +384,7 @@ def EncodeException(err): ...@@ -384,7 +384,7 @@ def EncodeException(err):
def MaybeRaise(result): def MaybeRaise(result):
"""Is this looks like an encoded Ganeti exception, raise it. """If this looks like an encoded Ganeti exception, raise it.
This function tries to parse the passed argument and if it looks This function tries to parse the passed argument and if it looks
like an encoding done by EncodeException, it will re-raise it. like an encoding done by EncodeException, it will re-raise it.
......
...@@ -261,7 +261,7 @@ class HttpClientRequestExecutor(http.HttpBase): ...@@ -261,7 +261,7 @@ class HttpClientRequestExecutor(http.HttpBase):
# Do the secret SSL handshake # Do the secret SSL handshake
if self.using_ssl: if self.using_ssl:
self.sock.set_connect_state() self.sock.set_connect_state() # pylint: disable-msg=E1103
try: try:
http.Handshake(self.sock, self.WRITE_TIMEOUT) http.Handshake(self.sock, self.WRITE_TIMEOUT)
except http.HttpSessionHandshakeUnexpectedEOF: except http.HttpSessionHandshakeUnexpectedEOF:
......
...@@ -68,7 +68,7 @@ class FakeHypervisor(hv_base.BaseHypervisor): ...@@ -68,7 +68,7 @@ class FakeHypervisor(hv_base.BaseHypervisor):
try: try:
inst_id = fh.readline().strip() inst_id = fh.readline().strip()
memory = utils.TryConvert(int, fh.readline().strip()) memory = utils.TryConvert(int, fh.readline().strip())
vcpus = utils.TryConvert(fh.readline().strip()) vcpus = utils.TryConvert(int, fh.readline().strip())
stat = "---b-" stat = "---b-"
times = "0" times = "0"
return (instance_name, inst_id, memory, vcpus, stat, times) return (instance_name, inst_id, memory, vcpus, stat, times)
......
...@@ -130,11 +130,12 @@ def InitAndVerifyQueue(must_lock): ...@@ -130,11 +130,12 @@ def InitAndVerifyQueue(must_lock):
if serial is None: if serial is None:
# There must be a serious problem # There must be a serious problem
raise errors.JobQueueError("Can't read/parse the job queue serial file") raise errors.JobQueueError("Can't read/parse the job queue"
" serial file")
if not must_lock: if not must_lock:
# There's no need for more error handling. Closing the lock file below # There's no need for more error handling. Closing the lock
# in case of an error will unlock it anyway. # file below in case of an error will unlock it anyway.
queue_lock.Unlock() queue_lock.Unlock()
except: except:
......
...@@ -18,11 +18,13 @@ ...@@ -18,11 +18,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. # 02110-1301, USA.
# Disable "Invalid name ..." message
# pylint: disable-msg=C0103
"""Module implementing the Ganeti locking code.""" """Module implementing the Ganeti locking code."""
# pylint: disable-msg=W0212
# W0212 since e.g. LockSet methods use (a lot) the internals of
# SharedLock
import os import os
import select import select
import threading import threading
...@@ -1202,7 +1204,7 @@ class GanetiLockManager: ...@@ -1202,7 +1204,7 @@ class GanetiLockManager:
# the test cases. # the test cases.
return utils.any((self._is_owned(l) for l in LEVELS[level + 1:])) return utils.any((self._is_owned(l) for l in LEVELS[level + 1:]))
def _BGL_owned(self): def _BGL_owned(self): # pylint: disable-msg=C0103
"""Check if the current thread owns the BGL. """Check if the current thread owns the BGL.
Both an exclusive or a shared acquisition work. Both an exclusive or a shared acquisition work.
...@@ -1210,7 +1212,8 @@ class GanetiLockManager: ...@@ -1210,7 +1212,8 @@ class GanetiLockManager:
""" """
return BGL in self.__keyring[LEVEL_CLUSTER]._list_owned() return BGL in self.__keyring[LEVEL_CLUSTER]._list_owned()
def _contains_BGL(self, level, names): @staticmethod
def _contains_BGL(level, names): # pylint: disable-msg=C0103
"""Check if the level contains the BGL. """Check if the level contains the BGL.
Check if acting on the given level and set of names will change Check if acting on the given level and set of names will change
......
...@@ -853,6 +853,8 @@ class Cluster(TaggableObject): ...@@ -853,6 +853,8 @@ class Cluster(TaggableObject):
"""Fill defaults for missing configuration values. """Fill defaults for missing configuration values.
""" """
# pylint: disable-msg=E0203
# because these are "defined" via slots, not manually
if self.hvparams is None: if self.hvparams is None:
self.hvparams = constants.HVC_DEFAULTS self.hvparams = constants.HVC_DEFAULTS
else: else:
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
import logging import logging
from ganeti import luxi from ganeti import luxi
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
import cgi import cgi
import re import re
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since the R_* names are not conforming
from ganeti import opcodes from ganeti import opcodes
from ganeti import http from ganeti import http
from ganeti import constants from ganeti import constants
......
...@@ -42,7 +42,8 @@ from ganeti import serializer ...@@ -42,7 +42,8 @@ from ganeti import serializer
from ganeti import constants from ganeti import constants
from ganeti import errors from ganeti import errors
import ganeti.http.client # pylint has a bug here, doesn't see this import
import ganeti.http.client # pylint: disable-msg=W0611
# Module level variable # Module level variable
...@@ -55,7 +56,7 @@ def Init(): ...@@ -55,7 +56,7 @@ def Init():
Must be called before using any RPC function. Must be called before using any RPC function.
""" """
global _http_manager global _http_manager # pylint: disable-msg=W0603
assert not _http_manager, "RPC module initialized more than once" assert not _http_manager, "RPC module initialized more than once"
...@@ -70,7 +71,7 @@ def Shutdown(): ...@@ -70,7 +71,7 @@ def Shutdown():
Must be called before quitting the program. Must be called before quitting the program.
""" """
global _http_manager global _http_manager # pylint: disable-msg=W0603
if _http_manager: if _http_manager:
_http_manager.Shutdown() _http_manager.Shutdown()
......
...@@ -24,6 +24,10 @@ This module introduces a simple abstraction over the serialization ...@@ -24,6 +24,10 @@ This module introduces a simple abstraction over the serialization
backend (currently json). backend (currently json).
""" """
# pylint: disable-msg=C0103
# C0103: Invalid name, since pylint doesn't see that Dump points to a
# function and not a constant
import simplejson import simplejson
import re import re
......
...@@ -11,7 +11,7 @@ load-plugins = ...@@ -11,7 +11,7 @@ load-plugins =
[REPORTS] [REPORTS]
output-format = colorized output-format = colorized
include-ids = no include-ids = yes
files-output = no files-output = no
reports = no reports = no
evaluation = 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) evaluation = 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
...@@ -19,15 +19,21 @@ comment = yes ...@@ -19,15 +19,21 @@ comment = yes
[BASIC] [BASIC]
required-attributes = required-attributes =
no-docstring-rgx = __.*__ # disabling docstring checks since we have way too many without (complex
# inheritance hierarchies)
#no-docstring-rgx = __.*__
no-docstring-rgx = .*
module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
const-rgx = ((_{0,2}[A-Z][A-Z0-9_]*)|(__.*__))$ # added lower-case names
const-rgx = ((_{0,2}[A-Z][A-Z0-9_]*)|(__.*__)|(_?[a-z_][a-z0-9_]*))$
class-rgx = _?[A-Z][a-zA-Z0-9]+$ class-rgx = _?[A-Z][a-zA-Z0-9]+$
function-rgx = (_?([A-Z]+[a-z0-9]+([A-Z]+[a-z0-9]*)*)|main)$ # added lower-case names
method-rgx = (_{0,2}[A-Z]+[a-z0-9]+([A-Z]+[a-z0-9]*)*|__.*__)$ function-rgx = (_?([A-Z]+[a-z0-9]+([A-Z]+[a-z0-9]*)*)|main|([a-z_][a-z0-9_]*))$
# add lower-case names, since derived classes must obey method names
method-rgx = (_{0,2}[A-Z]+[a-z0-9]+([A-Z]+[a-z0-9]*)*|__.*__|([a-z_][a-z0-9_]*))$
attr-rgx = [a-z_][a-z0-9_]{1,30}$ attr-rgx = [a-z_][a-z0-9_]{1,30}$
argument-rgx = [a-z_][a-z0-9_]*$ argument-rgx = [a-z_][a-z0-9_]*$
variable-rgx = (_?([a-z_][a-z0-9_]*)|([A-Z0-9_]+))$ variable-rgx = (_?([a-z_][a-z0-9_]*)|(_?[A-Z0-9_]+))$
inlinevar-rgx = [A-Za-z_][A-Za-z0-9_]*$ inlinevar-rgx = [A-Za-z_][A-Za-z0-9_]*$
good-names = i,j,k,_ good-names = i,j,k,_
bad-names = foo,bar,baz,toto,tutu,tata bad-names = foo,bar,baz,toto,tutu,tata
...@@ -48,15 +54,16 @@ ignore-iface-methods = ...@@ -48,15 +54,16 @@ ignore-iface-methods =
defining-attr-methods = __init__,__new__,setUp defining-attr-methods = __init__,__new__,setUp
[DESIGN] [DESIGN]
max-args = 6 max-args = 15
max-locals = 15 max-locals = 50
max-returns = 6 max-returns = 10
max-branchs = 12 max-branchs = 80
max-statements = 50 max-statements = 200
max-parents = 7 max-parents = 7
max-attributes = 7 max-attributes = 20
min-public-methods = 2 # zero as struct-like (PODS) classes don't export any methods
max-public-methods = 20 min-public-methods = 0
max-public-methods = 50
[IMPORTS] [IMPORTS]
deprecated-modules = regsub,string,TERMIOS,Bastion,rexec deprecated-modules = regsub,string,TERMIOS,Bastion,rexec
...@@ -66,7 +73,7 @@ int-import-graph = ...@@ -66,7 +73,7 @@ int-import-graph =
[FORMAT] [FORMAT]
max-line-length = 80 max-line-length = 80
max-module-lines = 1000 max-module-lines = 10000
indent-string = " " indent-string = " "
[MISCELLANEOUS] [MISCELLANEOUS]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment