/usr/share/ganeti/2.16/ganeti/opcodes.py is in ganeti-2.16 2.16.0~rc2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 | #
#
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""OpCodes module
Note that this file is autogenerated using @src/hs2py@ with a header
from @lib/opcodes.py.in_before@ and a footer from @lib/opcodes.py.in_after@.
This module implements part of the data structures which define the
cluster operations - the so-called opcodes.
Every operation which modifies the cluster state is expressed via
opcodes.
"""
# this are practically structures, so disable the message about too
# few public methods:
# pylint: disable=R0903
# pylint: disable=C0301
from ganeti import constants
from ganeti import ht
from ganeti import opcodes_base
class OpCode(opcodes_base.BaseOpCode):
"""Abstract OpCode.
This is the root of the actual OpCode hierarchy. All clases derived
from this class should override OP_ID.
@cvar OP_ID: The ID of this opcode. This should be unique amongst all
children of this class.
@cvar OP_DSC_FIELD: The name of a field whose value will be included in the
string returned by Summary(); see the docstring of that
method for details).
@cvar OP_DSC_FORMATTER: A callable that should format the OP_DSC_FIELD; if
not present, then the field will be simply converted
to string
@cvar OP_PARAMS: List of opcode attributes, the default values they should
get if not already defined, and types they must match.
@cvar OP_RESULT: Callable to verify opcode result
@cvar WITH_LU: Boolean that specifies whether this should be included in
mcpu's dispatch table
@ivar dry_run: Whether the LU should be run in dry-run mode, i.e. just
the check steps
@ivar priority: Opcode priority for queue
"""
# pylint: disable=E1101
# as OP_ID is dynamically defined
WITH_LU = True
OP_PARAMS = [
("dry_run", None, ht.TMaybe(ht.TBool), "Run checks only, don't execute"),
("debug_level", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Debug level"),
("priority", constants.OP_PRIO_DEFAULT,
ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"),
(opcodes_base.DEPEND_ATTR, None, opcodes_base.BuildJobDepCheck(True),
"Job dependencies; if used through ``SubmitManyJobs`` relative (negative)"
" job IDs can be used; see :doc:`design document <design-chained-jobs>`"
" for details"),
(opcodes_base.COMMENT_ATTR, None, ht.TMaybe(ht.TString),
"Comment describing the purpose of the opcode"),
(constants.OPCODE_REASON, [], ht.TMaybe(ht.TListOf(ht.TAny)),
"The reason trail, describing why the OpCode is executed"),
]
OP_RESULT = None
def __getstate__(self):
"""Specialized getstate for opcodes.
This method adds to the state dictionary the OP_ID of the class,
so that on unload we can identify the correct class for
instantiating the opcode.
@rtype: C{dict}
@return: the state as a dictionary
"""
data = opcodes_base.BaseOpCode.__getstate__(self)
data["OP_ID"] = self.OP_ID
return data
@classmethod
def LoadOpCode(cls, data):
"""Generic load opcode method.
The method identifies the correct opcode class from the dict-form
by looking for a OP_ID key, if this is not found, or its value is
not available in this module as a child of this class, we fail.
@type data: C{dict}
@param data: the serialized opcode
"""
if not isinstance(data, dict):
raise ValueError("Invalid data to LoadOpCode (%s)" % type(data))
if "OP_ID" not in data:
raise ValueError("Invalid data to LoadOpcode, missing OP_ID")
op_id = data["OP_ID"]
op_class = None
if op_id in OP_MAPPING:
op_class = OP_MAPPING[op_id]
else:
raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" %
op_id)
op = op_class()
new_data = data.copy()
del new_data["OP_ID"]
op.__setstate__(new_data)
return op
def Summary(self):
"""Generates a summary description of this opcode.
The summary is the value of the OP_ID attribute (without the "OP_"
prefix), plus the value of the OP_DSC_FIELD attribute, if one was
defined; this field should allow to easily identify the operation
(for an instance creation job, e.g., it would be the instance
name).
"""
assert self.OP_ID is not None and len(self.OP_ID) > 3
# all OP_ID start with OP_, we remove that
txt = self.OP_ID[3:]
field_name = getattr(self, "OP_DSC_FIELD", None)
if field_name:
field_value = getattr(self, field_name, None)
field_formatter = getattr(self, "OP_DSC_FORMATTER", None)
if callable(field_formatter):
field_value = field_formatter(field_value)
elif isinstance(field_value, (list, tuple)):
field_value = ",".join(str(i) for i in field_value)
txt = "%s(%s)" % (txt, field_value)
return txt
def TinySummary(self):
"""Generates a compact summary description of the opcode.
"""
assert self.OP_ID.startswith("OP_")
text = self.OP_ID[3:]
for (prefix, supplement) in opcodes_base.SUMMARY_PREFIX.items():
if text.startswith(prefix):
return supplement + text[len(prefix):]
return text
class OpInstanceMultiAllocBase(OpCode):
"""Allocates multiple instances.
"""
def __getstate__(self):
"""Generic serializer.
"""
state = OpCode.__getstate__(self)
if hasattr(self, "instances"):
# pylint: disable=E1101
state["instances"] = [inst.__getstate__() for inst in self.instances]
return state
def __setstate__(self, state):
"""Generic unserializer.
This method just restores from the serialized state the attributes
of the current instance.
@param state: the serialized opcode data
@type state: C{dict}
"""
if not isinstance(state, dict):
raise ValueError("Invalid data to __setstate__: expected dict, got %s" %
type(state))
if "instances" in state:
state["instances"] = map(OpCode.LoadOpCode, state["instances"])
return OpCode.__setstate__(self, state)
def Validate(self, set_defaults):
"""Validates this opcode.
We do this recursively.
@type set_defaults: bool
@param set_defaults: whether to set default values
@rtype: NoneType
@return: L{None}, if the validation succeeds
@raise errors.OpPrereqError: when a parameter value doesn't match
requirements
"""
OpCode.Validate(self, set_defaults)
for inst in self.instances: # pylint: disable=E1101
inst.Validate(set_defaults)
class OpClusterPostInit(OpCode):
"""Post cluster initialization.
This opcode does not touch the cluster at all. Its purpose is to run hooks
after the cluster has been initialized.
"""
OP_PARAMS = [
]
OP_RESULT = ht.TBool
class OpClusterDestroy(OpCode):
"""Destroy the cluster.
This opcode has no other parameters. All the state is irreversibly
lost after the execution of this opcode.
"""
OP_PARAMS = [
]
OP_RESULT = ht.TNonEmptyString
class OpClusterQuery(OpCode):
"""Query cluster information."""
OP_PARAMS = [
]
OP_RESULT = ht.TObject(ht.TAny)
class OpClusterVerify(OpCode):
"""Submits all jobs necessary to verify the cluster."""
OP_PARAMS = [
("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"),
("error_codes", False, ht.TBool, "Error codes"),
("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"),
("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"),
("verbose", False, ht.TBool, "Verbose mode"),
("group_name", None, ht.TMaybeString, "Optional group name"),
("verify_clutter", False, ht.TBool, "Whether to check for clutter in the 'authorized_keys' file.")
]
OP_RESULT = ht.TJobIdListOnly
class OpClusterVerifyConfig(OpCode):
"""Verify the cluster config."""
OP_PARAMS = [
("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"),
("error_codes", False, ht.TBool, "Error codes"),
("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"),
("verbose", False, ht.TBool, "Verbose mode")
]
OP_RESULT = ht.TBool
class OpClusterVerifyGroup(OpCode):
"""Run verify on a node group from the cluster.
@type skip_checks: C{list}
@ivar skip_checks: steps to be skipped from the verify process; this
needs to be a subset of
L{constants.VERIFY_OPTIONAL_CHECKS}; currently
only L{constants.VERIFY_NPLUSONE_MEM} can be passed
"""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("debug_simulate_errors", False, ht.TBool, "Whether to simulate errors (useful for debugging)"),
("error_codes", False, ht.TBool, "Error codes"),
("skip_checks", [], ht.TSetOf(ht.TVerifyOptionalChecks), "Which checks to skip"),
("ignore_errors", [], ht.TSetOf(ht.TCVErrorCode), "List of error codes that should be treated as warnings"),
("verbose", False, ht.TBool, "Verbose mode"),
("verify_clutter", False, ht.TBool, "Whether to check for clutter in the 'authorized_keys' file.")
]
OP_RESULT = ht.TBool
class OpClusterVerifyDisks(OpCode):
"""Verify the cluster disks."""
OP_PARAMS = [
("group_name", None, ht.TMaybeString, "Optional group name")
]
OP_RESULT = ht.TJobIdListOnly
class OpGroupVerifyDisks(OpCode):
"""Verifies the status of all disks in a node group.
Result: a tuple of three elements:
- dict of node names with issues (values: error msg)
- list of instances with degraded disks (that should be activated)
- dict of instances with missing logical volumes (values: (node, vol)
pairs with details about the missing volumes)
In normal operation, all lists should be empty. A non-empty instance
list (3rd element of the result) is still ok (errors were fixed) but
non-empty node list means some node is down, and probably there are
unfixable drbd errors.
Note that only instances that are drbd-based are taken into
consideration. This might need to be revisited in the future.
"""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name")
]
OP_RESULT = ht.TTupleOf(ht.TDictOf(ht.TString, ht.TString), ht.TListOf(ht.TString), ht.TDictOf(ht.TString, ht.TListOf(ht.TListOf(ht.TString))))
class OpClusterRepairDiskSizes(OpCode):
"""Verify the disk sizes of the instances and fixes configuration
mismatches.
Parameters: optional instances list, in case we want to restrict the
checks to only a subset of the instances.
Result: a list of tuples, (instance, disk, parameter, new-size) for
changed configurations.
In normal operation, the list should be empty.
@type instances: list
@ivar instances: the list of instances to check, or empty for all instances
"""
OP_PARAMS = [
("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonNegative(ht.TInt), ht.TNonEmptyString, ht.TNonNegative(ht.TInt)))
class OpClusterConfigQuery(OpCode):
"""Query cluster configuration values."""
OP_PARAMS = [
("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields")
]
OP_RESULT = ht.TListOf(ht.TAny)
class OpClusterRename(OpCode):
"""Rename the cluster.
@type name: C{str}
@ivar name: The new name of the cluster. The name and/or the master IP
address will be changed to match the new name and its IP
address.
"""
OP_DSC_FIELD = "name"
OP_PARAMS = [
("name", None, ht.TNonEmptyString, "A generic name")
]
OP_RESULT = ht.TNonEmptyString
class OpClusterSetParams(OpCode):
"""Change the parameters of the cluster.
@type vg_name: C{str} or C{None}
@ivar vg_name: The new volume group name or None to disable LVM usage.
"""
OP_PARAMS = [
("force", False, ht.TBool, "Whether to force the operation"),
("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"),
("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"),
("vg_name", None, ht.TMaybe(ht.TString), "Volume group name"),
("enabled_hypervisors", None, ht.TMaybe(ht.TListOf(ht.THypervisor)), "List of enabled hypervisors"),
("hvparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide hypervisor parameters, hypervisor-dependent"),
("beparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide backend parameter defaults"),
("os_hvp", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide per-OS hypervisor parameter defaults"),
("osparams", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TAny))), "Cluster-wide OS parameter defaults"),
("osparams_private_cluster", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TObject(ht.TPrivate(ht.TAny)))), "Cluster-wide private OS parameter defaults"),
("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"),
("candidate_pool_size", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Master candidate pool size"),
("max_running_jobs", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Maximal number of jobs to run simultaneously"),
("max_tracked_jobs", None, ht.TMaybe(ht.TPositive(ht.TInt)), "Maximal number of jobs tracked in the job queue"),
("uid_pool", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Set UID pool, must be list of lists describing UID ranges (two items, start and end inclusive)"),
("add_uids", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Extend UID pool, must be list of lists describing UID ranges (two items, start and end inclusive)"),
("remove_uids", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TInt, ht.TInt))), "Shrink UID pool, must be list of lists describing UID ranges (two items, start and end inclusive) to be removed"),
("maintain_node_health", None, ht.TMaybeBool, "Whether to automatically maintain node health"),
("prealloc_wipe_disks", None, ht.TMaybeBool, "Whether to wipe disks before allocating them to instances"),
("nicparams", None, ht.TMaybe(ht.TINicParams), "Cluster-wide NIC parameter defaults"),
("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide node parameter defaults"),
("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Cluster-wide ipolicy specs"),
("drbd_helper", None, ht.TMaybe(ht.TString), "DRBD helper program"),
("default_iallocator", None, ht.TMaybe(ht.TString), "Default iallocator for cluster"),
("default_iallocator_params", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default iallocator parameters for cluster"),
("mac_prefix", None, ht.TMaybeString, "Network specific mac prefix (that overrides the cluster one)"),
("master_netdev", None, ht.TMaybe(ht.TString), "Master network device"),
("master_netmask", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "Netmask of the master IP"),
("reserved_lvs", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of reserved LVs"),
("hidden_os", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TDdmSimple, ht.TNonEmptyString))), "Modify list of hidden operating systems: each modification must have two items, the operation and the OS name; the operation can be add or remove"),
("blacklisted_os", None, ht.TMaybe(ht.TListOf(ht.TTupleOf(ht.TDdmSimple, ht.TNonEmptyString))), "Modify list of blacklisted operating systems: each modification must have two items, the operation and the OS name; the operation can be add or remove"),
("use_external_mip_script", None, ht.TMaybeBool, "Whether to use an external master IP address setup script"),
("enabled_disk_templates", None, ht.TMaybe(ht.TListOf(ht.TDiskTemplate)), "List of enabled disk templates"),
("modify_etc_hosts", None, ht.TMaybeBool, ""),
("file_storage_dir", None, ht.TMaybe(ht.TString), ""),
("shared_file_storage_dir", None, ht.TMaybe(ht.TString), ""),
("gluster_storage_dir", None, ht.TMaybe(ht.TString), ""),
("install_image", None, ht.TMaybe(ht.TString), "OS image for running OS scripts in a safe environment"),
("instance_communication_network", None, ht.TMaybe(ht.TString), ""),
("zeroing_image", None, ht.TMaybe(ht.TString), ""),
("compression_tools", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of enabled compression tools"),
("enabled_user_shutdown", None, ht.TMaybeBool, "Whether user shutdown is enabled cluster wide"),
("enabled_data_collectors", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TBool)), "Set the active data collectors"),
("data_collector_interval", None, ht.TMaybe(ht.TDictOf(ht.TString, ht.TInt)), "Sets the interval in that data collectors are run")
]
OP_RESULT = ht.TOr(ht.TNone, ht.TJobIdListOnly)
class OpClusterRedistConf(OpCode):
"""Force a full push of the cluster configuration."""
OP_PARAMS = [
]
OP_RESULT = ht.TNone
class OpClusterActivateMasterIp(OpCode):
"""Activate the master IP on the master node."""
OP_PARAMS = [
]
OP_RESULT = ht.TNone
class OpClusterDeactivateMasterIp(OpCode):
"""Deactivate the master IP on the master node."""
OP_PARAMS = [
]
OP_RESULT = ht.TNone
class OpClusterRenewCrypto(OpCode):
"""Renews the cluster node's SSL client certificates."""
OP_PARAMS = [
("node_certificates", False, ht.TBool, "Whether to renew node SSL certificates"),
("renew_ssh_keys", False, ht.TBool, "Whether to renew SSH keys"),
("ssh_key_type", None, ht.TMaybe(ht.TSshKeyType), "The type of the SSH key Ganeti uses"),
("ssh_key_bits", None, ht.TMaybe(ht.TPositive(ht.TInt)), "The number of bits of the SSH key Ganeti uses"),
("verbose", False, ht.TBool, "Verbose mode"),
("debug", False, ht.TBool, "Debug mode")
]
OP_RESULT = ht.TNone
class OpQuery(OpCode):
"""Query for resources/items.
@ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
@ivar fields: List of fields to retrieve
@ivar qfilter: Query filter
"""
OP_DSC_FIELD = "what"
OP_PARAMS = [
("what", None, ht.TQueryTypeOp, "Resource(s) to query for"),
("use_locking", False, ht.TBool, "Whether to use synchronization"),
("fields", None, ht.TListOf(ht.TNonEmptyString), "Requested fields"),
("qfilter", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Query filter")
]
OP_RESULT = ht.TQueryResponse
class OpQueryFields(OpCode):
"""Query for available resource/item fields.
@ivar what: Resources to query for, must be one of L{constants.QR_VIA_OP}
@ivar fields: List of fields to retrieve
"""
OP_DSC_FIELD = "what"
OP_PARAMS = [
("what", None, ht.TQueryTypeOp, "Resource(s) to query for"),
("fields", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Requested fields; if not given, all are returned")
]
OP_RESULT = ht.TQueryFieldsResponse
class OpOobCommand(OpCode):
"""Interact with OOB."""
OP_PARAMS = [
("node_names", [], ht.TListOf(ht.TNonEmptyString), "List of node names to run the OOB command against"),
("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to run the OOB command against"),
("command", None, ht.TOobCommand, "OOB command to run"),
("timeout", 60, ht.TInt, "Timeout before the OOB helper will be terminated"),
("ignore_status", False, ht.TBool, "Ignores the node offline status for power off"),
("power_delay", 2.0, ht.TDouble, "Time in seconds to wait between powering on nodes")
]
OP_RESULT = ht.TListOf(ht.TListOf(ht.TTupleOf(ht.TQueryResultCode, ht.TAny)))
class OpRestrictedCommand(OpCode):
"""Runs a restricted command on node(s)."""
OP_PARAMS = [
("use_locking", False, ht.TBool, "Whether to use synchronization"),
("nodes", None, ht.TListOf(ht.TNonEmptyString), "Nodes on which the command should be run (at least one)"),
("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Node UUIDs on which the command should be run (at least one)"),
("command", None, ht.TNonEmptyString, "Restricted command name")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TBool, ht.TString))
class OpNodeRemove(OpCode):
"""Remove a node.
@type node_name: C{str}
@ivar node_name: The name of the node to remove. If the node still has
instances on it, the operation will fail.
"""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)")
]
OP_RESULT = ht.TNone
class OpNodeAdd(OpCode):
"""Add a node to the cluster.
@type node_name: C{str}
@ivar node_name: The name of the node to add. This can be a short name,
but it will be expanded to the FQDN.
@type primary_ip: IP address
@ivar primary_ip: The primary IP of the node. This will be ignored when
the opcode is submitted, but will be filled during the
node add (so it will be visible in the job query).
@type secondary_ip: IP address
@ivar secondary_ip: The secondary IP of the node. This needs to be passed
if the cluster has been initialized in 'dual-network'
mode, otherwise it must not be given.
@type readd: C{bool}
@ivar readd: Whether to re-add an existing node to the cluster. If
this is not passed, then the operation will abort if the node
name is already in the cluster; use this parameter to
'repair' a node that had its configuration broken, or was
reinstalled without removal from the cluster.
@type group: C{str}
@ivar group: The node group to which this node will belong.
@type vm_capable: C{bool}
@ivar vm_capable: The vm_capable node attribute
@type master_capable: C{bool}
@ivar master_capable: The master_capable node attribute
"""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"),
("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"),
("primary_ip", None, ht.TMaybeString, "Primary IP address"),
("secondary_ip", None, ht.TMaybeString, "Secondary IP address"),
("readd", False, ht.TBool, "Whether node is re-added to cluster"),
("group", None, ht.TMaybeString, "Initial node group"),
("master_capable", None, ht.TMaybeBool, "Whether node can become master or master candidate"),
("vm_capable", None, ht.TMaybeBool, "Whether node can host instances"),
("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters"),
("node_setup", False, ht.TBool, "Whether to perform a SSH setup on the new node")
]
OP_RESULT = ht.TNone
class OpNodeQueryvols(OpCode):
"""Get list of volumes on node."""
OP_PARAMS = [
("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"),
("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all nodes, node names otherwise")
]
OP_RESULT = ht.TListOf(ht.TAny)
class OpNodeQueryStorage(OpCode):
"""Get information on storage for node(s)."""
OP_PARAMS = [
("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"),
("storage_type", None, ht.TMaybe(ht.TStorageType), "Storage type"),
("nodes", [], ht.TListOf(ht.TNonEmptyString), "Empty list to query all, list of names to query otherwise"),
("name", None, ht.TMaybeString, "Storage name")
]
OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
class OpNodeModifyStorage(OpCode):
"""Modifies the properies of a storage unit"""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("storage_type", None, ht.TStorageType, "Storage type"),
("name", None, ht.TMaybeString, "Storage name"),
("changes", None, ht.TObject(ht.TAny), "Requested storage changes")
]
OP_RESULT = ht.TNone
class OpRepairNodeStorage(OpCode):
"""Repairs the volume group on a node."""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("storage_type", None, ht.TStorageType, "Storage type"),
("name", None, ht.TMaybeString, "Storage name"),
("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency")
]
OP_RESULT = ht.TNone
class OpNodeSetParams(OpCode):
"""Change the parameters of a node."""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("force", False, ht.TBool, "Whether to force the operation"),
("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"),
("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"),
("master_candidate", None, ht.TMaybeBool, "Whether the node should become a master candidate"),
("offline", None, ht.TMaybeBool, "Whether to mark the node offline"),
("drained", None, ht.TMaybeBool, "Whether to mark the node as drained"),
("auto_promote", False, ht.TBool, "Whether node(s) should be promoted to master candidate if necessary"),
("master_capable", None, ht.TMaybeBool, "Whether node can become master or master candidate"),
("vm_capable", None, ht.TMaybeBool, "Whether node can host instances"),
("secondary_ip", None, ht.TMaybeString, "Secondary IP address"),
("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Node parameters"),
("powered", None, ht.TMaybeBool, "Whether the node should be marked as powered")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
class OpNodePowercycle(OpCode):
"""Tries to powercycle a node."""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("force", False, ht.TBool, "Whether to force the operation")
]
OP_RESULT = ht.TMaybe(ht.TNonEmptyString)
class OpNodeMigrate(OpCode):
"""Migrate all instances from a node."""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"),
("live", None, ht.TMaybeBool, "Obsolete 'live' migration mode (do not use)"),
("target_node", None, ht.TMaybeString, "Target node for instance migration/failover"),
("target_node_uuid", None, ht.TMaybeString, "Target node UUID for instance migration/failover"),
("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances")
]
OP_RESULT = ht.TJobIdListOnly
class OpNodeEvacuate(OpCode):
"""Evacuate instances off a number of nodes."""
OP_DSC_FIELD = "node_name"
OP_PARAMS = [
("early_release", False, ht.TBool, "Whether to release locks as soon as possible"),
("node_name", None, ht.TNonEmptyString, "A required node name (for single-node LUs)"),
("node_uuid", None, ht.TMaybeString, "A node UUID (for single-node LUs)"),
("remote_node", None, ht.TMaybeString, "New secondary node"),
("remote_node_uuid", None, ht.TMaybeString, "New secondary node UUID"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("mode", None, ht.TEvacMode, "Node evacuation mode"),
("ignore_soft_errors", None, ht.TMaybeBool, "Ignore soft htools errors")
]
OP_RESULT = ht.TJobIdListOnly
class OpInstanceCreate(OpCode):
"""Create an instance.
@ivar instance_name: Instance name
@ivar mode: Instance creation mode (one of L{constants.INSTANCE_CREATE_MODES})
@ivar source_handshake: Signed handshake from source (remote import only)
@ivar source_x509_ca: Source X509 CA in PEM format (remote import only)
@ivar source_instance_name: Previous name of instance (remote import only)
@ivar source_shutdown_timeout: Shutdown timeout used for source instance
(remote import only)
"""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"),
("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"),
("name_check", True, ht.TBool, "Whether to check name"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("opportunistic_locking", False, ht.TBool, "Whether to employ opportunistic locking for nodes, meaning nodes already locked by another opcode won't be considered for instance allocation (only when an iallocator is used)"),
("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"),
("disks", None, ht.TListOf(ht.TIDiskParams), "List of instance disks"),
("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"),
("group_name", None, ht.TMaybeString, "Optional group name"),
("file_driver", None, ht.TMaybe(ht.TFileDriver), "Driver for file-backed disks"),
("file_storage_dir", None, ht.TMaybeString, "Directory for storing file-backed disks"),
("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"),
("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("identify_defaults", False, ht.TBool, "Reset instance parameters to default if equal"),
("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive"),
("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"),
("mode", None, ht.TInstCreateMode, "Instance creation mode"),
("nics", None, ht.TListOf(ht.TINicParams), "List of NIC (network interface) definitions"),
("no_install", None, ht.TMaybeBool, "Do not install the OS (will disable automatic start)"),
("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"),
("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance"),
("osparams_secret", None, ht.TMaybe(ht.TObject(ht.TSecret(ht.TAny))), "Secret OS parameters for instance"),
("os_type", None, ht.TMaybeString, "OS type for instance installation"),
("pnode", None, ht.TMaybeString, "Primary node for an instance"),
("pnode_uuid", None, ht.TMaybeString, "Primary node UUID for an instance"),
("snode", None, ht.TMaybeString, "Secondary node for an instance"),
("snode_uuid", None, ht.TMaybeString, "Secondary node UUID for an instance"),
("source_handshake", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Signed handshake from source (remote import only)"),
("source_instance_name", None, ht.TMaybeString, "Source instance name (remote import only)"),
("source_shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long source instance was given to shut down (remote import only)"),
("source_x509_ca", None, ht.TMaybeString, "Source X509 CA in PEM format (remote import only)"),
("src_node", None, ht.TMaybeString, "Source node for import"),
("src_node_uuid", None, ht.TMaybeString, "Source node UUID for import"),
("src_path", None, ht.TMaybeString, "Source directory for import"),
("compress", "none", ht.TString, "Compression mode to use for moves during backups/imports"),
("start", True, ht.TBool, "Whether to start instance after creation"),
("forthcoming", False, ht.TBool, "Whether to only reserve resources"),
("commit", False, ht.TBool, "Commit the already reserved instance"),
("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags"),
("instance_communication", False, ht.TBool, "Enable or disable the communication mechanism for an instance"),
("helper_startup_timeout", None, ht.TMaybe(ht.TInt), "Startup timeout for the helper VM"),
("helper_shutdown_timeout", None, ht.TMaybe(ht.TInt), "Shutdown timeout for the helper VM")
]
OP_RESULT = ht.TListOf(ht.TNonEmptyString)
class OpInstanceMultiAlloc(OpInstanceMultiAllocBase):
"""Allocates multiple instances."""
OP_PARAMS = [
("opportunistic_locking", False, ht.TBool, "Whether to employ opportunistic locking for nodes, meaning nodes already locked by another opcode won't be considered for instance allocation (only when an iallocator is used)"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("instances", [], ht.TListOf(ht.TAny), "List of instance create opcodes describing the instances to allocate")
]
OP_RESULT = ht.TInstanceMultiAllocResponse
class OpInstanceReinstall(OpCode):
"""Reinstall an instance's OS."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"),
("os_type", None, ht.TMaybeString, "OS type for instance installation"),
("osparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Temporary OS parameters (currently only in reinstall, might be added to install as well)"),
("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance reinstalls"),
("osparams_secret", None, ht.TMaybe(ht.TObject(ht.TSecret(ht.TAny))), "Secret OS parameters for instance reinstalls")
]
OP_RESULT = ht.TNone
class OpInstanceRemove(OpCode):
"""Remove an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("ignore_failures", False, ht.TBool, "Whether to ignore failures during removal")
]
OP_RESULT = ht.TNone
class OpInstanceRename(OpCode):
"""Rename an instance."""
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("new_name", None, ht.TNonEmptyString, "New instance name"),
("name_check", True, ht.TBool, "Whether to check name"),
("ip_check", True, ht.TBool, "Whether to ensure instance's IP address is inactive")
]
OP_RESULT = ht.TNonEmptyString
class OpInstanceStartup(OpCode):
"""Startup an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("force", False, ht.TBool, "Whether to force the operation"),
("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"),
("hvparams", {}, ht.TObject(ht.TAny), "Temporary hypervisor parameters, hypervisor-dependent"),
("beparams", {}, ht.TObject(ht.TAny), "Temporary backend parameters"),
("no_remember", False, ht.TBool, "Do not remember instance state changes"),
("startup_paused", False, ht.TBool, "Pause instance at startup"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down")
]
OP_RESULT = ht.TNone
class OpInstanceShutdown(OpCode):
"""Shutdown an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("force", False, ht.TBool, "Whether to force the operation"),
("ignore_offline_nodes", False, ht.TBool, "Whether to ignore offline nodes"),
("timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("no_remember", False, ht.TBool, "Do not remember instance state changes"),
("admin_state_source", None, ht.TMaybe(ht.TAdminStateSource), "Who last changed the instance admin state")
]
OP_RESULT = ht.TNone
class OpInstanceReboot(OpCode):
"""Reboot an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("ignore_secondaries", False, ht.TBool, "Whether to start the instance even if secondary disks are failing"),
("reboot_type", None, ht.TRebootType, "How to reboot the instance")
]
OP_RESULT = ht.TNone
class OpInstanceReplaceDisks(OpCode):
"""Replace the disks of an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("early_release", False, ht.TBool, "Whether to release locks as soon as possible"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("mode", None, ht.TReplaceDisksMode, "Replacement mode"),
("disks", [], ht.TListOf(ht.TDiskIndex), "List of disk indices"),
("remote_node", None, ht.TMaybeString, "New secondary node"),
("remote_node_uuid", None, ht.TMaybeString, "New secondary node UUID"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances")
]
OP_RESULT = ht.TNone
class OpInstanceFailover(OpCode):
"""Failover an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency"),
("target_node", None, ht.TMaybeString, "Target node for instance migration/failover"),
("target_node_uuid", None, ht.TMaybeString, "Target node UUID for instance migration/failover"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances")
]
OP_RESULT = ht.TNone
class OpInstanceMigrate(OpCode):
"""Migrate an instance.
This migrates (without shutting down an instance) to its secondary
node.
@ivar instance_name: the name of the instance
@ivar mode: the migration mode (live, non-live or None for auto)
"""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("mode", None, ht.TMaybe(ht.TMigrationMode), "Migration type (live/non-live)"),
("live", None, ht.TMaybeBool, "Obsolete 'live' migration mode (do not use)"),
("target_node", None, ht.TMaybeString, "Target node for instance migration/failover"),
("target_node_uuid", None, ht.TMaybeString, "Target node UUID for instance migration/failover"),
("allow_runtime_changes", True, ht.TBool, "Whether to allow runtime changes while migrating"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("cleanup", False, ht.TBool, "Whether a previously failed migration should be cleaned up"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("allow_failover", False, ht.TBool, "Whether we can fallback to failover if migration is not possible"),
("ignore_hvversions", False, ht.TBool, "Whether to ignore incompatible Hypervisor versions")
]
OP_RESULT = ht.TNone
class OpInstanceMove(OpCode):
"""Move an instance.
This move (with shutting down an instance and data copying) to an
arbitrary node.
@ivar instance_name: the name of the instance
@ivar target_node: the destination node
"""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("target_node", None, ht.TNonEmptyString, "Target node for instance move"),
("target_node_uuid", None, ht.TMaybeString, "Target node UUID for instance move"),
("compress", "none", ht.TString, "Compression mode to use during instance moves"),
("ignore_consistency", False, ht.TBool, "Whether to ignore disk consistency")
]
OP_RESULT = ht.TNone
class OpInstanceConsole(OpCode):
"""Connect to an instance's console."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)")
]
OP_RESULT = ht.TObject(ht.TAny)
class OpInstanceActivateDisks(OpCode):
"""Activate an instance's disks."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("ignore_size", False, ht.TBool, "Whether to ignore recorded disk size"),
("wait_for_sync", False, ht.TBool, "Whether to wait for the disk to synchronize (defaults to false)")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString, ht.TMaybe(ht.TNonEmptyString)))
class OpInstanceDeactivateDisks(OpCode):
"""Deactivate an instance's disks."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("force", False, ht.TBool, "Whether to force the operation")
]
OP_RESULT = ht.TNone
class OpInstanceRecreateDisks(OpCode):
"""Recreate an instance's disks."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("disks", [], ht.TRecreateDisksInfo, "Disk list for recreate disks"),
("nodes", [], ht.TListOf(ht.TNonEmptyString), "New instance nodes, if relocation is desired"),
("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "New instance node UUIDs, if relocation is desired"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances")
]
OP_RESULT = ht.TNone
class OpInstanceQueryData(OpCode):
"""Compute the run-time status of instances."""
OP_PARAMS = [
("use_locking", False, ht.TBool, "Whether to use synchronization"),
("instances", [], ht.TListOf(ht.TNonEmptyString), "List of instances"),
("static", False, ht.TBool, "Whether to only return configuration data without querying nodes")
]
OP_RESULT = ht.TObject(ht.TObject(ht.TAny))
class OpInstanceSetParams(OpCode):
"""Change the parameters of an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("force", False, ht.TBool, "Whether to force the operation"),
("force_variant", False, ht.TBool, "Whether to force an unknown OS variant"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations"),
("nics", [], ht.TSetParamsMods(ht.TINicParams), "List of NIC changes"),
("disks", [], ht.TSetParamsMods(ht.TIDiskParams), "List of disk changes"),
("beparams", {}, ht.TObject(ht.TAny), "Backend parameters for instance"),
("runtime_mem", None, ht.TMaybe(ht.TPositive(ht.TInt)), "New runtime memory"),
("hvparams", {}, ht.TObject(ht.TAny), "Hypervisor parameters for instance, hypervisor-dependent"),
("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"),
("ext_params", {}, ht.TObject(ht.TAny), "List of ExtStorage parameters"),
("file_driver", None, ht.TMaybe(ht.TFileDriver), "Driver for file-backed disks"),
("file_storage_dir", None, ht.TMaybeString, "Directory for storing file-backed disks"),
("pnode", None, ht.TMaybeString, "Primary node for an instance"),
("pnode_uuid", None, ht.TMaybeString, "Primary node UUID for an instance"),
("remote_node", None, ht.TMaybeString, "Secondary node (used when changing disk template)"),
("remote_node_uuid", None, ht.TMaybeString, "Secondary node UUID (used when changing disk template)"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("os_name", None, ht.TMaybeString, "Change the instance's OS without reinstalling the instance"),
("osparams", {}, ht.TObject(ht.TAny), "OS parameters for instance"),
("osparams_private", None, ht.TMaybe(ht.TObject(ht.TPrivate(ht.TAny))), "Private OS parameters for instance"),
("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"),
("offline", None, ht.TMaybeBool, "Whether to mark the instance as offline"),
("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"),
("hotplug", False, ht.TBool, ""),
("hotplug_if_possible", False, ht.TBool, ""),
("instance_communication", None, ht.TMaybeBool, "Enable or disable the communication mechanism for an instance")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
class OpInstanceGrowDisk(OpCode):
"""Grow a disk of an instance."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("wait_for_sync", True, ht.TBool, "Whether to wait for the disk to synchronize"),
("disk", None, ht.TDiskIndex, "Disk index for e.g. grow disk"),
("amount", None, ht.TNonNegative(ht.TInt), "Disk amount to add or grow to"),
("absolute", False, ht.TBool, "Whether the amount parameter is an absolute target or a relative one"),
("ignore_ipolicy", False, ht.TBool, "Whether to ignore ipolicy violations")
]
OP_RESULT = ht.TNone
class OpInstanceChangeGroup(OpCode):
"""Moves an instance to another node group."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("early_release", False, ht.TBool, "Whether to release locks as soon as possible"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")")
]
OP_RESULT = ht.TJobIdListOnly
class OpGroupAdd(OpCode):
"""Add a node group to the cluster."""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"),
("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"),
("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"),
("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"),
("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"),
("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs")
]
OP_RESULT = ht.TOr(ht.TNone, ht.TJobIdListOnly)
class OpGroupAssignNodes(OpCode):
"""Assign nodes to a node group."""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("force", False, ht.TBool, "Whether to force the operation"),
("nodes", None, ht.TListOf(ht.TNonEmptyString), "List of nodes to assign"),
("node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "List of node UUIDs to assign")
]
OP_RESULT = ht.TNone
class OpGroupSetParams(OpCode):
"""Change the parameters of a node group."""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("alloc_policy", None, ht.TMaybe(ht.TAllocPolicy), "Instance allocation policy"),
("ndparams", None, ht.TMaybe(ht.TObject(ht.TAny)), "Default node parameters for group"),
("diskparams", None, ht.TMaybe(ht.TDictOf(ht.TDiskTemplate, ht.TObject(ht.TAny))), "Disk templates' parameter defaults"),
("hv_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set hypervisor states"),
("disk_state", None, ht.TMaybe(ht.TObject(ht.TAny)), "Set disk states"),
("ipolicy", None, ht.TMaybe(ht.TObject(ht.TAny)), "Group-wide ipolicy specs")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TAny))
class OpGroupRemove(OpCode):
"""Remove a node group from the cluster."""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name")
]
OP_RESULT = ht.TNone
class OpGroupRename(OpCode):
"""Rename a node group in the cluster."""
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("new_name", None, ht.TNonEmptyString, "New group name")
]
OP_RESULT = ht.TNonEmptyString
class OpGroupEvacuate(OpCode):
"""Evacuate a node group in the cluster."""
OP_DSC_FIELD = "group_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("early_release", False, ht.TBool, "Whether to release locks as soon as possible"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"),
("sequential", False, ht.TBool, "Sequential job execution"),
("force_failover", False, ht.TBool, "Disallow migration moves and always use failovers")
]
OP_RESULT = ht.TJobIdListOnly
class OpOsDiagnose(OpCode):
"""Compute the list of guest operating systems."""
OP_PARAMS = [
("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"),
("names", [], ht.TListOf(ht.TNonEmptyString), "Which operating systems to diagnose")
]
OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
class OpExtStorageDiagnose(OpCode):
"""Compute the list of external storage providers."""
OP_PARAMS = [
("output_fields", None, ht.TListOf(ht.TNonEmptyString), "Selected output fields"),
("names", [], ht.TListOf(ht.TNonEmptyString), "Which ExtStorage Provider to diagnose")
]
OP_RESULT = ht.TListOf(ht.TListOf(ht.TAny))
class OpBackupPrepare(OpCode):
"""Prepares an instance export.
@ivar instance_name: Instance name
@ivar mode: Export mode (one of L{constants.EXPORT_MODES})
"""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("mode", None, ht.TExportMode, "Export mode")
]
OP_RESULT = ht.TMaybe(ht.TObject(ht.TAny))
class OpBackupExport(OpCode):
"""Export an instance.
For local exports, the export destination is the node name. For
remote exports, the export destination is a list of tuples, each
consisting of hostname/IP address, port, magic, HMAC and HMAC
salt. The HMAC is calculated using the cluster domain secret over
the value "${index}:${hostname}:${port}". The destination X509 CA
must be a signed certificate.
@ivar mode: Export mode (one of L{constants.EXPORT_MODES})
@ivar target_node: Export destination
@ivar x509_key_name: X509 key to use (remote export only)
@ivar destination_x509_ca: Destination X509 CA in PEM format (remote
export only)
"""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)"),
("compress", "none", ht.TString, "Compression mode to use for moves during backups/imports"),
("shutdown_timeout", 120, ht.TNonNegative(ht.TInt), "How long to wait for instance to shut down"),
("target_node", None, ht.TExportTarget, "Target node (depends on export mode)"),
("target_node_uuid", None, ht.TMaybeString, "Target node UUID (if local export)"),
("shutdown", True, ht.TBool, "Whether to shutdown the instance before export"),
("remove_instance", False, ht.TBool, "Whether to remove instance after export"),
("ignore_remove_failures", False, ht.TBool, "Whether to ignore failures while removing instances"),
("mode", "local", ht.TExportMode, "Export mode"),
("x509_key_name", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Name of X509 key (remote export only)"),
("destination_x509_ca", None, ht.TMaybeString, "Destination X509 CA (remote export only)"),
("zero_free_space", False, ht.TBool, "Whether to zero the free space on the disks of the instance"),
("zeroing_timeout_fixed", None, ht.TMaybe(ht.TInt), "The fixed part of time to wait before declaring the zeroing operation to have failed"),
("zeroing_timeout_per_mib", None, ht.TMaybe(ht.TDouble), "The variable part of time to wait before declaring the zeroing operation to have failed, dependent on total size of disks"),
("long_sleep", False, ht.TBool, "Whether to allow long instance shutdowns during exports")
]
OP_RESULT = ht.TTupleOf(ht.TBool, ht.TListOf(ht.TBool))
class OpBackupRemove(OpCode):
"""Remove an instance's export."""
OP_DSC_FIELD = "instance_name"
OP_PARAMS = [
("instance_name", None, ht.TString, "A required instance name (for single-instance LUs)"),
("instance_uuid", None, ht.TMaybeString, "An instance UUID (for single-instance LUs)")
]
OP_RESULT = ht.TNone
class OpTagsGet(OpCode):
"""Returns the tags of the given object."""
OP_DSC_FIELD = "name"
OP_PARAMS = [
("kind", None, ht.TTagKind, "Tag kind"),
("use_locking", False, ht.TBool, "Whether to use synchronization"),
("name", None, ht.TMaybe(ht.TString), "Name of object to retrieve tags from")
]
OP_RESULT = ht.TListOf(ht.TNonEmptyString)
class OpTagsSearch(OpCode):
"""Searches the tags in the cluster for a given pattern."""
OP_DSC_FIELD = "pattern"
OP_PARAMS = [
("pattern", None, ht.TNonEmptyString, "Search pattern (regular expression)")
]
OP_RESULT = ht.TListOf(ht.TTupleOf(ht.TNonEmptyString, ht.TNonEmptyString))
class OpTagsSet(OpCode):
"""Add a list of tags on a given object."""
OP_PARAMS = [
("kind", None, ht.TTagKind, "Tag kind"),
("tags", None, ht.TListOf(ht.TString), "List of tag names"),
("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be added")
]
OP_RESULT = ht.TNone
class OpTagsDel(OpCode):
"""Remove a list of tags from a given object."""
OP_PARAMS = [
("kind", None, ht.TTagKind, "Tag kind"),
("tags", None, ht.TListOf(ht.TString), "List of tag names"),
("name", None, ht.TMaybe(ht.TString), "Name of object where tag(s) should be deleted")
]
OP_RESULT = ht.TNone
class OpTestDelay(OpCode):
"""Sleeps for a configured amount of time.
This is used just for debugging and testing.
Parameters:
- duration: the time to sleep, in seconds
- on_master: if true, sleep on the master
- on_nodes: list of nodes in which to sleep
If the on_master parameter is true, it will execute a sleep on the
master (before any node sleep).
If the on_nodes list is not empty, it will sleep on those nodes
(after the sleep on the master, if that is enabled).
As an additional feature, the case of duration < 0 will be reported
as an execution error, so this opcode can be used as a failure
generator. The case of duration == 0 will not be treated specially.
"""
OP_DSC_FIELD = "duration"
OP_PARAMS = [
("duration", None, ht.TDouble, "Duration parameter for 'OpTestDelay'"),
("on_master", True, ht.TBool, "on_master field for 'OpTestDelay'"),
("on_nodes", [], ht.TListOf(ht.TNonEmptyString), "on_nodes field for 'OpTestDelay'"),
("on_node_uuids", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "on_node_uuids field for 'OpTestDelay'"),
("repeat", 0, ht.TNonNegative(ht.TInt), "Repeat parameter for OpTestDelay"),
("interruptible", False, ht.TBool, "Allows socket-based interruption of a running OpTestDelay"),
("no_locks", True, ht.TBool, "Don't take locks during the delay")
]
OP_RESULT = ht.TNone
class OpTestAllocator(OpCode):
"""Allocator framework testing.
This opcode has two modes:
- gather and return allocator input for a given mode (allocate new
or replace secondary) and a given instance definition (direction
'in')
- run a selected allocator for a given operation (as above) and
return the allocator output (direction 'out')
"""
OP_DSC_FIELD = "iallocator"
OP_PARAMS = [
("direction", None, ht.TIAllocatorTestDir, "IAllocator test direction"),
("mode", None, ht.TIAllocatorMode, "IAllocator test mode"),
("name", None, ht.TNonEmptyString, "IAllocator target name (new instance, node to evac, etc.)"),
("nics", None, ht.TMaybe(ht.TListOf(ht.TINicParams)), "Custom OpTestIAllocator nics"),
("disks", None, ht.TMaybe(ht.TListOf(ht.TAny)), "Custom OpTestAllocator disks"),
("hypervisor", None, ht.TMaybe(ht.THypervisor), "Selected hypervisor for an instance"),
("iallocator", None, ht.TMaybeString, "Iallocator for deciding the target node for shared-storage instances"),
("tags", [], ht.TListOf(ht.TNonEmptyString), "Instance tags"),
("memory", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "IAllocator memory field"),
("vcpus", None, ht.TMaybe(ht.TNonNegative(ht.TInt)), "IAllocator vcpus field"),
("os", None, ht.TMaybeString, "IAllocator os field"),
("disk_template", None, ht.TMaybe(ht.TDiskTemplate), "Instance disk template"),
("instances", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "IAllocator instances field"),
("evac_mode", None, ht.TMaybe(ht.TEvacMode), "IAllocator evac mode"),
("target_groups", None, ht.TMaybe(ht.TListOf(ht.TNonEmptyString)), "Destination group names or UUIDs (defaults to \"all but current group\")"),
("spindle_use", 1, ht.TNonNegative(ht.TInt), "IAllocator spindle use"),
("count", 1, ht.TNonNegative(ht.TInt), "IAllocator count field"),
("group_name", None, ht.TMaybeString, "Optional group name")
]
OP_RESULT = ht.TString
class OpTestJqueue(OpCode):
"""Utility opcode to test some aspects of the job queue."""
OP_PARAMS = [
("notify_waitlock", False, ht.TBool, "'OpTestJqueue' notify_waitlock"),
("notify_exec", False, ht.TBool, "'OpTestJQueue' notify_exec"),
("log_messages", [], ht.TListOf(ht.TString), "'OpTestJQueue' log_messages"),
("fail", False, ht.TBool, "'OpTestJQueue' fail attribute")
]
OP_RESULT = ht.TBool
class OpTestOsParams(OpCode):
"""Utility opcode to test secret os parameter transmission."""
OP_PARAMS = [
("osparams_secret", None, ht.TMaybe(ht.TObject(ht.TSecret(ht.TAny))), "Secret OS parameters for instance")
]
OP_RESULT = ht.TNone
class OpTestDummy(OpCode):
"""Utility opcode used by unittests."""
OP_PARAMS = [
("result", None, ht.TAny, "'OpTestDummy' result field"),
("messages", None, ht.TAny, "'OpTestDummy' messages field"),
("fail", None, ht.TAny, "'OpTestDummy' fail field"),
("submit_jobs", None, ht.TAny, "'OpTestDummy' submit_jobs field")
]
OP_RESULT = ht.TNone
WITH_LU = False
class OpNetworkAdd(OpCode):
"""Add an IP network to the cluster."""
OP_DSC_FIELD = "network_name"
OP_PARAMS = [
("network_name", None, ht.TNonEmptyString, "Network name"),
("network", None, ht.TIPv4Network, "Network address (IPv4 subnet)"),
("gateway", None, ht.TMaybe(ht.TIPv4Address), "Network gateway (IPv4 address)"),
("network6", None, ht.TMaybe(ht.TIPv6Network), "Network address (IPv6 subnet)"),
("gateway6", None, ht.TMaybe(ht.TIPv6Address), "Network gateway (IPv6 address)"),
("mac_prefix", None, ht.TMaybeString, "Network specific mac prefix (that overrides the cluster one)"),
("add_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which IP addresses to reserve"),
("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses"),
("tags", [], ht.TListOf(ht.TNonEmptyString), "Network tags")
]
OP_RESULT = ht.TNone
class OpNetworkRemove(OpCode):
"""Remove an existing network from the cluster.
Must not be connected to any nodegroup.
"""
OP_DSC_FIELD = "network_name"
OP_PARAMS = [
("network_name", None, ht.TNonEmptyString, "Network name"),
("force", False, ht.TBool, "Whether to force the operation")
]
OP_RESULT = ht.TNone
class OpNetworkSetParams(OpCode):
"""Modify Network's parameters except for IPv4 subnet"""
OP_DSC_FIELD = "network_name"
OP_PARAMS = [
("network_name", None, ht.TNonEmptyString, "Network name"),
("gateway", None, ht.TMaybe(ht.TIPv4Address), "Network gateway (IPv4 address)"),
("network6", None, ht.TMaybe(ht.TIPv6Network), "Network address (IPv6 subnet)"),
("gateway6", None, ht.TMaybe(ht.TIPv6Address), "Network gateway (IPv6 address)"),
("mac_prefix", None, ht.TMaybeString, "Network specific mac prefix (that overrides the cluster one)"),
("add_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which external IP addresses to reserve"),
("remove_reserved_ips", None, ht.TMaybe(ht.TListOf(ht.TIPv4Address)), "Which external IP addresses to release")
]
OP_RESULT = ht.TNone
class OpNetworkConnect(OpCode):
"""Connect a Network to a specific Nodegroup with the defined netparams
(mode, link). Nics in this Network will inherit those params.
Produce errors if a NIC (that its not already assigned to a network)
has an IP that is contained in the Network this will produce error unless
--no-conflicts-check is passed.
"""
OP_DSC_FIELD = "network_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("network_name", None, ht.TNonEmptyString, "Network name"),
("network_mode", None, ht.TNICMode, "Network mode when connecting to a group"),
("network_link", None, ht.TNonEmptyString, "Network link when connecting to a group"),
("network_vlan", "", ht.TString, "Network vlan when connecting to a group"),
("conflicts_check", True, ht.TBool, "Whether to check for conflicting IP addresses")
]
OP_RESULT = ht.TNone
class OpNetworkDisconnect(OpCode):
"""Disconnect a Network from a Nodegroup. Produce errors if NICs are
present in the Network unless --no-conficts-check option is passed.
"""
OP_DSC_FIELD = "network_name"
OP_PARAMS = [
("group_name", None, ht.TNonEmptyString, "Group name"),
("network_name", None, ht.TNonEmptyString, "Network name")
]
OP_RESULT = ht.TNone
def _GetOpList():
"""Returns list of all defined opcodes.
Does not eliminate duplicates by C{OP_ID}.
"""
return [v for v in globals().values()
if (isinstance(v, type) and issubclass(v, OpCode) and
hasattr(v, "OP_ID") and v is not OpCode and
v.OP_ID != 'OP_INSTANCE_MULTI_ALLOC_BASE')]
OP_MAPPING = dict((v.OP_ID, v) for v in _GetOpList())
|