2 Capabilities for clusters.
4 This module can classify clusters into a capability group, and provides some
5 helpful utility functions for determining what clusters are capable of doing.
7 Versions recognized by this module (and GWM at large):
9 * ANCIENT: Ganeti from before the dawn of time. Ganeti 2.1 and earlier, as
10 well as any unrecognized versions.
11 * GANETI22: Ganeti 2.2.x
12 * GANETI23: Ganeti 2.3.x
13 * GANETI24: Ganeti 2.4.x prior to 2.4.2
14 * GANETI242: Ganeti 2.4.2 and newer in the 2.4.x series
15 * GANETI25: Ganeti 2.5.x
16 * GANETI26: Ganeti 2.6.x
17 * FUTURE: Ganeti which probably is newer than, and somewhat
18 backwards-compatible with, the newest version of Ganeti which GWM
21 Note that all bets are off if the cluster's version doesn't correspond to the
22 x.y.z (major.minor.patch) versioning pattern.
37 def classify(cluster
):
39 Determine the class of a cluster by examining its version.
42 # Extract the version string from the cluster.
43 s
= cluster
.info
["software_version"]
45 # First, try the whole splitting thing. If we can't do it that way, assume
48 version
= tuple(int(x
) for x
in s
.split("."))
52 if version
>= (2, 7, 0):
54 if version
>= (2, 6, 0):
56 elif version
>= (2, 5, 0):
58 elif version
>= (2, 4, 2):
60 elif version
>= (2, 4, 0):
62 elif version
>= (2, 3, 0):
64 elif version
>= (2, 2, 0):
70 def has_shutdown_timeout(cluster
):
72 Determine whether a cluster supports timeouts for shutting down VMs.
75 return classify(cluster
) >= GANETI25
78 def has_cdrom2(cluster
):
80 Determine whether a cluster supports a second CDROM device.
83 return classify(cluster
) >= GANETI242
86 def has_balloonmem(cluster
):
88 Determine whether a cluster requires min/maxmem rather than
92 return classify(cluster
) >= GANETI26
95 def has_sharedfile(cluster
):
97 Determine whether a cluster supports the sharedfile disk template.
100 return classify(cluster
) >= GANETI25