Revision ddfa03fd
b/lib/cmdlib.py | ||
---|---|---|
16507 | 16507 |
else: |
16508 | 16508 |
self.network6 = self.op.network6 |
16509 | 16509 |
|
16510 |
network.AddressPool.Check(self.gateway, self.network) |
|
16511 |
network.AddressPool.Check(self.gateway6, self.network6) |
|
16510 | 16512 |
|
16511 | 16513 |
def BuildHooksEnv(self): |
16512 | 16514 |
"""Build hooks env. |
... | ... | |
16558 | 16560 |
if self.op.gateway6: |
16559 | 16561 |
self.nobj.gateway6 = self.gateway6 |
16560 | 16562 |
|
16561 |
self.pool.Validate() |
|
16562 |
|
|
16563 | 16563 |
self.cfg.Update(self.nobj, feedback_fn, ec_id) |
16564 | 16564 |
|
16565 | 16565 |
|
b/lib/network.py | ||
---|---|---|
71 | 71 |
else: |
72 | 72 |
self._InitializeReservations() |
73 | 73 |
|
74 |
self.Validate() |
|
74 |
self._Validate()
|
|
75 | 75 |
|
76 | 76 |
def _InitializeReservations(self): |
77 | 77 |
self.reservations = bitarray(self.network.numhosts) |
... | ... | |
88 | 88 |
|
89 | 89 |
self._Update() |
90 | 90 |
|
91 |
@classmethod |
|
92 |
def Check(cls, address, network): |
|
93 |
try: |
|
94 |
if network: |
|
95 |
network = ipaddr.IPNetwork(network) |
|
96 |
if address: |
|
97 |
address = ipaddr.IPAddress(address) |
|
98 |
except ValueError, e: |
|
99 |
raise errors.OpPrereqError(e, errors.ECODE_INVAL) |
|
100 |
|
|
101 |
if address and not network: |
|
102 |
raise errors.OpPrereqError("Address '%s' but no network." % address, |
|
103 |
errors.ECODE_INVAL) |
|
104 |
if address and address not in network: |
|
105 |
raise errors.OpPrereqError("Address '%s' not in network '%s'." % |
|
106 |
(address, network), |
|
107 |
errors.ECODE_INVAL) |
|
108 |
|
|
91 | 109 |
def Contains(self, address): |
92 | 110 |
if address: |
93 | 111 |
addr = ipaddr.IPAddress(address) |
... | ... | |
127 | 145 |
""" |
128 | 146 |
return (self.reservations | self.ext_reservations) |
129 | 147 |
|
130 |
def Validate(self): |
|
148 |
def _Validate(self):
|
|
131 | 149 |
if self.gateway: |
132 | 150 |
assert self.network |
133 | 151 |
assert self.gateway in self.network |
Also available in: Unified diff