Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e092b35a
authored
Apr 07, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: remove ResourcesRequestOperation
parent
aa47ae5b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
34 deletions
+23
-34
circle/request/models.py
+5
-1
circle/request/tests.py
+3
-3
circle/request/views.py
+2
-2
circle/vm/operations.py
+13
-28
No files found.
circle/request/models.py
View file @
e092b35a
...
...
@@ -180,7 +180,11 @@ class ResourceChangeAction(RequestAction):
validators
=
[
MinValueValidator
(
0
)])
def
accept
(
self
,
user
):
self
.
instance
.
resources_request
.
async
(
user
=
user
,
resource_request
=
self
)
self
.
instance
.
resources_change
.
async
(
user
=
user
,
num_cores
=
self
.
num_cores
,
ram_size
=
self
.
ram_size
,
max_ram_size
=
self
.
ram_size
,
priority
=
self
.
priority
,
with_shutdown
=
True
)
@property
def
accept_msg
(
self
):
...
...
circle/request/tests.py
View file @
e092b35a
...
...
@@ -27,7 +27,7 @@ from vm.models import Instance, InstanceTemplate, Lease
from
dashboard.models
import
Profile
from
request.models
import
Request
,
LeaseType
,
TemplateAccessType
from
dashboard.tests.test_views
import
LoginMixin
from
vm.operations
import
Resources
Request
Operation
from
vm.operations
import
ResourcesOperation
class
RequestTest
(
LoginMixin
,
MockCeleryMixin
,
TestCase
):
...
...
@@ -85,9 +85,9 @@ class RequestTest(LoginMixin, MockCeleryMixin, TestCase):
# workaround for NOSTATE
inst
.
emergency_change_state
(
new_state
=
"STOPPED"
,
system
=
True
)
with
patch
.
object
(
Resources
Request
Operation
,
'async'
)
as
mock_method
:
with
patch
.
object
(
ResourcesOperation
,
'async'
)
as
mock_method
:
mock_method
.
side_effect
=
(
new_request
.
action
.
instance
.
resources_
request
)
new_request
.
action
.
instance
.
resources_
change
)
new_request
.
accept
(
self
.
us
)
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
...
...
circle/request/views.py
View file @
e092b35a
...
...
@@ -31,7 +31,7 @@ from request.models import (
ExtendLeaseAction
,
ResourceChangeAction
,
)
from
vm.models
import
Instance
from
vm.operations
import
Resources
Request
Operation
from
vm.operations
import
ResourcesOperation
from
request.tables
import
(
RequestTable
,
TemplateAccessTypeTable
,
LeaseTypeTable
,
)
...
...
@@ -91,7 +91,7 @@ class RequestDetail(LoginRequiredMixin, DetailView):
context
=
super
(
RequestDetail
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'action'
]
=
request
.
action
context
[
'accept_states'
]
=
Resources
Request
Operation
.
accept_states
context
[
'accept_states'
]
=
ResourcesOperation
.
accept_states
return
context
...
...
circle/vm/operations.py
View file @
e092b35a
...
...
@@ -1334,10 +1334,21 @@ class ResourcesOperation(InstanceOperation):
description
=
_
(
"Change resources of a stopped virtual machine."
)
acl_level
=
"owner"
required_perms
=
(
'vm.change_resources'
,
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'RUNNING'
)
def
_operation
(
self
,
user
,
activity
,
num_cores
,
ram_size
,
max_ram_size
,
priority
):
num_cores
,
ram_size
,
max_ram_size
,
priority
,
with_shutdown
=
False
,
task
=
None
):
if
self
.
instance
.
status
==
'RUNNING'
and
not
with_shutdown
:
raise
Instance
.
WrongStateError
(
self
.
instance
)
try
:
self
.
instance
.
shutdown
(
parent_activity
=
activity
,
task
=
task
)
except
Instance
.
WrongStateError
:
pass
self
.
instance
.
_update_status
()
self
.
instance
.
num_cores
=
num_cores
self
.
instance
.
ram_size
=
ram_size
self
.
instance
.
max_ram_size
=
max_ram_size
...
...
@@ -1354,32 +1365,6 @@ class ResourcesOperation(InstanceOperation):
@register_operation
class
ResourcesRequestOperation
(
InstanceOperation
):
id
=
"resources_request"
name
=
_
(
"resources request"
)
description
=
""
required_perms
=
()
accept_states
=
(
"STOPPED"
,
"RUNNING"
,
"PENDING"
,
)
async_queue
=
"localhost.man.slow"
def
_operation
(
self
,
user
,
activity
,
resource_request
,
task
=
None
):
try
:
self
.
instance
.
shutdown
(
parent_activity
=
activity
,
task
=
task
)
except
Instance
.
WrongStateError
:
pass
self
.
instance
.
_update_status
()
self
.
instance
.
resources_change
(
parent_activity
=
activity
,
num_cores
=
resource_request
.
num_cores
,
ram_size
=
resource_request
.
ram_size
,
max_ram_size
=
resource_request
.
ram_size
,
priority
=
resource_request
.
priority
)
@register_operation
class
PasswordResetOperation
(
RemoteAgentOperation
):
id
=
'password_reset'
name
=
_
(
"password reset"
)
...
...
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