Override rpm repos from override_rpm_repos.yaml
It is necessary for tests. Test framework is to put rpm repos into file /root/override_rpm_repos.yaml file and then install fuel-release package. Change-Id: If8280af152608f86a5ea69f84abfaa1a0894b374
This commit is contained in:
parent
ba563efebb
commit
8736f9c13e
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2016 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import yaml
|
||||
|
||||
|
||||
def generate_yum_repos_config(repositories):
|
||||
config = ""
|
||||
for repo in repositories:
|
||||
config += """
|
||||
[{name}]
|
||||
name={name}
|
||||
baseurl={uri}
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
priority={priority}
|
||||
skip_if_unavailable=1
|
||||
""".format(**repo)
|
||||
return config
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'--repositories-file', dest='repositories_file', action='store',
|
||||
type=str, help='file where repositories are defined', required=True
|
||||
)
|
||||
parser.add_argument(
|
||||
'--output-file', dest='outfile', action='store',
|
||||
type=str, help='file where to write yum config', required=True
|
||||
)
|
||||
params, other_params = parser.parse_known_args()
|
||||
|
||||
with open(params.repositories_file) as f:
|
||||
repositories = yaml.safe_load(f)
|
||||
|
||||
with open(params.outfile, 'wt') as f:
|
||||
f.write(generate_yum_repos_config(repositories))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -49,6 +49,7 @@ for file in %{_builddir}/%{name}-%{version}/fuel-release/*.repo ; do
|
|||
done
|
||||
install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/bootstrap_admin_node.sh %{buildroot}%{_sbindir}/bootstrap_admin_node.sh
|
||||
install -D -p -m 755 %{_builddir}/%{name}-%{version}/iso/fix_default_repos.py %{buildroot}%{_sbindir}/fix_default_repos.py
|
||||
install -D -p -m 755 %{_builddir}/%{name}-%{version}/fuel-release/override_rpm_repos.py %{buildroot}%{_sbindir}/override_rpm_repos.py
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
@ -65,6 +66,8 @@ Release: %{release}
|
|||
License: GPLv2
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
|
||||
URL: http://github.com/Mirantis
|
||||
Requires: python
|
||||
Requires: PyYAML >= 3.10
|
||||
|
||||
%description -n fuel-release
|
||||
This packages provides /etc/fuel_release file
|
||||
|
@ -73,11 +76,18 @@ and Yum configuration for Fuel online repositories.
|
|||
%files -n fuel-release
|
||||
%defattr(-,root,root)
|
||||
%{_sysconfdir}/fuel_release
|
||||
%{_sbindir}/override_rpm_repos.py
|
||||
%config(noreplace) %attr(0644,root,root) /etc/yum/vars/fuelver
|
||||
%config(noreplace) %attr(0644,root,root) /etc/yum.repos.d/*
|
||||
%dir /etc/pki/fuel-gpg
|
||||
/etc/pki/fuel-gpg/*
|
||||
|
||||
%post -n fuel-release
|
||||
if [[ -f /root/override_rpm_repos.yaml ]]; then
|
||||
rm -f /etc/yum.repos.d/*.repo
|
||||
override_rpm_repos.py --repositories-file /root/override_rpm_repos.yaml --output-file /etc/yum.repos.d/overriden.repo
|
||||
fi
|
||||
|
||||
%package -n fuel-setup
|
||||
|
||||
Summary: Fuel deployment script package
|
||||
|
|
Loading…
Reference in New Issue