summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-06 13:27:23 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-06 13:27:23 -0400
commiteb5a4dda1fc221bf29c45eef47f0bfadec250943 (patch)
treea1c44d4cc521ba94dac2d61c23fc9cb40c639da0 /cloudinit/config
parentd75a912fb375afbab055db3178966d1f83b44143 (diff)
downloadvyos-cloud-init-eb5a4dda1fc221bf29c45eef47f0bfadec250943.tar.gz
vyos-cloud-init-eb5a4dda1fc221bf29c45eef47f0bfadec250943.zip
rh_subscription: only check subscription if configured
The rh_subscription config module would attempt to connect to the RHN servers even when no config is provided. Now, instead check to make sure that valid config is provided first. That consists of username and password or a activation key. LP: #1536706
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_rh_subscription.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index 6087c45c..2871984a 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -19,9 +19,14 @@
from cloudinit import util
-def handle(_name, cfg, _cloud, log, _args):
+def handle(name, cfg, _cloud, log, _args):
sm = SubscriptionManager(cfg)
sm.log = log
+ if not sm.is_configured():
+ log.debug("Activation key not provided, config module %s disabled.",
+ _name)
+ return None
+
if not sm.is_registered:
try:
verify, verify_msg = sm._verify_keys()
@@ -95,7 +100,6 @@ class SubscriptionManager(object):
self.disable_repo = self.rhel_cfg.get('disable-repo')
self.servicelevel = self.rhel_cfg.get('service-level')
self.subman = ['subscription-manager']
- self.is_registered = self._is_registered()
def log_success(self, msg):
'''Simple wrapper for logging info messages. Useful for unittests'''
@@ -134,7 +138,7 @@ class SubscriptionManager(object):
return False, no_auto
return True, None
- def _is_registered(self):
+ def is_registered(self):
'''
Checks if the system is already registered and returns
True if so, else False
@@ -400,3 +404,6 @@ class SubscriptionManager(object):
self.log.debug("Disabled the following repos: %s" %
(", ".join(disable_list)).replace('--disable=', ''))
return True
+
+ def is_configured(self):
+ return (self.userid and self.password) or self.activation_key