Merge lp:~rvb/maas/pxe-off-preseed into lp:maas/trunk
| Status: | Merged |
|---|---|
| Approved by: | Raphaël Badin on 2012-06-20 |
| Approved revision: | 664 |
| Merged at revision: | 658 |
| Proposed branch: | lp:~rvb/maas/pxe-off-preseed |
| Merge into: | lp:maas/trunk |
| Diff against target: |
320 lines (+145/-7) 8 files modified
contrib/preseeds_v2/generic (+1/-1) src/maasserver/preseed.py (+28/-3) src/maasserver/tests/test_preseed.py (+12/-1) src/maasserver/tests/test_utils.py (+33/-1) src/maasserver/utils.py (+21/-0) src/metadataserver/api.py (+20/-0) src/metadataserver/tests/test_api.py (+12/-0) src/metadataserver/urls.py (+18/-1) |
| To merge this branch: | bzr merge lp:~rvb/maas/pxe-off-preseed |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gavin Panella (community) | 2012-06-20 | Approve on 2012-06-20 | |
| Francesco Banconi (community) | code* | 2012-06-20 | Approve on 2012-06-20 |
|
Review via email:
|
|||
Commit Message
Add an anonymous method to turn off PXE booting. Use that method in the preseed template.
Description of the Change
This branch adds an anonymous method to turn off PXE booting (to the metadata service) and uses that method to generate the url put in the preseed file. That url will be called by the node once at the end of the installation process.
= Pre-imp =
This is part of the plan which was devised last week with Gavin (see http://
= Notes =
- I've filed bug 1015559 about the fact that the new method does not require authentication. The bug is referenced in the code.
- The call to "wget" is now a POST request. Cobbler uses a GET request to modify data :(.
- Drive-by fix: I've fixed the value of 'server_name' in the context used when rendering the preseed file. It now uses the method get_maas_
| Gavin Panella (allenap) wrote : | # |
Francesco wrote:
> The code looks good Raphaël.
> Just 3 details/suggestions for the absolute_reverse function:
>
> 1. :param `view_name` can also be a view callable reference.
Took a (small) bit of hunting around to find what you were referring
to. Including some context would be useful when writing a review. It's
useful also when reading comments after the preview diff has been
updated with newer changes.
> 2. maybe we could continue supporting the other kwargs that can be
> passed to `reverse`, i.e. `urlconf` and `current_app`.
It looks like they are accepted... or am I missing something?
> 3. you can take into consideration `urlparse.urljoin`
+1
I have some other comments, but they're all minor.
[1]
+ wget "{{node_
These parameters should probably be escaped with pipes.quote(), a bit
like ShellTemplate does by default (though, for preseeds, not by
default).
Adding, say, an "escape" object into the template's namespace might be
an interesting approach here, then you could write:
wget "{{node_
or, for example:
{{something
But that's just an idea off the top of my head.
[2]
+def absolute_
Not tempted to call it canonical_
[3]
+ response = self.client.post(
+ anon_netboot_
The phrase "netboot off" does not contain a verb. It might be clearer
if it did, "disable netboot" or "switch netboot off" for example. Or,
for bonus points, make it RESTfulish and permit something like:
wget ".../path/
[4]
+ # XXX: rvb 2012-06-20 bug=1015559: This method is accessible
+ # without authentication. This is a security threat.
I guess it's a denial of service vulnerability. It won't leak
information or permit unrelated modifications, so it's relatively
minor. I've updated the bug.
| Francesco Banconi (frankban) wrote : | # |
> Took a (small) bit of hunting around to find what you were referring
> to. Including some context would be useful when writing a review. It's
> useful also when reading comments after the preview diff has been
> updated with newer changes.
Good point Gavin, thank you.
> > 2. maybe we could continue supporting the other kwargs that can be
> > passed to `reverse`, i.e. `urlconf` and `current_app`.
>
> It looks like they are accepted... or am I missing something?
No you are not, my fault, they are already accepted.
- 660. By Raphaël Badin on 2012-06-20
-
Use urlparse.urljoin.
| Raphaël Badin (rvb) wrote : | # |
Thanks for the review Francesco!
Like Gavin said, I think it's really worth it to add a little of context when you're suggesting something. My suggestion would be to simply include 1 or 2 lines from the diff. Like:
35 + server_host = get_maas_
36 + # Create the url and the url-data (POST parameters) used to turn off
> 1. :param `view_name` can also be a view callable reference.
Indeed, I've updated the docstring.
> 2. maybe we could continue supporting the other kwargs that can be passed to
> `reverse`, i.e. `urlconf` and `current_app`.
It's already done actually, they will be passed down to Django's reverse method as part of *args, **kwargs.
> 3. you can take into consideration `urlparse.urljoin`
Good idea, done.
- 661. By Raphaël Badin on 2012-06-20
-
Fix doc.
- 662. By Raphaël Badin on 2012-06-20
-
Add escape filter.
| Raphaël Badin (rvb) wrote : | # |
Thanks for the review!
> [1]
>
> + wget "{{node_
> -O /dev/null && \
>
> These parameters should probably be escaped with pipes.quote(), a bit
> like ShellTemplate does by default (though, for preseeds, not by
> default).
>
> Adding, say, an "escape" object into the template's namespace might be
> an interesting approach here, then you could write:
>
> wget "{{node_
>
> or, for example:
>
> {{something_else | escape.html}}
>
> But that's just an idea off the top of my head.
That's an excellent idea, I've implemented it. It also justifies the existence of the specialized template class PreseedTemplate.
> [2]
> Not tempted to call it canonical_
Well… no :)
> [3]
>
> + response = self.client.post(
> + anon_netboot_
>
> The phrase "netboot off" does not contain a verb. It might be clearer
> if it did, "disable netboot" or "switch netboot off" for example. Or,
> for bonus points, make it RESTfulish and permit something like:
>
> wget ".../path/
Currently, this is in sync with the authenticated version of the same API method. I'll check with Julian who's created the original implementation before I change that.
> [4]
>
> + # XXX: rvb 2012-06-20 bug=1015559: This method is accessible
> + # without authentication. This is a security threat.
>
> I guess it's a denial of service vulnerability. It won't leak
> information or permit unrelated modifications, so it's relatively
> minor. I've updated the bug.
Right, thanks.
- 663. By Raphaël Badin on 2012-06-20
-
Fix doc.
- 664. By Raphaël Badin on 2012-06-20
-
Fix class name.
| Julian Edwards (julian-edwards) wrote : | # |
On Wednesday 20 June 2012 16:27:21 you wrote:
> > [3]
> >
> >
> >
> > + response = self.client.post(
> > + anon_netboot_
> >
> >
> >
> > The phrase "netboot off" does not contain a verb. It might be clearer
> > if it did, "disable netboot" or "switch netboot off" for example. Or,
> >
> > for bonus points, make it RESTfulish and permit something like:
> >
> > wget ".../path/
>
> Currently, this is in sync with the authenticated version of the same API
> method. I'll check with Julian who's created the original implementation
> before I change that.
I thought long and hard about whether to have a single operation with multiple
parameters.
In the end I went with two, "netboot_on" and "netboot_off". I guess they are
not verbish enough, but the rationale was that it would be easier for shell
scripts to pass fewer args and it's also more consistent with Cobbler (which
may be considered bad :D)
Making it RESTful-ish (-ish making me laugh here) is an interesting one. If
we want this anonymous for now it may be better to move this entirely over to
the maasserver API? The only reason I put it on the metadata server is
because of the existing OAuth key arrangement.
Thoughts?


The code looks good Raphaël.
Just 3 details/suggestions for the absolute_reverse function:
1. :param `view_name` can also be a view callable reference.
2. maybe we could continue supporting the other kwargs that can be passed to `reverse`, i.e. `urlconf` and `current_app`.
3. you can take into consideration `urlparse.urljoin`