Merge ~lloydwaltersj/maas:last-deploy-mock-data into maas:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Jack Lloyd-Walters
Approved revision: 93eea4277a2474ce5154a845125b162b4d9b0ee7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas:last-deploy-mock-data
Merge into: maas:master
Diff against target: 52 lines (+15/-1)
2 files modified
src/maasserver/models/bootresource.py (+12/-1)
src/maasserver/websockets/handlers/bootresource.py (+3/-0)
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
MAAS Lander Approve
Review via email: mp+434244@code.launchpad.net

Commit message

add mock deployment data

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1563/consoleText
COMMIT: f38be17ae643eb5f512c7176eb9659d606b199ec

review: Needs Fixing
6319f17... by Jack Lloyd-Walters

update for linting

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 6319f17f88d825cd2a57ec2ca683b605abab9bfb

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1565/consoleText
COMMIT: 8198bf537e1d5c78656653d140790a2d993a5d1d

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1566/consoleText
COMMIT: c816b818e935d98aa14203f3a114254508afc2e9

review: Needs Fixing
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1567/consoleText
COMMIT: 60f070d2c9d8507fdabbb4dacb427ba9c6cb65f1

review: Needs Fixing
93eea42... by Jack Lloyd-Walters

make everything happier

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b last-deploy-mock-data lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 93eea4277a2474ce5154a845125b162b4d9b0ee7

review: Approve
Revision history for this message
Adam Collard (adam-collard) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/bootresource.py b/src/maasserver/models/bootresource.py
index 9389830..3ec9528 100644
--- a/src/maasserver/models/bootresource.py
+++ b/src/maasserver/models/bootresource.py
@@ -16,6 +16,7 @@ from django.db.models import (
16 Prefetch,16 Prefetch,
17 Sum,17 Sum,
18)18)
19from django.utils import timezone
1920
20from maasserver.enum import (21from maasserver.enum import (
21 BOOT_RESOURCE_FILE_TYPE,22 BOOT_RESOURCE_FILE_TYPE,
@@ -114,7 +115,7 @@ class BootResourceManager(Manager):
114 def get_usable_architectures(self):115 def get_usable_architectures(self):
115 """Return the set of usable architectures.116 """Return the set of usable architectures.
116117
117 Return the architectures for which the has at least one118 Return the architectures for which the resource has at least one
118 commissioning image and at least one install image.119 commissioning image and at least one install image.
119 """120 """
120 arches = set()121 arches = set()
@@ -515,6 +516,16 @@ class BootResource(CleanSave, TimestampedModel):
515 """Return rtype text as displayed to the user."""516 """Return rtype text as displayed to the user."""
516 return BOOT_RESOURCE_TYPE_CHOICES_DICT[self.rtype]517 return BOOT_RESOURCE_TYPE_CHOICES_DICT[self.rtype]
517518
519 @property
520 def last_deployed(self) -> timezone.datetime:
521 """Returns the most recent time of deplyment for an image."""
522 # Mock data: Generates a random time based on the hash of the
523 # resource name.
524 ms_py = 3153600000000
525 return timezone.datetime(2022, 6, 1) + timezone.timedelta(
526 microseconds=hash(self.name) % ms_py
527 )
528
518 def clean(self):529 def clean(self):
519 """Validate the model.530 """Validate the model.
520531
diff --git a/src/maasserver/websockets/handlers/bootresource.py b/src/maasserver/websockets/handlers/bootresource.py
index 89d3fd3..908af1e 100644
--- a/src/maasserver/websockets/handlers/bootresource.py
+++ b/src/maasserver/websockets/handlers/bootresource.py
@@ -597,6 +597,9 @@ class BootResourceHandler(Handler):
597 "lastUpdate": resource.last_update.strftime(597 "lastUpdate": resource.last_update.strftime(
598 "%a, %d %b. %Y %H:%M:%S"598 "%a, %d %b. %Y %H:%M:%S"
599 ),599 ),
600 "lastDeployed": resource.last_deployed.strftime(
601 "%a, %d %b. %Y %H:%M:%S"
602 ),
600 }603 }
601 for resource in self.combine_resources(604 for resource in self.combine_resources(
602 BootResource.objects.filter(bootloader_type=None)605 BootResource.objects.filter(bootloader_type=None)

Subscribers

People subscribed via source and target branches