launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12644
[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 14:49:41 +0000
+++ src/maasserver/api.py 2012-09-28 17:23:22 +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:23:22 +0000
+++ src/maasserver/components.py 2012-09-28 17:23:22 +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-27 15:39:38 +0000
+++ src/maasserver/enum.py 2012-09-28 17:23:22 +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.
=== modified file 'src/maasserver/models/component_error.py'
--- src/maasserver/models/component_error.py 2012-09-28 17:23:22 +0000
+++ src/maasserver/models/component_error.py 2012-09-28 17:23:22 +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:23:22 +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 14:49:41 +0000
+++ src/maasserver/tests/test_api.py 2012-09-28 17:23:22 +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:23:22 +0000
+++ src/maasserver/tests/test_components.py 2012-09-28 17:23:22 +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:23:22 +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])