Merge lp:~ltrager/maas/lp1546274 into lp:~maas-committers/maas/trunk
- lp1546274
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Lee Trager | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 4883 | ||||
Proposed branch: | lp:~ltrager/maas/lp1546274 | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
48 lines (+27/-0) 2 files modified
src/maascli/actions/boot_resources_create.py (+2/-0) src/maascli/actions/tests/test_boot_resources_create.py (+25/-0) |
||||
To merge this branch: | bzr merge lp:~ltrager/maas/lp1546274 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+291026@code.launchpad.net |
Commit message
Allow get_resource_file() to accept a bytestream.
Description of the change
Mike Pontillo (mpontillo) wrote : | # |
Gavin Panella (allenap) : | # |
Lee Trager (ltrager) wrote : | # |
> I think I'm lacking some context here. What is an example of a file that will
> be used with this API? Are they always UTF-8 encoded text files?
Its used when uploading a custom boot image as such
$ maas admin boot-resources create name=u1510_amd64 title="Ubuntu 15.10 (AMD64)" architecture=
What's happening is that we use http.request to generate the request. http.request returns everything as a type byte. I beleive this was changed when we moved from Python 2.7 to 3. Our unit tests test with a string type which is why I added the isinstance.
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~ltrager/maas/lp1546274 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Hit:3 http://
Hit:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Get:8 http://
Get:9 http://
Get:10 http://
Fetched 22.3 MB in 4s (5,476 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu1).
archdetect-deb is already the newest version (1.117ubuntu1).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest version (4.3-14ubuntu1).
bind9 is already the newest version (1:9.10.
bind9utils is already the newest version (1:9.10.
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubu...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~ltrager/maas/lp1546274 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Hit:3 http://
Hit:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Get:8 http://
Get:9 http://
Get:10 http://
Fetched 22.3 MB in 3s (5,977 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu1).
archdetect-deb is already the newest version (1.117ubuntu1).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest version (4.3-14ubuntu1).
bind9 is already the newest version (1:9.10.
bind9utils is already the newest version (1:9.10.
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubu...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~ltrager/maas/lp1546274 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Hit:3 http://
Hit:4 http://
Fetched 95.6 kB in 0s (214 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu1).
archdetect-deb is already the newest version (1.117ubuntu1).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest version (4.3-14ubuntu1).
bind9 is already the newest version (1:9.10.
bind9utils is already the newest version (1:9.10.
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubun
dh-apport is already the newest version (2.20.1-0ubuntu1).
dh-systemd is already the newest version (1.29ubuntu1).
distro-info is already the newest version (0.14build1).
dnsutils is already the newest version (1:9.10.
firefox is already the newest version (45.0.1+
freeipmi-tools is already the newest version (1.4.11-1ubuntu1).
git is already the newest version (1:2.7.4-0ubuntu1).
isc-dhcp-common is already the newest version (4.3.3-5ubuntu11).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfs...
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~ltrager/maas/lp1546274 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Get:2 http://
Hit:3 http://
Hit:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Fetched 9,877 kB in 1s (5,269 kB/s)
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu1).
archdetect-deb is already the newest version (1.117ubuntu1).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest version (4.3-14ubuntu1).
bind9 is already the newest version (1:9.10.
bind9utils is already the newest version (1:9.10.
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubun
dh-apport is already the newest version (2.20.1-0ubuntu1).
dh-systemd is already the newest version (1.29ubuntu1).
distro-info is already the newest version (0.14build1).
dnsutils is already the newest version (1:9.10.
firefox is already the newest version (45.0.1+
MAAS Lander (maas-lander) wrote : | # |
The attempt to merge lp:~ltrager/maas/lp1546274 into lp:maas failed. Below is the output from the failed tests.
Hit:1 http://
Hit:2 http://
Hit:3 http://
Hit:4 http://
Reading package lists...
sudo DEBIAN_
--no-
Reading package lists...
Building dependency tree...
Reading state information...
apache2 is already the newest version (2.4.18-2ubuntu1).
archdetect-deb is already the newest version (1.117ubuntu1).
authbind is already the newest version (2.1.1+nmu1).
bash is already the newest version (4.3-14ubuntu1).
bind9 is already the newest version (1:9.10.
bind9utils is already the newest version (1:9.10.
build-essential is already the newest version (12.1ubuntu2).
curl is already the newest version (7.47.0-1ubuntu2).
debhelper is already the newest version (9.20160115ubun
dh-apport is already the newest version (2.20.1-0ubuntu1).
dh-systemd is already the newest version (1.29ubuntu1).
distro-info is already the newest version (0.14build1).
dnsutils is already the newest version (1:9.10.
firefox is already the newest version (45.0.1+
freeipmi-tools is already the newest version (1.4.11-1ubuntu1).
git is already the newest version (1:2.7.4-0ubuntu1).
isc-dhcp-common is already the newest version (4.3.3-5ubuntu11).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-jquery-
Preview Diff
1 | === modified file 'src/maascli/actions/boot_resources_create.py' |
2 | --- src/maascli/actions/boot_resources_create.py 2015-12-01 18:12:59 +0000 |
3 | +++ src/maascli/actions/boot_resources_create.py 2016-04-06 23:37:37 +0000 |
4 | @@ -131,6 +131,8 @@ |
5 | |
6 | def get_resource_file(self, content): |
7 | """Return the boot resource file for the created file.""" |
8 | + if isinstance(content, bytes): |
9 | + content = content.decode('utf-8') |
10 | data = json.loads(content) |
11 | if len(data['sets']) == 0: |
12 | # No sets returned, no way to get the resource file. |
13 | |
14 | === modified file 'src/maascli/actions/tests/test_boot_resources_create.py' |
15 | --- src/maascli/actions/tests/test_boot_resources_create.py 2016-03-28 13:54:47 +0000 |
16 | +++ src/maascli/actions/tests/test_boot_resources_create.py 2016-04-06 23:37:37 +0000 |
17 | @@ -166,6 +166,31 @@ |
18 | {'name': filename}, |
19 | action.get_resource_file(json.dumps(content))) |
20 | |
21 | + def test_get_resource_file_accepts_bytes(self): |
22 | + filename = factory.make_name('file') |
23 | + content = { |
24 | + 'sets': { |
25 | + '20140910': { |
26 | + 'files': { |
27 | + filename: { |
28 | + 'name': filename, |
29 | + }, |
30 | + }, |
31 | + }, |
32 | + '20140909': { |
33 | + 'files': { |
34 | + 'other': { |
35 | + 'name': 'other', |
36 | + }, |
37 | + }, |
38 | + }, |
39 | + }, |
40 | + } |
41 | + action = self.make_boot_resources_create_action() |
42 | + self.assertEqual( |
43 | + {'name': filename}, |
44 | + action.get_resource_file(json.dumps(content).encode('utf-8'))) |
45 | + |
46 | def test_put_upload_raise_CommandError_if_status_not_200(self): |
47 | self.configure_http_request(500, b'') |
48 | action = self.make_boot_resources_create_action() |
I think I'm lacking some context here. What is an example of a file that will be used with this API? Are they always UTF-8 encoded text files?