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
61c03f78
authored
Nov 28, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: move NodeActivity to vm.models.activity
parent
65aeedfe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
42 deletions
+39
-42
circle/vm/models/__init__.py
+1
-1
circle/vm/models/activity.py
+37
-0
circle/vm/models/node.py
+1
-41
No files found.
circle/vm/models/__init__.py
View file @
61c03f78
# flake8: noqa
# flake8: noqa
from
.activity
import
NodeActivity
from
.activity
import
InstanceActivity
from
.activity
import
InstanceActivity
from
.instance
import
InstanceActiveManager
from
.instance
import
InstanceActiveManager
from
.instance
import
BaseResourceConfigModel
from
.instance
import
BaseResourceConfigModel
...
@@ -12,7 +13,6 @@ from .network import InterfaceTemplate
...
@@ -12,7 +13,6 @@ from .network import InterfaceTemplate
from
.network
import
Interface
from
.network
import
Interface
from
.node
import
Trait
from
.node
import
Trait
from
.node
import
Node
from
.node
import
Node
from
.node
import
NodeActivity
from
.node
import
Lease
from
.node
import
Lease
__all__
=
[
__all__
=
[
...
...
circle/vm/models/activity.py
View file @
61c03f78
...
@@ -58,3 +58,40 @@ class InstanceActivity(ActivityModel):
...
@@ -58,3 +58,40 @@ class InstanceActivity(ActivityModel):
def
instance_activity
(
code_suffix
,
instance
,
task_uuid
=
None
,
user
=
None
):
def
instance_activity
(
code_suffix
,
instance
,
task_uuid
=
None
,
user
=
None
):
act
=
InstanceActivity
.
create
(
code_suffix
,
instance
,
task_uuid
,
user
)
act
=
InstanceActivity
.
create
(
code_suffix
,
instance
,
task_uuid
,
user
)
return
activitycontextimpl
(
act
)
return
activitycontextimpl
(
act
)
class
NodeActivity
(
ActivityModel
):
node
=
ForeignKey
(
'Node'
,
related_name
=
'activity_log'
,
help_text
=
_
(
'Node this activity works on.'
),
verbose_name
=
_
(
'node'
))
class
Meta
:
app_label
=
'vm'
db_table
=
'vm_nodeactivity'
@classmethod
def
create
(
cls
,
code_suffix
,
node
,
task_uuid
=
None
,
user
=
None
):
act
=
cls
(
activity_code
=
'vm.Node.'
+
code_suffix
,
node
=
node
,
parent
=
None
,
started
=
timezone
.
now
(),
task_uuid
=
task_uuid
,
user
=
user
)
act
.
save
()
return
act
def
create_sub
(
self
,
code_suffix
,
task_uuid
=
None
):
act
=
NodeActivity
(
activity_code
=
self
.
activity_code
+
'.'
+
code_suffix
,
node
=
self
.
node
,
parent
=
self
,
started
=
timezone
.
now
(),
task_uuid
=
task_uuid
,
user
=
self
.
user
)
act
.
save
()
return
act
@contextmanager
def
sub_activity
(
self
,
code_suffix
,
task_uuid
=
None
):
act
=
self
.
create_sub
(
code_suffix
,
task_uuid
)
return
activitycontextimpl
(
act
)
@contextmanager
def
node_activity
(
code_suffix
,
node
,
task_uuid
=
None
,
user
=
None
):
act
=
InstanceActivity
.
create
(
code_suffix
,
node
,
task_uuid
,
user
)
return
activitycontextimpl
(
act
)
circle/vm/models/node.py
View file @
61c03f78
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
contextlib
import
contextmanager
from
datetime
import
timedelta
from
datetime
import
timedelta
from
logging
import
getLogger
from
logging
import
getLogger
...
@@ -7,17 +6,15 @@ from django.db.models import (
...
@@ -7,17 +6,15 @@ from django.db.models import (
Model
,
CharField
,
IntegerField
,
ForeignKey
,
BooleanField
,
ManyToManyField
,
Model
,
CharField
,
IntegerField
,
ForeignKey
,
BooleanField
,
ManyToManyField
,
FloatField
,
FloatField
,
)
)
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
celery.exceptions
import
TimeoutError
from
celery.exceptions
import
TimeoutError
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
taggit.managers
import
TaggableManager
from
taggit.managers
import
TaggableManager
from
common.models
import
ActivityModel
,
activitycontextimpl
,
method_cache
from
common.models
import
method_cache
from
firewall.models
import
Host
from
firewall.models
import
Host
from
..tasks
import
vm_tasks
from
..tasks
import
vm_tasks
from
.activity
import
InstanceActivity
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
...
@@ -139,43 +136,6 @@ class Node(TimeStampedModel):
...
@@ -139,43 +136,6 @@ class Node(TimeStampedModel):
return
self
.
name
return
self
.
name
class
NodeActivity
(
ActivityModel
):
node
=
ForeignKey
(
Node
,
related_name
=
'activity_log'
,
help_text
=
_
(
'Node this activity works on.'
),
verbose_name
=
_
(
'node'
))
class
Meta
:
app_label
=
'vm'
db_table
=
'vm_nodeactivity'
@classmethod
def
create
(
cls
,
code_suffix
,
node
,
task_uuid
=
None
,
user
=
None
):
act
=
cls
(
activity_code
=
'vm.Node.'
+
code_suffix
,
node
=
node
,
parent
=
None
,
started
=
timezone
.
now
(),
task_uuid
=
task_uuid
,
user
=
user
)
act
.
save
()
return
act
def
create_sub
(
self
,
code_suffix
,
task_uuid
=
None
):
act
=
NodeActivity
(
activity_code
=
self
.
activity_code
+
'.'
+
code_suffix
,
node
=
self
.
node
,
parent
=
self
,
started
=
timezone
.
now
(),
task_uuid
=
task_uuid
,
user
=
self
.
user
)
act
.
save
()
return
act
@contextmanager
def
sub_activity
(
self
,
code_suffix
,
task_uuid
=
None
):
act
=
self
.
create_sub
(
code_suffix
,
task_uuid
)
return
activitycontextimpl
(
act
)
@contextmanager
def
node_activity
(
code_suffix
,
node
,
task_uuid
=
None
,
user
=
None
):
act
=
InstanceActivity
.
create
(
code_suffix
,
node
,
task_uuid
,
user
)
return
activitycontextimpl
(
act
)
class
Lease
(
Model
):
class
Lease
(
Model
):
"""Lease times for VM instances.
"""Lease times for VM instances.
...
...
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