Revision 45317e3a

b/lib/cmdlib.py
1367 1367
  return env
1368 1368

  
1369 1369

  
1370
def _BuildNetworkHookEnvByObject(net):
1371
  """Builds network related env varliables for hooks
1372

  
1373
  @type net: L{objects.Network}
1374
  @param net: the network object
1375

  
1376
  """
1377
  args = {
1378
    "name": net.name,
1379
    "subnet": net.network,
1380
    "gateway": net.gateway,
1381
    "network6": net.network6,
1382
    "gateway6": net.gateway6,
1383
    "network_type": net.network_type,
1384
    "mac_prefix": net.mac_prefix,
1385
    "tags": net.tags,
1386
  }
1387

  
1388
  return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
1389

  
1390

  
1391 1370
def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
1392 1371
                          minmem, maxmem, vcpus, nics, disk_template, disks,
1393 1372
                          bep, hvp, hypervisor_name, tags):
b/lib/constants.py
146 146
CONFD = "ganeti-confd"
147 147
RAPI = "ganeti-rapi"
148 148
MASTERD = "ganeti-masterd"
149
# used in the ganeti-nbma project
150
NLD = "ganeti-nld"
151 149

  
152 150
DAEMONS_PORTS = {
153 151
  # daemon-name: ("proto", "default-port")
......
155 153
  CONFD: ("udp", 1814),
156 154
  RAPI: ("tcp", 5080),
157 155
  "ssh": ("tcp", 22),
158
  # used in the ganeti-nbma project
159
  NLD: ("udp", 1816),
160 156
}
161 157
DEFAULT_NODED_PORT = DAEMONS_PORTS[NODED][1]
162 158
DEFAULT_CONFD_PORT = DAEMONS_PORTS[CONFD][1]
163 159
DEFAULT_RAPI_PORT = DAEMONS_PORTS[RAPI][1]
164
# used in the ganeti-nbma project
165
DEFAULT_NLD_PORT = DAEMONS_PORTS[NLD][1]
166 160

  
167 161
FIRST_DRBD_PORT = 11000
168 162
LAST_DRBD_PORT = 14999
b/lib/http/__init__.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2007, 2008, 2010 Google Inc.
4
# Copyright (C) 2007, 2008, 2010, 2012 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
530 530
    raise HttpError("Error in SSL handshake: %s" % err)
531 531

  
532 532

  
533
def InitSsl():
534
  """Initializes the SSL infrastructure.
535

  
536
  This function is idempotent.
537

  
538
  """
539
  if not OpenSSL.rand.status():
540
    raise EnvironmentError("OpenSSL could not collect enough entropy"
541
                           " for the PRNG")
542

  
543
  # TODO: Maybe add some additional seeding for OpenSSL's PRNG
544

  
545

  
546 533
class HttpSslParams(object):
547 534
  """Data class for SSL key and certificate.
548 535

  
b/lib/qlang.py
38 38
import pyparsing as pyp
39 39

  
40 40
from ganeti import errors
41
from ganeti import netutils
42 41
from ganeti import utils
43 42
from ganeti import compat
44 43

  
......
258 257
                                       " '%s': %s" % (text, err), err)
259 258

  
260 259

  
261
def _IsHostname(text):
262
  """Checks if a string could be a hostname.
263

  
264
  @rtype: bool
265

  
266
  """
267
  try:
268
    netutils.Hostname.GetNormalizedName(text)
269
  except errors.OpPrereqError:
270
    return False
271
  else:
272
    return True
273

  
274

  
275 260
def _CheckFilter(text):
276 261
  """CHecks if a string could be a filter.
277 262

  
b/lib/rapi/baserlib.py
85 85
  return map(_MapId, ids)
86 86

  
87 87

  
88
def ExtractField(sequence, index):
89
  """Creates a list containing one column out of a list of lists.
90

  
91
  @param sequence: sequence of lists
92
  @param index: index of field
93

  
94
  """
95
  return map(lambda item: item[index], sequence)
96

  
97

  
98 88
def MapFields(names, data):
99 89
  """Maps two lists into one dictionary.
100 90

  
......
127 117
  return items_details
128 118

  
129 119

  
130
def MakeParamsDict(opts, params):
131
  """Makes params dictionary out of a option set.
132

  
133
  This function returns a dictionary needed for hv or be parameters. But only
134
  those fields which provided in the option set. Takes parameters frozensets
135
  from constants.
136

  
137
  @type opts: dict
138
  @param opts: selected options
139
  @type params: frozenset
140
  @param params: subset of options
141
  @rtype: dict
142
  @return: dictionary of options, filtered by given subset.
143

  
144
  """
145
  result = {}
146

  
147
  for p in params:
148
    try:
149
      value = opts[p]
150
    except KeyError:
151
      continue
152
    result[p] = value
153

  
154
  return result
155

  
156

  
157 120
def FillOpcode(opcls, body, static, rename=None):
158 121
  """Fills an opcode with body parameters.
159 122

  
b/qa/qa_utils.py
118 118
    raise qa_error.Error("%r == %r" % (first, second))
119 119

  
120 120

  
121
def AssertNotEqual(first, second):
122
  """Raises an error when values are equal.
123

  
124
  """
125
  if not first != second:
126
    raise qa_error.Error("%r != %r" % (first, second))
127

  
128

  
129 121
def AssertMatch(string, pattern):
130 122
  """Raises an error when string doesn't match regexp pattern.
131 123

  

Also available in: Unified diff