Merge lp:~smoser/cloud-init/trunk.1536706 into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Scott Moser on 2016-04-12
Status: Merged
Merged at revision: 1205
Proposed branch: lp:~smoser/cloud-init/trunk.1536706
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 71 lines (+17/-6)
2 files modified
cloudinit/config/cc_rh_subscription.py (+10/-4)
tests/unittests/test_rh_subscription.py (+7/-2)
To merge this branch: bzr merge lp:~smoser/cloud-init/trunk.1536706
Reviewer Review Type Date Requested Status
cloud-init Commiters 2016-04-12 Pending
Review via email: mp+291656@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/config/cc_rh_subscription.py'
2--- cloudinit/config/cc_rh_subscription.py 2016-03-04 15:51:05 +0000
3+++ cloudinit/config/cc_rh_subscription.py 2016-04-12 17:01:26 +0000
4@@ -19,10 +19,14 @@
5 from cloudinit import util
6
7
8-def handle(_name, cfg, _cloud, log, _args):
9+def handle(name, cfg, _cloud, log, _args):
10 sm = SubscriptionManager(cfg)
11 sm.log = log
12- if not sm.is_registered:
13+ if not sm.is_configured():
14+ log.debug("%s: module not configured.", name)
15+ return None
16+
17+ if not sm.is_registered():
18 try:
19 verify, verify_msg = sm._verify_keys()
20 if verify is not True:
21@@ -95,7 +99,6 @@
22 self.disable_repo = self.rhel_cfg.get('disable-repo')
23 self.servicelevel = self.rhel_cfg.get('service-level')
24 self.subman = ['subscription-manager']
25- self.is_registered = self._is_registered()
26
27 def log_success(self, msg):
28 '''Simple wrapper for logging info messages. Useful for unittests'''
29@@ -134,7 +137,7 @@
30 return False, no_auto
31 return True, None
32
33- def _is_registered(self):
34+ def is_registered(self):
35 '''
36 Checks if the system is already registered and returns
37 True if so, else False
38@@ -400,3 +403,6 @@
39 self.log.debug("Disabled the following repos: %s" %
40 (", ".join(disable_list)).replace('--disable=', ''))
41 return True
42+
43+ def is_configured(self):
44+ return bool((self.userid and self.password) or self.activation_key)
45
46=== modified file 'tests/unittests/test_rh_subscription.py'
47--- tests/unittests/test_rh_subscription.py 2015-05-29 14:18:49 +0000
48+++ tests/unittests/test_rh_subscription.py 2016-04-12 17:01:26 +0000
49@@ -126,7 +126,8 @@
50 'enable-repo': 'not_a_list'
51 }}
52 config_badkey = {'rh_subscription':
53- {'activation_key': 'abcdef1234',
54+ {'activation-key': 'abcdef1234',
55+ 'fookey': 'bar',
56 'org': '123',
57 }}
58
59@@ -138,7 +139,11 @@
60 '''
61 Attempt to register without the password key/value
62 '''
63- self.input_is_missing_data(self.config_no_password)
64+ self.SM._sub_man_cli = mock.MagicMock(
65+ side_effect=[util.ProcessExecutionError, (self.reg, 'bar')])
66+ self.handle(self.name, self.config_no_password, self.cloud_init,
67+ self.log, self.args)
68+ self.assertEqual(self.SM._sub_man_cli.call_count, 0)
69
70 def test_no_org(self):
71 '''