summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_apt_configure.py
diff options
context:
space:
mode:
authorJoshua Powers <josh.powers@canonical.com>2017-04-27 14:31:48 -0600
committerScott Moser <smoser@brickies.net>2017-05-16 16:19:29 -0400
commit6edf0c72ce11e64627d3db6a0c4fd74a81039ed4 (patch)
treee0c41413f63e8cd9589a45f9ac2406bf5e09d9ba /cloudinit/config/cc_apt_configure.py
parent4bcc947301bedc5ebf430cfaf6e4597bfb174aa7 (diff)
downloadvyos-cloud-init-6edf0c72ce11e64627d3db6a0c4fd74a81039ed4.tar.gz
vyos-cloud-init-6edf0c72ce11e64627d3db6a0c4fd74a81039ed4.zip
unittests: fix unittests run on centos
Apt related tests were broken when running on centos becasue apt is not available. This fixes the unit test, with a small re-work of apt_configure. Also in 'tox -e centos6' only run nose on tests/unittests as tests/ also contain integration tests that should not be run.
Diffstat (limited to 'cloudinit/config/cc_apt_configure.py')
-rw-r--r--cloudinit/config/cc_apt_configure.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/cloudinit/config/cc_apt_configure.py b/cloudinit/config/cc_apt_configure.py
index f6885d7c..177cbcf7 100644
--- a/cloudinit/config/cc_apt_configure.py
+++ b/cloudinit/config/cc_apt_configure.py
@@ -282,16 +282,21 @@ def handle(name, ocfg, cloud, log, _):
apply_apt(cfg, cloud, target)
+def _should_configure_on_empty_apt():
+ # if no config was provided, should apt configuration be done?
+ if util.system_is_snappy():
+ return False, "system is snappy."
+ if not (util.which('apt-get') or util.which('apt')):
+ return False, "no apt commands."
+ return True, "Apt is available."
+
+
def apply_apt(cfg, cloud, target):
# cfg is the 'apt' top level dictionary already in 'v3' format.
if not cfg:
- # no config was provided. If apt configuration does not seem
- # necessary on this system, then return.
- if util.system_is_snappy():
- LOG.debug("Nothing to do: No apt config and running on snappy")
- return
- if not (util.which('apt-get') or util.which('apt')):
- LOG.debug("Nothing to do: No apt config and no apt commands")
+ should_config, msg = _should_configure_on_empty_apt()
+ if not should_config:
+ LOG.debug("Nothing to do: No apt config and %s", msg)
return
LOG.debug("handling apt config: %s", cfg)