summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-12 13:06:49 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-12 13:06:49 -0400
commit03c81fdcf924da8b87fd690761d4ce2fbd47854e (patch)
tree88f22f94e2ea940eb120f70d47ee5d579ce5f01c /cloudinit/config
parent5cfe3d6fa2d50a68f9b6c7ceb4b9d5db09687782 (diff)
parent578fed15061293ce421eec1c9c1e2e056631a734 (diff)
downloadvyos-cloud-init-03c81fdcf924da8b87fd690761d4ce2fbd47854e.tar.gz
vyos-cloud-init-03c81fdcf924da8b87fd690761d4ce2fbd47854e.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.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/cloudinit/config/cc_rh_subscription.py b/cloudinit/config/cc_rh_subscription.py
index 6087c45c..3a113aea 100644
--- a/cloudinit/config/cc_rh_subscription.py
+++ b/cloudinit/config/cc_rh_subscription.py
@@ -19,10 +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_registered:
+ if not sm.is_configured():
+ log.debug("%s: module not configured.", name)
+ return None
+
+ if not sm.is_registered():
try:
verify, verify_msg = sm._verify_keys()
if verify is not True:
@@ -95,7 +99,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 +137,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 +403,6 @@ class SubscriptionManager(object):
self.log.debug("Disabled the following repos: %s" %
(", ".join(disable_list)).replace('--disable=', ''))
return True
+
+ def is_configured(self):
+ return bool((self.userid and self.password) or self.activation_key)