Merge lp:~blake-rouse/maas/fix-keydata-base64 into lp:~maas-committers/maas/trunk

Proposed by Blake Rouse
Status: Merged
Approved by: Blake Rouse
Approved revision: no longer in the source branch.
Merged at revision: 2821
Proposed branch: lp:~blake-rouse/maas/fix-keydata-base64
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~blake-rouse/maas/rpc-import-images
Diff against target: 128 lines (+4/-26)
6 files modified
src/maasserver/bootresources.py (+1/-0)
src/maasserver/models/bootsource.py (+1/-5)
src/maasserver/models/tests/test_bootsource.py (+2/-3)
src/maasserver/rpc/bootsources.py (+0/-6)
src/maasserver/rpc/tests/test_bootsources.py (+0/-8)
src/maasserver/rpc/tests/test_regionservice.py (+0/-4)
To merge this branch: bzr merge lp:~blake-rouse/maas/fix-keydata-base64
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+232275@code.launchpad.net

Commit message

Removed base64 encoding of keyring_data on BootSource model, as its not needed for calling import boot images over RPC.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Cool, with one comment.

review: Approve
Revision history for this message
Gavin Panella (allenap) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/bootresources.py'
2--- src/maasserver/bootresources.py 2014-08-25 17:19:56 +0000
3+++ src/maasserver/bootresources.py 2014-08-26 17:41:09 +0000
4@@ -81,6 +81,7 @@
5 return {
6 'url': absolute_reverse(
7 'simplestreams_stream_handler', kwargs={'filename': 'index.json'}),
8+ 'keyring_data': b'',
9 'selections': [],
10 }
11
12
13=== modified file 'src/maasserver/models/bootsource.py'
14--- src/maasserver/models/bootsource.py 2014-08-15 03:43:34 +0000
15+++ src/maasserver/models/bootsource.py 2014-08-26 17:41:09 +0000
16@@ -17,8 +17,6 @@
17 ]
18
19
20-from base64 import b64encode
21-
22 from django.core.exceptions import ValidationError
23 from django.db.models import (
24 FilePathField,
25@@ -80,9 +78,7 @@
26 keyring_data = keyring_file.read()
27 return {
28 "url": self.url,
29- # TODO: Don't encode once this no longer needs to be
30- # transmitted to a Celery task.
31- "keyring_data": b64encode(keyring_data),
32+ "keyring_data": bytes(keyring_data),
33 "selections": [
34 selection.to_dict()
35 for selection in self.bootsourceselection_set.all()],
36
37=== modified file 'src/maasserver/models/tests/test_bootsource.py'
38--- src/maasserver/models/tests/test_bootsource.py 2014-08-12 15:15:06 +0000
39+++ src/maasserver/models/tests/test_bootsource.py 2014-08-26 17:41:09 +0000
40@@ -14,7 +14,6 @@
41 __metaclass__ = type
42 __all__ = []
43
44-from base64 import b64encode
45 import os
46
47 from django.core.exceptions import ValidationError
48@@ -75,7 +74,7 @@
49 source = boot_source.to_dict()
50 self.assertEqual(
51 source['keyring_data'],
52- b64encode(keyring_data))
53+ keyring_data)
54
55 def test_to_dict_handles_keyring_data(self):
56 keyring_data = b"Some Keyring Data"
57@@ -84,4 +83,4 @@
58 source = boot_source.to_dict()
59 self.assertEqual(
60 source['keyring_data'],
61- b64encode(keyring_data))
62+ keyring_data)
63
64=== modified file 'src/maasserver/rpc/bootsources.py'
65--- src/maasserver/rpc/bootsources.py 2014-08-25 14:33:20 +0000
66+++ src/maasserver/rpc/bootsources.py 2014-08-26 17:41:09 +0000
67@@ -16,8 +16,6 @@
68 "get_boot_sources",
69 ]
70
71-from base64 import b64decode
72-
73 from maasserver.models import BootSource
74 from maasserver.utils.async import transactional
75 from provisioningserver.utils.twisted import synchronous
76@@ -41,11 +39,7 @@
77 source.to_dict()
78 for source in BootSource.objects.all()
79 ]
80- # Replace the keyring_data value (base-64 encoded keyring) with
81- # the raw bytes; AMP is fine with bytes.
82 for source in sources:
83- keyring_data = source.pop("keyring_data")
84- source["keyring_data"] = b64decode(keyring_data)
85 if remove_os:
86 for selection in source['selections']:
87 del selection['os']
88
89=== modified file 'src/maasserver/rpc/tests/test_bootsources.py'
90--- src/maasserver/rpc/tests/test_bootsources.py 2014-08-25 14:08:13 +0000
91+++ src/maasserver/rpc/tests/test_bootsources.py 2014-08-26 17:41:09 +0000
92@@ -28,10 +28,6 @@
93 factory.make_boot_source_selection(source)
94
95 expected = source.to_dict()
96- # keyring_data contains the b64decoded representation since AMP
97- # is fine with bytes.
98- expected["keyring_data"] = keyring
99-
100 self.assertEqual([expected], get_boot_sources(nodegroup.uuid))
101
102 def test_removes_os_from_boot_source_selections(self):
103@@ -41,10 +37,6 @@
104 factory.make_boot_source_selection(source)
105
106 expected = source.to_dict()
107- # keyring_data contains the b64decoded representation since AMP
108- # is fine with bytes.
109- expected["keyring_data"] = keyring
110 del expected['selections'][0]['os']
111-
112 self.assertEqual(
113 [expected], get_boot_sources(nodegroup.uuid, remove_os=True))
114
115=== modified file 'src/maasserver/rpc/tests/test_regionservice.py'
116--- src/maasserver/rpc/tests/test_regionservice.py 2014-08-26 14:32:36 +0000
117+++ src/maasserver/rpc/tests/test_regionservice.py 2014-08-26 17:41:09 +0000
118@@ -266,10 +266,6 @@
119
120 uuid, boot_source = yield deferToThread(
121 self.make_boot_source_selection, keyring)
122-
123- # keyring_data contains the b64decoded representation since AMP
124- # is fine with bytes.
125- boot_source["keyring_data"] = keyring
126 del boot_source['selections'][0]['os']
127
128 response = yield call_responder(