Revision 2ff6426b
b/lib/cmdlib/cluster.py | ||
---|---|---|
56 | 56 |
CheckOSParams, CheckHVParams, AdjustCandidatePool, CheckNodePVs, \ |
57 | 57 |
ComputeIPolicyInstanceViolation, AnnotateDiskParams, SupportsOob, \ |
58 | 58 |
CheckIpolicyVsDiskTemplates, CheckDiskAccessModeValidity, \ |
59 |
CheckDiskAccessModeConsistency, CreateNewClientCert |
|
59 |
CheckDiskAccessModeConsistency, CreateNewClientCert, \ |
|
60 |
OpAddInstanceCommunicationNetwork, OpConnectInstanceCommunicationNetwork |
|
60 | 61 |
|
61 | 62 |
import ganeti.masterd.instance |
62 | 63 |
|
... | ... | |
1391 | 1392 |
network_exists = False |
1392 | 1393 |
|
1393 | 1394 |
if not network_exists: |
1394 |
op = opcodes.OpNetworkAdd( |
|
1395 |
network_name=network_name, |
|
1396 |
gateway=None, |
|
1397 |
network=constants.INSTANCE_COMMUNICATION_NETWORK4, |
|
1398 |
gateway6=None, |
|
1399 |
network6=constants.INSTANCE_COMMUNICATION_NETWORK6, |
|
1400 |
mac_prefix=constants.INSTANCE_COMMUNICATION_MAC_PREFIX, |
|
1401 |
add_reserved_ips=None, |
|
1402 |
conflicts_check=True, |
|
1403 |
tags=[]) |
|
1404 |
jobs.append(op) |
|
1395 |
jobs.append(OpAddInstanceCommunicationNetwork(network_name)) |
|
1405 | 1396 |
|
1406 | 1397 |
for group_uuid in cfg.GetNodeGroupList(): |
1407 | 1398 |
group = cfg.GetNodeGroup(group_uuid) |
... | ... | |
1416 | 1407 |
network_connected = False |
1417 | 1408 |
|
1418 | 1409 |
if not network_connected: |
1419 |
op = opcodes.OpNetworkConnect( |
|
1420 |
group_name=group_uuid, |
|
1421 |
network_name=network_name, |
|
1422 |
network_mode=constants.NIC_MODE_ROUTED, |
|
1423 |
network_link=constants.INSTANCE_COMMUNICATION_NETWORK_LINK, |
|
1424 |
conflicts_check=True) |
|
1410 |
op = OpConnectInstanceCommunicationNetwork(group_uuid, network_name) |
|
1425 | 1411 |
jobs.append(op) |
1426 | 1412 |
|
1427 | 1413 |
if jobs: |
b/lib/cmdlib/common.py | ||
---|---|---|
1285 | 1285 |
((crypto_type, new_digest), ) = result.payload |
1286 | 1286 |
assert crypto_type == constants.CRYPTO_TYPE_SSL_DIGEST |
1287 | 1287 |
return new_digest |
1288 |
|
|
1289 |
|
|
1290 |
def OpAddInstanceCommunicationNetwork(network): |
|
1291 |
"""Create OpCode that adds the instance communication network. |
|
1292 |
|
|
1293 |
This OpCode contains the configuration necessary for the instance |
|
1294 |
communication network. |
|
1295 |
|
|
1296 |
@type network: string |
|
1297 |
@param network: name or UUID of the instance communication network |
|
1298 |
|
|
1299 |
@rtype: L{ganeti.opcodes.OpCode} |
|
1300 |
@return: OpCode that creates the instance communication network |
|
1301 |
|
|
1302 |
""" |
|
1303 |
return opcodes.OpNetworkAdd( |
|
1304 |
network_name=network, |
|
1305 |
gateway=None, |
|
1306 |
network=constants.INSTANCE_COMMUNICATION_NETWORK4, |
|
1307 |
gateway6=None, |
|
1308 |
network6=constants.INSTANCE_COMMUNICATION_NETWORK6, |
|
1309 |
mac_prefix=constants.INSTANCE_COMMUNICATION_MAC_PREFIX, |
|
1310 |
add_reserved_ips=None, |
|
1311 |
conflicts_check=True, |
|
1312 |
tags=[]) |
|
1313 |
|
|
1314 |
|
|
1315 |
def OpConnectInstanceCommunicationNetwork(group_uuid, network): |
|
1316 |
"""Create OpCode that connects a group to the instance communication |
|
1317 |
network. |
|
1318 |
|
|
1319 |
This OpCode contains the configuration necessary for the instance |
|
1320 |
communication network. |
|
1321 |
|
|
1322 |
@type group_uuid: string |
|
1323 |
@param group_uuid: UUID of the group to connect |
|
1324 |
|
|
1325 |
@type network: string |
|
1326 |
@param network: name or UUID of the network to connect to, i.e., the |
|
1327 |
instance communication network |
|
1328 |
|
|
1329 |
@rtype: L{ganeti.opcodes.OpCode} |
|
1330 |
@return: OpCode that connects the group to the instance |
|
1331 |
communication network |
|
1332 |
|
|
1333 |
""" |
|
1334 |
return opcodes.OpNetworkConnect( |
|
1335 |
group_name=group_uuid, |
|
1336 |
network_name=network, |
|
1337 |
network_mode=constants.NIC_MODE_ROUTED, |
|
1338 |
network_link=constants.INSTANCE_COMMUNICATION_NETWORK_LINK, |
|
1339 |
conflicts_check=True) |
b/lib/cmdlib/group.py | ||
---|---|---|
28 | 28 |
from ganeti import errors |
29 | 29 |
from ganeti import locking |
30 | 30 |
from ganeti import objects |
31 |
from ganeti import opcodes |
|
32 | 31 |
from ganeti import utils |
33 | 32 |
from ganeti.masterd import iallocator |
34 | 33 |
from ganeti.cmdlib.base import LogicalUnit, NoHooksLU, ResultWithJobs |
... | ... | |
38 | 37 |
ComputeNewInstanceViolations, GetDefaultIAllocator, ShareAll, \ |
39 | 38 |
CheckInstancesNodeGroups, LoadNodeEvacResult, MapInstanceLvsToNodes, \ |
40 | 39 |
CheckIpolicyVsDiskTemplates, CheckDiskAccessModeValidity, \ |
41 |
CheckDiskAccessModeConsistency |
|
40 |
CheckDiskAccessModeConsistency, OpConnectInstanceCommunicationNetwork
|
|
42 | 41 |
|
43 | 42 |
import ganeti.masterd.instance |
44 | 43 |
|
... | ... | |
157 | 156 |
L{None} |
158 | 157 |
|
159 | 158 |
""" |
160 |
jobs = [] |
|
161 |
|
|
162 | 159 |
try: |
163 | 160 |
cfg.LookupNetwork(network_name) |
164 | 161 |
network_exists = True |
... | ... | |
166 | 163 |
network_exists = False |
167 | 164 |
|
168 | 165 |
if network_exists: |
169 |
op = opcodes.OpNetworkConnect( |
|
170 |
group_name=group_uuid, |
|
171 |
network_name=network_name, |
|
172 |
network_mode=constants.NIC_MODE_ROUTED, |
|
173 |
network_link=constants.INSTANCE_COMMUNICATION_NETWORK_LINK, |
|
174 |
conflicts_check=True) |
|
175 |
jobs.append(op) |
|
176 |
|
|
177 |
if jobs: |
|
178 |
return ResultWithJobs([jobs]) |
|
166 |
op = OpConnectInstanceCommunicationNetwork(group_uuid, network_name) |
|
167 |
return ResultWithJobs([[op]]) |
|
179 | 168 |
else: |
180 | 169 |
return None |
181 | 170 |
|
Also available in: Unified diff