Revision 4b700ca7 lib/cmdlib/network.py

b/lib/cmdlib/network.py
174 174
      for ip in self.op.add_reserved_ips:
175 175
        try:
176 176
          self.pool.Reserve(ip, external=True)
177
        except errors.AddressPoolError, err:
177
        except errors.NetworkError, err:
178 178
          raise errors.OpExecError("Cannot reserve IP address '%s': %s" %
179 179
                                   (ip, err))
180 180

  
......
272 272

  
273 273
    """
274 274
    self.nobj = self.cfg.GetNetwork(self.network_uuid)
275
    self.gateway = self.network.gateway
276
    self.mac_prefix = self.network.mac_prefix
277
    self.network6 = self.network.network6
278
    self.gateway6 = self.network.gateway6
279
    self.tags = self.network.tags
275
    self.network = self.nobj.network
276
    self.gateway = self.nobj.gateway
277
    self.mac_prefix = self.nobj.mac_prefix
278
    self.network6 = self.nobj.network6
279
    self.gateway6 = self.nobj.gateway6
280
    self.tags = self.nobj.tags
280 281

  
281 282
    self.pool = network.Network(self.nobj)
282 283

  
......
307 308
      else:
308 309
        self.network6 = self.op.network6
309 310

  
310
    network.Network.Check(self.gateway, self.network)
311
    network.Network.Check(self.gateway6, self.network6)
311 312

  
312 313
  def BuildHooksEnv(self):
313 314
    """Build hooks env.
......
315 316
    """
316 317
    args = {
317 318
      "name": self.op.network_name,
318
      "subnet": self.network.network,
319
      "subnet": self.network,
319 320
      "gateway": self.gateway,
320 321
      "network6": self.network6,
321 322
      "gateway6": self.gateway6,
......
339 340
    #      extend cfg.ReserveIp/ReleaseIp with the external flag
340 341
    ec_id = self.proc.GetECId()
341 342
    if self.op.gateway:
342
      if self.gateway == self.network.gateway:
343
      if self.gateway == self.nobj.gateway:
343 344
        self.LogWarning("Gateway is already %s", self.gateway)
344 345
      else:
345 346
        if self.gateway:
346 347
          self.cfg.ReserveIp(self.network_uuid, self.gateway, True, ec_id)
347
        if self.network.gateway:
348
        if self.nobj.gateway:
348 349
          self.cfg.ReleaseIp(self.network_uuid,
349
                             self.network.gateway, True, ec_id)
350
        self.network.gateway = self.gateway
350
                             self.nobj.gateway, True, ec_id)
351
        self.nobj.gateway = self.gateway
351 352

  
352 353
    if self.op.add_reserved_ips:
353 354
      for ip in self.op.add_reserved_ips:
......
355 356

  
356 357
    if self.op.remove_reserved_ips:
357 358
      for ip in self.op.remove_reserved_ips:
358
        if ip == self.network.gateway:
359
        if ip == self.nobj.gateway:
359 360
          self.LogWarning("Cannot unreserve Gateway's IP")
360 361
          continue
361 362
        self.cfg.ReleaseIp(self.network_uuid, ip, True, ec_id)
362 363

  
363 364
    if self.op.mac_prefix:
364
      self.network.mac_prefix = self.mac_prefix
365
      self.nobj.mac_prefix = self.mac_prefix
365 366

  
366 367
    if self.op.network6:
367
      self.network.network6 = self.network6
368
      self.nobj.network6 = self.network6
368 369

  
369 370
    if self.op.gateway6:
370
      self.network.gateway6 = self.gateway6
371

  
372
    self.pool.Validate()
371
      self.nobj.gateway6 = self.gateway6
373 372

  
374
    self.cfg.Update(self.network, feedback_fn)
373
    self.cfg.Update(self.nobj, feedback_fn)
375 374

  
376 375

  
377 376
class NetworkQuery(QueryBase):

Also available in: Unified diff