Merge lp:~ralsina/tanuki-agent/separate-provkit into lp:tanuki-agent

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 133
Merged at revision: 133
Proposed branch: lp:~ralsina/tanuki-agent/separate-provkit
Merge into: lp:tanuki-agent
Diff against target: 91 lines (+28/-7)
3 files modified
README.rst (+8/-0)
agent.py (+16/-6)
test_agent.py (+4/-1)
To merge this branch: bzr merge lp:~ralsina/tanuki-agent/separate-provkit
Reviewer Review Type Date Requested Status
Bret Barker (community) Approve
Review via email: mp+275890@code.launchpad.net

Commit message

Support having the prov kit commands in a separate [provkit] section.

Description of the change

Support having the prov kit commands in a separate [provkit] section.

This is backwards compatible, prints a warning to suggest you update your config file.

To post a comment you must log in.
Revision history for this message
Bret Barker (noise) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.rst'
2--- README.rst 2015-10-15 18:22:41 +0000
3+++ README.rst 2015-10-27 17:16:29 +0000
4@@ -52,6 +52,14 @@
5 Release Notes
6 =============
7
8+October 27 2015
9+---------------
10+
11+* The provisioning kit commands in the configuration file should be moved into
12+ a separate [provkit] section. Currently the agent will warn if they are still
13+ in the [config] section. For backwards compatibility, the old usage is still
14+ supported.
15+
16 October 15 2015
17 ---------------
18
19
20=== modified file 'agent.py'
21--- agent.py 2015-10-21 13:02:11 +0000
22+++ agent.py 2015-10-27 17:16:29 +0000
23@@ -54,9 +54,6 @@
24 'id': 'agent-queue',
25 'group': 'default',
26 'interval': 10,
27- 'provcommand': "/bin/echo provisioning now",
28- 'setupcommand': "/bin/echo setting up now",
29- 'testcommand': "/bin/echo -e '{\"foo\": \"bar\"}' > spi_test_result.json \\\c",
30 'logging_basedir': os.path.join(os.path.dirname(__file__), 'logs'),
31 'execution_basedir': os.path.join(os.path.dirname(__file__), 'run'),
32 'organization_id': '',
33@@ -64,6 +61,11 @@
34 'network_timeout': 10,
35 }
36
37+DEFAULT_COMMANDS = {
38+ 'provcommand': "/bin/echo provisioning now",
39+ 'setupcommand': "/bin/echo setting up now",
40+ 'testcommand': "/bin/echo -e '{\"foo\": \"bar\"}' > spi_test_result.json \\\c",
41+}
42
43 if 'BuiltinImporter' in str(__loader__):
44 nuitka = True
45@@ -126,12 +128,19 @@
46 'config', 'network_timeout', fallback=DEFAULT_CONFIG['network_timeout'])
47 self.server = self.config.get('config', 'server', fallback=DEFAULT_CONFIG['server'])
48
49+ if not self.config.has_section('provkit'):
50+ self.log.warning('Deprecation: The provisioning kit commands '
51+ 'should be moved to the [provkit] section.')
52+
53 self.testcommand = self.config.get(
54- 'config', 'testcommand', fallback=DEFAULT_CONFIG['testcommand'])
55+ 'provkit', 'testcommand', fallback=self.config.get(
56+ 'config', 'testcommand', fallback=DEFAULT_COMMANDS['testcommand']))
57 self.setupcommand = self.config.get(
58- 'config', 'setupcommand', fallback=DEFAULT_CONFIG['setupcommand'])
59+ 'provkit', 'setupcommand', fallback=self.config.get(
60+ 'config', 'setupcommand', fallback=DEFAULT_COMMANDS['setupcommand']))
61 self.provcommand = self.config.get(
62- 'config', 'provcommand', fallback=DEFAULT_CONFIG['provcommand'])
63+ 'provkit', 'provcommand', fallback=self.config.get(
64+ 'config', 'provcommand', fallback=DEFAULT_COMMANDS['provcommand']))
65
66 if 'auth' in self.config: # Has authentication configured
67 self.auth_data = {
68@@ -177,6 +186,7 @@
69 self.config = ConfigParser()
70 self.config['config'] = DEFAULT_CONFIG
71 self.config['environment'] = {}
72+ self.config['provkit'] = DEFAULT_COMMANDS
73 if self.confpath is None:
74 self.config.write(sys.stdout)
75 else:
76
77=== modified file 'test_agent.py'
78--- test_agent.py 2015-10-15 18:22:41 +0000
79+++ test_agent.py 2015-10-27 17:16:29 +0000
80@@ -452,7 +452,10 @@
81 """Test that it prints default config."""
82 agent.confpath = None
83 agent.do_default_config()
84- assert '[config]' in capsys.readouterr()[0]
85+ data = capsys.readouterr()[0]
86+ assert '[config]' in data
87+ assert '[provkit]' in data
88+ assert '[environment]' in data
89
90
91 def test_verbose(agent):

Subscribers

People subscribed via source and target branches

to all changes: