summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_ca_certs.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-21 17:36:09 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-21 17:36:09 -0700
commit421556807fe27e6443c67410634f8a05ab84fc37 (patch)
tree7074d4c0236ee287722fcd525ee9064141b4b4b4 /cloudinit/config/cc_ca_certs.py
parent155fa982b895b70572857ab25a324809470d74b3 (diff)
downloadvyos-cloud-init-421556807fe27e6443c67410634f8a05ab84fc37.tar.gz
vyos-cloud-init-421556807fe27e6443c67410634f8a05ab84fc37.zip
Testing is easier if we just pass the paths object, instead of the full cloud object here.
Diffstat (limited to 'cloudinit/config/cc_ca_certs.py')
-rw-r--r--cloudinit/config/cc_ca_certs.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/cloudinit/config/cc_ca_certs.py b/cloudinit/config/cc_ca_certs.py
index 3221a587..266a2d84 100644
--- a/cloudinit/config/cc_ca_certs.py
+++ b/cloudinit/config/cc_ca_certs.py
@@ -33,7 +33,7 @@ def update_ca_certs():
util.subp(["update-ca-certificates"])
-def add_ca_certs(cloud, certs):
+def add_ca_certs(paths, certs):
"""
Adds certificates to the system. To actually apply the new certificates
you must also call L{update_ca_certs}.
@@ -44,21 +44,21 @@ def add_ca_certs(cloud, certs):
# First ensure they are strings...
cert_file_contents = "\n".join([str(c) for c in certs])
cert_file_fullpath = os.path.join(CA_CERT_PATH, CA_CERT_FILENAME)
- cert_file_fullpath = cloud.paths.join(False, cert_file_fullpath)
+ cert_file_fullpath = paths.join(False, cert_file_fullpath)
util.write_file(cert_file_fullpath, cert_file_contents, mode=0644)
# Append cert filename to CA_CERT_CONFIG file.
- util.write_file(cloud.paths.join(False, CA_CERT_CONFIG),
+ util.write_file(paths.join(False, CA_CERT_CONFIG),
"\n%s" % CA_CERT_FILENAME, omode="ab")
-def remove_default_ca_certs(cloud):
+def remove_default_ca_certs(paths):
"""
Removes all default trusted CA certificates from the system. To actually
apply the change you must also call L{update_ca_certs}.
"""
- util.delete_dir_contents(cloud.paths.join(False, CA_CERT_PATH))
- util.delete_dir_contents(cloud.paths.join(False, CA_CERT_SYSTEM_PATH))
- util.write_file(cloud.paths.join(False, CA_CERT_CONFIG), "", mode=0644)
+ util.delete_dir_contents(paths.join(False, CA_CERT_PATH))
+ util.delete_dir_contents(paths.join(False, CA_CERT_SYSTEM_PATH))
+ util.write_file(paths.join(False, CA_CERT_CONFIG), "", mode=0644)
debconf_sel = "ca-certificates ca-certificates/trust_new_crts select no"
util.subp(('debconf-set-selections', '-'), debconf_sel)
@@ -85,14 +85,14 @@ def handle(name, cfg, cloud, log, _args):
# default trusted CA certs first.
if ca_cert_cfg.get("remove-defaults", False):
log.debug("Removing default certificates")
- remove_default_ca_certs(cloud)
+ remove_default_ca_certs(cloud.paths)
# If we are given any new trusted CA certs to add, add them.
if "trusted" in ca_cert_cfg:
trusted_certs = util.get_cfg_option_list(ca_cert_cfg, "trusted")
if trusted_certs:
log.debug("Adding %d certificates" % len(trusted_certs))
- add_ca_certs(cloud, trusted_certs)
+ add_ca_certs(cloud.paths, trusted_certs)
# Update the system with the new cert configuration.
log.debug("Updating certificates")