Merge ~hloeung/ubuntu-syncproxy-charm:master into ubuntu-syncproxy-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 11461150f6efda9033edcd4101f3d6ff99177cb3
Merged at revision: 676417cf36493a497fe1f8002ed302e7ae49c91a
Proposed branch: ~hloeung/ubuntu-syncproxy-charm:master
Merge into: ubuntu-syncproxy-charm:master
Diff against target: 227 lines (+59/-59)
3 files modified
config.yaml (+21/-21)
reactive/ubuntu_syncproxy.py (+12/-12)
tests/unit/test_ubuntu_syncproxy.py (+26/-26)
Reviewer Review Type Date Requested Status
Paul Collins lgtm Approve
Canonical IS Reviewers Pending
Review via email: mp+421799@code.launchpad.net

Commit message

Rename rsync-* configs in preparation for local rsync confs

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Paul Collins (pjdc) :
review: Approve (lgtm)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change has no commit message, setting status to needs review.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 676417cf36493a497fe1f8002ed302e7ae49c91a

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 15da353..8acc1c9 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -4,44 +4,44 @@ options:
6 default: 120
7 description: |
8 Number of days of syslog logs to retain during rotation.
9- rsync-host:
10+ sync-script:
11+ type: string
12+ default: ''
13+ description: |
14+ Sync script to trigger, see wiki page for examples.
15+ https://wiki.ubuntu.com/Mirrors/Scripts
16+ sync-user:
17+ type: string
18+ default: 'archvsync'
19+ description: |
20+ Archive sync user.
21+ sync-user-ssh-authorized-keys:
22+ type:
23+ default: ''
24+ description: |
25+ List of SSH authorized keys with triggers for sync-user.
26+ upstream-rsync-host:
27 type: string
28 default: 'archive.syncproxy.ubuntu.com'
29 description: |
30 Rsync host to sync contents from (source).
31- rsync-module:
32+ upstream-rsync-module:
33 type: string
34 default: 'ftp'
35 description: |
36 Rsync module to sync contents from (source).
37- rsync-target:
38+ upstream-rsync-target:
39 type: string
40 default: '/srv/ftp.root/ubuntu'
41 description: |
42 Target or destination directory on local host to sync to.
43- rsync-user:
44+ upstream-rsync-user:
45 type: string
46 default: 'syncproxy'
47 description: |
48 Rsync user to authenticate with rsync host.
49- rsync-password:
50+ upstream-rsync-password:
51 type: string
52 default: ''
53 description: |
54 Rsync password to authenticate with rsync host.
55- sync-script:
56- type: string
57- default: ''
58- description: |
59- Sync script to trigger, see wiki page for examples.
60- https://wiki.ubuntu.com/Mirrors/Scripts
61- sync-user:
62- type: string
63- default: 'archvsync'
64- description: |
65- Archive sync user.
66- sync-user-ssh-authorized-keys:
67- type:
68- default: ''
69- description: |
70- List of SSH authorized keys with triggers for sync-user.
71diff --git a/reactive/ubuntu_syncproxy.py b/reactive/ubuntu_syncproxy.py
72index 1041201..8d03712 100644
73--- a/reactive/ubuntu_syncproxy.py
74+++ b/reactive/ubuntu_syncproxy.py
75@@ -36,14 +36,14 @@ def install(script_dir='/usr/local/bin'):
76
77
78 @reactive.when_any(
79- 'config.changed.rsync-host',
80- 'config.changed.rsync-module',
81- 'config.changed.rsync-password',
82- 'config.changed.rsync-target',
83- 'config.changed.rsync-user',
84 'config.changed.sync-script',
85 'config.changed.sync-user',
86 'config.changed.sync-user-ssh-authorized-keys',
87+ 'config.changed.upstream-rsync-host',
88+ 'config.changed.upstream-rsync-module',
89+ 'config.changed.upstream-rsync-password',
90+ 'config.changed.upstream-rsync-target',
91+ 'config.changed.upstream-rsync-user',
92 )
93 def config_changed():
94 reactive.clear_flag('ubuntu-syncproxy.configured')
95@@ -82,21 +82,21 @@ def configure_ubuntu_syncproxy(home_path=''):
96 home_path = home_path or os.path.expanduser('~{}'.format(user))
97
98 rsync_conf = {
99- 'host': config['rsync-host'],
100- 'module': config['rsync-module'],
101- 'target': config['rsync-target'],
102- 'user': config['rsync-user'],
103- 'password': config['rsync-password'],
104+ 'host': config['upstream-rsync-host'],
105+ 'module': config['upstream-rsync-module'],
106+ 'target': config['upstream-rsync-target'],
107+ 'user': config['upstream-rsync-user'],
108+ 'password': config['upstream-rsync-password'],
109 }
110 for k in sorted(rsync_conf.keys()):
111 if not rsync_conf[k]:
112- status.blocked('Required rsync configs missing ({})'.format(k))
113+ status.blocked('Required sync rsync configs missing ({})'.format(k))
114 reactive.set_flag('ubuntu-syncproxy.configured')
115 return
116 if _setup_archive_sync_conf(rsync_conf, user, home_path):
117 status.maintenance('Wrote out updated archive sync conf (rsync)')
118
119- _setup_archive_sync_target(config['rsync-target'], user)
120+ _setup_archive_sync_target(config['upstream-rsync-target'], user)
121
122 user_ssh_keys = config['sync-user-ssh-authorized-keys']
123 if user_ssh_keys:
124diff --git a/tests/unit/test_ubuntu_syncproxy.py b/tests/unit/test_ubuntu_syncproxy.py
125index 068ebfb..5a1b43e 100644
126--- a/tests/unit/test_ubuntu_syncproxy.py
127+++ b/tests/unit/test_ubuntu_syncproxy.py
128@@ -61,14 +61,14 @@ class TestCharm(unittest.TestCase):
129 self.mock_config = patcher.start()
130 self.addCleanup(patcher.stop)
131 self.mock_config.return_value = {
132- 'rsync-host': 'ftpmaster.internal',
133- 'rsync-module': 'ftp',
134- 'rsync-user': 'syncproxy',
135- 'rsync-password': 'my-secure-rsync-password',
136- 'rsync-target': os.path.join(self.tmpdir, 'ubuntu-archive'),
137 'sync-script': '#!/bin/sh\necho "test"\n',
138 'sync-user': self.user,
139 'sync-user-ssh-authorized-keys': '',
140+ 'upstream-rsync-host': 'ftpmaster.internal',
141+ 'upstream-rsync-module': 'ftp',
142+ 'upstream-rsync-user': 'syncproxy',
143+ 'upstream-rsync-password': 'my-secure-rsync-password',
144+ 'upstream-rsync-target': os.path.join(self.tmpdir, 'ubuntu-archive'),
145 }
146
147 patcher = mock.patch('charmhelpers.core.hookenv.close_port')
148@@ -207,41 +207,41 @@ class TestCharm(unittest.TestCase):
149 @mock.patch('reactive.ubuntu_syncproxy._setup_archive_sync_conf')
150 @mock.patch('reactive.ubuntu_syncproxy._setup_archive_sync_target')
151 def test_configure_ubuntu_rsync_missing(self, setup_target, setup, set_flag, clear_flag):
152- self.mock_config.return_value['rsync-host'] = ''
153- self.mock_config.return_value['rsync-module'] = ''
154- self.mock_config.return_value['rsync-user'] = ''
155- self.mock_config.return_value['rsync-password'] = ''
156- self.mock_config.return_value['rsync-target'] = ''
157+ self.mock_config.return_value['upstream-rsync-host'] = ''
158+ self.mock_config.return_value['upstream-rsync-module'] = ''
159+ self.mock_config.return_value['upstream-rsync-user'] = ''
160+ self.mock_config.return_value['upstream-rsync-password'] = ''
161+ self.mock_config.return_value['upstream-rsync-target'] = ''
162
163 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
164- status.blocked.assert_called_with('Required rsync configs missing (host)')
165+ status.blocked.assert_called_with('Required sync rsync configs missing (host)')
166
167 status.blocked.reset_mock()
168- self.mock_config.return_value['rsync-host'] = 'ftpmaster.internal'
169+ self.mock_config.return_value['upstream-rsync-host'] = 'ftpmaster.internal'
170 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
171- status.blocked.assert_called_with('Required rsync configs missing (module)')
172+ status.blocked.assert_called_with('Required sync rsync configs missing (module)')
173
174 status.blocked.reset_mock()
175- self.mock_config.return_value['rsync-module'] = 'ftp'
176+ self.mock_config.return_value['upstream-rsync-module'] = 'ftp'
177 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
178- status.blocked.assert_called_with('Required rsync configs missing (password)')
179+ status.blocked.assert_called_with('Required sync rsync configs missing (password)')
180
181 status.blocked.reset_mock()
182- self.mock_config.return_value['rsync-password'] = 'my-secure-rsync-password'
183+ self.mock_config.return_value['upstream-rsync-password'] = 'my-secure-rsync-password'
184 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
185- status.blocked.assert_called_with('Required rsync configs missing (target)')
186+ status.blocked.assert_called_with('Required sync rsync configs missing (target)')
187
188 status.blocked.reset_mock()
189- self.mock_config.return_value['rsync-target'] = '/srv/ftp.root/ubuntu'
190+ self.mock_config.return_value['upstream-rsync-target'] = '/srv/ftp.root/ubuntu'
191 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
192- status.blocked.assert_called_with('Required rsync configs missing (user)')
193+ status.blocked.assert_called_with('Required sync rsync configs missing (user)')
194
195 setup.assert_not_called()
196 want = [mock.call('ubuntu-syncproxy.configured')]
197 set_flag.assert_has_calls(want, any_order=True)
198
199 status.blocked.reset_mock()
200- self.mock_config.return_value['rsync-user'] = 'syncproxy'
201+ self.mock_config.return_value['upstream-rsync-user'] = 'syncproxy'
202 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
203 status.blocked.assert_not_called()
204
205@@ -278,16 +278,16 @@ class TestCharm(unittest.TestCase):
206 self.mock_config.return_value[
207 'sync-user-ssh-authorized-keys'
208 ] = """
209-- from="91.189.88.154,185.125.188.80" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA-my-test-key-data-FF8/ArKew== archvsync@syowa
210-- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7l6nWM6Z2KfR4KmwF29Fv9nAgTLwHM5H/TWh-my-test-key-data-jRMlhyb6Q== archvsync@syowa
211-- ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABB-my-test-key-data-AxToEYNa/E= hloeung testing
212+- from="10.1.2.3" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA-my-test-key-data-FF8/ArKew== archvsync@my-test-upstream-host
213+- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7l6nWM6Z2KfR4KmwF29Fv9nAgTLwHM5H/TWh-my-test-key-data-jRMlhyb6Q== archvsync@my-test-upstream-host
214+- ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABB-my-test-key-data-AxToEYNa/E= testing
215 """ # NOQA: E501
216 ubuntu_syncproxy.configure_ubuntu_syncproxy(self.tmpdir)
217 ssh_auth_keys_path = os.path.join(self.tmpdir, '.ssh', 'authorized_keys')
218 self.assertTrue(os.path.exists(ssh_auth_keys_path))
219- want = """no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &",from="91.189.88.154,185.125.188.80" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA-my-test-key-data-FF8/ArKew== archvsync@syowa
220-no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7l6nWM6Z2KfR4KmwF29Fv9nAgTLwHM5H/TWh-my-test-key-data-jRMlhyb6Q== archvsync@syowa
221-no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &" ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABB-my-test-key-data-AxToEYNa/E= hloeung testing""" # NOQA: E501
222+ want = """no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &",from="10.1.2.3" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA-my-test-key-data-FF8/ArKew== archvsync@my-test-upstream-host
223+no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA7l6nWM6Z2KfR4KmwF29Fv9nAgTLwHM5H/TWh-my-test-key-data-jRMlhyb6Q== archvsync@my-test-upstream-host
224+no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty,command="~/archive-sync &" ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABB-my-test-key-data-AxToEYNa/E= testing""" # NOQA: E501
225 with open(ssh_auth_keys_path, 'r', encoding='utf-8') as f:
226 got = f.read()
227 self.assertEqual(want, got)

Subscribers

People subscribed via source and target branches