Revision 4a67e386 lib/client/gnt_cluster.py
b/lib/client/gnt_cluster.py | ||
---|---|---|
1776 | 1776 |
def _ReadIntentToUpgrade(): |
1777 | 1777 |
"""Read the file documenting the intent to upgrade the cluster. |
1778 | 1778 |
|
1779 |
@rtype: string or None
|
|
1780 |
@return: the version to upgrade to, if the file exists, and None
|
|
1781 |
otherwise. |
|
1779 |
@rtype: (string, string) or (None, None)
|
|
1780 |
@return: (old version, version to upgrade to), if the file exists,
|
|
1781 |
and (None, None) otherwise.
|
|
1782 | 1782 |
|
1783 | 1783 |
""" |
1784 | 1784 |
if not os.path.isfile(pathutils.INTENT_TO_UPGRADE): |
1785 |
return None
|
|
1785 |
return (None, None)
|
|
1786 | 1786 |
|
1787 | 1787 |
contentstring = utils.ReadFile(pathutils.INTENT_TO_UPGRADE) |
1788 | 1788 |
contents = utils.UnescapeAndSplit(contentstring) |
1789 | 1789 |
if len(contents) != 3: |
1790 | 1790 |
# file syntactically mal-formed |
1791 |
return None
|
|
1792 |
return contents[1]
|
|
1791 |
return (None, None)
|
|
1792 |
return (contents[0], contents[1])
|
|
1793 | 1793 |
|
1794 | 1794 |
|
1795 | 1795 |
def _WriteIntentToUpgrade(version): |
... | ... | |
1906 | 1906 |
return (True, rollback) |
1907 | 1907 |
|
1908 | 1908 |
|
1909 |
def _UpgradeAfterConfigurationChange(): |
|
1909 |
def _UpgradeAfterConfigurationChange(oldversion):
|
|
1910 | 1910 |
""" |
1911 | 1911 |
Carry out the upgrade actions necessary after switching to the new |
1912 | 1912 |
Ganeti version and updating the configuration. |
... | ... | |
1916 | 1916 |
interface. Also, as the configuration change is the point of no return, |
1917 | 1917 |
all actions are pushed trough, even if some of them fail. |
1918 | 1918 |
|
1919 |
@param oldversion: the version the upgrade started from |
|
1920 |
@type oldversion: string |
|
1919 | 1921 |
@rtype: int |
1920 | 1922 |
@return: the intended return value |
1921 | 1923 |
|
... | ... | |
1953 | 1955 |
|
1954 | 1956 |
_RunCommandAndReport(["rm", "-f", pathutils.INTENT_TO_UPGRADE]) |
1955 | 1957 |
|
1958 |
ToStdout("Running post-upgrade hooks") |
|
1959 |
if not _RunCommandAndReport([pathutils.POST_UPGRADE, oldversion]): |
|
1960 |
returnvalue = 1 |
|
1961 |
|
|
1956 | 1962 |
ToStdout("Verifying cluster.") |
1957 | 1963 |
if not _RunCommandAndReport(["gnt-cluster", "verify"]): |
1958 | 1964 |
returnvalue = 1 |
... | ... | |
1976 | 1982 |
" has to be given") |
1977 | 1983 |
return 1 |
1978 | 1984 |
|
1985 |
oldversion = constants.RELEASE_VERSION |
|
1986 |
|
|
1979 | 1987 |
if opts.resume: |
1980 | 1988 |
ssconf.CheckMaster(False) |
1981 |
versionstring = _ReadIntentToUpgrade() |
|
1989 |
oldversion, versionstring = _ReadIntentToUpgrade()
|
|
1982 | 1990 |
if versionstring is None: |
1983 | 1991 |
return 0 |
1984 | 1992 |
version = utils.version.ParseVersion(versionstring) |
... | ... | |
2033 | 2041 |
_ExecuteCommands(rollback) |
2034 | 2042 |
return 1 |
2035 | 2043 |
|
2036 |
return _UpgradeAfterConfigurationChange() |
|
2044 |
return _UpgradeAfterConfigurationChange(oldversion)
|
|
2037 | 2045 |
|
2038 | 2046 |
|
2039 | 2047 |
commands = { |
Also available in: Unified diff