Revision 7f60a422 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
8501 | 8501 |
_RELO_KEYS = [ |
8502 | 8502 |
"name", "relocate_from", |
8503 | 8503 |
] |
8504 |
_EVAC_KEYS = [ |
|
8505 |
"evac_nodes", |
|
8506 |
] |
|
8504 | 8507 |
|
8505 | 8508 |
def __init__(self, cfg, rpc, mode, **kwargs): |
8506 | 8509 |
self.cfg = cfg |
... | ... | |
8514 | 8517 |
self.hypervisor = None |
8515 | 8518 |
self.relocate_from = None |
8516 | 8519 |
self.name = None |
8520 |
self.evac_nodes = None |
|
8517 | 8521 |
# computed fields |
8518 | 8522 |
self.required_nodes = None |
8519 | 8523 |
# init result fields |
... | ... | |
8524 | 8528 |
elif self.mode == constants.IALLOCATOR_MODE_RELOC: |
8525 | 8529 |
keyset = self._RELO_KEYS |
8526 | 8530 |
fn = self._AddRelocateInstance |
8531 |
elif self.mode == constants.IALLOCATOR_MODE_MEVAC: |
|
8532 |
keyset = self._EVAC_KEYS |
|
8533 |
fn = self._AddEvacuateNodes |
|
8527 | 8534 |
else: |
8528 | 8535 |
raise errors.ProgrammerError("Unknown mode '%s' passed to the" |
8529 | 8536 |
" IAllocator" % self.mode) |
... | ... | |
8532 | 8539 |
raise errors.ProgrammerError("Invalid input parameter '%s' to" |
8533 | 8540 |
" IAllocator" % key) |
8534 | 8541 |
setattr(self, key, kwargs[key]) |
8542 |
|
|
8535 | 8543 |
for key in keyset: |
8536 | 8544 |
if key not in kwargs: |
8537 | 8545 |
raise errors.ProgrammerError("Missing input parameter '%s' to" |
... | ... | |
8565 | 8573 |
hypervisor_name = self.hypervisor |
8566 | 8574 |
elif self.mode == constants.IALLOCATOR_MODE_RELOC: |
8567 | 8575 |
hypervisor_name = cfg.GetInstanceInfo(self.name).hypervisor |
8576 |
elif self.mode == constants.IALLOCATOR_MODE_MEVAC: |
|
8577 |
hypervisor_name = cluster_info.enabled_hypervisors[0] |
|
8568 | 8578 |
|
8569 | 8579 |
node_data = self.rpc.call_node_info(node_list, cfg.GetVGName(), |
8570 | 8580 |
hypervisor_name) |
... | ... | |
8730 | 8740 |
} |
8731 | 8741 |
return request |
8732 | 8742 |
|
8743 |
def _AddEvacuateNodes(self): |
|
8744 |
"""Add evacuate nodes data to allocator structure. |
|
8745 |
|
|
8746 |
""" |
|
8747 |
request = { |
|
8748 |
"evac_nodes": self.evac_nodes |
|
8749 |
} |
|
8750 |
return request |
|
8751 |
|
|
8733 | 8752 |
def _BuildInputData(self, fn): |
8734 | 8753 |
"""Build input data structures. |
8735 | 8754 |
|
Also available in: Unified diff