Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
07e58f59
authored
Apr 19, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-operations-view'
parents
21a68f69
24bad338
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
circle/dashboard/tests/test_mockedviews.py
+1
-0
circle/vm/operations.py
+11
-2
circle/vm/tests/test_operations.py
+7
-0
No files found.
circle/dashboard/tests/test_mockedviews.py
View file @
07e58f59
...
@@ -112,6 +112,7 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -112,6 +112,7 @@ class VmOperationViewTestCase(unittest.TestCase):
self
.
assertEquals
(
self
.
assertEquals
(
view
.
as_view
()(
request
,
pk
=
1234
)
.
render
()
.
status_code
,
200
)
view
.
as_view
()(
request
,
pk
=
1234
)
.
render
()
.
status_code
,
200
)
def
FakeRequestFactory
(
*
args
,
**
kwargs
):
def
FakeRequestFactory
(
*
args
,
**
kwargs
):
''' FakeRequestFactory, FakeMessages and FakeRequestContext are good for
''' FakeRequestFactory, FakeMessages and FakeRequestContext are good for
mocking out django views; they are MUCH faster than the Django test client.
mocking out django views; they are MUCH faster than the Django test client.
...
...
circle/vm/operations.py
View file @
07e58f59
from
__future__
import
absolute_import
,
unicode_literals
from
__future__
import
absolute_import
,
unicode_literals
from
logging
import
getLogger
from
logging
import
getLogger
from
re
import
match
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -202,7 +203,15 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -202,7 +203,15 @@ class SaveAsTemplateOperation(InstanceOperation):
"""
)
"""
)
icon
=
'save'
icon
=
'save'
def
_operation
(
self
,
activity
,
name
,
user
,
system
,
timeout
=
300
,
def
_rename
(
self
,
name
):
m
=
match
(
"^(.*)( v(
\
d+))?$"
,
name
)
if
m
.
group
(
3
)
is
None
:
v
=
2
else
:
v
=
int
(
v
)
+
1
return
"
%
s v
%
d"
%
(
m
.
group
(
1
),
v
)
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
300
,
with_shutdown
=
True
,
**
kwargs
):
with_shutdown
=
True
,
**
kwargs
):
if
with_shutdown
:
if
with_shutdown
:
try
:
try
:
...
@@ -219,7 +228,7 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -219,7 +228,7 @@ class SaveAsTemplateOperation(InstanceOperation):
'description'
:
self
.
instance
.
description
,
'description'
:
self
.
instance
.
description
,
'lease'
:
self
.
instance
.
lease
,
# Can be problem in new VM
'lease'
:
self
.
instance
.
lease
,
# Can be problem in new VM
'max_ram_size'
:
self
.
instance
.
max_ram_size
,
'max_ram_size'
:
self
.
instance
.
max_ram_size
,
'name'
:
name
,
'name'
:
self
.
_rename
(
self
.
instance
.
name
)
,
'num_cores'
:
self
.
instance
.
num_cores
,
'num_cores'
:
self
.
instance
.
num_cores
,
'owner'
:
user
,
'owner'
:
user
,
'parent'
:
self
.
instance
.
template
,
# Can be problem
'parent'
:
self
.
instance
.
template
,
# Can be problem
...
...
circle/vm/tests/test_operations.py
View file @
07e58f59
...
@@ -43,6 +43,13 @@ class SaveAsTemplateOperationTestCase(TestCase):
...
@@ -43,6 +43,13 @@ class SaveAsTemplateOperationTestCase(TestCase):
def
test_operation_registered
(
self
):
def
test_operation_registered
(
self
):
assert
SaveAsTemplateOperation
.
id
in
getattr
(
Instance
,
op_reg_name
)
assert
SaveAsTemplateOperation
.
id
in
getattr
(
Instance
,
op_reg_name
)
def
test_rename
(
self
):
assert
SaveAsTemplateOperation
.
_rename
(
"foo"
)
==
"foo v2"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v2"
)
==
"foo v3"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v"
)
==
"foo v v2"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v9"
)
==
"foo v10"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v111"
)
==
"foo v112"
class
ShutdownOperationTestCase
(
TestCase
):
class
ShutdownOperationTestCase
(
TestCase
):
def
test_operation_registered
(
self
):
def
test_operation_registered
(
self
):
...
...
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