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:
parent
0a867848c1
commit
4dc9841f35
|
@ -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):
|
||||
|
|
|
@ -66,3 +66,5 @@ RUNNING_REQUIRED_CONTAINERS = [
|
|||
|
||||
OPENSTACK_FIXTURES = \
|
||||
"/usr/lib/python2.6/site-packages/nailgun/fixtures/openstack.yaml"
|
||||
|
||||
COBBLER_DROP_VERSION = "7.0"
|
||||
|
|
|
@ -116,3 +116,30 @@ TENANT_GET_SAMPLE = """
|
|||
| name | services |
|
||||
+-------------+-----------------------------------+
|
||||
"""[1:]
|
||||
|
||||
|
||||
@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]
|
||||
|
|
|
@ -18,6 +18,8 @@ import time
|
|||
import uuid
|
||||
import yaml
|
||||
|
||||
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
|
||||
|
@ -364,3 +366,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
|
||||
|
|
Loading…
Reference in New Issue