Restore fixes for partitioning schema for versions before 7.0

Partitions schema created by fuel-agent for image-based provisioning differs
from the schema used for cobbler provisioning. Cobbler provisioning was
supported in versions prior to 7.0.

If version of the environment is lower than 7.0 and provisioning method is not
image-based, fix the partitions schema at the nodes being upgraded.

Change-Id: I27a5477186efe62e3e3dc6f96b16889da1a49250
Closes-bug: 1574624
(cherry picked from commit 306321cbc9)
This commit is contained in:
Oleg Gelbukh 2016-05-11 14:44:55 +00:00
parent 53e2fa6e99
commit bdc0a19831
4 changed files with 47 additions and 3 deletions

View File

@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
class ComputeUpgrade(upgrade.UpgradeHandler):
def prepare(self):
env = self.node.env
if env_util.get_env_provision_method(env) != 'image':
if env_util.incompatible_provision_method(env):
self.create_configdrive_partition()
disk.update_node_partition_info(self.node.id)
if node_util.is_live_migration_supported(self.node):

View File

@ -77,3 +77,4 @@ OSD_REPOS_UPDATE = [
'deb http://{admin_ip}:8080/ubuntu/x86_64/ mos8.0 main restricted',
),
]
COBBLER_DROP_VERSION = "7.0"

View File

@ -269,3 +269,30 @@ def test_change_env_settings(mocker, env_id, master_ip):
}
}
})
@pytest.mark.parametrize("mock_method,version,expected_result",
[("cobbler", "5.1.1", True),
("image", "6.0", False),
("cobbler", "6.0", True),
("image", "6.0", False),
("image", "7.0", False),
("image", "", False),
(None, None, False)])
def test_incompatible_provision_method(mocker,
mock_method,
version,
expected_result):
mock_env = mock.Mock()
mock_env.data = {"fuel_version": version, "id": "test"}
mock_get_method = mocker.patch("octane.util.env.get_env_provision_method")
mock_get_method.return_value = mock_method
if version:
result = env_util.incompatible_provision_method(mock_env)
assert expected_result == result
else:
with pytest.raises(Exception) as exc_info:
env_util.incompatible_provision_method(mock_env)
assert ("Cannot find version of environment {0}:"
" attribute 'fuel_version' missing or has incorrect value"
.format(mock_env.data["id"])) == exc_info.value.args[0]

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from distutils import version
import fuelclient
import json
import logging
import os.path
@ -18,7 +18,8 @@ import time
import uuid
import yaml
import fuelclient
from distutils import version
from fuelclient.objects import environment as environment_obj
from fuelclient.objects import node as node_obj
from fuelclient.objects import task as task_obj
@ -412,3 +413,18 @@ def iter_deployment_info(env, roles):
for node in controllers:
info = find_node_deployment_info(node, roles, full_info)
yield (node, info)
def incompatible_provision_method(env):
if env.data.get("fuel_version"):
env_version = version.StrictVersion(env.data["fuel_version"])
else:
error_message = ("Cannot find version of environment {0}:"
" attribute 'fuel_version' missing or has"
" incorrect value".format(env.data["id"]))
raise Exception(error_message)
provision_method = get_env_provision_method(env)
if env_version < version.StrictVersion(magic_consts.COBBLER_DROP_VERSION) \
and provision_method != 'image':
return True
return False