1360 |
1360 |
feedback_fn("Cluster DRBD helper already in desired state,"
|
1361 |
1361 |
" not changing")
|
1362 |
1362 |
|
|
1363 |
@staticmethod
|
|
1364 |
def _EnsureInstanceCommunicationNetwork(cfg, network_name):
|
|
1365 |
"""Ensure that the instance communication network exists and is
|
|
1366 |
connected to all groups.
|
|
1367 |
|
|
1368 |
The instance communication network given by L{network_name} it is
|
|
1369 |
created, if necessary, via the opcode 'OpNetworkAdd'. Also, the
|
|
1370 |
instance communication network is connected to all existing node
|
|
1371 |
groups, if necessary, via the opcode 'OpNetworkConnect'.
|
|
1372 |
|
|
1373 |
@type cfg: L{ganeti.config.ConfigWriter}
|
|
1374 |
@param cfg: Ganeti configuration
|
|
1375 |
|
|
1376 |
@type network_name: string
|
|
1377 |
@param network_name: instance communication network name
|
|
1378 |
|
|
1379 |
@rtype: L{ganeti.cmdlib.ResultWithJobs} or L{None}
|
|
1380 |
@return: L{ganeti.cmdlib.ResultWithJobs} if the instance
|
|
1381 |
communication needs to be created or it needs to be
|
|
1382 |
connected to a group, otherwise L{None}
|
|
1383 |
|
|
1384 |
"""
|
|
1385 |
jobs = []
|
|
1386 |
|
|
1387 |
try:
|
|
1388 |
network_uuid = cfg.LookupNetwork(network_name)
|
|
1389 |
network_exists = True
|
|
1390 |
except errors.OpPrereqError:
|
|
1391 |
network_exists = False
|
|
1392 |
|
|
1393 |
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)
|
|
1405 |
|
|
1406 |
for group_uuid in cfg.GetNodeGroupList():
|
|
1407 |
group = cfg.GetNodeGroup(group_uuid)
|
|
1408 |
|
|
1409 |
if network_exists:
|
|
1410 |
network_connected = network_uuid in group.networks
|
|
1411 |
else:
|
|
1412 |
# The network was created asynchronously by the previous
|
|
1413 |
# opcode and, therefore, we don't have access to its
|
|
1414 |
# network_uuid. As a result, we assume that the network is
|
|
1415 |
# not connected to any group yet.
|
|
1416 |
network_connected = False
|
|
1417 |
|
|
1418 |
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)
|
|
1425 |
jobs.append(op)
|
|
1426 |
|
|
1427 |
if jobs:
|
|
1428 |
return ResultWithJobs([jobs])
|
|
1429 |
else:
|
|
1430 |
return None
|
|
1431 |
|
|
1432 |
@staticmethod
|
|
1433 |
def _ModifyInstanceCommunicationNetwork(cfg, cluster, network_name,
|
|
1434 |
feedback_fn):
|
|
1435 |
"""Update the instance communication network stored in the cluster
|
|
1436 |
configuration.
|
|
1437 |
|
|
1438 |
Compares the user-supplied instance communication network against
|
|
1439 |
the one stored in the Ganeti cluster configuration. If there is a
|
|
1440 |
change, the instance communication network may be possibly created
|
|
1441 |
and connected to all groups (see
|
|
1442 |
L{LUClusterSetParams._EnsureInstanceCommunicationNetwork}).
|
|
1443 |
|
|
1444 |
@type cfg: L{ganeti.config.ConfigWriter}
|
|
1445 |
@param cfg: Ganeti configuration
|
|
1446 |
|
|
1447 |
@type cluster: L{ganeti.objects.Cluster}
|
|
1448 |
@param cluster: Ganeti cluster
|
|
1449 |
|
|
1450 |
@type network_name: string
|
|
1451 |
@param network_name: instance communication network name
|
|
1452 |
|
|
1453 |
@type feedback_fn: function
|
|
1454 |
@param feedback_fn: see L{ganeti.cmdlist.base.LogicalUnit}
|
|
1455 |
|
|
1456 |
@rtype: L{LUClusterSetParams._EnsureInstanceCommunicationNetwork} or L{None}
|
|
1457 |
@return: see L{LUClusterSetParams._EnsureInstanceCommunicationNetwork}
|
|
1458 |
|
|
1459 |
"""
|
|
1460 |
config_network_name = cfg.GetInstanceCommunicationNetwork()
|
|
1461 |
|
|
1462 |
if network_name == config_network_name:
|
|
1463 |
feedback_fn("Instance communication network already is '%s', nothing to"
|
|
1464 |
" do." % network_name)
|
|
1465 |
else:
|
|
1466 |
try:
|
|
1467 |
cfg.LookupNetwork(config_network_name)
|
|
1468 |
feedback_fn("Previous instance communication network '%s'"
|
|
1469 |
" should be removed manually." % config_network_name)
|
|
1470 |
except errors.OpPrereqError:
|
|
1471 |
pass
|
|
1472 |
|
|
1473 |
if network_name:
|
|
1474 |
feedback_fn("Changing instance communication network to '%s', only new"
|
|
1475 |
" instances will be affected."
|
|
1476 |
% network_name)
|
|
1477 |
else:
|
|
1478 |
feedback_fn("Disabling instance communication network, only new"
|
|
1479 |
" instances will be affected.")
|
|
1480 |
|
|
1481 |
cluster.instance_communication_network = network_name
|
|
1482 |
|
|
1483 |
if network_name:
|
|
1484 |
return LUClusterSetParams._EnsureInstanceCommunicationNetwork(
|
|
1485 |
cfg,
|
|
1486 |
network_name)
|
|
1487 |
else:
|
|
1488 |
return None
|
|
1489 |
|
1363 |
1490 |
def Exec(self, feedback_fn):
|
1364 |
1491 |
"""Change the parameters of the cluster.
|
1365 |
1492 |
|
... | ... | |
1502 |
1629 |
result.Warn("Could not re-enable the master ip on the master,"
|
1503 |
1630 |
" please restart manually", self.LogWarning)
|
1504 |
1631 |
|
|
1632 |
network_name = self.op.instance_communication_network
|
|
1633 |
if network_name is not None:
|
|
1634 |
return self._ModifyInstanceCommunicationNetwork(self.cfg, self.cluster,
|
|
1635 |
network_name, feedback_fn)
|
|
1636 |
else:
|
|
1637 |
return None
|
|
1638 |
|
1505 |
1639 |
|
1506 |
1640 |
class LUClusterVerify(NoHooksLU):
|
1507 |
1641 |
"""Submits all jobs necessary to verify the cluster.
|