summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgy Kibardin <gkibardin@mirantis.com>2017-01-13 13:27:27 +0300
committerGeorgy Kibardin <gkibardin@mirantis.com>2017-01-13 15:41:49 +0300
commitfae06cf5aa86e2d0a1cbc18bee41bfa830b1962f (patch)
treef65ef642a7bed45068e60da84d4e74a2a3f39c22
parent6a1ae7f5204dadcdc5326c668c09ca5840bd5c7e (diff)
Separate create and build templates
In order to prevent build templates to render during plugin creation we need to put them into different directories. Change-Id: I439bc7618a43ad07cc73fb69b60d99d725c3f9d0 Closes-Bug: #1655289
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+2: Ilya Kutukov <post.ilya@gmail.com> Code-Review+1: Andriy Popovych <apopovych@mirantis.com> Code-Review+2: Evgeniy L <eli@mirantis.com> Workflow+1: Evgeniy L <eli@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 25 Apr 2017 14:51:31 +0000 Reviewed-on: https://review.openstack.org/419880 Project: openstack/fuel-plugins Branch: refs/heads/master
-rw-r--r--fuel_plugin_builder/actions/build.py35
-rw-r--r--fuel_plugin_builder/templates/base/build/Release.mako (renamed from fuel_plugin_builder/templates/v1/build/Release.mako)0
-rw-r--r--fuel_plugin_builder/templates/base/plugin_data/LICENSE (renamed from fuel_plugin_builder/templates/base/LICENSE)0
-rw-r--r--fuel_plugin_builder/templates/base/plugin_data/README.md.mako (renamed from fuel_plugin_builder/templates/base/README.md.mako)0
-rwxr-xr-xfuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako (renamed from fuel_plugin_builder/templates/base/deployment_scripts/deploy.sh.mako)0
-rw-r--r--fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako (renamed from fuel_plugin_builder/templates/base/environment_config.yaml.mako)0
-rwxr-xr-xfuel_plugin_builder/templates/base/plugin_data/pre_build_hook (renamed from fuel_plugin_builder/templates/base/pre_build_hook)0
-rw-r--r--fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep (renamed from fuel_plugin_builder/templates/base/repositories/centos/.gitkeep)0
-rw-r--r--fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep (renamed from fuel_plugin_builder/templates/base/repositories/ubuntu/.gitkeep)0
-rw-r--r--fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako (renamed from fuel_plugin_builder/templates/v1/metadata.yaml.mako)0
-rw-r--r--fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml (renamed from fuel_plugin_builder/templates/v1/tasks.yaml)0
-rw-r--r--fuel_plugin_builder/tests/test_version_mapping.py10
-rw-r--r--fuel_plugin_builder/version_mapping.py13
13 files changed, 28 insertions, 30 deletions
diff --git a/fuel_plugin_builder/actions/build.py b/fuel_plugin_builder/actions/build.py
index 7e91fb0..ca9a9bc 100644
--- a/fuel_plugin_builder/actions/build.py
+++ b/fuel_plugin_builder/actions/build.py
@@ -32,9 +32,14 @@ from fuel_plugin_builder import version_mapping
32logger = logging.getLogger(__name__) 32logger = logging.getLogger(__name__)
33 33
34 34
35def get_template_path(file_name):
36 return os.path.abspath(join_path(
37 os.path.dirname(__file__), '..', 'templates', file_name))
38
39
35class BaseBuildPlugin(BaseAction): 40class BaseBuildPlugin(BaseAction):
36 41
37 release_tmpl_src_path = None 42 release_tmpl_src_path = get_template_path('base/build/Release.mako')
38 43
39 @abc.abstractproperty 44 @abc.abstractproperty
40 def requires(self): 45 def requires(self):
@@ -109,13 +114,12 @@ class BaseBuildPlugin(BaseAction):
109 utils.exec_piped_cmds( 114 utils.exec_piped_cmds(
110 ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'], 115 ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'],
111 cwd=repo_path) 116 cwd=repo_path)
112 if self.release_tmpl_src_path: 117 release_path = join_path(repo_path, 'Release')
113 release_path = join_path(repo_path, 'Release') 118 utils.render_to_file(
114 utils.render_to_file( 119 self.release_tmpl_src_path,
115 self.release_tmpl_src_path, 120 release_path,
116 release_path, 121 {'plugin_name': self.meta['name'],
117 {'plugin_name': self.meta['name'], 122 'major_version': self.plugin_version})
118 'major_version': self.plugin_version})
119 123
120 @classmethod 124 @classmethod
121 def build_centos_repos(cls, releases_paths): 125 def build_centos_repos(cls, releases_paths):
@@ -147,10 +151,6 @@ class BaseBuildPlugin(BaseAction):
147class BuildPluginV1(BaseBuildPlugin): 151class BuildPluginV1(BaseBuildPlugin):
148 152
149 requires = ['rpm', 'createrepo', 'dpkg-scanpackages'] 153 requires = ['rpm', 'createrepo', 'dpkg-scanpackages']
150 release_tmpl_src_path = os.path.abspath(join_path(
151 os.path.dirname(__file__),
152 '..',
153 'templates/v1/build/Release.mako'))
154 154
155 @property 155 @property
156 def result_package_mask(self): 156 def result_package_mask(self):
@@ -171,7 +171,7 @@ class BuildPluginV2(BuildPluginV1):
171 171
172 requires = ['rpmbuild', 'rpm', 'createrepo', 'dpkg-scanpackages'] 172 requires = ['rpmbuild', 'rpm', 'createrepo', 'dpkg-scanpackages']
173 173
174 rpm_spec_src_path = 'templates/v2/build/plugin_rpm.spec.mako' 174 rpm_spec_src_path = get_template_path('v2/build/plugin_rpm.spec.mako')
175 175
176 def __init__(self, *args, **kwargs): 176 def __init__(self, *args, **kwargs):
177 super(BuildPluginV2, self).__init__(*args, **kwargs) 177 super(BuildPluginV2, self).__init__(*args, **kwargs)
@@ -186,11 +186,6 @@ class BuildPluginV2(BuildPluginV1):
186 tar_name = '{0}.fp'.format(self.full_name) 186 tar_name = '{0}.fp'.format(self.full_name)
187 self.tar_path = join_path(self.rpm_src_path, tar_name) 187 self.tar_path = join_path(self.rpm_src_path, tar_name)
188 188
189 fpb_dir = join_path(os.path.dirname(__file__), '..')
190
191 self.spec_src = os.path.abspath(join_path(
192 fpb_dir, self.rpm_spec_src_path))
193
194 self.spec_dst = join_path(self.rpm_path, 'plugin_rpm.spec') 189 self.spec_dst = join_path(self.rpm_path, 'plugin_rpm.spec')
195 190
196 self.rpm_packages_mask = join_path( 191 self.rpm_packages_mask = join_path(
@@ -208,7 +203,7 @@ class BuildPluginV2(BuildPluginV1):
208 203
209 utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name) 204 utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name)
210 utils.render_to_file( 205 utils.render_to_file(
211 self.spec_src, 206 self.rpm_spec_src_path,
212 self.spec_dst, 207 self.spec_dst,
213 self._make_data_for_template()) 208 self._make_data_for_template())
214 209
@@ -235,7 +230,7 @@ class BuildPluginV2(BuildPluginV1):
235 230
236class BuildPluginV3(BuildPluginV2): 231class BuildPluginV3(BuildPluginV2):
237 232
238 rpm_spec_src_path = 'templates/v3/build/plugin_rpm.spec.mako' 233 rpm_spec_src_path = get_template_path('v3/build/plugin_rpm.spec.mako')
239 234
240 def _make_data_for_template(self): 235 def _make_data_for_template(self):
241 data = super(BuildPluginV3, self)._make_data_for_template() 236 data = super(BuildPluginV3, self)._make_data_for_template()
diff --git a/fuel_plugin_builder/templates/v1/build/Release.mako b/fuel_plugin_builder/templates/base/build/Release.mako
index 65a9a7d..65a9a7d 100644
--- a/fuel_plugin_builder/templates/v1/build/Release.mako
+++ b/fuel_plugin_builder/templates/base/build/Release.mako
diff --git a/fuel_plugin_builder/templates/base/LICENSE b/fuel_plugin_builder/templates/base/plugin_data/LICENSE
index e06d208..e06d208 100644
--- a/fuel_plugin_builder/templates/base/LICENSE
+++ b/fuel_plugin_builder/templates/base/plugin_data/LICENSE
diff --git a/fuel_plugin_builder/templates/base/README.md.mako b/fuel_plugin_builder/templates/base/plugin_data/README.md.mako
index 560fd46..560fd46 100644
--- a/fuel_plugin_builder/templates/base/README.md.mako
+++ b/fuel_plugin_builder/templates/base/plugin_data/README.md.mako
diff --git a/fuel_plugin_builder/templates/base/deployment_scripts/deploy.sh.mako b/fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako
index 1a669d1..1a669d1 100755
--- a/fuel_plugin_builder/templates/base/deployment_scripts/deploy.sh.mako
+++ b/fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako
diff --git a/fuel_plugin_builder/templates/base/environment_config.yaml.mako b/fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako
index 72ef4ab..72ef4ab 100644
--- a/fuel_plugin_builder/templates/base/environment_config.yaml.mako
+++ b/fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako
diff --git a/fuel_plugin_builder/templates/base/pre_build_hook b/fuel_plugin_builder/templates/base/plugin_data/pre_build_hook
index dc05e98..dc05e98 100755
--- a/fuel_plugin_builder/templates/base/pre_build_hook
+++ b/fuel_plugin_builder/templates/base/plugin_data/pre_build_hook
diff --git a/fuel_plugin_builder/templates/base/repositories/centos/.gitkeep b/fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep
index e69de29..e69de29 100644
--- a/fuel_plugin_builder/templates/base/repositories/centos/.gitkeep
+++ b/fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep
diff --git a/fuel_plugin_builder/templates/base/repositories/ubuntu/.gitkeep b/fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep
index e69de29..e69de29 100644
--- a/fuel_plugin_builder/templates/base/repositories/ubuntu/.gitkeep
+++ b/fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep
diff --git a/fuel_plugin_builder/templates/v1/metadata.yaml.mako b/fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako
index df9b788..df9b788 100644
--- a/fuel_plugin_builder/templates/v1/metadata.yaml.mako
+++ b/fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako
diff --git a/fuel_plugin_builder/templates/v1/tasks.yaml b/fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml
index bfa8873..bfa8873 100644
--- a/fuel_plugin_builder/templates/v1/tasks.yaml
+++ b/fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml
diff --git a/fuel_plugin_builder/tests/test_version_mapping.py b/fuel_plugin_builder/tests/test_version_mapping.py
index 9f7b529..ccbf453 100644
--- a/fuel_plugin_builder/tests/test_version_mapping.py
+++ b/fuel_plugin_builder/tests/test_version_mapping.py
@@ -31,7 +31,7 @@ class TestVersionMapping(BaseTestCase):
31 self.assertEqual(result['version'], '1.0.0') 31 self.assertEqual(result['version'], '1.0.0')
32 self.assertEqual( 32 self.assertEqual(
33 result['templates'], 33 result['templates'],
34 ['templates/base', 'templates/v1/']) 34 ['templates/base/plugin_data', 'templates/v1/plugin_data/'])
35 self.assertEqual(result['validator'], ValidatorV1) 35 self.assertEqual(result['validator'], ValidatorV1)
36 36
37 def test_get_plugin_for_version_2(self): 37 def test_get_plugin_for_version_2(self):
@@ -39,7 +39,7 @@ class TestVersionMapping(BaseTestCase):
39 self.assertEqual(result['version'], '2.0.0') 39 self.assertEqual(result['version'], '2.0.0')
40 self.assertEqual( 40 self.assertEqual(
41 result['templates'], 41 result['templates'],
42 ['templates/base', 'templates/v2/plugin_data/']) 42 ['templates/base/plugin_data', 'templates/v2/plugin_data/'])
43 self.assertEqual(result['validator'], ValidatorV2) 43 self.assertEqual(result['validator'], ValidatorV2)
44 44
45 def test_get_plugin_for_version_3(self): 45 def test_get_plugin_for_version_3(self):
@@ -47,7 +47,7 @@ class TestVersionMapping(BaseTestCase):
47 self.assertEqual(result['version'], '3.0.0') 47 self.assertEqual(result['version'], '3.0.0')
48 self.assertEqual( 48 self.assertEqual(
49 result['templates'], 49 result['templates'],
50 ['templates/base', 'templates/v3/plugin_data/']) 50 ['templates/base/plugin_data', 'templates/v3/plugin_data/'])
51 self.assertEqual(result['validator'], ValidatorV3) 51 self.assertEqual(result['validator'], ValidatorV3)
52 52
53 def test_get_plugin_for_version_4(self): 53 def test_get_plugin_for_version_4(self):
@@ -56,7 +56,7 @@ class TestVersionMapping(BaseTestCase):
56 self.assertEqual( 56 self.assertEqual(
57 result['templates'], 57 result['templates'],
58 [ 58 [
59 'templates/base', 59 'templates/base/plugin_data',
60 'templates/v3/plugin_data/', 60 'templates/v3/plugin_data/',
61 'templates/v4/plugin_data/']) 61 'templates/v4/plugin_data/'])
62 self.assertEqual(result['validator'], ValidatorV4) 62 self.assertEqual(result['validator'], ValidatorV4)
@@ -67,7 +67,7 @@ class TestVersionMapping(BaseTestCase):
67 self.assertEqual( 67 self.assertEqual(
68 result['templates'], 68 result['templates'],
69 [ 69 [
70 'templates/base', 70 'templates/base/plugin_data',
71 'templates/v3/plugin_data/', 71 'templates/v3/plugin_data/',
72 'templates/v4/plugin_data/', 72 'templates/v4/plugin_data/',
73 'templates/v5/plugin_data/']) 73 'templates/v5/plugin_data/'])
diff --git a/fuel_plugin_builder/version_mapping.py b/fuel_plugin_builder/version_mapping.py
index 0b109d2..61533ba 100644
--- a/fuel_plugin_builder/version_mapping.py
+++ b/fuel_plugin_builder/version_mapping.py
@@ -30,27 +30,30 @@ def get_mapping():
30 30
31 return [ 31 return [
32 {'version': '1.0.0', 32 {'version': '1.0.0',
33 'templates': ['templates/base', 'templates/v1/'], 33 'templates': ['templates/base/plugin_data',
34 'templates/v1/plugin_data/'],
34 'validator': validators.ValidatorV1, 35 'validator': validators.ValidatorV1,
35 'builder': build.BuildPluginV1}, 36 'builder': build.BuildPluginV1},
36 {'version': '2.0.0', 37 {'version': '2.0.0',
37 'templates': ['templates/base', 'templates/v2/plugin_data/'], 38 'templates': ['templates/base/plugin_data',
39 'templates/v2/plugin_data/'],
38 'validator': validators.ValidatorV2, 40 'validator': validators.ValidatorV2,
39 'builder': build.BuildPluginV2}, 41 'builder': build.BuildPluginV2},
40 {'version': '3.0.0', 42 {'version': '3.0.0',
41 'templates': ['templates/base', 'templates/v3/plugin_data/'], 43 'templates': ['templates/base/plugin_data',
44 'templates/v3/plugin_data/'],
42 'validator': validators.ValidatorV3, 45 'validator': validators.ValidatorV3,
43 'builder': build.BuildPluginV3}, 46 'builder': build.BuildPluginV3},
44 {'version': '4.0.0', 47 {'version': '4.0.0',
45 'templates': [ 48 'templates': [
46 'templates/base', 49 'templates/base/plugin_data',
47 'templates/v3/plugin_data/', 50 'templates/v3/plugin_data/',
48 'templates/v4/plugin_data/'], 51 'templates/v4/plugin_data/'],
49 'validator': validators.ValidatorV4, 52 'validator': validators.ValidatorV4,
50 'builder': build.BuildPluginV4}, 53 'builder': build.BuildPluginV4},
51 {'version': '5.0.0', 54 {'version': '5.0.0',
52 'templates': [ 55 'templates': [
53 'templates/base', 56 'templates/base/plugin_data',
54 'templates/v3/plugin_data/', 57 'templates/v3/plugin_data/',
55 'templates/v4/plugin_data/', 58 'templates/v4/plugin_data/',
56 'templates/v5/plugin_data/'], 59 'templates/v5/plugin_data/'],