Revision 4e771a95 lib/cmdlib/cluster.py
b/lib/cmdlib/cluster.py | ||
---|---|---|
56 | 56 |
GetWantedInstances, MergeAndVerifyHvState, MergeAndVerifyDiskState, \ |
57 | 57 |
GetUpdatedIPolicy, ComputeNewInstanceViolations, GetUpdatedParams, \ |
58 | 58 |
CheckOSParams, CheckHVParams, AdjustCandidatePool, CheckNodePVs, \ |
59 |
ComputeIPolicyInstanceViolation, AnnotateDiskParams, SupportsOob |
|
59 |
ComputeIPolicyInstanceViolation, AnnotateDiskParams, SupportsOob, \ |
|
60 |
CheckIpolicyVsDiskTemplates |
|
60 | 61 |
|
61 | 62 |
import ganeti.masterd.instance |
62 | 63 |
|
... | ... | |
789 | 790 |
enabled_disk_templates = cluster.enabled_disk_templates |
790 | 791 |
return (enabled_disk_templates, new_enabled_disk_templates) |
791 | 792 |
|
792 |
@staticmethod |
|
793 |
def _CheckIpolicyVsDiskTemplates(ipolicy, enabled_disk_templates): |
|
794 |
"""Checks ipolicy disk templates against enabled disk tempaltes. |
|
795 |
|
|
796 |
@type ipolicy: dict |
|
797 |
@param ipolicy: the new ipolicy |
|
798 |
@type enabled_disk_templates: list of string |
|
799 |
@param enabled_disk_templates: list of enabled disk templates on the |
|
800 |
cluster |
|
801 |
@rtype: errors.OpPrereqError |
|
802 |
@raises: exception if there is at least one allowed disk template that |
|
803 |
is not also enabled. |
|
804 |
|
|
805 |
""" |
|
806 |
assert constants.IPOLICY_DTS in ipolicy |
|
807 |
allowed_disk_templates = ipolicy[constants.IPOLICY_DTS] |
|
808 |
not_enabled = [] |
|
809 |
for allowed_disk_template in allowed_disk_templates: |
|
810 |
if not allowed_disk_template in enabled_disk_templates: |
|
811 |
not_enabled.append(allowed_disk_template) |
|
812 |
if not_enabled: |
|
813 |
raise errors.OpPrereqError("The following disk template are allowed" |
|
814 |
" by the ipolicy, but not enabled on the" |
|
815 |
" cluster: %s" % utils.CommaJoin(not_enabled)) |
|
816 |
|
|
817 | 793 |
def _CheckIpolicy(self, cluster, enabled_disk_templates): |
818 | 794 |
"""Checks the ipolicy. |
819 | 795 |
|
... | ... | |
829 | 805 |
self.new_ipolicy = GetUpdatedIPolicy(cluster.ipolicy, self.op.ipolicy, |
830 | 806 |
group_policy=False) |
831 | 807 |
|
832 |
self._CheckIpolicyVsDiskTemplates(self.new_ipolicy,
|
|
833 |
enabled_disk_templates)
|
|
808 |
CheckIpolicyVsDiskTemplates(self.new_ipolicy, |
|
809 |
enabled_disk_templates) |
|
834 | 810 |
|
835 | 811 |
all_instances = self.cfg.GetAllInstancesInfo().values() |
836 | 812 |
violations = set() |
... | ... | |
850 | 826 |
" violate them: %s", |
851 | 827 |
utils.CommaJoin(utils.NiceSort(violations))) |
852 | 828 |
else: |
853 |
self._CheckIpolicyVsDiskTemplates(cluster.ipolicy,
|
|
854 |
enabled_disk_templates)
|
|
829 |
CheckIpolicyVsDiskTemplates(cluster.ipolicy, |
|
830 |
enabled_disk_templates) |
|
855 | 831 |
|
856 | 832 |
def CheckPrereq(self): |
857 | 833 |
"""Check prerequisites. |
Also available in: Unified diff