Revision 53195377 lib/cmdlib/network.py
b/lib/cmdlib/network.py | ||
---|---|---|
110 | 110 |
self.add_locks[locking.LEVEL_NETWORK] = self.network_uuid |
111 | 111 |
|
112 | 112 |
def CheckPrereq(self): |
113 |
if self.op.network is None: |
|
114 |
raise errors.OpPrereqError("Network must be given", |
|
115 |
errors.ECODE_INVAL) |
|
116 |
|
|
117 | 113 |
try: |
118 | 114 |
existing_uuid = self.cfg.LookupNetwork(self.op.network_name) |
119 | 115 |
except errors.OpPrereqError: |
... | ... | |
137 | 133 |
uuid=self.network_uuid) |
138 | 134 |
|
139 | 135 |
# Initialize the associated address pool |
140 |
try: |
|
141 |
self.pool = network.AddressPool.InitializeNetwork(self.nobj) |
|
142 |
except errors.AddressPoolError, err: |
|
143 |
raise errors.OpPrereqError("Cannot create IP address pool for network" |
|
144 |
" '%s': %s" % (self.op.network_name, err)) |
|
136 |
# This raises the appropriate OpPrereqError |
|
137 |
self.pool = network.Network(self.nobj) |
|
145 | 138 |
|
146 | 139 |
def BuildHooksEnv(self): |
147 | 140 |
"""Build hooks env. |
... | ... | |
278 | 271 |
"""Check prerequisites. |
279 | 272 |
|
280 | 273 |
""" |
281 |
self.network = self.cfg.GetNetwork(self.network_uuid)
|
|
274 |
self.nobj = self.cfg.GetNetwork(self.network_uuid)
|
|
282 | 275 |
self.gateway = self.network.gateway |
283 | 276 |
self.mac_prefix = self.network.mac_prefix |
284 | 277 |
self.network6 = self.network.network6 |
285 | 278 |
self.gateway6 = self.network.gateway6 |
286 | 279 |
self.tags = self.network.tags |
287 | 280 |
|
288 |
self.pool = network.AddressPool(self.network)
|
|
281 |
self.pool = network.Network(self.nobj)
|
|
289 | 282 |
|
290 | 283 |
if self.op.gateway: |
291 | 284 |
if self.op.gateway == constants.VALUE_NONE: |
... | ... | |
293 | 286 |
else: |
294 | 287 |
self.gateway = self.op.gateway |
295 | 288 |
|
289 |
network.Network.Check(self.gateway, self.network) |
|
290 |
|
|
296 | 291 |
if self.op.mac_prefix: |
297 | 292 |
if self.op.mac_prefix == constants.VALUE_NONE: |
298 | 293 |
self.mac_prefix = None |
... | ... | |
312 | 307 |
else: |
313 | 308 |
self.network6 = self.op.network6 |
314 | 309 |
|
310 |
network.Network.Check(self.gateway, self.network) |
|
311 |
|
|
315 | 312 |
def BuildHooksEnv(self): |
316 | 313 |
"""Build hooks env. |
317 | 314 |
|
... | ... | |
453 | 450 |
|
454 | 451 |
if query.NETQ_STATS in self.requested_data: |
455 | 452 |
stats = \ |
456 |
dict((uuid, |
|
457 |
self._GetStats(network.AddressPool(all_networks[uuid]))) |
|
453 |
dict((uuid, network.Network(all_networks[uuid]).GetStats()) |
|
458 | 454 |
for uuid in network_uuids) |
459 | 455 |
else: |
460 | 456 |
stats = None |
... | ... | |
615 | 611 |
|
616 | 612 |
# check only if not already connected |
617 | 613 |
elif self.op.conflicts_check: |
618 |
pool = network.AddressPool(self.cfg.GetNetwork(self.network_uuid))
|
|
614 |
pool = network.Network(self.cfg.GetNetwork(self.network_uuid))
|
|
619 | 615 |
|
620 | 616 |
_NetworkConflictCheck(self, lambda nic: pool.Contains(nic.ip), |
621 | 617 |
"connect to", owned_instances) |
Also available in: Unified diff