launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07007
[Merge] lp:~jtv/maas/bug-973084 into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/bug-973084 into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #973084 in MAAS: "Display commissioning failure"
https://bugs.launchpad.net/maas/+bug/973084
For more details, see:
https://code.launchpad.net/~jtv/maas/bug-973084/+merge/100840
(The new field does not become visible if there is no error to display.)
Screenshot: http://people.canonical.com/~jtv/node-error.png
I wonder if maybe the error deserves special styling. Maybe not. Feel free to criticize placement; I think I picked about the right spot but I can't say I'm the best judge, especially right now.
Jeroen
--
https://code.launchpad.net/~jtv/maas/bug-973084/+merge/100840
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/bug-973084 into lp:maas.
=== added file 'src/maasserver/migrations/0004_add_node_error.py'
--- src/maasserver/migrations/0004_add_node_error.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/migrations/0004_add_node_error.py 2012-04-04 17:20:40 +0000
@@ -0,0 +1,132 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding field 'Node.error'
+ db.add_column('maasserver_node', 'error', self.gf('django.db.models.fields.CharField')(default=u'', max_length=255, blank=True), keep_default=False)
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'Node.error'
+ db.delete_column('maasserver_node', 'error')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'maasserver.config': {
+ 'Meta': {'object_name': 'Config'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'value': ('maasserver.fields.JSONObjectField', [], {'null': 'True'})
+ },
+ 'maasserver.filestorage': {
+ 'Meta': {'object_name': 'FileStorage'},
+ 'data': ('django.db.models.fields.files.FileField', [], {'max_length': '255'}),
+ 'filename': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
+ },
+ 'maasserver.macaddress': {
+ 'Meta': {'object_name': 'MACAddress'},
+ 'created': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'mac_address': ('maasserver.fields.MACAddressField', [], {'unique': 'True'}),
+ 'node': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['maasserver.Node']"}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {})
+ },
+ 'maasserver.node': {
+ 'Meta': {'object_name': 'Node'},
+ 'after_commissioning_action': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'architecture': ('django.db.models.fields.CharField', [], {'default': "u'i386'", 'max_length': '10'}),
+ 'created': ('django.db.models.fields.DateField', [], {}),
+ 'error': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
+ 'hostname': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'owner': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'power_type': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '10', 'blank': 'True'}),
+ 'status': ('django.db.models.fields.IntegerField', [], {'default': '0', 'max_length': '10'}),
+ 'system_id': ('django.db.models.fields.CharField', [], {'default': "u'node-75a4d6a0-7e71-11e1-b17c-0025bce60bc2'", 'unique': 'True', 'max_length': '41'}),
+ 'token': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['piston.Token']", 'null': 'True'}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {})
+ },
+ 'maasserver.sshkey': {
+ 'Meta': {'object_name': 'SSHKey'},
+ 'created': ('django.db.models.fields.DateField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'key': ('django.db.models.fields.TextField', [], {}),
+ 'updated': ('django.db.models.fields.DateTimeField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+ },
+ 'maasserver.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'})
+ },
+ 'piston.consumer': {
+ 'Meta': {'object_name': 'Consumer'},
+ 'description': ('django.db.models.fields.TextField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'key': ('django.db.models.fields.CharField', [], {'max_length': '18'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'secret': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '16'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'consumers'", 'null': 'True', 'to': "orm['auth.User']"})
+ },
+ 'piston.token': {
+ 'Meta': {'object_name': 'Token'},
+ 'callback': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'callback_confirmed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'consumer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['piston.Consumer']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_approved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'key': ('django.db.models.fields.CharField', [], {'max_length': '18'}),
+ 'secret': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+ 'timestamp': ('django.db.models.fields.IntegerField', [], {'default': '1333556156L'}),
+ 'token_type': ('django.db.models.fields.IntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'tokens'", 'null': 'True', 'to': "orm['auth.User']"}),
+ 'verifier': ('django.db.models.fields.CharField', [], {'max_length': '10'})
+ }
+ }
+
+ complete_apps = ['maasserver']
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py 2012-04-04 15:10:59 +0000
+++ src/maasserver/models.py 2012-04-04 17:20:40 +0000
@@ -511,6 +511,8 @@
token = models.ForeignKey(
Token, db_index=True, null=True, editable=False, unique=False)
+ error = models.CharField(max_length=255, blank=True, default='')
+
objects = NodeManager()
def __unicode__(self):
=== modified file 'src/maasserver/templates/maasserver/node_view.html'
--- src/maasserver/templates/maasserver/node_view.html 2012-04-04 14:16:34 +0000
+++ src/maasserver/templates/maasserver/node_view.html 2012-04-04 17:20:40 +0000
@@ -65,6 +65,14 @@
{{ node.display_status }}
</span>
</li>
+ {% if node.error %}
+ <li class="block first">
+ <h4>Error output</h4>
+ <span>
+ {{ node.error }}
+ </span>
+ </li>
+ {% endif %}
{% if node.owner %}
<li class="block size2 first">
<h4>Owner</h4>
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py 2012-04-04 14:45:23 +0000
+++ src/maasserver/tests/test_views.py 2012-04-04 17:20:40 +0000
@@ -647,6 +647,7 @@
self.assertEqual(0, len(doc.cssselect('form#node_actions input')))
+<<<<<<< TREE
def test_view_node_POST_admin_can_start_commissioning_node(self):
self.logged_in_user.is_superuser = True
self.logged_in_user.save()
@@ -662,6 +663,26 @@
self.assertEqual(
NODE_STATUS.COMMISSIONING, reload_object(node).status)
+=======
+ def test_view_node_shows_no_error_if_no_error_set(self):
+ node = factory.make_node(owner=self.logged_in_user)
+ node_link = reverse('node-view', args=[node.system_id])
+ response = self.client.get(node_link)
+ doc = fromstring(response.content)
+ content_text = doc.cssselect('#content')[0].text_content()
+ self.assertNotIn("Error output", content_text)
+
+ def test_view_node_shows_error_if_set(self):
+ node = factory.make_node(
+ owner=self.logged_in_user, error=factory.getRandomString())
+ node_link = reverse('node-view', args=[node.system_id])
+ response = self.client.get(node_link)
+ doc = fromstring(response.content)
+ content_text = doc.cssselect('#content')[0].text_content()
+ self.assertIn("Error output", content_text)
+ self.assertIn(node.error, content_text)
+
+>>>>>>> MERGE-SOURCE
class AdminNodeViewsTest(AdminLoggedInTestCase):
=== modified file 'src/metadataserver/api.py'
--- src/metadataserver/api.py 2012-04-04 16:04:47 +0000
+++ src/metadataserver/api.py 2012-04-04 17:20:40 +0000
@@ -159,9 +159,13 @@
return rc.ALL_OK
target_status = self.signaling_statuses.get(status)
- if target_status not in (None, node.status):
- node.status = target_status
- node.save()
+ if target_status in (None, node.status):
+ # No status change. Nothing to be done.
+ return rc.ALL_OK
+
+ node.status = target_status
+ node.error = request.POST.get('error', '')
+ node.save()
return rc.ALL_OK
=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py 2012-04-04 15:59:19 +0000
+++ src/metadataserver/tests/test_api.py 2012-04-04 17:20:40 +0000
@@ -323,3 +323,44 @@
response = client.post(url, success_params)
self.assertEqual(httplib.OK, response.status_code)
self.assertEqual(NODE_STATUS.READY, reload_object(node).status)
+
+ def test_signaling_commissioning_failure_makes_node_Failed_Tests(self):
+ node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
+ client = self.make_node_client(node=node)
+ response = client.post(
+ self.make_url('/latest/'), {'op': 'signal', 'status': 'FAILED'})
+ self.assertEqual(httplib.OK, response.status_code)
+ self.assertEqual(NODE_STATUS.FAILED_TESTS, reload_object(node).status)
+
+ def test_signaling_commissioning_failure_is_idempotent(self):
+ node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
+ client = self.make_node_client(node=node)
+ url = self.make_url('/latest/')
+ failure_params = {'op': 'signal', 'status': 'FAILED'}
+ client.post(url, failure_params)
+ response = client.post(url, failure_params)
+ self.assertEqual(httplib.OK, response.status_code)
+ self.assertEqual(NODE_STATUS.FAILED_TESTS, reload_object(node).status)
+
+ def test_signaling_commissioning_failure_sets_node_error(self):
+ node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
+ client = self.make_node_client(node=node)
+ error_text = factory.getRandomString()
+ response = client.post(
+ self.make_url('/latest/'),
+ {
+ 'op': 'signal',
+ 'status': 'FAILED',
+ 'error': error_text,
+ })
+ self.assertEqual(httplib.OK, response.status_code)
+ self.assertEqual(error_text, reload_object(node).error)
+
+ def test_signaling_no_error_clears_existing_error(self):
+ node = factory.make_node(
+ status=NODE_STATUS.COMMISSIONING, error=factory.getRandomString())
+ client = self.make_node_client(node=node)
+ response = client.post(
+ self.make_url('/latest/'), {'op': 'signal', 'status': 'OK'})
+ self.assertEqual(httplib.OK, response.status_code)
+ self.assertEqual('', reload_object(node).error)