launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #13401
[Merge] lp:~rvb/maas/add-interface-ui into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/add-interface-ui into lp:maas.
Commit message:
Add UI to create a cluster interface.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/add-interface-ui/+merge/129631
This branch adds the UI to add a cluster interface (The API method for this already exists). Even if cluster interfaces are created automatically when a cluster controller registers, since the UI to delete an interface exists, it's only fair that the UI to add it back also exists.
--
https://code.launchpad.net/~rvb/maas/add-interface-ui/+merge/129631
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/add-interface-ui into lp:maas.
=== modified file 'src/maasserver/templates/maasserver/nodegroup_edit.html'
--- src/maasserver/templates/maasserver/nodegroup_edit.html 2012-10-08 12:50:32 +0000
+++ src/maasserver/templates/maasserver/nodegroup_edit.html 2012-10-15 09:37:22 +0000
@@ -53,6 +53,8 @@
{% endfor %}
</tbody>
</table>
+ <a class="button right"
+ href="{% url 'cluster-interface-create' cluster.uuid %}">Add interface</a>
</form>
</div>
<div class="clear"></div>
=== added file 'src/maasserver/templates/maasserver/nodegroupinterface_new.html'
--- src/maasserver/templates/maasserver/nodegroupinterface_new.html 1970-01-01 00:00:00 +0000
+++ src/maasserver/templates/maasserver/nodegroupinterface_new.html 2012-10-15 09:37:22 +0000
@@ -0,0 +1,23 @@
+{% extends "maasserver/base.html" %}
+
+{% block nav-active-settings %}active{% endblock %}
+{% block title %}Create Cluster Interface{% endblock %}
+{% block page-title %}Create Cluster Interface{% endblock %}
+
+{% block content %}
+<div class="block size10 first">
+ <form action="." method="post" class="block">
+ {% csrf_token %}
+ <ul>
+ {% for field in form %}
+ {% include "maasserver/form_field.html" %}
+ {% endfor %}
+ </ul>
+ <input type="submit" value="Save interface" class="button right" />
+ <a class="link-button"
+ href="{% url 'cluster-edit' nodegroup.uuid %}">Cancel</a>
+ </form>
+ </div>
+ <div class="clear"></div>
+</div>
+{% endblock %}
=== modified file 'src/maasserver/tests/test_views_settings_clusters.py'
--- src/maasserver/tests/test_views_settings_clusters.py 2012-10-08 16:31:20 +0000
+++ src/maasserver/tests/test_views_settings_clusters.py 2012-10-15 09:37:22 +0000
@@ -110,6 +110,13 @@
reload_object(nodegroup),
MatchesStructure.byEquality(**data))
+ def test_contains_link_to_add_interface(self):
+ nodegroup = factory.make_node_group()
+ links = get_content_links(
+ self.client.get(reverse('cluster-edit', args=[nodegroup.uuid])))
+ self.assertIn(
+ reverse('cluster-interface-create', args=[nodegroup.uuid]), links)
+
class ClusterInterfaceDeleteTest(AdminLoggedInTestCase):
@@ -147,6 +154,23 @@
MatchesStructure.byEquality(**data))
+class ClusterInterfaceCreateTest(AdminLoggedInTestCase):
+
+ def test_can_create_cluster_interface(self):
+ nodegroup = factory.make_node_group(
+ management=NODEGROUPINTERFACE_MANAGEMENT.UNMANAGED)
+ create_link = reverse(
+ 'cluster-interface-create', args=[nodegroup.uuid])
+ data = factory.get_interface_fields()
+ response = self.client.post(create_link, data)
+ self.assertEqual(httplib.FOUND, response.status_code, response.content)
+ interface = NodeGroupInterface.objects.get(
+ nodegroup__uuid=nodegroup.uuid, interface=data['interface'])
+ self.assertThat(
+ reload_object(interface),
+ MatchesStructure.byEquality(**data))
+
+
# XXX: rvb 2012-10-08 bug=1063881: apache transforms '//' into '/' in
# the urls it passes around and this happens when an interface has an empty
# name.
=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py 2012-10-08 18:00:04 +0000
+++ src/maasserver/urls.py 2012-10-15 09:37:22 +0000
@@ -51,6 +51,7 @@
from maasserver.views.settings_clusters import (
ClusterDelete,
ClusterEdit,
+ ClusterInterfaceCreate,
ClusterInterfaceDelete,
ClusterInterfaceEdit,
)
@@ -134,6 +135,9 @@
r'^clusters/(?P<uuid>[\w\-]+)/delete/$', ClusterDelete.as_view(),
name='cluster-delete'),
adminurl(
+ r'^clusters/(?P<uuid>[\w\-]+)/interfaces/add/$',
+ ClusterInterfaceCreate.as_view(), name='cluster-interface-create'),
+ adminurl(
r'^clusters/(?P<uuid>[\w\-]+)/interfaces/(?P<interface>[\w\-]*)/'
'edit/$',
ClusterInterfaceEdit.as_view(), name='cluster-interface-edit'),
=== modified file 'src/maasserver/views/settings_clusters.py'
--- src/maasserver/views/settings_clusters.py 2012-10-02 22:02:11 +0000
+++ src/maasserver/views/settings_clusters.py 2012-10-15 09:37:22 +0000
@@ -13,6 +13,7 @@
__all__ = [
"ClusterDelete",
"ClusterEdit",
+ "ClusterInterfaceCreate",
"ClusterInterfaceDelete",
"ClusterInterfaceEdit",
]
@@ -22,6 +23,7 @@
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.generic import (
+ CreateView,
DeleteView,
UpdateView,
)
@@ -117,3 +119,28 @@
interface = self.kwargs.get('interface', None)
return get_object_or_404(
NodeGroupInterface, nodegroup__uuid=uuid, interface=interface)
+
+
+class ClusterInterfaceCreate(CreateView):
+ template_name = 'maasserver/nodegroupinterface_new.html'
+ form_class = NodeGroupInterfaceForm
+ context_object_name = 'interface'
+
+ def get_success_url(self):
+ uuid = self.kwargs.get('uuid', None)
+ return reverse('cluster-edit', args=[uuid])
+
+ def form_valid(self, form):
+ self.object = form.save(nodegroup=self.get_nodegroup())
+ messages.info(self.request, "Interface created.")
+ return super(ClusterInterfaceCreate, self).form_valid(form)
+
+ def get_nodegroup(self):
+ nodegroup_uuid = self.kwargs.get('uuid', None)
+ return get_object_or_404(NodeGroup, uuid=nodegroup_uuid)
+
+ def get_context_data(self, **kwargs):
+ context = super(
+ ClusterInterfaceCreate, self).get_context_data(**kwargs)
+ context['nodegroup'] = self.get_nodegroup()
+ return context