Commit ab7f53b9 by Őry Máté

vm: rename Instance.destoryed to destroyed_at

parent b2b4580c
......@@ -1344,7 +1344,7 @@
"pk": 1,
"model": "vm.instance",
"fields": {
"destroyed": null,
"destroyed_at": null,
"disks": [
1
],
......@@ -1375,7 +1375,7 @@
"pk": 12,
"model": "vm.instance",
"fields": {
"destroyed": null,
"destroyed_at": null,
"disks": [],
"boot_menu": false,
"owner": 1,
......
......@@ -88,7 +88,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
favs = Instance.objects.filter(favourite__user=self.request.user)
instances = Instance.get_objects_with_level(
'user', user).filter(destroyed=None)
'user', user).filter(destroyed_at=None)
display = list(favs) + list(set(instances) - set(favs))
for d in display:
d.fav = True if d in favs else False
......@@ -882,7 +882,7 @@ class VmList(LoginRequiredMixin, ListView):
favourite__user=self.request.user).values_list('pk', flat=True)
instances = Instance.get_objects_with_level(
'user', self.request.user).filter(
destroyed=None).all()
destroyed_at=None).all()
instances = [{
'pk': i.pk,
'name': i.name,
......@@ -899,7 +899,7 @@ class VmList(LoginRequiredMixin, ListView):
logger.debug('VmList.get_queryset() called. User: %s',
unicode(self.request.user))
queryset = Instance.get_objects_with_level(
'user', self.request.user).filter(destroyed=None)
'user', self.request.user).filter(destroyed_at=None)
s = self.request.GET.get("s")
if s:
queryset = queryset.filter(name__icontains=s)
......
......@@ -162,7 +162,7 @@ class DomainDetail(LoginRequiredMixin, SuperuserRequiredMixin,
domain=self.object,
host__in=Host.objects.filter(
interface__in=Interface.objects.filter(
instance__destroyed=None)
instance__destroyed_at=None)
)
)
context['record_list'] = SmallRecordTable(q)
......@@ -618,7 +618,7 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
context = super(VlanDetail, self).get_context_data(**kwargs)
q = Host.objects.filter(interface__in=Interface.objects.filter(
vlan=self.object, instance__destroyed=None
vlan=self.object, instance__destroyed_at=None
))
context['host_list'] = SmallHostTable(q)
......
......@@ -70,7 +70,7 @@ class InstanceActiveManager(Manager):
def get_query_set(self):
return super(InstanceActiveManager,
self).get_query_set().filter(destroyed=None)
self).get_query_set().filter(destroyed_at=None)
class VirtualMachineDescModel(BaseResourceConfigModel):
......@@ -203,9 +203,9 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
help_text=_("TCP port where VNC console listens."),
unique=True, verbose_name=_('vnc_port'))
owner = ForeignKey(User)
destroyed = DateTimeField(blank=True, null=True,
help_text=_("The virtual machine's time of "
"destruction."))
destroyed_at = DateTimeField(blank=True, null=True,
help_text=_("The virtual machine's time of "
"destruction."))
objects = Manager()
active = InstanceActiveManager()
......@@ -752,7 +752,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
asynchronously.
:type task_uuid: str
"""
if self.destroyed:
if self.destroyed_at:
raise self.InstanceDestroyedError(self)
def __on_commit(activity):
......@@ -901,7 +901,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
asynchronously.
:type task_uuid: str
"""
if self.destroyed:
if self.destroyed_at:
return # already destroyed, nothing to do here
def __on_commit(activity):
......@@ -921,7 +921,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
self.__cleanup_after_destroy_vm(act)
self.destroyed = timezone.now()
self.destroyed_at = timezone.now()
self.save()
def destroy_async(self, user=None):
......
......@@ -59,7 +59,7 @@ class Interface(Model):
@property
def destroyed(self):
return self.instance.destroyed
return self.instance.destroyed_at
@property
def mac(self):
......
......@@ -25,7 +25,7 @@ def garbage_collector(timeout=15):
:type timeout: int
"""
now = timezone.now()
for i in Instance.objects.filter(destroyed=None).all():
for i in Instance.objects.filter(destroyed_at=None).all():
if i.time_of_delete and now > i.time_of_delete:
i.destroy_async()
logger.info("Expired instance %d destroyed.", i.pk)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment