launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12642
[Merge] lp:~jtv/maas/components-enum into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/components-enum into lp:maas with lp:~jtv/maas/db-persistent-errors as a prerequisite.
Commit message:
Move COMPONENTS enum into its appropriate enums module.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/components-enum/+merge/127028
This was the outcome of a review discussion for a more important (and already large) branch. This is one necessary step on the way to giving ComponentError.component a "choices" property.
Jeroen
--
https://code.launchpad.net/~jtv/maas/components-enum/+merge/127028
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/components-enum into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-09-28 12:29:50 +0000
+++ src/maasserver/api.py 2012-09-28 17:06:25 +0000
@@ -113,12 +113,12 @@
generate_api_docs,
)
from maasserver.components import (
- COMPONENT,
discard_persistent_error,
register_persistent_error,
)
from maasserver.enum import (
ARCHITECTURE,
+ COMPONENT,
NODE_PERMISSION,
NODE_STATUS,
NODEGROUP_STATUS,
=== modified file 'src/maasserver/components.py'
--- src/maasserver/components.py 2012-09-28 17:06:25 +0000
+++ src/maasserver/components.py 2012-09-28 17:06:25 +0000
@@ -19,19 +19,24 @@
from maasserver.models import ComponentError
-class COMPONENT:
- PSERV = 'provisioning server'
- IMPORT_PXE_FILES = 'maas-import-pxe-files script'
-
-
def discard_persistent_error(component):
+ """Drop the persistent error for `component`.
+
+ :param component: An enum value of :class:`COMPONENT`.
+ """
ComponentError.objects.filter(component=component).delete()
def register_persistent_error(component, error_message):
+ """Register a persistent error for `component`.
+
+ :param component: An enum value of :class:`COMPONENT`.
+ :param error_message: Human-readable error text.
+ """
discard_persistent_error(component)
ComponentError.objects.create(component=component, error=error_message)
def get_persistent_errors():
+ """Return list of current persistent error messages."""
return sorted(err.error for err in ComponentError.objects.all())
=== modified file 'src/maasserver/enum.py'
--- src/maasserver/enum.py 2012-09-19 09:50:46 +0000
+++ src/maasserver/enum.py 2012-09-28 17:06:25 +0000
@@ -13,6 +13,7 @@
__all__ = [
'ARCHITECTURE',
'ARCHITECTURE_CHOICES',
+ 'COMPONENT',
'NODEGROUP_STATUS',
'NODEGROUP_STATUS_CHOICES',
'NODEGROUPINTERFACE_MANAGEMENT',
@@ -29,6 +30,12 @@
from collections import OrderedDict
+class COMPONENT:
+ """Major moving parts of the application that may have failure states."""
+ PSERV = 'provisioning server'
+ IMPORT_PXE_FILES = 'maas-import-pxe-files script'
+
+
class NODE_STATUS:
"""The vocabulary of a `Node`'s possible statuses."""
# A node starts out as READY.
=== removed file 'src/maasserver/migrations/0031_componenterror.py'
--- src/maasserver/migrations/0031_componenterror.py 2012-09-28 17:06:25 +0000
+++ src/maasserver/migrations/0031_componenterror.py 1970-01-01 00:00:00 +0000
@@ -1,202 +0,0 @@
-# -*- coding: utf-8 -*-
-import datetime
-
-from django.db import models
-from south.db import db
-from south.v2 import SchemaMigration
-
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
- # Adding model 'ComponentError'
- db.create_table(u'maasserver_componenterror', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('component', self.gf('django.db.models.fields.CharField')(unique=True, max_length=40)),
- ('error', self.gf('django.db.models.fields.CharField')(max_length=1000)),
- ))
- db.send_create_signal(u'maasserver', ['ComponentError'])
-
-
- def backwards(self, orm):
- # Deleting model 'ComponentError'
- db.delete_table(u'maasserver_componenterror')
-
-
- 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'})
- },
- u'maasserver.bootimage': {
- 'Meta': {'unique_together': "((u'architecture', u'subarchitecture', u'release', u'purpose'),)", 'object_name': 'BootImage'},
- 'architecture': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'purpose': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'release': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'subarchitecture': ('django.db.models.fields.CharField', [], {'max_length': '255'})
- },
- u'maasserver.componenterror': {
- 'Meta': {'object_name': 'ComponentError'},
- 'component': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40'}),
- 'error': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
- },
- u'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'})
- },
- u'maasserver.dhcplease': {
- 'Meta': {'object_name': 'DHCPLease'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'ip': ('django.db.models.fields.IPAddressField', [], {'unique': 'True', 'max_length': '15'}),
- 'mac': ('maasserver.fields.MACAddressField', [], {}),
- 'nodegroup': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['maasserver.NodeGroup']"})
- },
- u'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': '200'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
- },
- u'maasserver.macaddress': {
- 'Meta': {'object_name': 'MACAddress'},
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'mac_address': ('maasserver.fields.MACAddressField', [], {'unique': 'True'}),
- 'node': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['maasserver.Node']"}),
- 'updated': ('django.db.models.fields.DateTimeField', [], {})
- },
- u'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'}),
- 'cpu_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- 'distro_series': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '10', 'null': 'True', 'blank': 'True'}),
- 'error': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
- 'hardware_details': ('maasserver.fields.XMLField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
- 'hostname': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'memory': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
- 'netboot': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'nodegroup': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['maasserver.NodeGroup']", 'null': 'True'}),
- 'owner': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
- 'power_parameters': ('maasserver.fields.JSONObjectField', [], {'default': "u''", '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-0de6dbce-0979-11e2-ac17-002608dc6120'", 'unique': 'True', 'max_length': '41'}),
- 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['maasserver.Tag']", 'symmetrical': 'False'}),
- 'token': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['piston.Token']", 'null': 'True'}),
- 'updated': ('django.db.models.fields.DateTimeField', [], {})
- },
- u'maasserver.nodegroup': {
- 'Meta': {'object_name': 'NodeGroup'},
- 'api_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '18'}),
- 'api_token': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['piston.Token']", 'unique': 'True'}),
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- 'dhcp_key': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'blank': 'True'}),
- 'status': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
- 'updated': ('django.db.models.fields.DateTimeField', [], {}),
- 'uuid': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '36'})
- },
- u'maasserver.nodegroupinterface': {
- 'Meta': {'unique_together': "((u'nodegroup', u'interface'),)", 'object_name': 'NodeGroupInterface'},
- 'broadcast_ip': ('django.db.models.fields.GenericIPAddressField', [], {'default': 'None', 'max_length': '39', 'null': 'True', 'blank': 'True'}),
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'interface': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '255', 'blank': 'True'}),
- 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}),
- 'ip_range_high': ('django.db.models.fields.GenericIPAddressField', [], {'default': 'None', 'max_length': '39', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
- 'ip_range_low': ('django.db.models.fields.GenericIPAddressField', [], {'default': 'None', 'max_length': '39', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
- 'management': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
- 'nodegroup': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['maasserver.NodeGroup']"}),
- 'router_ip': ('django.db.models.fields.GenericIPAddressField', [], {'default': 'None', 'max_length': '39', 'null': 'True', 'blank': 'True'}),
- 'subnet_mask': ('django.db.models.fields.GenericIPAddressField', [], {'default': 'None', 'max_length': '39', 'null': 'True', 'blank': 'True'}),
- 'updated': ('django.db.models.fields.DateTimeField', [], {})
- },
- u'maasserver.sshkey': {
- 'Meta': {'unique_together': "((u'user', u'key'),)", 'object_name': 'SSHKey'},
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- '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']"})
- },
- u'maasserver.tag': {
- 'Meta': {'object_name': 'Tag'},
- 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'created': ('django.db.models.fields.DateTimeField', [], {}),
- 'definition': ('django.db.models.fields.TextField', [], {}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}),
- 'updated': ('django.db.models.fields.DateTimeField', [], {})
- },
- u'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': '1348842630L'}),
- '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']
\ No newline at end of file
=== modified file 'src/maasserver/models/component_error.py'
--- src/maasserver/models/component_error.py 2012-09-28 17:06:25 +0000
+++ src/maasserver/models/component_error.py 2012-09-28 17:06:25 +0000
@@ -15,14 +15,13 @@
]
-from django.db.models import (
- CharField,
- Model,
- )
+from django.db.models import CharField
from maasserver import DefaultMeta
-
-
-class ComponentError(Model):
+from maasserver.models.cleansave import CleanSave
+from maasserver.models.timestampedmodel import TimestampedModel
+
+
+class ComponentError(CleanSave, TimestampedModel):
"""Error state of a major component of the system."""
class Meta(DefaultMeta):
=== modified file 'src/maasserver/start_up.py'
--- src/maasserver/start_up.py 2012-09-14 12:15:56 +0000
+++ src/maasserver/start_up.py 2012-09-28 17:06:25 +0000
@@ -18,11 +18,9 @@
from textwrap import dedent
from lockfile import FileLock
-from maasserver.components import (
- COMPONENT,
- register_persistent_error,
- )
+from maasserver.components import register_persistent_error
from maasserver.dns import write_full_dns_config
+from maasserver.enum import COMPONENT
from maasserver.maasavahi import setup_maas_avahi_service
from maasserver.models import (
BootImage,
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-09-28 12:55:42 +0000
+++ src/maasserver/tests/test_api.py 2012-09-28 17:06:25 +0000
@@ -46,10 +46,10 @@
get_oauth_token,
get_overrided_query_dict,
)
-from maasserver.components import COMPONENT
from maasserver.enum import (
ARCHITECTURE,
ARCHITECTURE_CHOICES,
+ COMPONENT,
DISTRO_SERIES,
NODE_AFTER_COMMISSIONING_ACTION,
NODE_STATUS,
=== modified file 'src/maasserver/tests/test_components.py'
--- src/maasserver/tests/test_components.py 2012-09-28 17:06:25 +0000
+++ src/maasserver/tests/test_components.py 2012-09-28 17:06:25 +0000
@@ -16,11 +16,11 @@
import random
from maasserver.components import (
- COMPONENT,
discard_persistent_error,
get_persistent_errors,
register_persistent_error,
)
+from maasserver.enum import COMPONENT
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
from maasserver.utils import map_enum
=== modified file 'src/maasserver/tests/test_start_up.py'
--- src/maasserver/tests/test_start_up.py 2012-09-14 02:16:48 +0000
+++ src/maasserver/tests/test_start_up.py 2012-09-28 17:06:25 +0000
@@ -21,10 +21,8 @@
FileLock,
LockTimeout,
)
-from maasserver import (
- components,
- start_up,
- )
+from maasserver import start_up
+from maasserver.enum import COMPONENT
from maasserver.models import (
BootImage,
NodeGroup,
@@ -116,7 +114,7 @@
start_up.start_up()
self.assertIn(
- components.COMPONENT.IMPORT_PXE_FILES,
+ COMPONENT.IMPORT_PXE_FILES,
[args[0][0] for args in recorder.call_args_list])
def test_start_up_does_not_warn_if_boot_images_are_known(self):
@@ -128,5 +126,5 @@
start_up.start_up()
self.assertNotIn(
- components.COMPONENT.IMPORT_PXE_FILES,
+ COMPONENT.IMPORT_PXE_FILES,
[args[0][0] for args in recorder.call_args_list])
Follow ups