summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-24 19:59:04 +0000
committerGerrit Code Review <review@openstack.org>2016-08-24 19:59:04 +0000
commitf4bf5159dd223542a512b9cd73ec89e39c4525fe (patch)
tree6b17103688cefc8dac2d51279fe7adb626368a49
parent09a6e1c20fbd36e3bba9591917593783cbc49998 (diff)
parentb54f9d4c29808c4561b20af508b85b9e40fa72b6 (diff)
Merge "Move partition info transformation to extension"
-rw-r--r--cluster_upgrade/objects/adapters.py9
-rw-r--r--cluster_upgrade/transformations/__init__.py4
-rw-r--r--cluster_upgrade/transformations/volumes.py53
-rw-r--r--cluster_upgrade/upgrade.py9
-rw-r--r--setup.cfg2
5 files changed, 75 insertions, 2 deletions
diff --git a/cluster_upgrade/objects/adapters.py b/cluster_upgrade/objects/adapters.py
index e2b3eb0..d3b00e4 100644
--- a/cluster_upgrade/objects/adapters.py
+++ b/cluster_upgrade/objects/adapters.py
@@ -14,6 +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
17from nailgun.extensions.volume_manager import extension as volume_ext
17from nailgun import objects 18from nailgun import objects
18 19
19 20
@@ -208,6 +209,14 @@ class NailgunNodeAdapter(object):
208 def add_pending_change(self, change): 209 def add_pending_change(self, change):
209 objects.Node.add_pending_change(self.node, change) 210 objects.Node.add_pending_change(self.node, change)
210 211
212 def get_volumes(self):
213 return volume_ext.VolumeManagerExtension.get_node_volumes(self.node)
214
215 def set_volumes(self, volumes):
216 return volume_ext.VolumeManagerExtension.set_node_volumes(
217 self.node, volumes
218 )
219
211 220
212class NailgunNetworkGroupAdapter(object): 221class NailgunNetworkGroupAdapter(object):
213 222
diff --git a/cluster_upgrade/transformations/__init__.py b/cluster_upgrade/transformations/__init__.py
index 64c14d7..7e1d861 100644
--- a/cluster_upgrade/transformations/__init__.py
+++ b/cluster_upgrade/transformations/__init__.py
@@ -64,8 +64,8 @@ class Manager(object):
64 def apply(self, from_version, to_version, data): 64 def apply(self, from_version, to_version, data):
65 strict_from = distutils.version.StrictVersion(from_version) 65 strict_from = distutils.version.StrictVersion(from_version)
66 strict_to = distutils.version.StrictVersion(to_version) 66 strict_to = distutils.version.StrictVersion(to_version)
67 assert strict_from < strict_to, \ 67 assert strict_from <= strict_to, \
68 "from_version must be smaller than to_version" 68 "from_version must not be greater than to_version"
69 data = copy.deepcopy(data) 69 data = copy.deepcopy(data)
70 for version, transformers in self.transformers: 70 for version, transformers in self.transformers:
71 if version <= strict_from: 71 if version <= strict_from:
diff --git a/cluster_upgrade/transformations/volumes.py b/cluster_upgrade/transformations/volumes.py
new file mode 100644
index 0000000..cb9dca7
--- /dev/null
+++ b/cluster_upgrade/transformations/volumes.py
@@ -0,0 +1,53 @@
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
15from cluster_upgrade import transformations
16
17
18def transform_node_volumes(volumes):
19 try:
20 os_vg = next(vol for vol in volumes
21 if 'id' in vol and vol['id'] == 'os')
22 except StopIteration:
23 return volumes
24
25 other_volumes = [vol for vol in volumes
26 if 'id' not in vol or vol['id'] != 'os']
27
28 for disk in other_volumes:
29 disk_volumes = disk['volumes']
30 disk['volumes'] = []
31
32 for v in disk_volumes:
33 if v['type'] == 'pv' and v['vg'] == 'os' and v['size'] > 0:
34 for vv in os_vg['volumes']:
35 partition = {'name': vv['name'],
36 'size': vv['size'],
37 'type': 'partition',
38 'mount': vv['mount'],
39 'file_system': vv['file_system']}
40 disk['volumes'].append(partition)
41 else:
42 if v['type'] == 'lvm_meta_pool' or v['type'] == 'boot':
43 v['size'] = 0
44 disk['volumes'].append(v)
45
46 return volumes
47
48
49class Manager(transformations.Manager):
50 default_config = {
51 '6.1': ['node_volumes']
52 }
53 name = 'volumes'
diff --git a/cluster_upgrade/upgrade.py b/cluster_upgrade/upgrade.py
index e1b9ec8..bd2c580 100644
--- a/cluster_upgrade/upgrade.py
+++ b/cluster_upgrade/upgrade.py
@@ -28,6 +28,7 @@ from nailgun import utils
28from . import transformations # That's weird, but that's how hacking likes 28from . import transformations # That's weird, but that's how hacking likes
29from .objects import adapters 29from .objects import adapters
30from .transformations import cluster as cluster_trs 30from .transformations import cluster as cluster_trs
31from .transformations import volumes as volumes_trs
31 32
32 33
33def merge_attributes(a, b): 34def merge_attributes(a, b):
@@ -75,6 +76,7 @@ class UpgradeHelper(object):
75 network_configuration.NovaNetworkConfigurationSerializer, 76 network_configuration.NovaNetworkConfigurationSerializer,
76 } 77 }
77 cluster_transformations = transformations.Lazy(cluster_trs.Manager) 78 cluster_transformations = transformations.Lazy(cluster_trs.Manager)
79 volumes_transformations = transformations.Lazy(volumes_trs.Manager)
78 80
79 @classmethod 81 @classmethod
80 def clone_cluster(cls, orig_cluster, data): 82 def clone_cluster(cls, orig_cluster, data):
@@ -215,6 +217,13 @@ class UpgradeHelper(object):
215 orig_cluster = adapters.NailgunClusterAdapter.get_by_uid( 217 orig_cluster = adapters.NailgunClusterAdapter.get_by_uid(
216 node.cluster_id) 218 node.cluster_id)
217 219
220 volumes = cls.volumes_transformations.apply(
221 orig_cluster.release.environment_version,
222 seed_cluster.release.environment_version,
223 node.get_volumes(),
224 )
225 node.set_volumes(volumes)
226
218 orig_manager = orig_cluster.get_network_manager() 227 orig_manager = orig_cluster.get_network_manager()
219 228
220 netgroups_id_mapping = cls.get_netgroups_id_mapping( 229 netgroups_id_mapping = cls.get_netgroups_id_mapping(
diff --git a/setup.cfg b/setup.cfg
index aa902e4..ea69fea 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -25,6 +25,8 @@ packages =
25[entry_points] 25[entry_points]
26nailgun.extensions = 26nailgun.extensions =
27 cluster_upgrade = cluster_upgrade.extension:ClusterUpgradeExtension 27 cluster_upgrade = cluster_upgrade.extension:ClusterUpgradeExtension
28nailgun.cluster_upgrade.transformations.volumes.6.1 =
29 node_volumes = cluster_upgrade.transformations.volumes:transform_node_volumes
28nailgun.cluster_upgrade.transformations.cluster.9.0 = 30nailgun.cluster_upgrade.transformations.cluster.9.0 =
29 dns_list = cluster_upgrade.transformations.cluster:transform_dns_list 31 dns_list = cluster_upgrade.transformations.cluster:transform_dns_list
30 ntp_list = cluster_upgrade.transformations.cluster:transform_ntp_list 32 ntp_list = cluster_upgrade.transformations.cluster:transform_ntp_list