Rename types of VIPs during upgrade to 7.0
In the 7.0 release the networking templates were introduced. They use the ip.addrs.vip_type column as names of VIPs and these names differ from names of previous releases. To solve this we can renamed VIPs of older releases during upgrade to 7.0 accoring the rules: management: haproxy -> management public: haproxy -> public public: vrouter -> vrouter_pub Change-Id: Ia77d13ea90408a06896f2a49c6e43d44c6af1d0d Closes-Bug: #1482577
This commit is contained in:
parent
6782ddfe16
commit
f7f28096f1
|
@ -97,6 +97,10 @@ class NailgunReleaseAdapter(object):
|
|||
def is_deployable(self):
|
||||
return self.release.is_deployable
|
||||
|
||||
@property
|
||||
def environment_version(self):
|
||||
return self.release.environment_version
|
||||
|
||||
def __cmp__(self, other):
|
||||
if isinstance(other, NailgunReleaseAdapter):
|
||||
other = other.release
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
import copy
|
||||
import six
|
||||
|
||||
from nailgun import consts
|
||||
from nailgun.objects.serializers import network_configuration
|
||||
|
||||
from . import base as base_tests
|
||||
|
@ -65,11 +64,12 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
|
|||
new_cluster = self.helper.create_cluster_clone(self.cluster_61,
|
||||
self.data)
|
||||
orig_net_manager = self.cluster_61.get_network_manager()
|
||||
new_net_manager = new_cluster.get_network_manager()
|
||||
serialize_nets = network_configuration.\
|
||||
NeutronNetworkConfigurationSerializer.\
|
||||
serialize_for_cluster
|
||||
|
||||
# Do some unordinary changes
|
||||
nets = network_configuration.NeutronNetworkConfigurationSerializer.\
|
||||
serialize_for_cluster(self.cluster_61.cluster)
|
||||
nets = serialize_nets(self.cluster_61.cluster)
|
||||
nets["networks"][0].update({
|
||||
"cidr": "172.16.42.0/24",
|
||||
"gateway": "172.16.42.1",
|
||||
|
@ -80,13 +80,16 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
|
|||
|
||||
self.helper.copy_network_config(self.cluster_61, new_cluster)
|
||||
|
||||
orig_vips = orig_net_manager.get_assigned_vips()
|
||||
new_vips = new_net_manager.get_assigned_vips()
|
||||
for net_name in (consts.NETWORKS.public,
|
||||
consts.NETWORKS.management):
|
||||
for vip_type in consts.NETWORK_VIP_TYPES:
|
||||
self.assertEqual(orig_vips[net_name][vip_type],
|
||||
new_vips[net_name][vip_type])
|
||||
orig_nets = serialize_nets(self.cluster_61_db)
|
||||
new_nets = serialize_nets(new_cluster.cluster)
|
||||
self.assertEqual(orig_nets["management_vip"],
|
||||
new_nets["management_vip"])
|
||||
self.assertEqual(orig_nets["management_vrouter_vip"],
|
||||
new_nets["management_vrouter_vip"])
|
||||
self.assertEqual(orig_nets["public_vip"],
|
||||
new_nets["public_vip"])
|
||||
self.assertEqual(orig_nets["public_vrouter_vip"],
|
||||
new_nets["public_vrouter_vip"])
|
||||
|
||||
def test_clone_cluster(self):
|
||||
orig_net_manager = self.cluster_61.get_network_manager()
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
import copy
|
||||
from distutils import version
|
||||
import six
|
||||
|
||||
from nailgun import consts
|
||||
|
@ -105,6 +107,41 @@ class UpgradeHelper(object):
|
|||
orig_cluster.editable_attrs,
|
||||
new_cluster.editable_attrs)
|
||||
|
||||
@classmethod
|
||||
def transform_vips_for_net_groups_70(cls, vips):
|
||||
"""Rename or remove types of VIPs for 7.0 network groups.
|
||||
|
||||
This method renames types of VIPs from older releases (<7.0) to
|
||||
be compatible with network groups of the 7.0 release according
|
||||
to the rules:
|
||||
|
||||
management: haproxy -> management
|
||||
public: haproxy -> public
|
||||
public: vrouter -> vrouter_pub
|
||||
|
||||
Note, that in the result VIPs are present only those IPs that
|
||||
correspond to the given rules.
|
||||
"""
|
||||
rename_vip_rules = {
|
||||
"management": {
|
||||
"haproxy": "management",
|
||||
"vrouter": "vrouter",
|
||||
},
|
||||
"public": {
|
||||
"haproxy": "public",
|
||||
"vrouter": "vrouter_pub",
|
||||
},
|
||||
}
|
||||
renamed_vips = collections.defaultdict(dict)
|
||||
for ng_name, vips in six.iteritems(vips):
|
||||
ng_vip_rules = rename_vip_rules[ng_name]
|
||||
for vip_type, vip_addr in six.iteritems(vips):
|
||||
if vip_type not in ng_vip_rules:
|
||||
continue
|
||||
new_vip_type = ng_vip_rules[vip_type]
|
||||
renamed_vips[ng_name][new_vip_type] = vip_addr
|
||||
return renamed_vips
|
||||
|
||||
@classmethod
|
||||
def copy_network_config(cls, orig_cluster, new_cluster):
|
||||
nets_serializer = cls.network_serializers[orig_cluster.net_provider]
|
||||
|
@ -121,6 +158,12 @@ class UpgradeHelper(object):
|
|||
if ng_name not in (consts.NETWORKS.public,
|
||||
consts.NETWORKS.management):
|
||||
vips.pop(ng_name)
|
||||
# NOTE(akscram): In the 7.0 release was introduced networking
|
||||
# templates that use the vip_type column as
|
||||
# unique names of VIPs.
|
||||
if version.LooseVersion(orig_cluster.release.environment_version) < \
|
||||
version.LooseVersion("7.0"):
|
||||
vips = cls.transform_vips_for_net_groups_70(vips)
|
||||
new_net_manager.assign_given_vips_for_net_groups(vips)
|
||||
new_net_manager.assign_vips_for_net_groups()
|
||||
|
||||
|
|
Loading…
Reference in New Issue