Revision 3ecf6786 lib/config.py
b/lib/config.py | ||
---|---|---|
107 | 107 |
break |
108 | 108 |
retries -= 1 |
109 | 109 |
else: |
110 |
raise errors.ConfigurationError, ("Can't generate unique MAC")
|
|
110 |
raise errors.ConfigurationError("Can't generate unique MAC") |
|
111 | 111 |
return mac |
112 | 112 |
|
113 | 113 |
def _ComputeAllLVs(self): |
... | ... | |
151 | 151 |
if unique_id not in existing and unique_id is not None: |
152 | 152 |
break |
153 | 153 |
else: |
154 |
raise errors.ConfigurationError, ("Not able generate an unique ID"
|
|
155 |
" (last tried ID: %s" % unique_id)
|
|
154 |
raise errors.ConfigurationError("Not able generate an unique ID" |
|
155 |
" (last tried ID: %s" % unique_id) |
|
156 | 156 |
self._temporary_ids.add(unique_id) |
157 | 157 |
return unique_id |
158 | 158 |
|
... | ... | |
215 | 215 |
if disk.dev_type == "drbd": |
216 | 216 |
pnode, snode, port = disk.logical_id |
217 | 217 |
if node_name not in (pnode, snode): |
218 |
raise errors.ConfigurationError, ("DRBD device not knowing node %s" %
|
|
219 |
node_name)
|
|
218 |
raise errors.ConfigurationError("DRBD device not knowing node %s" % |
|
219 |
node_name) |
|
220 | 220 |
pnode_info = self.GetNodeInfo(pnode) |
221 | 221 |
snode_info = self.GetNodeInfo(snode) |
222 | 222 |
if pnode_info is None or snode_info is None: |
... | ... | |
237 | 237 |
|
238 | 238 |
""" |
239 | 239 |
if not isinstance(port, int): |
240 |
raise errors.ProgrammerError, ("Invalid type passed for port")
|
|
240 |
raise errors.ProgrammerError("Invalid type passed for port") |
|
241 | 241 |
|
242 | 242 |
self._OpenConfig() |
243 | 243 |
self._config_data.cluster.tcpudp_port_pool.add(port) |
... | ... | |
267 | 267 |
else: |
268 | 268 |
port = self._config_data.cluster.highest_used_port + 1 |
269 | 269 |
if port >= constants.LAST_DRBD_PORT: |
270 |
raise errors.ConfigurationError, ("The highest used port is greater"
|
|
271 |
" than %s. Aborting." %
|
|
272 |
constants.LAST_DRBD_PORT)
|
|
270 |
raise errors.ConfigurationError("The highest used port is greater" |
|
271 |
" than %s. Aborting." % |
|
272 |
constants.LAST_DRBD_PORT) |
|
273 | 273 |
self._config_data.cluster.highest_used_port = port |
274 | 274 |
|
275 | 275 |
self._WriteConfig() |
... | ... | |
312 | 312 |
self._OpenConfig() |
313 | 313 |
|
314 | 314 |
if instance_name not in self._config_data.instances: |
315 |
raise errors.ConfigurationError, ("Unknown instance '%s'" %
|
|
316 |
instance_name)
|
|
315 |
raise errors.ConfigurationError("Unknown instance '%s'" % |
|
316 |
instance_name) |
|
317 | 317 |
instance = self._config_data.instances[instance_name] |
318 | 318 |
instance.status = "up" |
319 | 319 |
self._WriteConfig() |
... | ... | |
325 | 325 |
self._OpenConfig() |
326 | 326 |
|
327 | 327 |
if instance_name not in self._config_data.instances: |
328 |
raise errors.ConfigurationError, ("Unknown instance '%s'" % |
|
329 |
instance_name) |
|
328 |
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name) |
|
330 | 329 |
del self._config_data.instances[instance_name] |
331 | 330 |
self._WriteConfig() |
332 | 331 |
|
... | ... | |
337 | 336 |
self._OpenConfig() |
338 | 337 |
|
339 | 338 |
if instance_name not in self._config_data.instances: |
340 |
raise errors.ConfigurationError, ("Unknown instance '%s'" % |
|
341 |
instance_name) |
|
339 |
raise errors.ConfigurationError("Unknown instance '%s'" % instance_name) |
|
342 | 340 |
instance = self._config_data.instances[instance_name] |
343 | 341 |
instance.status = "down" |
344 | 342 |
self._WriteConfig() |
... | ... | |
404 | 402 |
""" |
405 | 403 |
self._OpenConfig() |
406 | 404 |
if node_name not in self._config_data.nodes: |
407 |
raise errors.ConfigurationError, ("Unknown node '%s'" % node_name)
|
|
405 |
raise errors.ConfigurationError("Unknown node '%s'" % node_name) |
|
408 | 406 |
|
409 | 407 |
del self._config_data.nodes[node_name] |
410 | 408 |
self._WriteConfig() |
... | ... | |
467 | 465 |
try: |
468 | 466 |
st = os.stat(self._cfg_file) |
469 | 467 |
except OSError, err: |
470 |
raise errors.ConfigurationError, "Can't stat config file: %s" % err
|
|
468 |
raise errors.ConfigurationError("Can't stat config file: %s" % err)
|
|
471 | 469 |
if (self._config_data is not None and |
472 | 470 |
self._config_time is not None and |
473 | 471 |
self._config_time == st.st_mtime and |
... | ... | |
480 | 478 |
try: |
481 | 479 |
data = objects.ConfigObject.Load(f) |
482 | 480 |
except Exception, err: |
483 |
raise errors.ConfigurationError, err
|
|
481 |
raise errors.ConfigurationError(err)
|
|
484 | 482 |
finally: |
485 | 483 |
f.close() |
486 | 484 |
if (not hasattr(data, 'cluster') or |
487 | 485 |
not hasattr(data.cluster, 'config_version')): |
488 |
raise errors.ConfigurationError, ("Incomplete configuration"
|
|
489 |
" (missing cluster.config_version)")
|
|
486 |
raise errors.ConfigurationError("Incomplete configuration" |
|
487 |
" (missing cluster.config_version)") |
|
490 | 488 |
if data.cluster.config_version != constants.CONFIG_VERSION: |
491 |
raise errors.ConfigurationError, ("Cluster configuration version"
|
|
492 |
" mismatch, got %s instead of %s" %
|
|
493 |
(data.cluster.config_version,
|
|
494 |
constants.CONFIG_VERSION))
|
|
489 |
raise errors.ConfigurationError("Cluster configuration version" |
|
490 |
" mismatch, got %s instead of %s" % |
|
491 |
(data.cluster.config_version, |
|
492 |
constants.CONFIG_VERSION)) |
|
495 | 493 |
self._config_data = data |
496 | 494 |
self._config_time = st.st_mtime |
497 | 495 |
self._config_size = st.st_size |
... | ... | |
550 | 548 |
try: |
551 | 549 |
st = os.stat(destination) |
552 | 550 |
except OSError, err: |
553 |
raise errors.ConfigurationError, "Can't stat config file: %s" % err
|
|
551 |
raise errors.ConfigurationError("Can't stat config file: %s" % err)
|
|
554 | 552 |
self._config_time = st.st_mtime |
555 | 553 |
self._config_size = st.st_size |
556 | 554 |
self._config_inode = st.st_ino |
... | ... | |
637 | 635 |
|
638 | 636 |
""" |
639 | 637 |
if self._config_data is None: |
640 |
raise errors.ProgrammerError, ("Configuration file not read,"
|
|
641 |
" cannot save.")
|
|
638 |
raise errors.ProgrammerError("Configuration file not read," |
|
639 |
" cannot save.") |
|
642 | 640 |
if isinstance(target, objects.Cluster): |
643 | 641 |
test = target == self._config_data.cluster |
644 | 642 |
elif isinstance(target, objects.Node): |
... | ... | |
646 | 644 |
elif isinstance(target, objects.Instance): |
647 | 645 |
test = target in self._config_data.instances.values() |
648 | 646 |
else: |
649 |
raise errors.ProgrammerError, ("Invalid object type (%s) passed to"
|
|
650 |
" ConfigWriter.Update" % type(target))
|
|
647 |
raise errors.ProgrammerError("Invalid object type (%s) passed to" |
|
648 |
" ConfigWriter.Update" % type(target)) |
|
651 | 649 |
if not test: |
652 |
raise errors.ConfigurationError, ("Configuration updated since object"
|
|
653 |
" has been read or unknown object")
|
|
650 |
raise errors.ConfigurationError("Configuration updated since object" |
|
651 |
" has been read or unknown object") |
|
654 | 652 |
self._WriteConfig() |
Also available in: Unified diff