launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #09714
[Merge] lp:~jtv/maas/migrate-nodecommissionresult into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/migrate-nodecommissionresult into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/migrate-nodecommissionresult/+merge/113969
As per the migration plan. This is the last model to be migrated, although its tests still follow in a separate branch due to land tomorrow.
Nothing very interesting here. In retrospect I could have gone for a simple renaming, but I don't think the code is under much change and we had more stuff still in the module when I wrote the preparatory branch.
Jeroen
--
https://code.launchpad.net/~jtv/maas/migrate-nodecommissionresult/+merge/113969
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/migrate-nodecommissionresult into lp:maas.
=== modified file 'src/metadataserver/models/__init__.py'
--- src/metadataserver/models/__init__.py 2012-07-03 04:06:55 +0000
+++ src/metadataserver/models/__init__.py 2012-07-09 13:00:36 +0000
@@ -20,64 +20,10 @@
'NodeUserData',
]
-from django.db.models import (
- CharField,
- ForeignKey,
- Manager,
- Model,
- )
-from django.shortcuts import get_object_or_404
-from maasserver.models.cleansave import CleanSave
from maasserver.utils import ignore_unused
-from metadataserver import DefaultMeta
+from metadataserver.models.nodecommissionresult import NodeCommissionResult
from metadataserver.models.nodekey import NodeKey
from metadataserver.models.nodeuserdata import NodeUserData
-ignore_unused(NodeKey, NodeUserData)
-
-
-class NodeCommissionResultManager(Manager):
-# Scheduled for model migration on 2012-07-09
- """Utility to manage a collection of :class:`NodeCommissionResult`s."""
-
- def clear_results(self, node):
- """Remove all existing results for a node."""
- self.filter(node=node).delete()
-
- def store_data(self, node, name, data):
- """Store data about a node."""
- existing, created = self.get_or_create(
- node=node, name=name, defaults=dict(data=data))
- if not created:
- existing.data = data
- existing.save()
-
- def get_data(self, node, name):
- """Get data about a node."""
- ncr = get_object_or_404(NodeCommissionResult, node=node, name=name)
- return ncr.data
-
-
-# Scheduled for model migration on 2012-07-09
-class NodeCommissionResult(CleanSave, Model):
- """Storage for data returned from node commissioning.
-
- Commissioning a node results in various bits of data that need to be
- stored, such as lshw output. This model allows storing of this data
- as unicode text, with an arbitrary name, for later retrieval.
-
- :ivar node: The context :class:`Node`.
- :ivar name: A unique name to use for the data being stored.
- :ivar data: The file's actual data, unicode only.
- """
-
- class Meta(DefaultMeta):
- unique_together = ('node', 'name')
-
- objects = NodeCommissionResultManager()
-
- node = ForeignKey(
- 'maasserver.Node', null=False, editable=False, unique=False)
- name = CharField(max_length=100, unique=False, editable=False)
- data = CharField(max_length=1024 * 1024, editable=True)
+ignore_unused(NodeCommissionResult, NodeKey, NodeUserData)
=== added file 'src/metadataserver/models/nodecommissionresult.py'
--- src/metadataserver/models/nodecommissionresult.py 1970-01-01 00:00:00 +0000
+++ src/metadataserver/models/nodecommissionresult.py 2012-07-09 13:00:36 +0000
@@ -0,0 +1,70 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+""":class:`NodeCommissionResult` model."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = [
+ 'NodeCommissionResult',
+ ]
+
+
+from django.db.models import (
+ CharField,
+ ForeignKey,
+ Manager,
+ Model,
+ )
+from django.shortcuts import get_object_or_404
+from maasserver.models.cleansave import CleanSave
+from metadataserver import DefaultMeta
+
+
+class NodeCommissionResultManager(Manager):
+ """Utility to manage a collection of :class:`NodeCommissionResult`s."""
+
+ def clear_results(self, node):
+ """Remove all existing results for a node."""
+ self.filter(node=node).delete()
+
+ def store_data(self, node, name, data):
+ """Store data about a node."""
+ existing, created = self.get_or_create(
+ node=node, name=name, defaults=dict(data=data))
+ if not created:
+ existing.data = data
+ existing.save()
+
+ def get_data(self, node, name):
+ """Get data about a node."""
+ ncr = get_object_or_404(NodeCommissionResult, node=node, name=name)
+ return ncr.data
+
+
+class NodeCommissionResult(CleanSave, Model):
+ """Storage for data returned from node commissioning.
+
+ Commissioning a node results in various bits of data that need to be
+ stored, such as lshw output. This model allows storing of this data
+ as unicode text, with an arbitrary name, for later retrieval.
+
+ :ivar node: The context :class:`Node`.
+ :ivar name: A unique name to use for the data being stored.
+ :ivar data: The file's actual data, unicode only.
+ """
+
+ class Meta(DefaultMeta):
+ unique_together = ('node', 'name')
+
+ objects = NodeCommissionResultManager()
+
+ node = ForeignKey(
+ 'maasserver.Node', null=False, editable=False, unique=False)
+ name = CharField(max_length=100, unique=False, editable=False)
+ data = CharField(max_length=1024 * 1024, editable=True)