Revision 3ecf6786 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
77 | 77 |
for attr_name in self._OP_REQP: |
78 | 78 |
attr_val = getattr(op, attr_name, None) |
79 | 79 |
if attr_val is None: |
80 |
raise errors.OpPrereqError, ("Required parameter '%s' missing" %
|
|
81 |
attr_name)
|
|
80 |
raise errors.OpPrereqError("Required parameter '%s' missing" % |
|
81 |
attr_name) |
|
82 | 82 |
if self.REQ_CLUSTER: |
83 | 83 |
if not cfg.IsCluster(): |
84 |
raise errors.OpPrereqError, ("Cluster not initialized yet,"
|
|
85 |
" use 'gnt-cluster init' first.")
|
|
84 |
raise errors.OpPrereqError("Cluster not initialized yet," |
|
85 |
" use 'gnt-cluster init' first.") |
|
86 | 86 |
if self.REQ_MASTER: |
87 | 87 |
master = sstore.GetMasterNode() |
88 | 88 |
if master != socket.gethostname(): |
89 |
raise errors.OpPrereqError, ("Commands must be run on the master"
|
|
90 |
" node %s" % master)
|
|
89 |
raise errors.OpPrereqError("Commands must be run on the master" |
|
90 |
" node %s" % master) |
|
91 | 91 |
|
92 | 92 |
def CheckPrereq(self): |
93 | 93 |
"""Check prerequisites for this LU. |
... | ... | |
172 | 172 |
|
173 | 173 |
""" |
174 | 174 |
if nodes is not None and not isinstance(nodes, list): |
175 |
raise errors.OpPrereqError, "Invalid argument type 'nodes'"
|
|
175 |
raise errors.OpPrereqError("Invalid argument type 'nodes'")
|
|
176 | 176 |
|
177 | 177 |
if nodes: |
178 | 178 |
wanted_nodes = [] |
... | ... | |
180 | 180 |
for name in nodes: |
181 | 181 |
node = lu.cfg.GetNodeInfo(lu.cfg.ExpandNodeName(name)) |
182 | 182 |
if node is None: |
183 |
raise errors.OpPrereqError, ("No such node name '%s'" % name)
|
|
183 |
raise errors.OpPrereqError("No such node name '%s'" % name) |
|
184 | 184 |
wanted_nodes.append(node) |
185 | 185 |
|
186 | 186 |
return wanted_nodes |
... | ... | |
202 | 202 |
all_fields = static_fields | dynamic_fields |
203 | 203 |
|
204 | 204 |
if not all_fields.issuperset(selected): |
205 |
raise errors.OpPrereqError, ("Unknown output fields selected: %s"
|
|
206 |
% ",".join(frozenset(selected).
|
|
207 |
difference(all_fields)))
|
|
205 |
raise errors.OpPrereqError("Unknown output fields selected: %s" |
|
206 |
% ",".join(frozenset(selected). |
|
207 |
difference(all_fields))) |
|
208 | 208 |
|
209 | 209 |
|
210 | 210 |
def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status, |
... | ... | |
462 | 462 |
"-f", "/root/.ssh/id_dsa", |
463 | 463 |
"-q", "-N", ""]) |
464 | 464 |
if result.failed: |
465 |
raise errors.OpExecError, ("could not generate ssh keypair, error %s" %
|
|
466 |
result.output)
|
|
465 |
raise errors.OpExecError("Could not generate ssh keypair, error %s" %
|
|
466 |
result.output) |
|
467 | 467 |
|
468 | 468 |
f = open('/root/.ssh/id_dsa.pub', 'r') |
469 | 469 |
try: |
... | ... | |
489 | 489 |
"-keyout", constants.SSL_CERT_FILE, |
490 | 490 |
"-out", constants.SSL_CERT_FILE, "-batch"]) |
491 | 491 |
if result.failed: |
492 |
raise errors.OpExecError, ("could not generate server ssl cert, command"
|
|
493 |
" %s had exitcode %s and error message %s" %
|
|
494 |
(result.cmd, result.exit_code, result.output))
|
|
492 |
raise errors.OpExecError("could not generate server ssl cert, command" |
|
493 |
" %s had exitcode %s and error message %s" % |
|
494 |
(result.cmd, result.exit_code, result.output)) |
|
495 | 495 |
|
496 | 496 |
os.chmod(constants.SSL_CERT_FILE, 0400) |
497 | 497 |
|
498 | 498 |
result = utils.RunCmd([constants.NODE_INITD_SCRIPT, "restart"]) |
499 | 499 |
|
500 | 500 |
if result.failed: |
501 |
raise errors.OpExecError, ("could not start the node daemon, command %s"
|
|
502 |
" had exitcode %s and error %s" %
|
|
503 |
(result.cmd, result.exit_code, result.output))
|
|
501 |
raise errors.OpExecError("Could not start the node daemon, command %s"
|
|
502 |
" had exitcode %s and error %s" % |
|
503 |
(result.cmd, result.exit_code, result.output)) |
|
504 | 504 |
|
505 | 505 |
|
506 | 506 |
class LUInitCluster(LogicalUnit): |
... | ... | |
531 | 531 |
|
532 | 532 |
""" |
533 | 533 |
if config.ConfigWriter.IsCluster(): |
534 |
raise errors.OpPrereqError, ("Cluster is already initialised")
|
|
534 |
raise errors.OpPrereqError("Cluster is already initialised") |
|
535 | 535 |
|
536 | 536 |
hostname_local = socket.gethostname() |
537 | 537 |
self.hostname = hostname = utils.LookupHostname(hostname_local) |
538 | 538 |
if not hostname: |
539 |
raise errors.OpPrereqError, ("Cannot resolve my own hostname ('%s')" %
|
|
540 |
hostname_local)
|
|
539 |
raise errors.OpPrereqError("Cannot resolve my own hostname ('%s')" % |
|
540 |
hostname_local) |
|
541 | 541 |
|
542 | 542 |
self.clustername = clustername = utils.LookupHostname(self.op.cluster_name) |
543 | 543 |
if not clustername: |
544 |
raise errors.OpPrereqError, ("Cannot resolve given cluster name ('%s')"
|
|
545 |
% self.op.cluster_name)
|
|
544 |
raise errors.OpPrereqError("Cannot resolve given cluster name ('%s')" |
|
545 |
% self.op.cluster_name) |
|
546 | 546 |
|
547 | 547 |
result = utils.RunCmd(["fping", "-S127.0.0.1", "-q", hostname['ip']]) |
548 | 548 |
if result.failed: |
549 |
raise errors.OpPrereqError, ("Inconsistency: this host's name resolves"
|
|
550 |
" to %s,\nbut this ip address does not"
|
|
551 |
" belong to this host."
|
|
552 |
" Aborting." % hostname['ip'])
|
|
549 |
raise errors.OpPrereqError("Inconsistency: this host's name resolves" |
|
550 |
" to %s,\nbut this ip address does not" |
|
551 |
" belong to this host." |
|
552 |
" Aborting." % hostname['ip']) |
|
553 | 553 |
|
554 | 554 |
secondary_ip = getattr(self.op, "secondary_ip", None) |
555 | 555 |
if secondary_ip and not utils.IsValidIP(secondary_ip): |
556 |
raise errors.OpPrereqError, ("Invalid secondary ip given")
|
|
556 |
raise errors.OpPrereqError("Invalid secondary ip given") |
|
557 | 557 |
if secondary_ip and secondary_ip != hostname['ip']: |
558 | 558 |
result = utils.RunCmd(["fping", "-S127.0.0.1", "-q", secondary_ip]) |
559 | 559 |
if result.failed: |
560 |
raise errors.OpPrereqError, ("You gave %s as secondary IP,\n"
|
|
561 |
"but it does not belong to this host." %
|
|
562 |
secondary_ip)
|
|
560 |
raise errors.OpPrereqError("You gave %s as secondary IP,\n" |
|
561 |
"but it does not belong to this host." % |
|
562 |
secondary_ip) |
|
563 | 563 |
self.secondary_ip = secondary_ip |
564 | 564 |
|
565 | 565 |
# checks presence of the volume group given |
566 | 566 |
vgstatus = _HasValidVG(utils.ListVolumeGroups(), self.op.vg_name) |
567 | 567 |
|
568 | 568 |
if vgstatus: |
569 |
raise errors.OpPrereqError, ("Error: %s" % vgstatus)
|
|
569 |
raise errors.OpPrereqError("Error: %s" % vgstatus) |
|
570 | 570 |
|
571 | 571 |
if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", |
572 | 572 |
self.op.mac_prefix): |
573 |
raise errors.OpPrereqError, ("Invalid mac prefix given '%s'" %
|
|
574 |
self.op.mac_prefix)
|
|
573 |
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % |
|
574 |
self.op.mac_prefix) |
|
575 | 575 |
|
576 | 576 |
if self.op.hypervisor_type not in hypervisor.VALID_HTYPES: |
577 |
raise errors.OpPrereqError, ("Invalid hypervisor type given '%s'" %
|
|
578 |
self.op.hypervisor_type)
|
|
577 |
raise errors.OpPrereqError("Invalid hypervisor type given '%s'" % |
|
578 |
self.op.hypervisor_type) |
|
579 | 579 |
|
580 | 580 |
result = utils.RunCmd(["ip", "link", "show", "dev", self.op.master_netdev]) |
581 | 581 |
if result.failed: |
582 |
raise errors.OpPrereqError, ("Invalid master netdev given (%s): '%s'" %
|
|
583 |
(self.op.master_netdev, result.output))
|
|
582 |
raise errors.OpPrereqError("Invalid master netdev given (%s): '%s'" % |
|
583 |
(self.op.master_netdev, result.output)) |
|
584 | 584 |
|
585 | 585 |
def Exec(self, feedback_fn): |
586 | 586 |
"""Initialize the cluster. |
... | ... | |
647 | 647 |
|
648 | 648 |
nodelist = self.cfg.GetNodeList() |
649 | 649 |
if len(nodelist) != 1 or nodelist[0] != master: |
650 |
raise errors.OpPrereqError, ("There are still %d node(s) in "
|
|
651 |
"this cluster." % (len(nodelist) - 1))
|
|
650 |
raise errors.OpPrereqError("There are still %d node(s) in"
|
|
651 |
" this cluster." % (len(nodelist) - 1))
|
|
652 | 652 |
instancelist = self.cfg.GetInstanceList() |
653 | 653 |
if instancelist: |
654 |
raise errors.OpPrereqError, ("There are still %d instance(s) in "
|
|
655 |
"this cluster." % len(instancelist))
|
|
654 |
raise errors.OpPrereqError("There are still %d instance(s) in"
|
|
655 |
" this cluster." % len(instancelist))
|
|
656 | 656 |
|
657 | 657 |
def Exec(self, feedback_fn): |
658 | 658 |
"""Destroys the cluster. |
... | ... | |
932 | 932 |
logger.ToStderr("Can't get any data from node %s" % node) |
933 | 933 |
retries += 1 |
934 | 934 |
if retries >= 10: |
935 |
raise errors.RemoteError, ("Can't contact node %s for mirror data,"
|
|
936 |
" aborting." % node)
|
|
935 |
raise errors.RemoteError("Can't contact node %s for mirror data," |
|
936 |
" aborting." % node) |
|
937 | 937 |
time.sleep(6) |
938 | 938 |
continue |
939 | 939 |
retries = 0 |
... | ... | |
1012 | 1012 |
node_list = self.cfg.GetNodeList() |
1013 | 1013 |
node_data = rpc.call_os_diagnose(node_list) |
1014 | 1014 |
if node_data == False: |
1015 |
raise errors.OpExecError, "Can't gather the list of OSes"
|
|
1015 |
raise errors.OpExecError("Can't gather the list of OSes")
|
|
1016 | 1016 |
return node_data |
1017 | 1017 |
|
1018 | 1018 |
|
... | ... | |
1058 | 1058 |
|
1059 | 1059 |
masternode = self.sstore.GetMasterNode() |
1060 | 1060 |
if node.name == masternode: |
1061 |
raise errors.OpPrereqError, ("Node is the master node,"
|
|
1062 |
" you need to failover first.")
|
|
1061 |
raise errors.OpPrereqError("Node is the master node," |
|
1062 |
" you need to failover first.") |
|
1063 | 1063 |
|
1064 | 1064 |
for instance_name in instance_list: |
1065 | 1065 |
instance = self.cfg.GetInstanceInfo(instance_name) |
1066 | 1066 |
if node.name == instance.primary_node: |
1067 |
raise errors.OpPrereqError, ("Instance %s still running on the node,"
|
|
1068 |
" please remove first." % instance_name)
|
|
1067 |
raise errors.OpPrereqError("Instance %s still running on the node," |
|
1068 |
" please remove first." % instance_name) |
|
1069 | 1069 |
if node.name in instance.secondary_nodes: |
1070 |
raise errors.OpPrereqError, ("Instance %s has node as a secondary,"
|
|
1071 |
" please remove first." % instance_name)
|
|
1070 |
raise errors.OpPrereqError("Instance %s has node as a secondary," |
|
1071 |
" please remove first." % instance_name) |
|
1072 | 1072 |
self.op.node_name = node.name |
1073 | 1073 |
self.node = node |
1074 | 1074 |
|
... | ... | |
1168 | 1168 |
elif field in self.dynamic_fields: |
1169 | 1169 |
val = live_data[node.name].get(field, "?") |
1170 | 1170 |
else: |
1171 |
raise errors.ParameterError, field
|
|
1171 |
raise errors.ParameterError(field)
|
|
1172 | 1172 |
val = str(val) |
1173 | 1173 |
node_output.append(val) |
1174 | 1174 |
output.append(node_output) |
... | ... | |
1238 | 1238 |
else: |
1239 | 1239 |
val = '-' |
1240 | 1240 |
else: |
1241 |
raise errors.ParameterError, field
|
|
1241 |
raise errors.ParameterError(field)
|
|
1242 | 1242 |
node_output.append(str(val)) |
1243 | 1243 |
|
1244 | 1244 |
output.append(node_output) |
... | ... | |
1285 | 1285 |
|
1286 | 1286 |
dns_data = utils.LookupHostname(node_name) |
1287 | 1287 |
if not dns_data: |
1288 |
raise errors.OpPrereqError, ("Node %s is not resolvable" % node_name)
|
|
1288 |
raise errors.OpPrereqError("Node %s is not resolvable" % node_name) |
|
1289 | 1289 |
|
1290 | 1290 |
node = dns_data['hostname'] |
1291 | 1291 |
primary_ip = self.op.primary_ip = dns_data['ip'] |
... | ... | |
1293 | 1293 |
if secondary_ip is None: |
1294 | 1294 |
secondary_ip = primary_ip |
1295 | 1295 |
if not utils.IsValidIP(secondary_ip): |
1296 |
raise errors.OpPrereqError, ("Invalid secondary IP given")
|
|
1296 |
raise errors.OpPrereqError("Invalid secondary IP given") |
|
1297 | 1297 |
self.op.secondary_ip = secondary_ip |
1298 | 1298 |
node_list = cfg.GetNodeList() |
1299 | 1299 |
if node in node_list: |
1300 |
raise errors.OpPrereqError, ("Node %s is already in the configuration"
|
|
1301 |
% node)
|
|
1300 |
raise errors.OpPrereqError("Node %s is already in the configuration" |
|
1301 |
% node) |
|
1302 | 1302 |
|
1303 | 1303 |
for existing_node_name in node_list: |
1304 | 1304 |
existing_node = cfg.GetNodeInfo(existing_node_name) |
... | ... | |
1306 | 1306 |
existing_node.secondary_ip == primary_ip or |
1307 | 1307 |
existing_node.primary_ip == secondary_ip or |
1308 | 1308 |
existing_node.secondary_ip == secondary_ip): |
1309 |
raise errors.OpPrereqError, ("New node ip address(es) conflict with"
|
|
1310 |
" existing node %s" % existing_node.name)
|
|
1309 |
raise errors.OpPrereqError("New node ip address(es) conflict with" |
|
1310 |
" existing node %s" % existing_node.name) |
|
1311 | 1311 |
|
1312 | 1312 |
# check that the type of the node (single versus dual homed) is the |
1313 | 1313 |
# same as for the master |
... | ... | |
1316 | 1316 |
newbie_singlehomed = secondary_ip == primary_ip |
1317 | 1317 |
if master_singlehomed != newbie_singlehomed: |
1318 | 1318 |
if master_singlehomed: |
1319 |
raise errors.OpPrereqError, ("The master has no private ip but the"
|
|
1320 |
" new node has one")
|
|
1319 |
raise errors.OpPrereqError("The master has no private ip but the" |
|
1320 |
" new node has one") |
|
1321 | 1321 |
else: |
1322 |
raise errors.OpPrereqError ("The master has a private ip but the"
|
|
1323 |
" new node doesn't have one")
|
|
1322 |
raise errors.OpPrereqError("The master has a private ip but the" |
|
1323 |
" new node doesn't have one") |
|
1324 | 1324 |
|
1325 | 1325 |
# checks reachablity |
1326 | 1326 |
command = ["fping", "-q", primary_ip] |
1327 | 1327 |
result = utils.RunCmd(command) |
1328 | 1328 |
if result.failed: |
1329 |
raise errors.OpPrereqError, ("Node not reachable by ping")
|
|
1329 |
raise errors.OpPrereqError("Node not reachable by ping") |
|
1330 | 1330 |
|
1331 | 1331 |
if not newbie_singlehomed: |
1332 | 1332 |
# check reachability from my secondary ip to newbie's secondary ip |
1333 | 1333 |
command = ["fping", "-S%s" % myself.secondary_ip, "-q", secondary_ip] |
1334 | 1334 |
result = utils.RunCmd(command) |
1335 | 1335 |
if result.failed: |
1336 |
raise errors.OpPrereqError, ("Node secondary ip not reachable by ping")
|
|
1336 |
raise errors.OpPrereqError("Node secondary ip not reachable by ping") |
|
1337 | 1337 |
|
1338 | 1338 |
self.new_node = objects.Node(name=node, |
1339 | 1339 |
primary_ip=primary_ip, |
... | ... | |
1349 | 1349 |
# set up inter-node password and certificate and restarts the node daemon |
1350 | 1350 |
gntpass = self.sstore.GetNodeDaemonPassword() |
1351 | 1351 |
if not re.match('^[a-zA-Z0-9.]{1,64}$', gntpass): |
1352 |
raise errors.OpExecError, ("ganeti password corruption detected")
|
|
1352 |
raise errors.OpExecError("ganeti password corruption detected") |
|
1353 | 1353 |
f = open(constants.SSL_CERT_FILE) |
1354 | 1354 |
try: |
1355 | 1355 |
gntpem = f.read(8192) |
... | ... | |
1360 | 1360 |
# cert doesn't contain this, the here-document will be correctly |
1361 | 1361 |
# parsed by the shell sequence below |
1362 | 1362 |
if re.search('^!EOF\.', gntpem, re.MULTILINE): |
1363 |
raise errors.OpExecError, ("invalid PEM encoding in the SSL certificate")
|
|
1363 |
raise errors.OpExecError("invalid PEM encoding in the SSL certificate") |
|
1364 | 1364 |
if not gntpem.endswith("\n"): |
1365 |
raise errors.OpExecError, ("PEM must end with newline")
|
|
1365 |
raise errors.OpExecError("PEM must end with newline") |
|
1366 | 1366 |
logger.Info("copy cluster pass to %s and starting the node daemon" % node) |
1367 | 1367 |
|
1368 | 1368 |
# remove first the root's known_hosts file |
... | ... | |
1381 | 1381 |
|
1382 | 1382 |
result = ssh.SSHCall(node, 'root', mycommand, batch=False, ask_key=True) |
1383 | 1383 |
if result.failed: |
1384 |
raise errors.OpExecError, ("Remote command on node %s, error: %s,"
|
|
1385 |
" output: %s" %
|
|
1386 |
(node, result.fail_reason, result.output))
|
|
1384 |
raise errors.OpExecError("Remote command on node %s, error: %s," |
|
1385 |
" output: %s" % |
|
1386 |
(node, result.fail_reason, result.output)) |
|
1387 | 1387 |
|
1388 | 1388 |
# check connectivity |
1389 | 1389 |
time.sleep(4) |
... | ... | |
1394 | 1394 |
logger.Info("communication to node %s fine, sw version %s match" % |
1395 | 1395 |
(node, result)) |
1396 | 1396 |
else: |
1397 |
raise errors.OpExecError, ("Version mismatch master version %s,"
|
|
1398 |
" node version %s" %
|
|
1399 |
(constants.PROTOCOL_VERSION, result))
|
|
1397 |
raise errors.OpExecError("Version mismatch master version %s," |
|
1398 |
" node version %s" % |
|
1399 |
(constants.PROTOCOL_VERSION, result)) |
|
1400 | 1400 |
else: |
1401 |
raise errors.OpExecError, ("Cannot get version from the new node")
|
|
1401 |
raise errors.OpExecError("Cannot get version from the new node") |
|
1402 | 1402 |
|
1403 | 1403 |
# setup ssh on node |
1404 | 1404 |
logger.Info("copy ssh key to node %s" % node) |
... | ... | |
1418 | 1418 |
keyarray[3], keyarray[4], keyarray[5]) |
1419 | 1419 |
|
1420 | 1420 |
if not result: |
1421 |
raise errors.OpExecError, ("Cannot transfer ssh keys to the new node")
|
|
1421 |
raise errors.OpExecError("Cannot transfer ssh keys to the new node") |
|
1422 | 1422 |
|
1423 | 1423 |
# Add node to our /etc/hosts, and add key to known_hosts |
1424 | 1424 |
_UpdateEtcHosts(new_node.name, new_node.primary_ip) |
... | ... | |
1429 | 1429 |
result = ssh.SSHCall(node, "root", |
1430 | 1430 |
"fping -S 127.0.0.1 -q %s" % new_node.secondary_ip) |
1431 | 1431 |
if result.failed: |
1432 |
raise errors.OpExecError, ("Node claims it doesn't have the"
|
|
1433 |
" secondary ip you gave (%s).\n"
|
|
1434 |
"Please fix and re-run this command." %
|
|
1435 |
new_node.secondary_ip)
|
|
1432 |
raise errors.OpExecError("Node claims it doesn't have the" |
|
1433 |
" secondary ip you gave (%s).\n" |
|
1434 |
"Please fix and re-run this command." % |
|
1435 |
new_node.secondary_ip) |
|
1436 | 1436 |
|
1437 | 1437 |
# Distribute updated /etc/hosts and known_hosts to all nodes, |
1438 | 1438 |
# including the node just added |
... | ... | |
1493 | 1493 |
self.old_master = self.sstore.GetMasterNode() |
1494 | 1494 |
|
1495 | 1495 |
if self.old_master == self.new_master: |
1496 |
raise errors.OpPrereqError, ("This commands must be run on the node"
|
|
1497 |
" where you want the new master to be.\n"
|
|
1498 |
"%s is already the master" %
|
|
1499 |
self.old_master)
|
|
1496 |
raise errors.OpPrereqError("This commands must be run on the node" |
|
1497 |
" where you want the new master to be.\n" |
|
1498 |
"%s is already the master" % |
|
1499 |
self.old_master) |
|
1500 | 1500 |
|
1501 | 1501 |
def Exec(self, feedback_fn): |
1502 | 1502 |
"""Failover the master node. |
... | ... | |
1659 | 1659 |
instance = self.cfg.GetInstanceInfo( |
1660 | 1660 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
1661 | 1661 |
if instance is None: |
1662 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
1663 |
self.op.instance_name)
|
|
1662 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
1663 |
self.op.instance_name) |
|
1664 | 1664 |
self.instance = instance |
1665 | 1665 |
|
1666 | 1666 |
|
... | ... | |
1670 | 1670 |
""" |
1671 | 1671 |
disks_ok, disks_info = _AssembleInstanceDisks(self.instance, self.cfg) |
1672 | 1672 |
if not disks_ok: |
1673 |
raise errors.OpExecError, ("Cannot activate block devices")
|
|
1673 |
raise errors.OpExecError("Cannot activate block devices") |
|
1674 | 1674 |
|
1675 | 1675 |
return disks_info |
1676 | 1676 |
|
... | ... | |
1712 | 1712 |
|
1713 | 1713 |
|
1714 | 1714 |
def _StartInstanceDisks(cfg, instance, force): |
1715 |
"""Start the disks of an instance. |
|
1716 |
|
|
1717 |
""" |
|
1715 | 1718 |
disks_ok, dummy = _AssembleInstanceDisks(instance, cfg, |
1716 | 1719 |
ignore_secondaries=force) |
1717 | 1720 |
if not disks_ok: |
... | ... | |
1719 | 1722 |
if force is not None and not force: |
1720 | 1723 |
logger.Error("If the message above refers to a secondary node," |
1721 | 1724 |
" you can retry the operation using '--force'.") |
1722 |
raise errors.OpExecError, ("Disk consistency error")
|
|
1725 |
raise errors.OpExecError("Disk consistency error") |
|
1723 | 1726 |
|
1724 | 1727 |
|
1725 | 1728 |
class LUDeactivateInstanceDisks(NoHooksLU): |
... | ... | |
1737 | 1740 |
instance = self.cfg.GetInstanceInfo( |
1738 | 1741 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
1739 | 1742 |
if instance is None: |
1740 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
1741 |
self.op.instance_name)
|
|
1743 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
1744 |
self.op.instance_name) |
|
1742 | 1745 |
self.instance = instance |
1743 | 1746 |
|
1744 | 1747 |
def Exec(self, feedback_fn): |
... | ... | |
1749 | 1752 |
ins_l = rpc.call_instance_list([instance.primary_node]) |
1750 | 1753 |
ins_l = ins_l[instance.primary_node] |
1751 | 1754 |
if not type(ins_l) is list: |
1752 |
raise errors.OpExecError, ("Can't contact node '%s'" %
|
|
1753 |
instance.primary_node)
|
|
1755 |
raise errors.OpExecError("Can't contact node '%s'" % |
|
1756 |
instance.primary_node) |
|
1754 | 1757 |
|
1755 | 1758 |
if self.instance.name in ins_l: |
1756 |
raise errors.OpExecError, ("Instance is running, can't shutdown"
|
|
1757 |
" block devices.")
|
|
1759 |
raise errors.OpExecError("Instance is running, can't shutdown" |
|
1760 |
" block devices.") |
|
1758 | 1761 |
|
1759 | 1762 |
_ShutdownInstanceDisks(instance, self.cfg) |
1760 | 1763 |
|
... | ... | |
1811 | 1814 |
instance = self.cfg.GetInstanceInfo( |
1812 | 1815 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
1813 | 1816 |
if instance is None: |
1814 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
1815 |
self.op.instance_name)
|
|
1817 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
1818 |
self.op.instance_name) |
|
1816 | 1819 |
|
1817 | 1820 |
# check bridges existance |
1818 | 1821 |
brlist = [nic.bridge for nic in instance.nics] |
1819 | 1822 |
if not rpc.call_bridges_exist(instance.primary_node, brlist): |
1820 |
raise errors.OpPrereqError, ("one or more target bridges %s does not"
|
|
1821 |
" exist on destination node '%s'" %
|
|
1822 |
(brlist, instance.primary_node))
|
|
1823 |
raise errors.OpPrereqError("one or more target bridges %s does not" |
|
1824 |
" exist on destination node '%s'" % |
|
1825 |
(brlist, instance.primary_node)) |
|
1823 | 1826 |
|
1824 | 1827 |
self.instance = instance |
1825 | 1828 |
self.op.instance_name = instance.name |
... | ... | |
1836 | 1839 |
|
1837 | 1840 |
nodeinfo = rpc.call_node_info([node_current], self.cfg.GetVGName()) |
1838 | 1841 |
if not nodeinfo: |
1839 |
raise errors.OpExecError, ("Could not contact node %s for infos" %
|
|
1840 |
(node_current))
|
|
1842 |
raise errors.OpExecError("Could not contact node %s for infos" % |
|
1843 |
(node_current)) |
|
1841 | 1844 |
|
1842 | 1845 |
freememory = nodeinfo[node_current]['memory_free'] |
1843 | 1846 |
memory = instance.memory |
1844 | 1847 |
if memory > freememory: |
1845 |
raise errors.OpExecError, ("Not enough memory to start instance"
|
|
1846 |
" %s on node %s"
|
|
1847 |
" needed %s MiB, available %s MiB" %
|
|
1848 |
(instance.name, node_current, memory,
|
|
1849 |
freememory))
|
|
1848 |
raise errors.OpExecError("Not enough memory to start instance" |
|
1849 |
" %s on node %s" |
|
1850 |
" needed %s MiB, available %s MiB" % |
|
1851 |
(instance.name, node_current, memory, |
|
1852 |
freememory)) |
|
1850 | 1853 |
|
1851 | 1854 |
_StartInstanceDisks(self.cfg, instance, force) |
1852 | 1855 |
|
1853 | 1856 |
if not rpc.call_instance_start(node_current, instance, extra_args): |
1854 | 1857 |
_ShutdownInstanceDisks(instance, self.cfg) |
1855 |
raise errors.OpExecError, ("Could not start instance")
|
|
1858 |
raise errors.OpExecError("Could not start instance") |
|
1856 | 1859 |
|
1857 | 1860 |
self.cfg.MarkInstanceUp(instance.name) |
1858 | 1861 |
|
... | ... | |
1885 | 1888 |
instance = self.cfg.GetInstanceInfo( |
1886 | 1889 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
1887 | 1890 |
if instance is None: |
1888 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
1889 |
self.op.instance_name)
|
|
1891 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
1892 |
self.op.instance_name) |
|
1890 | 1893 |
self.instance = instance |
1891 | 1894 |
|
1892 | 1895 |
def Exec(self, feedback_fn): |
... | ... | |
1930 | 1933 |
instance = self.cfg.GetInstanceInfo( |
1931 | 1934 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
1932 | 1935 |
if instance is None: |
1933 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
1934 |
self.op.instance_name)
|
|
1936 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
1937 |
self.op.instance_name) |
|
1935 | 1938 |
if instance.disk_template == constants.DT_DISKLESS: |
1936 |
raise errors.OpPrereqError, ("Instance '%s' has no disks" %
|
|
1937 |
self.op.instance_name)
|
|
1939 |
raise errors.OpPrereqError("Instance '%s' has no disks" % |
|
1940 |
self.op.instance_name) |
|
1938 | 1941 |
if instance.status != "down": |
1939 |
raise errors.OpPrereqError, ("Instance '%s' is marked to be up" %
|
|
1940 |
self.op.instance_name)
|
|
1942 |
raise errors.OpPrereqError("Instance '%s' is marked to be up" % |
|
1943 |
self.op.instance_name) |
|
1941 | 1944 |
remote_info = rpc.call_instance_info(instance.primary_node, instance.name) |
1942 | 1945 |
if remote_info: |
1943 |
raise errors.OpPrereqError, ("Instance '%s' is running on the node %s" %
|
|
1944 |
(self.op.instance_name,
|
|
1945 |
instance.primary_node))
|
|
1946 |
raise errors.OpPrereqError("Instance '%s' is running on the node %s" % |
|
1947 |
(self.op.instance_name, |
|
1948 |
instance.primary_node)) |
|
1946 | 1949 |
|
1947 | 1950 |
self.op.os_type = getattr(self.op, "os_type", None) |
1948 | 1951 |
if self.op.os_type is not None: |
... | ... | |
1950 | 1953 |
pnode = self.cfg.GetNodeInfo( |
1951 | 1954 |
self.cfg.ExpandNodeName(instance.primary_node)) |
1952 | 1955 |
if pnode is None: |
1953 |
raise errors.OpPrereqError, ("Primary node '%s' is unknown" %
|
|
1954 |
self.op.pnode)
|
|
1956 |
raise errors.OpPrereqError("Primary node '%s' is unknown" % |
|
1957 |
self.op.pnode) |
|
1955 | 1958 |
os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name] |
1956 | 1959 |
if not isinstance(os_obj, objects.OS): |
1957 |
raise errors.OpPrereqError, ("OS '%s' not in supported OS list for"
|
|
1958 |
" primary node" % self.op.os_type)
|
|
1960 |
raise errors.OpPrereqError("OS '%s' not in supported OS list for" |
|
1961 |
" primary node" % self.op.os_type) |
|
1959 | 1962 |
|
1960 | 1963 |
self.instance = instance |
1961 | 1964 |
|
... | ... | |
1974 | 1977 |
try: |
1975 | 1978 |
feedback_fn("Running the instance OS create scripts...") |
1976 | 1979 |
if not rpc.call_instance_os_add(inst.primary_node, inst, "sda", "sdb"): |
1977 |
raise errors.OpExecError, ("Could not install OS for instance %s "
|
|
1978 |
"on node %s" %
|
|
1979 |
(inst.name, inst.primary_node))
|
|
1980 |
raise errors.OpExecError("Could not install OS for instance %s " |
|
1981 |
"on node %s" % |
|
1982 |
(inst.name, inst.primary_node)) |
|
1980 | 1983 |
finally: |
1981 | 1984 |
_ShutdownInstanceDisks(inst, self.cfg) |
1982 | 1985 |
|
... | ... | |
2009 | 2012 |
instance = self.cfg.GetInstanceInfo( |
2010 | 2013 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
2011 | 2014 |
if instance is None: |
2012 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
2013 |
self.op.instance_name)
|
|
2015 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
2016 |
self.op.instance_name) |
|
2014 | 2017 |
self.instance = instance |
2015 | 2018 |
|
2016 | 2019 |
def Exec(self, feedback_fn): |
... | ... | |
2022 | 2025 |
(instance.name, instance.primary_node)) |
2023 | 2026 |
|
2024 | 2027 |
if not rpc.call_instance_shutdown(instance.primary_node, instance): |
2025 |
raise errors.OpExecError, ("Could not shutdown instance %s on node %s" %
|
|
2026 |
(instance.name, instance.primary_node))
|
|
2028 |
raise errors.OpExecError("Could not shutdown instance %s on node %s" % |
|
2029 |
(instance.name, instance.primary_node)) |
|
2027 | 2030 |
|
2028 | 2031 |
logger.Info("removing block devices for instance %s" % instance.name) |
2029 | 2032 |
|
... | ... | |
2124 | 2127 |
elif field == "mac": |
2125 | 2128 |
val = instance.nics[0].mac |
2126 | 2129 |
else: |
2127 |
raise errors.ParameterError, field
|
|
2130 |
raise errors.ParameterError(field)
|
|
2128 | 2131 |
val = str(val) |
2129 | 2132 |
iout.append(val) |
2130 | 2133 |
output.append(iout) |
... | ... | |
2162 | 2165 |
instance = self.cfg.GetInstanceInfo( |
2163 | 2166 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
2164 | 2167 |
if instance is None: |
2165 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
2166 |
self.op.instance_name)
|
|
2168 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
2169 |
self.op.instance_name) |
|
2167 | 2170 |
|
2168 | 2171 |
# check memory requirements on the secondary node |
2169 | 2172 |
target_node = instance.secondary_nodes[0] |
2170 | 2173 |
nodeinfo = rpc.call_node_info([target_node], self.cfg.GetVGName()) |
2171 | 2174 |
info = nodeinfo.get(target_node, None) |
2172 | 2175 |
if not info: |
2173 |
raise errors.OpPrereqError, ("Cannot get current information"
|
|
2174 |
" from node '%s'" % nodeinfo)
|
|
2176 |
raise errors.OpPrereqError("Cannot get current information" |
|
2177 |
" from node '%s'" % nodeinfo) |
|
2175 | 2178 |
if instance.memory > info['memory_free']: |
2176 |
raise errors.OpPrereqError, ("Not enough memory on target node %s."
|
|
2177 |
" %d MB available, %d MB required" %
|
|
2178 |
(target_node, info['memory_free'],
|
|
2179 |
instance.memory))
|
|
2179 |
raise errors.OpPrereqError("Not enough memory on target node %s." |
|
2180 |
" %d MB available, %d MB required" % |
|
2181 |
(target_node, info['memory_free'], |
|
2182 |
instance.memory)) |
|
2180 | 2183 |
|
2181 | 2184 |
# check bridge existance |
2182 | 2185 |
brlist = [nic.bridge for nic in instance.nics] |
2183 | 2186 |
if not rpc.call_bridges_exist(instance.primary_node, brlist): |
2184 |
raise errors.OpPrereqError, ("one or more target bridges %s does not"
|
|
2185 |
" exist on destination node '%s'" %
|
|
2186 |
(brlist, instance.primary_node))
|
|
2187 |
raise errors.OpPrereqError("One or more target bridges %s does not"
|
|
2188 |
" exist on destination node '%s'" % |
|
2189 |
(brlist, instance.primary_node)) |
|
2187 | 2190 |
|
2188 | 2191 |
self.instance = instance |
2189 | 2192 |
|
... | ... | |
2204 | 2207 |
# for remote_raid1, these are md over drbd |
2205 | 2208 |
if not _CheckDiskConsistency(self.cfg, dev, target_node, False): |
2206 | 2209 |
if not self.op.ignore_consistency: |
2207 |
raise errors.OpExecError, ("Disk %s is degraded on target node,"
|
|
2208 |
" aborting failover." % dev.iv_name)
|
|
2210 |
raise errors.OpExecError("Disk %s is degraded on target node," |
|
2211 |
" aborting failover." % dev.iv_name) |
|
2209 | 2212 |
|
2210 | 2213 |
feedback_fn("* checking target node resource availability") |
2211 | 2214 |
nodeinfo = rpc.call_node_info([target_node], self.cfg.GetVGName()) |
2212 | 2215 |
|
2213 | 2216 |
if not nodeinfo: |
2214 |
raise errors.OpExecError, ("Could not contact target node %s." %
|
|
2215 |
target_node)
|
|
2217 |
raise errors.OpExecError("Could not contact target node %s." % |
|
2218 |
target_node) |
|
2216 | 2219 |
|
2217 | 2220 |
free_memory = int(nodeinfo[target_node]['memory_free']) |
2218 | 2221 |
memory = instance.memory |
2219 | 2222 |
if memory > free_memory: |
2220 |
raise errors.OpExecError, ("Not enough memory to create instance %s on"
|
|
2221 |
" node %s. needed %s MiB, available %s MiB" %
|
|
2222 |
(instance.name, target_node, memory,
|
|
2223 |
free_memory))
|
|
2223 |
raise errors.OpExecError("Not enough memory to create instance %s on" |
|
2224 |
" node %s. needed %s MiB, available %s MiB" % |
|
2225 |
(instance.name, target_node, memory, |
|
2226 |
free_memory)) |
|
2224 | 2227 |
|
2225 | 2228 |
feedback_fn("* shutting down instance on source node") |
2226 | 2229 |
logger.Info("Shutting down instance %s on node %s" % |
... | ... | |
2233 | 2236 |
|
2234 | 2237 |
feedback_fn("* deactivating the instance's disks on source node") |
2235 | 2238 |
if not _ShutdownInstanceDisks(instance, self.cfg, ignore_primary=True): |
2236 |
raise errors.OpExecError, ("Can't shut down the instance's disks.")
|
|
2239 |
raise errors.OpExecError("Can't shut down the instance's disks.") |
|
2237 | 2240 |
|
2238 | 2241 |
instance.primary_node = target_node |
2239 | 2242 |
# distribute new instance config to the other nodes |
... | ... | |
2247 | 2250 |
ignore_secondaries=True) |
2248 | 2251 |
if not disks_ok: |
2249 | 2252 |
_ShutdownInstanceDisks(instance, self.cfg) |
2250 |
raise errors.OpExecError, ("Can't activate the instance's disks")
|
|
2253 |
raise errors.OpExecError("Can't activate the instance's disks") |
|
2251 | 2254 |
|
2252 | 2255 |
feedback_fn("* starting the instance on the target node") |
2253 | 2256 |
if not rpc.call_instance_start(target_node, instance, None): |
... | ... | |
2398 | 2401 |
|
2399 | 2402 |
|
2400 | 2403 |
def _GetInstanceInfoText(instance): |
2404 |
"""Compute that text that should be added to the disk's metadata. |
|
2405 |
|
|
2406 |
""" |
|
2401 | 2407 |
return "originstname+%s" % instance.name |
2402 | 2408 |
|
2403 | 2409 |
|
... | ... | |
2510 | 2516 |
""" |
2511 | 2517 |
if self.op.mode not in (constants.INSTANCE_CREATE, |
2512 | 2518 |
constants.INSTANCE_IMPORT): |
2513 |
raise errors.OpPrereqError, ("Invalid instance creation mode '%s'" %
|
|
2514 |
self.op.mode)
|
|
2519 |
raise errors.OpPrereqError("Invalid instance creation mode '%s'" % |
|
2520 |
self.op.mode) |
|
2515 | 2521 |
|
2516 | 2522 |
if self.op.mode == constants.INSTANCE_IMPORT: |
2517 | 2523 |
src_node = getattr(self.op, "src_node", None) |
2518 | 2524 |
src_path = getattr(self.op, "src_path", None) |
2519 | 2525 |
if src_node is None or src_path is None: |
2520 |
raise errors.OpPrereqError, ("Importing an instance requires source"
|
|
2521 |
" node and path options")
|
|
2526 |
raise errors.OpPrereqError("Importing an instance requires source" |
|
2527 |
" node and path options") |
|
2522 | 2528 |
src_node_full = self.cfg.ExpandNodeName(src_node) |
2523 | 2529 |
if src_node_full is None: |
2524 |
raise errors.OpPrereqError, ("Unknown source node '%s'" % src_node)
|
|
2530 |
raise errors.OpPrereqError("Unknown source node '%s'" % src_node) |
|
2525 | 2531 |
self.op.src_node = src_node = src_node_full |
2526 | 2532 |
|
2527 | 2533 |
if not os.path.isabs(src_path): |
2528 |
raise errors.OpPrereqError, ("The source path must be absolute")
|
|
2534 |
raise errors.OpPrereqError("The source path must be absolute") |
|
2529 | 2535 |
|
2530 | 2536 |
export_info = rpc.call_export_info(src_node, src_path) |
2531 | 2537 |
|
2532 | 2538 |
if not export_info: |
2533 |
raise errors.OpPrereqError, ("No export found in dir %s" % src_path)
|
|
2539 |
raise errors.OpPrereqError("No export found in dir %s" % src_path) |
|
2534 | 2540 |
|
2535 | 2541 |
if not export_info.has_section(constants.INISECT_EXP): |
2536 |
raise errors.ProgrammerError, ("Corrupted export config")
|
|
2542 |
raise errors.ProgrammerError("Corrupted export config") |
|
2537 | 2543 |
|
2538 | 2544 |
ei_version = export_info.get(constants.INISECT_EXP, 'version') |
2539 | 2545 |
if (int(ei_version) != constants.EXPORT_VERSION): |
2540 |
raise errors.OpPrereqError, ("Wrong export version %s (wanted %d)" %
|
|
2541 |
(ei_version, constants.EXPORT_VERSION))
|
|
2546 |
raise errors.OpPrereqError("Wrong export version %s (wanted %d)" % |
|
2547 |
(ei_version, constants.EXPORT_VERSION)) |
|
2542 | 2548 |
|
2543 | 2549 |
if int(export_info.get(constants.INISECT_INS, 'disk_count')) > 1: |
2544 |
raise errors.OpPrereqError, ("Can't import instance with more than"
|
|
2545 |
" one data disk")
|
|
2550 |
raise errors.OpPrereqError("Can't import instance with more than" |
|
2551 |
" one data disk") |
|
2546 | 2552 |
|
2547 | 2553 |
# FIXME: are the old os-es, disk sizes, etc. useful? |
2548 | 2554 |
self.op.os_type = export_info.get(constants.INISECT_EXP, 'os') |
... | ... | |
2551 | 2557 |
self.src_image = diskimage |
2552 | 2558 |
else: # INSTANCE_CREATE |
2553 | 2559 |
if getattr(self.op, "os_type", None) is None: |
2554 |
raise errors.OpPrereqError, ("No guest OS specified")
|
|
2560 |
raise errors.OpPrereqError("No guest OS specified") |
|
2555 | 2561 |
|
2556 | 2562 |
# check primary node |
2557 | 2563 |
pnode = self.cfg.GetNodeInfo(self.cfg.ExpandNodeName(self.op.pnode)) |
2558 | 2564 |
if pnode is None: |
2559 |
raise errors.OpPrereqError, ("Primary node '%s' is unknown" %
|
|
2560 |
self.op.pnode)
|
|
2565 |
raise errors.OpPrereqError("Primary node '%s' is unknown" % |
|
2566 |
self.op.pnode) |
|
2561 | 2567 |
self.op.pnode = pnode.name |
2562 | 2568 |
self.pnode = pnode |
2563 | 2569 |
self.secondaries = [] |
2564 | 2570 |
# disk template and mirror node verification |
2565 | 2571 |
if self.op.disk_template not in constants.DISK_TEMPLATES: |
2566 |
raise errors.OpPrereqError, ("Invalid disk template name")
|
|
2572 |
raise errors.OpPrereqError("Invalid disk template name") |
|
2567 | 2573 |
|
2568 | 2574 |
if self.op.disk_template == constants.DT_REMOTE_RAID1: |
2569 | 2575 |
if getattr(self.op, "snode", None) is None: |
2570 |
raise errors.OpPrereqError, ("The 'remote_raid1' disk template needs"
|
|
2571 |
" a mirror node")
|
|
2576 |
raise errors.OpPrereqError("The 'remote_raid1' disk template needs" |
|
2577 |
" a mirror node") |
|
2572 | 2578 |
|
2573 | 2579 |
snode_name = self.cfg.ExpandNodeName(self.op.snode) |
2574 | 2580 |
if snode_name is None: |
2575 |
raise errors.OpPrereqError, ("Unknown secondary node '%s'" %
|
|
2576 |
self.op.snode)
|
|
2581 |
raise errors.OpPrereqError("Unknown secondary node '%s'" % |
|
2582 |
self.op.snode) |
|
2577 | 2583 |
elif snode_name == pnode.name: |
2578 |
raise errors.OpPrereqError, ("The secondary node cannot be"
|
|
2579 |
" the primary node.")
|
|
2584 |
raise errors.OpPrereqError("The secondary node cannot be" |
|
2585 |
" the primary node.") |
|
2580 | 2586 |
self.secondaries.append(snode_name) |
2581 | 2587 |
|
2582 | 2588 |
# Check lv size requirements |
... | ... | |
2593 | 2599 |
} |
2594 | 2600 |
|
2595 | 2601 |
if self.op.disk_template not in req_size_dict: |
2596 |
raise errors.ProgrammerError, ("Disk template '%s' size requirement"
|
|
2597 |
" is unknown" % self.op.disk_template)
|
|
2602 |
raise errors.ProgrammerError("Disk template '%s' size requirement" |
|
2603 |
" is unknown" % self.op.disk_template) |
|
2598 | 2604 |
|
2599 | 2605 |
req_size = req_size_dict[self.op.disk_template] |
2600 | 2606 |
|
2601 | 2607 |
for node in nodenames: |
2602 | 2608 |
info = nodeinfo.get(node, None) |
2603 | 2609 |
if not info: |
2604 |
raise errors.OpPrereqError, ("Cannot get current information"
|
|
2605 |
" from node '%s'" % nodeinfo)
|
|
2610 |
raise errors.OpPrereqError("Cannot get current information" |
|
2611 |
" from node '%s'" % nodeinfo) |
|
2606 | 2612 |
if req_size > info['vg_free']: |
2607 |
raise errors.OpPrereqError, ("Not enough disk space on target node %s."
|
|
2608 |
" %d MB available, %d MB required" %
|
|
2609 |
(node, info['vg_free'], req_size))
|
|
2613 |
raise errors.OpPrereqError("Not enough disk space on target node %s." |
|
2614 |
" %d MB available, %d MB required" % |
|
2615 |
(node, info['vg_free'], req_size)) |
|
2610 | 2616 |
|
2611 | 2617 |
# os verification |
2612 | 2618 |
os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name] |
2613 | 2619 |
if not isinstance(os_obj, objects.OS): |
2614 |
raise errors.OpPrereqError, ("OS '%s' not in supported os list for"
|
|
2615 |
" primary node" % self.op.os_type)
|
|
2620 |
raise errors.OpPrereqError("OS '%s' not in supported os list for" |
|
2621 |
" primary node" % self.op.os_type) |
|
2616 | 2622 |
|
2617 | 2623 |
# instance verification |
2618 | 2624 |
hostname1 = utils.LookupHostname(self.op.instance_name) |
2619 | 2625 |
if not hostname1: |
2620 |
raise errors.OpPrereqError, ("Instance name '%s' not found in dns" %
|
|
2621 |
self.op.instance_name)
|
|
2626 |
raise errors.OpPrereqError("Instance name '%s' not found in dns" % |
|
2627 |
self.op.instance_name) |
|
2622 | 2628 |
|
2623 | 2629 |
self.op.instance_name = instance_name = hostname1['hostname'] |
2624 | 2630 |
instance_list = self.cfg.GetInstanceList() |
2625 | 2631 |
if instance_name in instance_list: |
2626 |
raise errors.OpPrereqError, ("Instance '%s' is already in the cluster" %
|
|
2627 |
instance_name)
|
|
2632 |
raise errors.OpPrereqError("Instance '%s' is already in the cluster" % |
|
2633 |
instance_name) |
|
2628 | 2634 |
|
2629 | 2635 |
ip = getattr(self.op, "ip", None) |
2630 | 2636 |
if ip is None or ip.lower() == "none": |
... | ... | |
2633 | 2639 |
inst_ip = hostname1['ip'] |
2634 | 2640 |
else: |
2635 | 2641 |
if not utils.IsValidIP(ip): |
2636 |
raise errors.OpPrereqError, ("given IP address '%s' doesn't look"
|
|
2637 |
" like a valid IP" % ip)
|
|
2642 |
raise errors.OpPrereqError("given IP address '%s' doesn't look" |
|
2643 |
" like a valid IP" % ip) |
|
2638 | 2644 |
inst_ip = ip |
2639 | 2645 |
self.inst_ip = inst_ip |
2640 | 2646 |
|
2641 | 2647 |
command = ["fping", "-q", hostname1['ip']] |
2642 | 2648 |
result = utils.RunCmd(command) |
2643 | 2649 |
if not result.failed: |
2644 |
raise errors.OpPrereqError, ("IP %s of instance %s already in use" %
|
|
2645 |
(hostname1['ip'], instance_name))
|
|
2650 |
raise errors.OpPrereqError("IP %s of instance %s already in use" % |
|
2651 |
(hostname1['ip'], instance_name)) |
|
2646 | 2652 |
|
2647 | 2653 |
# bridge verification |
2648 | 2654 |
bridge = getattr(self.op, "bridge", None) |
... | ... | |
2652 | 2658 |
self.op.bridge = bridge |
2653 | 2659 |
|
2654 | 2660 |
if not rpc.call_bridges_exist(self.pnode.name, [self.op.bridge]): |
2655 |
raise errors.OpPrereqError, ("target bridge '%s' does not exist on"
|
|
2656 |
" destination node '%s'" %
|
|
2657 |
(self.op.bridge, pnode.name))
|
|
2661 |
raise errors.OpPrereqError("target bridge '%s' does not exist on" |
|
2662 |
" destination node '%s'" % |
|
2663 |
(self.op.bridge, pnode.name)) |
|
2658 | 2664 |
|
2659 | 2665 |
if self.op.start: |
2660 | 2666 |
self.instance_status = 'up' |
... | ... | |
2690 | 2696 |
feedback_fn("* creating instance disks...") |
2691 | 2697 |
if not _CreateDisks(self.cfg, iobj): |
2692 | 2698 |
_RemoveDisks(iobj, self.cfg) |
2693 |
raise errors.OpExecError, ("Device creation failed, reverting...")
|
|
2699 |
raise errors.OpExecError("Device creation failed, reverting...") |
|
2694 | 2700 |
|
2695 | 2701 |
feedback_fn("adding instance %s to cluster config" % instance) |
2696 | 2702 |
|
... | ... | |
2709 | 2715 |
if disk_abort: |
2710 | 2716 |
_RemoveDisks(iobj, self.cfg) |
2711 | 2717 |
self.cfg.RemoveInstance(iobj.name) |
2712 |
raise errors.OpExecError, ("There are some degraded disks for"
|
|
2713 |
" this instance")
|
|
2718 |
raise errors.OpExecError("There are some degraded disks for" |
|
2719 |
" this instance") |
|
2714 | 2720 |
|
2715 | 2721 |
feedback_fn("creating os for instance %s on node %s" % |
2716 | 2722 |
(instance, pnode_name)) |
... | ... | |
2719 | 2725 |
if self.op.mode == constants.INSTANCE_CREATE: |
2720 | 2726 |
feedback_fn("* running the instance OS create scripts...") |
2721 | 2727 |
if not rpc.call_instance_os_add(pnode_name, iobj, "sda", "sdb"): |
2722 |
raise errors.OpExecError, ("could not add os for instance %s"
|
|
2723 |
" on node %s" %
|
|
2724 |
(instance, pnode_name))
|
|
2728 |
raise errors.OpExecError("could not add os for instance %s" |
|
2729 |
" on node %s" % |
|
2730 |
(instance, pnode_name)) |
|
2725 | 2731 |
|
2726 | 2732 |
elif self.op.mode == constants.INSTANCE_IMPORT: |
2727 | 2733 |
feedback_fn("* running the instance OS import scripts...") |
... | ... | |
2729 | 2735 |
src_image = self.src_image |
2730 | 2736 |
if not rpc.call_instance_os_import(pnode_name, iobj, "sda", "sdb", |
2731 | 2737 |
src_node, src_image): |
2732 |
raise errors.OpExecError, ("Could not import os for instance"
|
|
2733 |
" %s on node %s" %
|
|
2734 |
(instance, pnode_name))
|
|
2738 |
raise errors.OpExecError("Could not import os for instance" |
|
2739 |
" %s on node %s" % |
|
2740 |
(instance, pnode_name)) |
|
2735 | 2741 |
else: |
2736 | 2742 |
# also checked in the prereq part |
2737 |
raise errors.ProgrammerError, ("Unknown OS initialization mode '%s'"
|
|
2738 |
% self.op.mode)
|
|
2743 |
raise errors.ProgrammerError("Unknown OS initialization mode '%s'" |
|
2744 |
% self.op.mode) |
|
2739 | 2745 |
|
2740 | 2746 |
if self.op.start: |
2741 | 2747 |
logger.Info("starting instance %s on node %s" % (instance, pnode_name)) |
2742 | 2748 |
feedback_fn("* starting instance...") |
2743 | 2749 |
if not rpc.call_instance_start(pnode_name, iobj, None): |
2744 |
raise errors.OpExecError, ("Could not start instance")
|
|
2750 |
raise errors.OpExecError("Could not start instance") |
|
2745 | 2751 |
|
2746 | 2752 |
|
2747 | 2753 |
class LUConnectConsole(NoHooksLU): |
... | ... | |
2763 | 2769 |
instance = self.cfg.GetInstanceInfo( |
2764 | 2770 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
2765 | 2771 |
if instance is None: |
2766 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
2767 |
self.op.instance_name)
|
|
2772 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
2773 |
self.op.instance_name) |
|
2768 | 2774 |
self.instance = instance |
2769 | 2775 |
|
2770 | 2776 |
def Exec(self, feedback_fn): |
... | ... | |
2776 | 2782 |
|
2777 | 2783 |
node_insts = rpc.call_instance_list([node])[node] |
2778 | 2784 |
if node_insts is False: |
2779 |
raise errors.OpExecError, ("Can't connect to node %s." % node)
|
|
2785 |
raise errors.OpExecError("Can't connect to node %s." % node) |
|
2780 | 2786 |
|
2781 | 2787 |
if instance.name not in node_insts: |
2782 |
raise errors.OpExecError, ("Instance %s is not running." % instance.name)
|
|
2788 |
raise errors.OpExecError("Instance %s is not running." % instance.name) |
|
2783 | 2789 |
|
2784 | 2790 |
logger.Debug("connecting to console of %s on %s" % (instance.name, node)) |
2785 | 2791 |
|
... | ... | |
2820 | 2826 |
instance = self.cfg.GetInstanceInfo( |
2821 | 2827 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
2822 | 2828 |
if instance is None: |
2823 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
2824 |
self.op.instance_name)
|
|
2829 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
2830 |
self.op.instance_name) |
|
2825 | 2831 |
self.instance = instance |
2826 | 2832 |
|
2827 | 2833 |
remote_node = self.cfg.ExpandNodeName(self.op.remote_node) |
2828 | 2834 |
if remote_node is None: |
2829 |
raise errors.OpPrereqError, ("Node '%s' not known" % self.op.remote_node)
|
|
2835 |
raise errors.OpPrereqError("Node '%s' not known" % self.op.remote_node) |
|
2830 | 2836 |
self.remote_node = remote_node |
2831 | 2837 |
|
2832 | 2838 |
if remote_node == instance.primary_node: |
2833 |
raise errors.OpPrereqError, ("The specified node is the primary node of"
|
|
2834 |
" the instance.")
|
|
2839 |
raise errors.OpPrereqError("The specified node is the primary node of" |
|
2840 |
" the instance.") |
|
2835 | 2841 |
|
2836 | 2842 |
if instance.disk_template != constants.DT_REMOTE_RAID1: |
2837 |
raise errors.OpPrereqError, ("Instance's disk layout is not"
|
|
2838 |
" remote_raid1.")
|
|
2843 |
raise errors.OpPrereqError("Instance's disk layout is not" |
|
2844 |
" remote_raid1.") |
|
2839 | 2845 |
for disk in instance.disks: |
2840 | 2846 |
if disk.iv_name == self.op.disk_name: |
2841 | 2847 |
break |
2842 | 2848 |
else: |
2843 |
raise errors.OpPrereqError, ("Can't find this device ('%s') in the"
|
|
2844 |
" instance." % self.op.disk_name)
|
|
2849 |
raise errors.OpPrereqError("Can't find this device ('%s') in the" |
|
2850 |
" instance." % self.op.disk_name) |
|
2845 | 2851 |
if len(disk.children) > 1: |
2846 |
raise errors.OpPrereqError, ("The device already has two slave"
|
|
2847 |
" devices.\n"
|
|
2848 |
"This would create a 3-disk raid1"
|
|
2849 |
" which we don't allow.")
|
|
2852 |
raise errors.OpPrereqError("The device already has two slave" |
|
2853 |
" devices.\n" |
|
2854 |
"This would create a 3-disk raid1" |
|
2855 |
" which we don't allow.") |
|
2850 | 2856 |
self.disk = disk |
2851 | 2857 |
|
2852 | 2858 |
def Exec(self, feedback_fn): |
... | ... | |
2866 | 2872 |
#HARDCODE |
2867 | 2873 |
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, new_drbd, False, |
2868 | 2874 |
_GetInstanceInfoText(instance)): |
2869 |
raise errors.OpExecError, ("Failed to create new component on secondary"
|
|
2870 |
" node %s" % remote_node)
|
|
2875 |
raise errors.OpExecError("Failed to create new component on secondary" |
|
2876 |
" node %s" % remote_node) |
|
2871 | 2877 |
|
2872 | 2878 |
logger.Info("adding new mirror component on primary") |
2873 | 2879 |
#HARDCODE |
... | ... | |
2876 | 2882 |
# remove secondary dev |
2877 | 2883 |
self.cfg.SetDiskID(new_drbd, remote_node) |
2878 | 2884 |
rpc.call_blockdev_remove(remote_node, new_drbd) |
2879 |
raise errors.OpExecError, ("Failed to create volume on primary")
|
|
2885 |
raise errors.OpExecError("Failed to create volume on primary") |
|
2880 | 2886 |
|
2881 | 2887 |
# the device exists now |
2882 | 2888 |
# call the primary node to add the mirror to md |
... | ... | |
2890 | 2896 |
self.cfg.SetDiskID(new_drbd, instance.primary_node) |
2891 | 2897 |
if not rpc.call_blockdev_remove(instance.primary_node, new_drbd): |
2892 | 2898 |
logger.Error("Can't rollback on primary") |
2893 |
raise errors.OpExecError, "Can't add mirror component to md array"
|
|
2899 |
raise errors.OpExecError("Can't add mirror component to md array")
|
|
2894 | 2900 |
|
2895 | 2901 |
disk.children.append(new_drbd) |
2896 | 2902 |
|
... | ... | |
2934 | 2940 |
instance = self.cfg.GetInstanceInfo( |
2935 | 2941 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
2936 | 2942 |
if instance is None: |
2937 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
2938 |
self.op.instance_name)
|
|
2943 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
2944 |
self.op.instance_name) |
|
2939 | 2945 |
self.instance = instance |
2940 | 2946 |
|
2941 | 2947 |
if instance.disk_template != constants.DT_REMOTE_RAID1: |
2942 |
raise errors.OpPrereqError, ("Instance's disk layout is not"
|
|
2943 |
" remote_raid1.")
|
|
2948 |
raise errors.OpPrereqError("Instance's disk layout is not" |
|
2949 |
" remote_raid1.") |
|
2944 | 2950 |
for disk in instance.disks: |
2945 | 2951 |
if disk.iv_name == self.op.disk_name: |
2946 | 2952 |
break |
2947 | 2953 |
else: |
2948 |
raise errors.OpPrereqError, ("Can't find this device ('%s') in the"
|
|
2949 |
" instance." % self.op.disk_name)
|
|
2954 |
raise errors.OpPrereqError("Can't find this device ('%s') in the" |
|
2955 |
" instance." % self.op.disk_name) |
|
2950 | 2956 |
for child in disk.children: |
2951 | 2957 |
if child.dev_type == "drbd" and child.logical_id[2] == self.op.disk_id: |
2952 | 2958 |
break |
2953 | 2959 |
else: |
2954 |
raise errors.OpPrereqError, ("Can't find the device with this port.")
|
|
2960 |
raise errors.OpPrereqError("Can't find the device with this port.") |
|
2955 | 2961 |
|
2956 | 2962 |
if len(disk.children) < 2: |
2957 |
raise errors.OpPrereqError, ("Cannot remove the last component from"
|
|
2958 |
" a mirror.")
|
|
2963 |
raise errors.OpPrereqError("Cannot remove the last component from" |
|
2964 |
" a mirror.") |
|
2959 | 2965 |
self.disk = disk |
2960 | 2966 |
self.child = child |
2961 | 2967 |
if self.child.logical_id[0] == instance.primary_node: |
... | ... | |
2975 | 2981 |
self.cfg.SetDiskID(disk, instance.primary_node) |
2976 | 2982 |
if not rpc.call_blockdev_removechild(instance.primary_node, |
2977 | 2983 |
disk, child): |
2978 |
raise errors.OpExecError, ("Can't remove child from mirror.")
|
|
2984 |
raise errors.OpExecError("Can't remove child from mirror.") |
|
2979 | 2985 |
|
2980 | 2986 |
for node in child.logical_id[:2]: |
2981 | 2987 |
self.cfg.SetDiskID(child, node) |
... | ... | |
3019 | 3025 |
instance = self.cfg.GetInstanceInfo( |
3020 | 3026 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
3021 | 3027 |
if instance is None: |
3022 |
raise errors.OpPrereqError, ("Instance '%s' not known" %
|
|
3023 |
self.op.instance_name)
|
|
3028 |
raise errors.OpPrereqError("Instance '%s' not known" % |
|
3029 |
self.op.instance_name) |
|
3024 | 3030 |
self.instance = instance |
3025 | 3031 |
|
3026 | 3032 |
if instance.disk_template != constants.DT_REMOTE_RAID1: |
3027 |
raise errors.OpPrereqError, ("Instance's disk layout is not"
|
|
3028 |
" remote_raid1.")
|
|
3033 |
raise errors.OpPrereqError("Instance's disk layout is not" |
|
3034 |
" remote_raid1.") |
|
3029 | 3035 |
|
3030 | 3036 |
if len(instance.secondary_nodes) != 1: |
3031 |
raise errors.OpPrereqError, ("The instance has a strange layout,"
|
|
3032 |
" expected one secondary but found %d" %
|
|
3033 |
len(instance.secondary_nodes))
|
|
3037 |
raise errors.OpPrereqError("The instance has a strange layout," |
|
3038 |
" expected one secondary but found %d" % |
|
3039 |
len(instance.secondary_nodes)) |
|
3034 | 3040 |
|
3035 | 3041 |
remote_node = getattr(self.op, "remote_node", None) |
3036 | 3042 |
if remote_node is None: |
... | ... | |
3038 | 3044 |
else: |
3039 | 3045 |
remote_node = self.cfg.ExpandNodeName(remote_node) |
3040 | 3046 |
if remote_node is None: |
3041 |
raise errors.OpPrereqError, ("Node '%s' not known" %
|
|
3042 |
self.op.remote_node)
|
|
3047 |
raise errors.OpPrereqError("Node '%s' not known" % |
|
3048 |
self.op.remote_node) |
|
3043 | 3049 |
if remote_node == instance.primary_node: |
3044 |
raise errors.OpPrereqError, ("The specified node is the primary node of"
|
|
3045 |
" the instance.")
|
|
3050 |
raise errors.OpPrereqError("The specified node is the primary node of" |
|
3051 |
" the instance.") |
|
3046 | 3052 |
self.op.remote_node = remote_node |
3047 | 3053 |
|
3048 | 3054 |
def Exec(self, feedback_fn): |
... | ... | |
3067 | 3073 |
#HARDCODE |
3068 | 3074 |
if not _CreateBlockDevOnSecondary(cfg, remote_node, new_drbd, False, |
3069 | 3075 |
_GetInstanceInfoText(instance)): |
3070 |
raise errors.OpExecError, ("Failed to create new component on"
|
|
3071 |
" secondary node %s\n"
|
|
3072 |
"Full abort, cleanup manually!" %
|
|
3073 |
remote_node)
|
|
3076 |
raise errors.OpExecError("Failed to create new component on" |
|
3077 |
" secondary node %s\n" |
|
3078 |
"Full abort, cleanup manually!" % |
|
3079 |
remote_node) |
|
3074 | 3080 |
|
3075 | 3081 |
logger.Info("adding new mirror component on primary") |
3076 | 3082 |
#HARDCODE |
... | ... | |
3094 | 3100 |
cfg.SetDiskID(new_drbd, instance.primary_node) |
3095 | 3101 |
if not rpc.call_blockdev_remove(instance.primary_node, new_drbd): |
3096 | 3102 |
logger.Error("Can't rollback on primary") |
3097 |
raise errors.OpExecError, ("Full abort, cleanup manually!!")
|
|
3103 |
raise errors.OpExecError("Full abort, cleanup manually!!") |
|
3098 | 3104 |
|
3099 | 3105 |
dev.children.append(new_drbd) |
3100 | 3106 |
cfg.AddInstance(instance) |
... | ... | |
3110 | 3116 |
cfg.SetDiskID(dev, instance.primary_node) |
3111 | 3117 |
is_degr = rpc.call_blockdev_find(instance.primary_node, dev)[5] |
3112 | 3118 |
if is_degr: |
3113 |
raise errors.OpExecError, ("MD device %s is degraded!" % name)
|
|
3119 |
raise errors.OpExecError("MD device %s is degraded!" % name) |
|
3114 | 3120 |
cfg.SetDiskID(new_drbd, instance.primary_node) |
3115 | 3121 |
is_degr = rpc.call_blockdev_find(instance.primary_node, new_drbd)[5] |
3116 | 3122 |
if is_degr: |
3117 |
raise errors.OpExecError, ("New drbd device %s is degraded!" % name)
|
|
3123 |
raise errors.OpExecError("New drbd device %s is degraded!" % name) |
|
3118 | 3124 |
|
3119 | 3125 |
for name in iv_names: |
3120 | 3126 |
dev, child, new_drbd = iv_names[name] |
... | ... | |
3151 | 3157 |
|
3152 | 3158 |
""" |
3153 | 3159 |
if not isinstance(self.op.instances, list): |
3154 |
raise errors.OpPrereqError, "Invalid argument type 'instances'"
|
|
3160 |
raise errors.OpPrereqError("Invalid argument type 'instances'")
|
|
3155 | 3161 |
if self.op.instances: |
3156 | 3162 |
self.wanted_instances = [] |
3157 | 3163 |
names = self.op.instances |
3158 | 3164 |
for name in names: |
3159 | 3165 |
instance = self.cfg.GetInstanceInfo(self.cfg.ExpandInstanceName(name)) |
3160 | 3166 |
if instance is None: |
3161 |
raise errors.OpPrereqError, ("No such instance name '%s'" % name)
|
|
3167 |
raise errors.OpPrereqError("No such instance name '%s'" % name) |
|
3162 | 3168 |
self.wanted_instances.append(instance) |
3163 | 3169 |
else: |
3164 | 3170 |
self.wanted_instances = [self.cfg.GetInstanceInfo(name) for name |
... | ... | |
3314 | 3320 |
self.ip = getattr(self.op, "ip", None) |
3315 | 3321 |
self.bridge = getattr(self.op, "bridge", None) |
3316 | 3322 |
if [self.mem, self.vcpus, self.ip, self.bridge].count(None) == 4: |
3317 |
raise errors.OpPrereqError, ("No changes submitted")
|
|
3323 |
raise errors.OpPrereqError("No changes submitted") |
|
3318 | 3324 |
if self.mem is not None: |
3319 | 3325 |
try: |
3320 | 3326 |
self.mem = int(self.mem) |
3321 | 3327 |
except ValueError, err: |
3322 |
raise errors.OpPrereqError, ("Invalid memory size: %s" % str(err))
|
|
3328 |
raise errors.OpPrereqError("Invalid memory size: %s" % str(err)) |
|
3323 | 3329 |
if self.vcpus is not None: |
3324 | 3330 |
try: |
3325 | 3331 |
self.vcpus = int(self.vcpus) |
3326 | 3332 |
except ValueError, err: |
3327 |
raise errors.OpPrereqError, ("Invalid vcpus number: %s" % str(err))
|
|
3333 |
raise errors.OpPrereqError("Invalid vcpus number: %s" % str(err)) |
|
3328 | 3334 |
if self.ip is not None: |
3329 | 3335 |
self.do_ip = True |
3330 | 3336 |
if self.ip.lower() == "none": |
3331 | 3337 |
self.ip = None |
3332 | 3338 |
else: |
3333 | 3339 |
if not utils.IsValidIP(self.ip): |
3334 |
raise errors.OpPrereqError, ("Invalid IP address '%s'." % self.ip)
|
|
3340 |
raise errors.OpPrereqError("Invalid IP address '%s'." % self.ip) |
|
3335 | 3341 |
else: |
3336 | 3342 |
self.do_ip = False |
3337 | 3343 |
self.do_bridge = (self.bridge is not None) |
... | ... | |
3339 | 3345 |
instance = self.cfg.GetInstanceInfo( |
3340 | 3346 |
self.cfg.ExpandInstanceName(self.op.instance_name)) |
3341 | 3347 |
if instance is None: |
3342 |
raise errors.OpPrereqError, ("No such instance name '%s'" %
|
|
3343 |
self.op.instance_name)
|
|
3348 |
raise errors.OpPrereqError("No such instance name '%s'" % |
|
3349 |
self.op.instance_name) |
|
3344 | 3350 |
self.op.instance_name = instance.name |
3345 | 3351 |
self.instance = instance |
3346 | 3352 |
return |
... | ... | |
3426 | 3432 |
instance_name = self.cfg.ExpandInstanceName(self.op.instance_name) |
3427 | 3433 |
self.instance = self.cfg.GetInstanceInfo(instance_name) |
3428 | 3434 |
if self.instance is None: |
3429 |
raise errors.OpPrereqError, ("Instance '%s' not found" %
|
|
3430 |
self.op.instance_name)
|
|
3435 |
raise errors.OpPrereqError("Instance '%s' not found" % |
|
3436 |
self.op.instance_name) |
|
3431 | 3437 |
|
3432 | 3438 |
# node verification |
3433 | 3439 |
dst_node_short = self.cfg.ExpandNodeName(self.op.target_node) |
3434 | 3440 |
self.dst_node = self.cfg.GetNodeInfo(dst_node_short) |
3435 | 3441 |
|
3436 | 3442 |
if self.dst_node is None: |
3437 |
raise errors.OpPrereqError, ("Destination node '%s' is unknown." %
|
|
3438 |
self.op.target_node)
|
|
3443 |
raise errors.OpPrereqError("Destination node '%s' is unknown." % |
|
3444 |
self.op.target_node) |
|
3439 | 3445 |
self.op.target_node = self.dst_node.name |
3440 | 3446 |
|
3441 | 3447 |
def Exec(self, feedback_fn): |
... | ... | |
3523 | 3529 |
elif self.op.kind == constants.TAG_NODE: |
3524 | 3530 |
name = self.cfg.ExpandNodeName(self.op.name) |
3525 | 3531 |
if name is None: |
3526 |
raise errors.OpPrereqError, ("Invalid node name (%s)" %
|
|
3527 |
(self.op.name,))
|
|
3532 |
raise errors.OpPrereqError("Invalid node name (%s)" % |
|
3533 |
(self.op.name,)) |
|
3528 | 3534 |
self.op.name = name |
3529 | 3535 |
self.target = self.cfg.GetNodeInfo(name) |
3530 | 3536 |
elif self.op.kind == constants.TAG_INSTANCE: |
3531 | 3537 |
name = self.cfg.ExpandInstanceName(name) |
3532 | 3538 |
if name is None: |
3533 |
raise errors.OpPrereqError, ("Invalid instance name (%s)" %
|
|
3534 |
(self.op.name,))
|
|
3539 |
raise errors.OpPrereqError("Invalid instance name (%s)" % |
|
3540 |
(self.op.name,)) |
|
3535 | 3541 |
self.op.name = name |
3536 | 3542 |
self.target = self.cfg.GetInstanceInfo(name) |
3537 | 3543 |
else: |
3538 |
raise errors.OpPrereqError, ("Wrong tag type requested (%s)" %
|
|
3539 |
str(self.op.kind))
|
|
3544 |
raise errors.OpPrereqError("Wrong tag type requested (%s)" % |
|
3545 |
str(self.op.kind)) |
|
3540 | 3546 |
|
3541 | 3547 |
|
3542 | 3548 |
class LUGetTags(TagsLU): |
... | ... | |
3574 | 3580 |
try: |
3575 | 3581 |
self.target.AddTag(self.op.tag) |
3576 | 3582 |
except errors.TagError, err: |
3577 |
raise errors.OpExecError, ("Error while setting tag: %s" % str(err))
|
|
3583 |
raise errors.OpExecError("Error while setting tag: %s" % str(err)) |
|
3578 | 3584 |
try: |
3579 | 3585 |
self.cfg.Update(self.target) |
3580 | 3586 |
except errors.ConfigurationError: |
3581 |
raise errors.OpRetryError, ("There has been a modification to the"
|
|
3582 |
" config file and the operation has been"
|
|
3583 |
" aborted. Please retry.")
|
|
3587 |
raise errors.OpRetryError("There has been a modification to the" |
|
3588 |
" config file and the operation has been" |
|
3589 |
" aborted. Please retry.") |
|
3584 | 3590 |
|
3585 | 3591 |
|
3586 | 3592 |
class LUDelTag(TagsLU): |
... | ... | |
3598 | 3604 |
TagsLU.CheckPrereq(self) |
3599 | 3605 |
objects.TaggableObject.ValidateTag(self.op.tag) |
3600 | 3606 |
if self.op.tag not in self.target.GetTags(): |
3601 |
raise errors.OpPrereqError, ("Tag not found")
|
|
3607 |
raise errors.OpPrereqError("Tag not found") |
|
3602 | 3608 |
|
3603 | 3609 |
def Exec(self, feedback_fn): |
3604 | 3610 |
"""Remove the tag from the object. |
... | ... | |
3608 | 3614 |
try: |
3609 | 3615 |
self.cfg.Update(self.target) |
3610 | 3616 |
except errors.ConfigurationError: |
3611 |
raise errors.OpRetryError, ("There has been a modification to the" |
|
3612 |
" config file and the operation has been" |
|
3613 |
" aborted. Please retry.") |
|
3617 |
raise errors.OpRetryError("There has been a modification to the" |
|
3618 |
" config file and the operation has been" |
|
3619 |
" aborted. Please retry.") |
Also available in: Unified diff