summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-06-21 09:28:19 +0000
committerGerrit Code Review <review@openstack.org>2016-06-21 09:28:19 +0000
commit5b324fad3b4f78c80bcf384009c3a119f0693bfe (patch)
tree76d2c65dee2f26de754901ee257bcf876194a316
parent395976a985cd694cba18817a8bd718b81c99f38e (diff)
parent8736f9c13eec4ec94f3e30d6c9428f0148950ef5 (diff)
Merge "Override rpm repos from override_rpm_repos.yaml"
-rwxr-xr-xfuel-release/override_rpm_repos.py55
-rw-r--r--specs/fuel-main.spec10
2 files changed, 65 insertions, 0 deletions
diff --git a/fuel-release/override_rpm_repos.py b/fuel-release/override_rpm_repos.py
new file mode 100755
index 0000000..8fc200b
--- /dev/null
+++ b/fuel-release/override_rpm_repos.py
@@ -0,0 +1,55 @@
1#!/usr/bin/env python
2# Copyright 2016 Mirantis, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import argparse
17import yaml
18
19
20def generate_yum_repos_config(repositories):
21 config = ""
22 for repo in repositories:
23 config += """
24[{name}]
25name={name}
26baseurl={uri}
27enabled=1
28gpgcheck=0
29priority={priority}
30skip_if_unavailable=1
31""".format(**repo)
32 return config
33
34
35def main():
36 parser = argparse.ArgumentParser()
37 parser.add_argument(
38 '--repositories-file', dest='repositories_file', action='store',
39 type=str, help='file where repositories are defined', required=True
40 )
41 parser.add_argument(
42 '--output-file', dest='outfile', action='store',
43 type=str, help='file where to write yum config', required=True
44 )
45 params, other_params = parser.parse_known_args()
46
47 with open(params.repositories_file) as f:
48 repositories = yaml.safe_load(f)
49
50 with open(params.outfile, 'wt') as f:
51 f.write(generate_yum_repos_config(repositories))
52
53
54if __name__ == "__main__":
55 main()
diff --git a/specs/fuel-main.spec b/specs/fuel-main.spec
index 5053255..9d38a34 100644
--- a/specs/fuel-main.spec
+++ b/specs/fuel-main.spec
@@ -49,6 +49,7 @@ for file in %{_builddir}/%{name}-%{version}/fuel-release/*.repo ; do
49done 49done
50install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/bootstrap_admin_node.sh %{buildroot}%{_sbindir}/bootstrap_admin_node.sh 50install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/bootstrap_admin_node.sh %{buildroot}%{_sbindir}/bootstrap_admin_node.sh
51install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/fix_default_repos.py %{buildroot}%{_sbindir}/fix_default_repos.py 51install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/fix_default_repos.py %{buildroot}%{_sbindir}/fix_default_repos.py
52install -D -p -m 755 %{_builddir}/%{name}-%{version}/fuel-release/override_rpm_repos.py %{buildroot}%{_sbindir}/override_rpm_repos.py
52 53
53%clean 54%clean
54rm -rf %{buildroot} 55rm -rf %{buildroot}
@@ -65,6 +66,8 @@ Release: %{release}
65License: GPLv2 66License: GPLv2
66BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot 67BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
67URL: http://github.com/Mirantis 68URL: http://github.com/Mirantis
69Requires: python
70Requires: PyYAML >= 3.10
68 71
69%description -n fuel-release 72%description -n fuel-release
70This packages provides /etc/fuel_release file 73This packages provides /etc/fuel_release file
@@ -73,11 +76,18 @@ and Yum configuration for Fuel online repositories.
73%files -n fuel-release 76%files -n fuel-release
74%defattr(-,root,root) 77%defattr(-,root,root)
75%{_sysconfdir}/fuel_release 78%{_sysconfdir}/fuel_release
79%{_sbindir}/override_rpm_repos.py
76%config(noreplace) %attr(0644,root,root) /etc/yum/vars/fuelver 80%config(noreplace) %attr(0644,root,root) /etc/yum/vars/fuelver
77%config(noreplace) %attr(0644,root,root) /etc/yum.repos.d/* 81%config(noreplace) %attr(0644,root,root) /etc/yum.repos.d/*
78%dir /etc/pki/fuel-gpg 82%dir /etc/pki/fuel-gpg
79/etc/pki/fuel-gpg/* 83/etc/pki/fuel-gpg/*
80 84
85%post -n fuel-release
86if [[ -f /root/override_rpm_repos.yaml ]]; then
87 rm -f /etc/yum.repos.d/*.repo
88 override_rpm_repos.py --repositories-file /root/override_rpm_repos.yaml --output-file /etc/yum.repos.d/overriden.repo
89fi
90
81%package -n fuel-setup 91%package -n fuel-setup
82 92
83Summary: Fuel deployment script package 93Summary: Fuel deployment script package