Revision 5cfa6c37 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1399 | 1399 |
|
1400 | 1400 |
|
1401 | 1401 |
def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6, |
1402 |
network_type, mac_prefix, tags):
|
|
1402 |
mac_prefix, tags): |
|
1403 | 1403 |
"""Builds network related env variables for hooks |
1404 | 1404 |
|
1405 | 1405 |
This builds the hook environment from individual variables. |
... | ... | |
1414 | 1414 |
@param network6: the ipv6 subnet |
1415 | 1415 |
@type gateway6: string |
1416 | 1416 |
@param gateway6: the ipv6 gateway |
1417 |
@type network_type: string |
|
1418 |
@param network_type: the type of the network |
|
1419 | 1417 |
@type mac_prefix: string |
1420 | 1418 |
@param mac_prefix: the mac_prefix |
1421 | 1419 |
@type tags: list |
... | ... | |
1435 | 1433 |
env["NETWORK_GATEWAY6"] = gateway6 |
1436 | 1434 |
if mac_prefix: |
1437 | 1435 |
env["NETWORK_MAC_PREFIX"] = mac_prefix |
1438 |
if network_type: |
|
1439 |
env["NETWORK_TYPE"] = network_type |
|
1440 | 1436 |
if tags: |
1441 | 1437 |
env["NETWORK_TAGS"] = " ".join(tags) |
1442 | 1438 |
|
... | ... | |
16232 | 16228 |
"network6": self.op.network6, |
16233 | 16229 |
"gateway6": self.op.gateway6, |
16234 | 16230 |
"mac_prefix": self.op.mac_prefix, |
16235 |
"network_type": self.op.network_type, |
|
16236 | 16231 |
"tags": self.op.tags, |
16237 | 16232 |
} |
16238 | 16233 |
return _BuildNetworkHookEnv(**args) # pylint: disable=W0142 |
... | ... | |
16247 | 16242 |
network6=self.op.network6, |
16248 | 16243 |
gateway6=self.op.gateway6, |
16249 | 16244 |
mac_prefix=self.op.mac_prefix, |
16250 |
network_type=self.op.network_type, |
|
16251 | 16245 |
uuid=self.network_uuid, |
16252 | 16246 |
family=constants.IP4_VERSION) |
16253 | 16247 |
# Initialize the associated address pool |
... | ... | |
16389 | 16383 |
""" |
16390 | 16384 |
self.network = self.cfg.GetNetwork(self.network_uuid) |
16391 | 16385 |
self.gateway = self.network.gateway |
16392 |
self.network_type = self.network.network_type |
|
16393 | 16386 |
self.mac_prefix = self.network.mac_prefix |
16394 | 16387 |
self.network6 = self.network.network6 |
16395 | 16388 |
self.gateway6 = self.network.gateway6 |
... | ... | |
16407 | 16400 |
" reserved" % self.gateway, |
16408 | 16401 |
errors.ECODE_STATE) |
16409 | 16402 |
|
16410 |
if self.op.network_type: |
|
16411 |
if self.op.network_type == constants.VALUE_NONE: |
|
16412 |
self.network_type = None |
|
16413 |
else: |
|
16414 |
self.network_type = self.op.network_type |
|
16415 |
|
|
16416 | 16403 |
if self.op.mac_prefix: |
16417 | 16404 |
if self.op.mac_prefix == constants.VALUE_NONE: |
16418 | 16405 |
self.mac_prefix = None |
... | ... | |
16443 | 16430 |
"network6": self.network6, |
16444 | 16431 |
"gateway6": self.gateway6, |
16445 | 16432 |
"mac_prefix": self.mac_prefix, |
16446 |
"network_type": self.network_type, |
|
16447 | 16433 |
"tags": self.tags, |
16448 | 16434 |
} |
16449 | 16435 |
return _BuildNetworkHookEnv(**args) # pylint: disable=W0142 |
... | ... | |
16503 | 16489 |
if self.op.gateway6: |
16504 | 16490 |
self.network.gateway6 = self.gateway6 |
16505 | 16491 |
|
16506 |
if self.op.network_type: |
|
16507 |
self.network.network_type = self.network_type |
|
16508 |
|
|
16509 | 16492 |
self.pool.Validate() |
16510 | 16493 |
|
16511 | 16494 |
self.cfg.Update(self.network, feedback_fn) |
Also available in: Unified diff