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
=== modified file 'README.rst'
--- README.rst 2015-10-15 18:22:41 +0000
+++ README.rst 2015-10-27 17:16:29 +0000
@@ -52,6 +52,14 @@
52Release Notes52Release Notes
53=============53=============
5454
55October 27 2015
56---------------
57
58* The provisioning kit commands in the configuration file should be moved into
59 a separate [provkit] section. Currently the agent will warn if they are still
60 in the [config] section. For backwards compatibility, the old usage is still
61 supported.
62
55October 15 201563October 15 2015
56---------------64---------------
5765
5866
=== modified file 'agent.py'
--- agent.py 2015-10-21 13:02:11 +0000
+++ agent.py 2015-10-27 17:16:29 +0000
@@ -54,9 +54,6 @@
54 'id': 'agent-queue',54 'id': 'agent-queue',
55 'group': 'default',55 'group': 'default',
56 'interval': 10,56 'interval': 10,
57 'provcommand': "/bin/echo provisioning now",
58 'setupcommand': "/bin/echo setting up now",
59 'testcommand': "/bin/echo -e '{\"foo\": \"bar\"}' > spi_test_result.json \\\c",
60 'logging_basedir': os.path.join(os.path.dirname(__file__), 'logs'),57 'logging_basedir': os.path.join(os.path.dirname(__file__), 'logs'),
61 'execution_basedir': os.path.join(os.path.dirname(__file__), 'run'),58 'execution_basedir': os.path.join(os.path.dirname(__file__), 'run'),
62 'organization_id': '',59 'organization_id': '',
@@ -64,6 +61,11 @@
64 'network_timeout': 10,61 'network_timeout': 10,
65}62}
6663
64DEFAULT_COMMANDS = {
65 'provcommand': "/bin/echo provisioning now",
66 'setupcommand': "/bin/echo setting up now",
67 'testcommand': "/bin/echo -e '{\"foo\": \"bar\"}' > spi_test_result.json \\\c",
68}
6769
68if 'BuiltinImporter' in str(__loader__):70if 'BuiltinImporter' in str(__loader__):
69 nuitka = True71 nuitka = True
@@ -126,12 +128,19 @@
126 'config', 'network_timeout', fallback=DEFAULT_CONFIG['network_timeout'])128 'config', 'network_timeout', fallback=DEFAULT_CONFIG['network_timeout'])
127 self.server = self.config.get('config', 'server', fallback=DEFAULT_CONFIG['server'])129 self.server = self.config.get('config', 'server', fallback=DEFAULT_CONFIG['server'])
128130
131 if not self.config.has_section('provkit'):
132 self.log.warning('Deprecation: The provisioning kit commands '
133 'should be moved to the [provkit] section.')
134
129 self.testcommand = self.config.get(135 self.testcommand = self.config.get(
130 'config', 'testcommand', fallback=DEFAULT_CONFIG['testcommand'])136 'provkit', 'testcommand', fallback=self.config.get(
137 'config', 'testcommand', fallback=DEFAULT_COMMANDS['testcommand']))
131 self.setupcommand = self.config.get(138 self.setupcommand = self.config.get(
132 'config', 'setupcommand', fallback=DEFAULT_CONFIG['setupcommand'])139 'provkit', 'setupcommand', fallback=self.config.get(
140 'config', 'setupcommand', fallback=DEFAULT_COMMANDS['setupcommand']))
133 self.provcommand = self.config.get(141 self.provcommand = self.config.get(
134 'config', 'provcommand', fallback=DEFAULT_CONFIG['provcommand'])142 'provkit', 'provcommand', fallback=self.config.get(
143 'config', 'provcommand', fallback=DEFAULT_COMMANDS['provcommand']))
135144
136 if 'auth' in self.config: # Has authentication configured145 if 'auth' in self.config: # Has authentication configured
137 self.auth_data = {146 self.auth_data = {
@@ -177,6 +186,7 @@
177 self.config = ConfigParser()186 self.config = ConfigParser()
178 self.config['config'] = DEFAULT_CONFIG187 self.config['config'] = DEFAULT_CONFIG
179 self.config['environment'] = {}188 self.config['environment'] = {}
189 self.config['provkit'] = DEFAULT_COMMANDS
180 if self.confpath is None:190 if self.confpath is None:
181 self.config.write(sys.stdout)191 self.config.write(sys.stdout)
182 else:192 else:
183193
=== modified file 'test_agent.py'
--- test_agent.py 2015-10-15 18:22:41 +0000
+++ test_agent.py 2015-10-27 17:16:29 +0000
@@ -452,7 +452,10 @@
452 """Test that it prints default config."""452 """Test that it prints default config."""
453 agent.confpath = None453 agent.confpath = None
454 agent.do_default_config()454 agent.do_default_config()
455 assert '[config]' in capsys.readouterr()[0]455 data = capsys.readouterr()[0]
456 assert '[config]' in data
457 assert '[provkit]' in data
458 assert '[environment]' in data
456459
457460
458def test_verbose(agent):461def test_verbose(agent):

Subscribers

People subscribed via source and target branches

to all changes: