From 45317e3aa04a646d856cca14bef721e6f761652b Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 19 Dec 2012 12:18:40 +0100
Subject: [PATCH] Remove some unused Python code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch removes code which is no longer used due to refactoring:

- http.InitSsl, last usage removed in commit 33231500 (β€œConvert RPC
  client to PycURL”)
- rapi.baserlib.MakeParamsDict, last usage remove in commit 4e5a68f8
  (β€œRAPI: rlib1 removal”)
- rapi.baserlib.ExtractField, last usage removed in commit 028c6b76
  (β€œRAPI:Fix root list and unittest for it.”)
- qa.qa_utils.AssertNotEqual, last real usage removed in commit
  2f4b4f78 (β€œSimplify QA commands”) (but it was still imported for a
  while, until we extended pylint to run over the QA code as well)
- qlang._IsHostname, added in commit f8638e28 (β€œDetect globbing
  patterns as query arguments”) but never used
- cmdlib._BuildNetworkHookEnvByObject, last usage removed in commit
  f22433c0 (β€œLocking related fixes for networks”)
- NLD constants, which are obsoleteβ€”the nbma project is no longer
  maintained and it's not working with current ganeti

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py        | 21 ---------------------
 lib/constants.py     |  6 ------
 lib/http/__init__.py | 15 +--------------
 lib/qlang.py         | 15 ---------------
 lib/rapi/baserlib.py | 37 -------------------------------------
 qa/qa_utils.py       |  8 --------
 6 files changed, 1 insertion(+), 101 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 00f6a52f0..c09e1d881 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -1367,27 +1367,6 @@ def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6,
   return env
 
 
-def _BuildNetworkHookEnvByObject(net):
-  """Builds network related env varliables for hooks
-
-  @type net: L{objects.Network}
-  @param net: the network object
-
-  """
-  args = {
-    "name": net.name,
-    "subnet": net.network,
-    "gateway": net.gateway,
-    "network6": net.network6,
-    "gateway6": net.gateway6,
-    "network_type": net.network_type,
-    "mac_prefix": net.mac_prefix,
-    "tags": net.tags,
-  }
-
-  return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
-
-
 def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
                           minmem, maxmem, vcpus, nics, disk_template, disks,
                           bep, hvp, hypervisor_name, tags):
diff --git a/lib/constants.py b/lib/constants.py
index 3e6a0eb84..e96bcba2c 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -146,8 +146,6 @@ NODED = "ganeti-noded"
 CONFD = "ganeti-confd"
 RAPI = "ganeti-rapi"
 MASTERD = "ganeti-masterd"
-# used in the ganeti-nbma project
-NLD = "ganeti-nld"
 
 DAEMONS_PORTS = {
   # daemon-name: ("proto", "default-port")
@@ -155,14 +153,10 @@ DAEMONS_PORTS = {
   CONFD: ("udp", 1814),
   RAPI: ("tcp", 5080),
   "ssh": ("tcp", 22),
-  # used in the ganeti-nbma project
-  NLD: ("udp", 1816),
 }
 DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
 DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
 DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
-# used in the ganeti-nbma project
-DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
 
 FIRST_DRBD_PORT = 11000
 LAST_DRBD_PORT = 14999
diff --git a/lib/http/__init__.py b/lib/http/__init__.py
index e7adcbfe1..0ba1e32d7 100644
--- a/lib/http/__init__.py
+++ b/lib/http/__init__.py
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2007, 2008, 2010 Google Inc.
+# Copyright (C) 2007, 2008, 2010, 2012 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
@@ -530,19 +530,6 @@ def Handshake(sock, write_timeout):
     raise HttpError("Error in SSL handshake: %s" % err)
 
 
-def InitSsl():
-  """Initializes the SSL infrastructure.
-
-  This function is idempotent.
-
-  """
-  if not OpenSSL.rand.status():
-    raise EnvironmentError("OpenSSL could not collect enough entropy"
-                           " for the PRNG")
-
-  # TODO: Maybe add some additional seeding for OpenSSL's PRNG
-
-
 class HttpSslParams(object):
   """Data class for SSL key and certificate.
 
diff --git a/lib/qlang.py b/lib/qlang.py
index af423e102..2352391bc 100644
--- a/lib/qlang.py
+++ b/lib/qlang.py
@@ -38,7 +38,6 @@ import logging
 import pyparsing as pyp
 
 from ganeti import errors
-from ganeti import netutils
 from ganeti import utils
 from ganeti import compat
 
@@ -258,20 +257,6 @@ def ParseFilter(text, parser=None):
                                        " '%s': %s" % (text, err), err)
 
 
-def _IsHostname(text):
-  """Checks if a string could be a hostname.
-
-  @rtype: bool
-
-  """
-  try:
-    netutils.Hostname.GetNormalizedName(text)
-  except errors.OpPrereqError:
-    return False
-  else:
-    return True
-
-
 def _CheckFilter(text):
   """CHecks if a string could be a filter.
 
diff --git a/lib/rapi/baserlib.py b/lib/rapi/baserlib.py
index a5f89032a..99a71a00d 100644
--- a/lib/rapi/baserlib.py
+++ b/lib/rapi/baserlib.py
@@ -85,16 +85,6 @@ def BuildUriList(ids, uri_format, uri_fields=("name", "uri")):
   return map(_MapId, ids)
 
 
-def ExtractField(sequence, index):
-  """Creates a list containing one column out of a list of lists.
-
-  @param sequence: sequence of lists
-  @param index: index of field
-
-  """
-  return map(lambda item: item[index], sequence)
-
-
 def MapFields(names, data):
   """Maps two lists into one dictionary.
 
@@ -127,33 +117,6 @@ def MapBulkFields(itemslist, fields):
   return items_details
 
 
-def MakeParamsDict(opts, params):
-  """Makes params dictionary out of a option set.
-
-  This function returns a dictionary needed for hv or be parameters. But only
-  those fields which provided in the option set. Takes parameters frozensets
-  from constants.
-
-  @type opts: dict
-  @param opts: selected options
-  @type params: frozenset
-  @param params: subset of options
-  @rtype: dict
-  @return: dictionary of options, filtered by given subset.
-
-  """
-  result = {}
-
-  for p in params:
-    try:
-      value = opts[p]
-    except KeyError:
-      continue
-    result[p] = value
-
-  return result
-
-
 def FillOpcode(opcls, body, static, rename=None):
   """Fills an opcode with body parameters.
 
diff --git a/qa/qa_utils.py b/qa/qa_utils.py
index 873459d46..930190ff6 100644
--- a/qa/qa_utils.py
+++ b/qa/qa_utils.py
@@ -118,14 +118,6 @@ def AssertEqual(first, second):
     raise qa_error.Error("%r == %r" % (first, second))
 
 
-def AssertNotEqual(first, second):
-  """Raises an error when values are equal.
-
-  """
-  if not first != second:
-    raise qa_error.Error("%r != %r" % (first, second))
-
-
 def AssertMatch(string, pattern):
   """Raises an error when string doesn't match regexp pattern.
 
-- 
GitLab