forked from pool/cloud-init
Accepting request 443055 from home:kukuk:branches:Cloud:Tools
- Fix datasourceLocalDisk module in case directory exists but is empty. - Add Conflicts for otherproviders of cloud-init-config. - Add require for python-six (used by several modules) - Add LocalDisk datasource [FATE#321107] - Reworked zypp_add_repos.diff to behave similar to zypper ar - Move cloud.cfg into an own sub-package, so that we can have a product specific version. [FATE#322039] OBS-URL: https://build.opensuse.org/request/show/443055 OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=67
This commit is contained in:
parent
a8ad7745b2
commit
1609354cf9
@ -1,3 +1,31 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Dec 1 12:31:09 CET 2016 - kukuk@suse.de
|
||||||
|
|
||||||
|
- Fix datasourceLocalDisk module in case directory exists but is
|
||||||
|
empty.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 30 08:48:11 UTC 2016 - kukuk@suse.com
|
||||||
|
|
||||||
|
- Add Conflicts for otherproviders of cloud-init-config.
|
||||||
|
- Add require for python-six (used by several modules)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Nov 28 07:20:13 UTC 2016 - kukuk@suse.com
|
||||||
|
|
||||||
|
- Add LocalDisk datasource [FATE#321107]
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 23 15:05:06 CET 2016 - kukuk@suse.de
|
||||||
|
|
||||||
|
- Reworked zypp_add_repos.diff to behave similar to zypper ar
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Nov 22 10:57:01 CET 2016 - kukuk@suse.de
|
||||||
|
|
||||||
|
- Move cloud.cfg into an own sub-package, so that we can have
|
||||||
|
a product specific version. [FATE#322039]
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Sun Nov 13 13:33:41 CET 2016 - kukuk@suse.de
|
Sun Nov 13 13:33:41 CET 2016 - kukuk@suse.de
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ Patch24: cloud-init-handle-no-carrier.patch
|
|||||||
Patch25: cloud-init-digital-ocean-datasource.patch
|
Patch25: cloud-init-digital-ocean-datasource.patch
|
||||||
Patch26: cloud-init-digital-ocean-datasource-enable-by-default.patch
|
Patch26: cloud-init-digital-ocean-datasource-enable-by-default.patch
|
||||||
Patch27: cloud-init-sysconfig-netpathfix.patch
|
Patch27: cloud-init-sysconfig-netpathfix.patch
|
||||||
Patch28: zypp_add_repos.diff
|
Patch28: zypp_add_repos.diff
|
||||||
|
Patch29: datasourceLocalDisk.patch
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: filesystem
|
BuildRequires: filesystem
|
||||||
BuildRequires: python-devel
|
BuildRequires: python-devel
|
||||||
@ -92,9 +93,11 @@ Requires: python-pyserial
|
|||||||
Requires: python-PyYAML
|
Requires: python-PyYAML
|
||||||
Requires: python-requests
|
Requires: python-requests
|
||||||
Requires: python-setuptools
|
Requires: python-setuptools
|
||||||
|
Requires: python-six
|
||||||
Requires: python-xml
|
Requires: python-xml
|
||||||
Requires: sudo
|
Requires: sudo
|
||||||
Requires: util-linux
|
Requires: util-linux
|
||||||
|
Requires: cloud-init-config
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
%define docdir %{_defaultdocdir}/%{name}
|
%define docdir %{_defaultdocdir}/%{name}
|
||||||
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
|
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
|
||||||
@ -134,6 +137,16 @@ Requires: sysconfig-network
|
|||||||
Cloud-init is an init script that initializes a cloud node (VM)
|
Cloud-init is an init script that initializes a cloud node (VM)
|
||||||
according to the fetched configuration data from the admin node.
|
according to the fetched configuration data from the admin node.
|
||||||
|
|
||||||
|
%package config-suse
|
||||||
|
Summary: Configuration file for Cloud node initialization tool
|
||||||
|
Requires: cloud-init = %{version}
|
||||||
|
Provides: cloud-init-config
|
||||||
|
Conflicts: otherproviders(cloud-init-config)
|
||||||
|
|
||||||
|
%description config-suse
|
||||||
|
This package contains the product specific configuration file
|
||||||
|
for cloud-init.
|
||||||
|
|
||||||
%package doc
|
%package doc
|
||||||
Summary: Cloud node initialization tool - Documentation
|
Summary: Cloud node initialization tool - Documentation
|
||||||
Group: System/Management
|
Group: System/Management
|
||||||
@ -178,6 +191,7 @@ Unit tests for the cloud-init tools
|
|||||||
%patch26 -p1
|
%patch26 -p1
|
||||||
%patch27
|
%patch27
|
||||||
%patch28 -p0
|
%patch28 -p0
|
||||||
|
%patch29 -p0
|
||||||
|
|
||||||
%if 0%{?suse_version} <= 1130
|
%if 0%{?suse_version} <= 1130
|
||||||
# disable ecdsa for SLE 11 (not available)
|
# disable ecdsa for SLE 11 (not available)
|
||||||
@ -268,7 +282,9 @@ popd
|
|||||||
%{docdir}/LICENSE
|
%{docdir}/LICENSE
|
||||||
%{_bindir}/cloud-init
|
%{_bindir}/cloud-init
|
||||||
%{_bindir}/cloud-init-per
|
%{_bindir}/cloud-init-per
|
||||||
%config(noreplace) %{_sysconfdir}/cloud/
|
%dir %{_sysconfdir}/cloud
|
||||||
|
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d
|
||||||
|
%config(noreplace) %{_sysconfdir}/cloud/templates
|
||||||
%{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
|
%{_sysconfdir}/dhcp/dhclient-exit-hooks.d/hook-dhclient
|
||||||
%{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
|
%{_sysconfdir}/NetworkManager/dispatcher.d/hook-network-manager
|
||||||
%{python_sitelib}/cloudinit
|
%{python_sitelib}/cloudinit
|
||||||
@ -309,7 +325,9 @@ popd
|
|||||||
%dir /etc/dhcp
|
%dir /etc/dhcp
|
||||||
%dir /etc/dhcp/dhclient-exit-hooks.d
|
%dir /etc/dhcp/dhclient-exit-hooks.d
|
||||||
|
|
||||||
|
%files config-suse
|
||||||
|
%defattr(-,root,root)
|
||||||
|
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg
|
||||||
|
|
||||||
%files doc
|
%files doc
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
|
104
datasourceLocalDisk.patch
Normal file
104
datasourceLocalDisk.patch
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
--- cloudinit/sources/DataSourceLocalDisk.py 2016/11/25 19:01:00 1.1
|
||||||
|
+++ cloudinit/sources/DataSourceLocalDisk.py 2016/11/26 20:42:02
|
||||||
|
@@ -0,0 +1,101 @@
|
||||||
|
+# vi: ts=4 expandtab
|
||||||
|
+#
|
||||||
|
+# Copyright (C) 2016 SUSE Linux GmbH
|
||||||
|
+#
|
||||||
|
+# Author: Thorsten Kukuk <kukuk@suse.com>
|
||||||
|
+#
|
||||||
|
+# This program is free software: you can redistribute it and/or modify
|
||||||
|
+# it under the terms of the GNU General Public License version 3, as
|
||||||
|
+# published by the Free Software Foundation.
|
||||||
|
+#
|
||||||
|
+# This program is distributed in the hope that it will be useful,
|
||||||
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
+# GNU General Public License for more details.
|
||||||
|
+#
|
||||||
|
+# You should have received a copy of the GNU General Public License
|
||||||
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
+
|
||||||
|
+import os
|
||||||
|
+
|
||||||
|
+from cloudinit import log as logging
|
||||||
|
+from cloudinit import sources
|
||||||
|
+from cloudinit import util
|
||||||
|
+
|
||||||
|
+LOG = logging.getLogger(__name__)
|
||||||
|
+
|
||||||
|
+DEFAULT_IID = "iid-localdisk"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+class DataSourceLocalDisk(sources.DataSource):
|
||||||
|
+ def __init__(self, sys_cfg, distro, paths):
|
||||||
|
+ sources.DataSource.__init__(self, sys_cfg, distro, paths)
|
||||||
|
+ self.seed = None
|
||||||
|
+ self.seed_dir = os.path.join(paths.seed_dir, 'localdisk')
|
||||||
|
+
|
||||||
|
+ def __str__(self):
|
||||||
|
+ root = sources.DataSource.__str__(self)
|
||||||
|
+ return "%s [seed=%s][dsmode=%s]" % (root, self.seed, self.dsmode)
|
||||||
|
+
|
||||||
|
+ def get_data(self):
|
||||||
|
+ if not os.path.isdir('/cloud-init-config')
|
||||||
|
+ return False
|
||||||
|
+
|
||||||
|
+ defaults = {"instance-id": DEFAULT_IID}
|
||||||
|
+
|
||||||
|
+ found = []
|
||||||
|
+ mydata = {'meta-data': {}, 'user-data': "", 'vendor-data': ""}
|
||||||
|
+
|
||||||
|
+ # Check to see if the seed dir has data.
|
||||||
|
+ try:
|
||||||
|
+ seeded = util.pathprefix2dict(self.seed_dir, ['user-data','meta-data'],['vendor-data'])
|
||||||
|
+ found.append(self.seed_dir)
|
||||||
|
+ mydata = _merge_new_seed(mydata, seeded)
|
||||||
|
+ except ValueError as e:
|
||||||
|
+ pass
|
||||||
|
+
|
||||||
|
+ try:
|
||||||
|
+ seeded = util.pathprefix2dict('/cloud-init-config', ['user-data','meta-data'],['vendor-data'])
|
||||||
|
+ found.append('/cloud-init-config')
|
||||||
|
+ mydata = _merge_new_seed(mydata, seeded)
|
||||||
|
+ except ValueError as e:
|
||||||
|
+ return False
|
||||||
|
+
|
||||||
|
+ # Merge in the defaults
|
||||||
|
+ mydata['meta-data'] = util.mergemanydict([mydata['meta-data'],
|
||||||
|
+ defaults])
|
||||||
|
+
|
||||||
|
+ self.seed = ",".join(found)
|
||||||
|
+ self.metadata = mydata['meta-data']
|
||||||
|
+ self.userdata_raw = mydata['user-data']
|
||||||
|
+ self.vendordata_raw = mydata['vendor-data']
|
||||||
|
+ return True
|
||||||
|
+
|
||||||
|
+ def check_instance_id(self, sys_cfg):
|
||||||
|
+ # quickly (local check only) if self.instance_id is still valid
|
||||||
|
+ return sources.instance_id_matches_system_uuid(self.get_instance_id())
|
||||||
|
+
|
||||||
|
+def _merge_new_seed(cur, seeded):
|
||||||
|
+ ret = cur.copy()
|
||||||
|
+
|
||||||
|
+ newmd = seeded.get('meta-data', {})
|
||||||
|
+ if not isinstance(seeded['meta-data'], dict):
|
||||||
|
+ newmd = util.load_yaml(seeded['meta-data'])
|
||||||
|
+ ret['meta-data'] = util.mergemanydict([cur['meta-data'], newmd])
|
||||||
|
+
|
||||||
|
+ if 'user-data' in seeded:
|
||||||
|
+ ret['user-data'] = seeded['user-data']
|
||||||
|
+ if 'vendor-data' in seeded:
|
||||||
|
+ ret['vendor-data'] = seeded['vendor-data']
|
||||||
|
+ return ret
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+# Used to match classes to dependencies
|
||||||
|
+datasources = [
|
||||||
|
+ (DataSourceLocalDisk, (sources.DEP_FILESYSTEM, )),
|
||||||
|
+]
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+# Return a list of data sources that match this set of dependencies
|
||||||
|
+def get_datasource_list(depends):
|
||||||
|
+ return sources.list_from_depends(depends, datasources)
|
@ -1,9 +1,13 @@
|
|||||||
--- cloudinit/config/cc_zypp_add_repo.py
|
--- cloudinit/config/cc_zypp_add_repo.py
|
||||||
+++ cloudinit/config/cc_zypp_add_repo.py 2016/11/13 16:56:21
|
+++ cloudinit/config/cc_zypp_add_repo.py 2016/11/23 13:10:49
|
||||||
@@ -0,0 +1,106 @@
|
@@ -0,0 +1,112 @@
|
||||||
+# vi: ts=4 expandtab
|
+# vi: ts=4 expandtab
|
||||||
+#
|
+#
|
||||||
+# This file is based on cc_yum_add_repo.py:
|
+# Copyright (C) 2016 SUSE LLC.
|
||||||
|
+# This file is based on cc_yum_add_repo.py and was rewritten by
|
||||||
|
+# Thorsten Kukuk <kukuk@suse.com> for zypp repos.
|
||||||
|
+#
|
||||||
|
+# Original file was:
|
||||||
+#
|
+#
|
||||||
+# Copyright (C) 2012 Yahoo! Inc.
|
+# Copyright (C) 2012 Yahoo! Inc.
|
||||||
+#
|
+#
|
||||||
@ -56,7 +60,6 @@
|
|||||||
+ # of zypper repos and don't verify keys/values further
|
+ # of zypper repos and don't verify keys/values further
|
||||||
+ to_be[repo_id][k] = _format_repo_value(v)
|
+ to_be[repo_id][k] = _format_repo_value(v)
|
||||||
+ lines = to_be.write()
|
+ lines = to_be.write()
|
||||||
+ lines.insert(0, "# Created by cloud-init on %s" % (util.time_rfc2822()))
|
|
||||||
+ return "\n".join(lines)
|
+ return "\n".join(lines)
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
@ -77,7 +80,7 @@
|
|||||||
+ log.info("Skipping repo %s, file %s already exists!",
|
+ log.info("Skipping repo %s, file %s already exists!",
|
||||||
+ repo_id, repo_fn_pth)
|
+ repo_id, repo_fn_pth)
|
||||||
+ continue
|
+ continue
|
||||||
+ elif canon_repo_id in repo_locations:
|
+ elif repo_id in repo_locations:
|
||||||
+ log.info("Skipping repo %s, file %s already pending!",
|
+ log.info("Skipping repo %s, file %s already pending!",
|
||||||
+ repo_id, repo_fn_pth)
|
+ repo_id, repo_fn_pth)
|
||||||
+ continue
|
+ continue
|
||||||
@ -97,9 +100,12 @@
|
|||||||
+ " configuration 'required' entry"),
|
+ " configuration 'required' entry"),
|
||||||
+ repo_id, req_field)
|
+ repo_id, req_field)
|
||||||
+ missing_required += 1
|
+ missing_required += 1
|
||||||
|
+ for field in ['enabled', 'autorefresh']:
|
||||||
|
+ if field not in repo_config:
|
||||||
|
+ repo_config[field] = '1'
|
||||||
+ if not missing_required:
|
+ if not missing_required:
|
||||||
+ repo_configs[canon_repo_id] = repo_config
|
+ repo_configs[repo_id] = repo_config
|
||||||
+ repo_locations[canon_repo_id] = repo_fn_pth
|
+ repo_locations[repo_id] = repo_fn_pth
|
||||||
+ else:
|
+ else:
|
||||||
+ log.warn("Repository %s is missing %s required fields, skipping!",
|
+ log.warn("Repository %s is missing %s required fields, skipping!",
|
||||||
+ repo_id, missing_required)
|
+ repo_id, missing_required)
|
||||||
@ -108,23 +114,23 @@
|
|||||||
+ repo_configs.get(c_repo_id))
|
+ repo_configs.get(c_repo_id))
|
||||||
+ util.write_file(path, repo_blob)
|
+ util.write_file(path, repo_blob)
|
||||||
--- doc/examples/cloud-config-zypp-repo.txt
|
--- doc/examples/cloud-config-zypp-repo.txt
|
||||||
+++ doc/examples/cloud-config-zypp-repo.txt 2016/11/13 17:04:12
|
+++ doc/examples/cloud-config-zypp-repo.txt 2016/11/23 12:59:42
|
||||||
@@ -0,0 +1,18 @@
|
@@ -0,0 +1,18 @@
|
||||||
+#cloud-config
|
+#cloud-config
|
||||||
+# vim: syntax=yaml
|
+# vim: syntax=yaml
|
||||||
+#
|
+#
|
||||||
+# Add zypper repository configuration to the system
|
+# Add zypper repository configuration to the system
|
||||||
+#
|
+#
|
||||||
+# The following example adds the file /etc/zypp/repos.d/EPEL_TESTING.repo
|
+# The following example adds the file /etc/zypp/repos.d/Test_Repo.repo
|
||||||
+# which can then subsequently be used by zypper for later operations.
|
+# which can then subsequently be used by zypper for later operations.
|
||||||
+zypp_repos:
|
+zypp_repos:
|
||||||
+ # The name of the repository
|
+ # The name of the repository
|
||||||
+ EPEL_Testing:
|
+ "Test Repo":
|
||||||
+ # Any repository configuration options
|
+ # Any repository configuration options
|
||||||
+ name: Extra Packages for Testing
|
+ name: Extra Packages for Testing
|
||||||
+ enabled: true
|
+ enabled: true
|
||||||
+ autorefresh: true
|
+ autorefresh: true
|
||||||
+ keeppackages: false
|
+ keeppackages: false
|
||||||
+ baseurl: http://download.example.com/ibs/EPEL/1.0/standard/
|
+ baseurl: http://download.example.com/ibs/TEST/1.0/standard/
|
||||||
+ gpgcheck: true
|
+ gpgcheck: true
|
||||||
+ gpgkey: http://download.example.com/ibs/EPEL/1.0/standard/repodata/repomd.xml.key
|
+ gpgkey: http://download.example.com/ibs/TEST/1.0/standard/repodata/repomd.xml.key
|
||||||
|
Loading…
Reference in New Issue
Block a user