Revision 89e8508e lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
2258 | 2258 |
msg = "cannot reach the master IP" |
2259 | 2259 |
_ErrorIf(True, constants.CV_ENODENET, node, msg) |
2260 | 2260 |
|
2261 |
def _VerifyInstancePolicy(self, instance): |
|
2262 |
"""Verify instance specs against instance policy set on node group level. |
|
2263 |
|
|
2264 |
|
|
2265 |
""" |
|
2266 |
cluster = self.cfg.GetClusterInfo() |
|
2267 |
full_beparams = cluster.FillBE(instance) |
|
2268 |
ipolicy = cluster.SimpleFillIPolicy(self.group_info.ipolicy) |
|
2269 |
|
|
2270 |
mem_size = full_beparams.get(constants.BE_MAXMEM, None) |
|
2271 |
cpu_count = full_beparams.get(constants.BE_VCPUS, None) |
|
2272 |
disk_count = len(instance.disks) |
|
2273 |
disk_sizes = [disk.size for disk in instance.disks] |
|
2274 |
nic_count = len(instance.nics) |
|
2275 |
|
|
2276 |
test_settings = [ |
|
2277 |
(constants.ISPEC_MEM_SIZE, mem_size), |
|
2278 |
(constants.ISPEC_CPU_COUNT, cpu_count), |
|
2279 |
(constants.ISPEC_DISK_COUNT, disk_count), |
|
2280 |
(constants.ISPEC_NIC_COUNT, nic_count), |
|
2281 |
] + map((lambda d: (constants.ISPEC_DISK_SIZE, d)), disk_sizes) |
|
2282 |
|
|
2283 |
for (name, value) in test_settings: |
|
2284 |
test_result = _CheckMinMaxSpecs(name, ipolicy, value) |
|
2285 |
self._ErrorIf(test_result is not None, |
|
2286 |
constants.CV_EINSTANCEPOLICY, instance.name, |
|
2287 |
test_result) |
|
2288 |
|
|
2289 | 2261 |
def _VerifyInstance(self, instance, instanceconfig, node_image, |
2290 | 2262 |
diskstatus): |
2291 | 2263 |
"""Verify an instance. |
Also available in: Unified diff