Revision 1cce2c47 lib/config.py

b/lib/config.py
276 276
    prefix = None
277 277
    if net:
278 278
      net_uuid = self._UnlockedLookupNetwork(net)
279
      if net_uuid:
280
        nobj = self._UnlockedGetNetwork(net_uuid)
281
        if nobj.mac_prefix:
282
          prefix = nobj.mac_prefix
279
      nobj = self._UnlockedGetNetwork(net_uuid)
280
      if nobj.mac_prefix:
281
        prefix = nobj.mac_prefix
283 282

  
284 283
    return prefix
285 284

  
......
365 364

  
366 365
    """
367 366
    net_uuid = self._UnlockedLookupNetwork(net)
368
    if net_uuid:
369
      self._UnlockedReleaseIp(net_uuid, address, ec_id)
367
    self._UnlockedReleaseIp(net_uuid, address, ec_id)
370 368

  
371 369
  @locking.ssynchronized(_config_lock, shared=1)
372 370
  def GenerateIp(self, net, ec_id):
......
410 408

  
411 409
    """
412 410
    net_uuid = self._UnlockedLookupNetwork(net)
413
    if net_uuid:
414
      return self._UnlockedReserveIp(net_uuid, address, ec_id)
411
    return self._UnlockedReserveIp(net_uuid, address, ec_id)
415 412

  
416 413
  @locking.ssynchronized(_config_lock, shared=1)
417 414
  def ReserveLV(self, lv_name, ec_id):
......
1452 1449
    for nic in instance.nics:
1453 1450
      if nic.network is not None and nic.ip is not None:
1454 1451
        net_uuid = self._UnlockedLookupNetwork(nic.network)
1455
        if net_uuid:
1456
          # Return all IP addresses to the respective address pools
1457
          self._UnlockedCommitIp(constants.RELEASE_ACTION, net_uuid, nic.ip)
1452
        # Return all IP addresses to the respective address pools
1453
        self._UnlockedCommitIp(constants.RELEASE_ACTION, net_uuid, nic.ip)
1458 1454

  
1459 1455
    del self._config_data.instances[instance_name]
1460 1456
    self._config_data.cluster.serial_no += 1
......
2469 2465
    if check_uuid:
2470 2466
      self._EnsureUUID(net, ec_id)
2471 2467

  
2472
    existing_uuid = self._UnlockedLookupNetwork(net.name)
2473
    if existing_uuid:
2474
      raise errors.OpPrereqError("Desired network name '%s' already"
2475
                                 " exists as a network (UUID: %s)" %
2476
                                 (net.name, existing_uuid),
2477
                                 errors.ECODE_EXISTS)
2478 2468
    net.serial_no = 1
2479 2469
    self._config_data.networks[net.uuid] = net
2480 2470
    self._config_data.cluster.serial_no += 1
......
2494 2484
    for net in self._config_data.networks.values():
2495 2485
      if net.name == target:
2496 2486
        return net.uuid
2497
    return None
2487
    raise errors.OpPrereqError("Network '%s' not found" % target,
2488
                               errors.ECODE_NOENT)
2498 2489

  
2499 2490
  @locking.ssynchronized(_config_lock, shared=1)
2500 2491
  def LookupNetwork(self, target):
......
2541 2532

  
2542 2533
    """
2543 2534
    net_uuid = self._UnlockedLookupNetwork(net)
2544
    if net_uuid is None:
2545
      return None
2546

  
2547 2535
    node_info = self._UnlockedGetNodeInfo(node)
2548 2536
    nodegroup_info = self._UnlockedGetNodeGroup(node_info.group)
2549 2537
    netparams = nodegroup_info.networks.get(net_uuid, None)

Also available in: Unified diff