summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-24 19:59:09 +0000
committerGerrit Code Review <review@openstack.org>2016-08-24 19:59:09 +0000
commit0ae07c813ee42191caa24edf45b52b3e91f85182 (patch)
treeb898d3c296626c14970ddda683199266c7e02ddb
parentf4bf5159dd223542a512b9cd73ec89e39c4525fe (diff)
parent8de47e0dbf5955b3cbe59a3956e1ca1f4d8679ef (diff)
Merge "Add VIPs transformer"
-rw-r--r--cluster_upgrade/transformations/vip.py62
-rw-r--r--cluster_upgrade/upgrade.py51
-rw-r--r--setup.cfg2
3 files changed, 72 insertions, 43 deletions
diff --git a/cluster_upgrade/transformations/vip.py b/cluster_upgrade/transformations/vip.py
new file mode 100644
index 0000000..417b5f6
--- /dev/null
+++ b/cluster_upgrade/transformations/vip.py
@@ -0,0 +1,62 @@
1# coding: utf-8
2
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import collections
16
17from cluster_upgrade import transformations
18
19
20def transform_vips(data):
21 """Rename or remove types of VIPs for 7.0 network groups.
22
23 This method renames types of VIPs from older releases (<7.0) to
24 be compatible with network groups of the 7.0 release according
25 to the rules:
26
27 management: haproxy -> management
28 public: haproxy -> public
29 public: vrouter -> vrouter_pub
30
31 Note, that in the result VIPs are present only those IPs that
32 correspond to the given rules.
33 """
34 rename_vip_rules = {
35 "management": {
36 "haproxy": "management",
37 "vrouter": "vrouter",
38 },
39 "public": {
40 "haproxy": "public",
41 "vrouter": "vrouter_pub",
42 },
43 }
44 renamed_vips = collections.defaultdict(dict)
45 for ng_name, vips_obj in data.items():
46
47 ng_vip_rules = rename_vip_rules[ng_name]
48 for vip_name, vip_addr in vips_obj.items():
49 if vip_name not in ng_vip_rules:
50 continue
51
52 new_vip_name = ng_vip_rules[vip_name]
53 renamed_vips[ng_name][new_vip_name] = vip_addr
54
55 return renamed_vips
56
57
58class Manager(transformations.Manager):
59 default_config = {
60 '7.0': ['transform_vips']
61 }
62 name = 'vip'
diff --git a/cluster_upgrade/upgrade.py b/cluster_upgrade/upgrade.py
index bd2c580..dde0606 100644
--- a/cluster_upgrade/upgrade.py
+++ b/cluster_upgrade/upgrade.py
@@ -14,9 +14,7 @@
14# License for the specific language governing permissions and limitations 14# License for the specific language governing permissions and limitations
15# under the License. 15# under the License.
16 16
17import collections
18import copy 17import copy
19from distutils import version
20import six 18import six
21 19
22from nailgun import consts 20from nailgun import consts
@@ -28,6 +26,7 @@ from nailgun import utils
28from . import transformations # That's weird, but that's how hacking likes 26from . import transformations # That's weird, but that's how hacking likes
29from .objects import adapters 27from .objects import adapters
30from .transformations import cluster as cluster_trs 28from .transformations import cluster as cluster_trs
29from .transformations import vip
31from .transformations import volumes as volumes_trs 30from .transformations import volumes as volumes_trs
32 31
33 32
@@ -76,6 +75,7 @@ class UpgradeHelper(object):
76 network_configuration.NovaNetworkConfigurationSerializer, 75 network_configuration.NovaNetworkConfigurationSerializer,
77 } 76 }
78 cluster_transformations = transformations.Lazy(cluster_trs.Manager) 77 cluster_transformations = transformations.Lazy(cluster_trs.Manager)
78 vip_transformations = transformations.Lazy(vip.Manager)
79 volumes_transformations = transformations.Lazy(volumes_trs.Manager) 79 volumes_transformations = transformations.Lazy(volumes_trs.Manager)
80 80
81 @classmethod 81 @classmethod
@@ -125,41 +125,6 @@ class UpgradeHelper(object):
125 attrs['editable']['provision']['method']['value'] = 'image' 125 attrs['editable']['provision']['method']['value'] = 'image'
126 126
127 @classmethod 127 @classmethod
128 def transform_vips_for_net_groups_70(cls, vips):
129 """Rename or remove types of VIPs for 7.0 network groups.
130
131 This method renames types of VIPs from older releases (<7.0) to
132 be compatible with network groups of the 7.0 release according
133 to the rules:
134
135 management: haproxy -> management
136 public: haproxy -> public
137 public: vrouter -> vrouter_pub
138
139 Note, that in the result VIPs are present only those IPs that
140 correspond to the given rules.
141 """
142 rename_vip_rules = {
143 "management": {
144 "haproxy": "management",
145 "vrouter": "vrouter",
146 },
147 "public": {
148 "haproxy": "public",
149 "vrouter": "vrouter_pub",
150 },
151 }
152 renamed_vips = collections.defaultdict(dict)
153 for ng_name, vips in six.iteritems(vips):
154 ng_vip_rules = rename_vip_rules[ng_name]
155 for vip_name, vip_addr in six.iteritems(vips):
156 if vip_name not in ng_vip_rules:
157 continue
158 new_vip_name = ng_vip_rules[vip_name]
159 renamed_vips[ng_name][new_vip_name] = vip_addr
160 return renamed_vips
161
162 @classmethod
163 def copy_network_config(cls, orig_cluster, new_cluster): 128 def copy_network_config(cls, orig_cluster, new_cluster):
164 nets_serializer = cls.network_serializers[orig_cluster.net_provider] 129 nets_serializer = cls.network_serializers[orig_cluster.net_provider]
165 nets = merge_nets( 130 nets = merge_nets(
@@ -179,12 +144,12 @@ class UpgradeHelper(object):
179 assigned_vips = orig_net_manager.get_assigned_vips() 144 assigned_vips = orig_net_manager.get_assigned_vips()
180 for ng_name in (consts.NETWORKS.public, consts.NETWORKS.management): 145 for ng_name in (consts.NETWORKS.public, consts.NETWORKS.management):
181 vips[ng_name] = assigned_vips[ng_name] 146 vips[ng_name] = assigned_vips[ng_name]
182 # NOTE(akscram): In the 7.0 release was introduced networking 147
183 # templates that use the vip_name column as 148 vips = cls.vip_transformations.apply(
184 # unique names of VIPs. 149 orig_cluster.release.environment_version,
185 if version.LooseVersion(orig_cluster.release.environment_version) < \ 150 new_cluster.release.environment_version,
186 version.LooseVersion("7.0"): 151 vips
187 vips = cls.transform_vips_for_net_groups_70(vips) 152 )
188 new_net_manager.assign_given_vips_for_net_groups(vips) 153 new_net_manager.assign_given_vips_for_net_groups(vips)
189 new_net_manager.assign_vips_for_net_groups() 154 new_net_manager.assign_vips_for_net_groups()
190 155
diff --git a/setup.cfg b/setup.cfg
index ea69fea..c88b57f 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,3 +31,5 @@ nailgun.cluster_upgrade.transformations.cluster.9.0 =
31 dns_list = cluster_upgrade.transformations.cluster:transform_dns_list 31 dns_list = cluster_upgrade.transformations.cluster:transform_dns_list
32 ntp_list = cluster_upgrade.transformations.cluster:transform_ntp_list 32 ntp_list = cluster_upgrade.transformations.cluster:transform_ntp_list
33 drop_provision = cluster_upgrade.transformations.cluster:drop_generated_provision 33 drop_provision = cluster_upgrade.transformations.cluster:drop_generated_provision
34nailgun.cluster_upgrade.transformations.vip.7.0 =
35 transform_vips = cluster_upgrade.transformations.vip:transform_vips