Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ab7f53b9
authored
Mar 14, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: rename Instance.destoryed to destroyed_at
parent
b2b4580c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
16 deletions
+16
-16
circle/dashboard/fixtures/test-vm-fixture.json
+2
-2
circle/dashboard/views.py
+3
-3
circle/network/views.py
+2
-2
circle/vm/migrations/0019_rename_instance_destroyed.py
+0
-0
circle/vm/models/instance.py
+7
-7
circle/vm/models/network.py
+1
-1
circle/vm/tasks/local_periodic_tasks.py
+1
-1
No files found.
circle/dashboard/fixtures/test-vm-fixture.json
View file @
ab7f53b9
...
@@ -1344,7 +1344,7 @@
...
@@ -1344,7 +1344,7 @@
"pk"
:
1
,
"pk"
:
1
,
"model"
:
"vm.instance"
,
"model"
:
"vm.instance"
,
"fields"
:
{
"fields"
:
{
"destroyed"
:
null
,
"destroyed
_at
"
:
null
,
"disks"
:
[
"disks"
:
[
1
1
],
],
...
@@ -1375,7 +1375,7 @@
...
@@ -1375,7 +1375,7 @@
"pk"
:
12
,
"pk"
:
12
,
"model"
:
"vm.instance"
,
"model"
:
"vm.instance"
,
"fields"
:
{
"fields"
:
{
"destroyed"
:
null
,
"destroyed
_at
"
:
null
,
"disks"
:
[],
"disks"
:
[],
"boot_menu"
:
false
,
"boot_menu"
:
false
,
"owner"
:
1
,
"owner"
:
1
,
...
...
circle/dashboard/views.py
View file @
ab7f53b9
...
@@ -88,7 +88,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
...
@@ -88,7 +88,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
favs
=
Instance
.
objects
.
filter
(
favourite__user
=
self
.
request
.
user
)
favs
=
Instance
.
objects
.
filter
(
favourite__user
=
self
.
request
.
user
)
instances
=
Instance
.
get_objects_with_level
(
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
))
display
=
list
(
favs
)
+
list
(
set
(
instances
)
-
set
(
favs
))
for
d
in
display
:
for
d
in
display
:
d
.
fav
=
True
if
d
in
favs
else
False
d
.
fav
=
True
if
d
in
favs
else
False
...
@@ -882,7 +882,7 @@ class VmList(LoginRequiredMixin, ListView):
...
@@ -882,7 +882,7 @@ class VmList(LoginRequiredMixin, ListView):
favourite__user
=
self
.
request
.
user
)
.
values_list
(
'pk'
,
flat
=
True
)
favourite__user
=
self
.
request
.
user
)
.
values_list
(
'pk'
,
flat
=
True
)
instances
=
Instance
.
get_objects_with_level
(
instances
=
Instance
.
get_objects_with_level
(
'user'
,
self
.
request
.
user
)
.
filter
(
'user'
,
self
.
request
.
user
)
.
filter
(
destroyed
=
None
)
.
all
()
destroyed
_at
=
None
)
.
all
()
instances
=
[{
instances
=
[{
'pk'
:
i
.
pk
,
'pk'
:
i
.
pk
,
'name'
:
i
.
name
,
'name'
:
i
.
name
,
...
@@ -899,7 +899,7 @@ class VmList(LoginRequiredMixin, ListView):
...
@@ -899,7 +899,7 @@ class VmList(LoginRequiredMixin, ListView):
logger
.
debug
(
'VmList.get_queryset() called. User:
%
s'
,
logger
.
debug
(
'VmList.get_queryset() called. User:
%
s'
,
unicode
(
self
.
request
.
user
))
unicode
(
self
.
request
.
user
))
queryset
=
Instance
.
get_objects_with_level
(
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"
)
s
=
self
.
request
.
GET
.
get
(
"s"
)
if
s
:
if
s
:
queryset
=
queryset
.
filter
(
name__icontains
=
s
)
queryset
=
queryset
.
filter
(
name__icontains
=
s
)
...
...
circle/network/views.py
View file @
ab7f53b9
...
@@ -162,7 +162,7 @@ class DomainDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -162,7 +162,7 @@ class DomainDetail(LoginRequiredMixin, SuperuserRequiredMixin,
domain
=
self
.
object
,
domain
=
self
.
object
,
host__in
=
Host
.
objects
.
filter
(
host__in
=
Host
.
objects
.
filter
(
interface__in
=
Interface
.
objects
.
filter
(
interface__in
=
Interface
.
objects
.
filter
(
instance__destroyed
=
None
)
instance__destroyed
_at
=
None
)
)
)
)
)
context
[
'record_list'
]
=
SmallRecordTable
(
q
)
context
[
'record_list'
]
=
SmallRecordTable
(
q
)
...
@@ -618,7 +618,7 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -618,7 +618,7 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
context
=
super
(
VlanDetail
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
VlanDetail
,
self
)
.
get_context_data
(
**
kwargs
)
q
=
Host
.
objects
.
filter
(
interface__in
=
Interface
.
objects
.
filter
(
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
)
context
[
'host_list'
]
=
SmallHostTable
(
q
)
...
...
circle/vm/migrations/0019_rename_instance_destroyed.py
0 → 100644
View file @
ab7f53b9
This diff is collapsed.
Click to expand it.
circle/vm/models/instance.py
View file @
ab7f53b9
...
@@ -70,7 +70,7 @@ class InstanceActiveManager(Manager):
...
@@ -70,7 +70,7 @@ class InstanceActiveManager(Manager):
def
get_query_set
(
self
):
def
get_query_set
(
self
):
return
super
(
InstanceActiveManager
,
return
super
(
InstanceActiveManager
,
self
)
.
get_query_set
()
.
filter
(
destroyed
=
None
)
self
)
.
get_query_set
()
.
filter
(
destroyed
_at
=
None
)
class
VirtualMachineDescModel
(
BaseResourceConfigModel
):
class
VirtualMachineDescModel
(
BaseResourceConfigModel
):
...
@@ -203,9 +203,9 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -203,9 +203,9 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
help_text
=
_
(
"TCP port where VNC console listens."
),
help_text
=
_
(
"TCP port where VNC console listens."
),
unique
=
True
,
verbose_name
=
_
(
'vnc_port'
))
unique
=
True
,
verbose_name
=
_
(
'vnc_port'
))
owner
=
ForeignKey
(
User
)
owner
=
ForeignKey
(
User
)
destroyed
=
DateTimeField
(
blank
=
True
,
null
=
True
,
destroyed
_at
=
DateTimeField
(
blank
=
True
,
null
=
True
,
help_text
=
_
(
"The virtual machine's time of "
help_text
=
_
(
"The virtual machine's time of "
"destruction."
))
"destruction."
))
objects
=
Manager
()
objects
=
Manager
()
active
=
InstanceActiveManager
()
active
=
InstanceActiveManager
()
...
@@ -752,7 +752,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -752,7 +752,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
asynchronously.
asynchronously.
:type task_uuid: str
:type task_uuid: str
"""
"""
if
self
.
destroyed
:
if
self
.
destroyed
_at
:
raise
self
.
InstanceDestroyedError
(
self
)
raise
self
.
InstanceDestroyedError
(
self
)
def
__on_commit
(
activity
):
def
__on_commit
(
activity
):
...
@@ -901,7 +901,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -901,7 +901,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
asynchronously.
asynchronously.
:type task_uuid: str
:type task_uuid: str
"""
"""
if
self
.
destroyed
:
if
self
.
destroyed
_at
:
return
# already destroyed, nothing to do here
return
# already destroyed, nothing to do here
def
__on_commit
(
activity
):
def
__on_commit
(
activity
):
...
@@ -921,7 +921,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -921,7 +921,7 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
self
.
__cleanup_after_destroy_vm
(
act
)
self
.
__cleanup_after_destroy_vm
(
act
)
self
.
destroyed
=
timezone
.
now
()
self
.
destroyed
_at
=
timezone
.
now
()
self
.
save
()
self
.
save
()
def
destroy_async
(
self
,
user
=
None
):
def
destroy_async
(
self
,
user
=
None
):
...
...
circle/vm/models/network.py
View file @
ab7f53b9
...
@@ -59,7 +59,7 @@ class Interface(Model):
...
@@ -59,7 +59,7 @@ class Interface(Model):
@property
@property
def
destroyed
(
self
):
def
destroyed
(
self
):
return
self
.
instance
.
destroyed
return
self
.
instance
.
destroyed
_at
@property
@property
def
mac
(
self
):
def
mac
(
self
):
...
...
circle/vm/tasks/local_periodic_tasks.py
View file @
ab7f53b9
...
@@ -25,7 +25,7 @@ def garbage_collector(timeout=15):
...
@@ -25,7 +25,7 @@ def garbage_collector(timeout=15):
:type timeout: int
:type timeout: int
"""
"""
now
=
timezone
.
now
()
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
:
if
i
.
time_of_delete
and
now
>
i
.
time_of_delete
:
i
.
destroy_async
()
i
.
destroy_async
()
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
logger
.
info
(
"Expired instance
%
d destroyed."
,
i
.
pk
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment