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
1abc2a1f
authored
Apr 26, 2014
by
cloud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply szakdoga patch
parent
5d753e30
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
2 deletions
+70
-2
circle/dashboard/templates/dashboard/vm-detail.html
+11
-2
circle/dashboard/views.py
+10
-0
circle/vm/models/instance.py
+49
-0
No files found.
circle/dashboard/templates/dashboard/vm-detail.html
View file @
1abc2a1f
...
...
@@ -6,8 +6,16 @@
{% block content %}
<div
class=
"body-content"
>
<div
class=
"page-header"
>
<div
class=
"pull-right"
style=
"padding-top: 15px;"
id=
"ops"
>
{% include "dashboard/vm-detail/_operations.html" %}
<div
class=
"pull-right"
style=
"padding-top: 15px;"
>
<form
style=
"display: inline;"
method=
"POST"
action=
"{% url "
dashboard
.
views
.
detail
"
pk=
instance.pk
%}"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"deploy_local"
/>
<button
title=
"{% trans "
Deploy
on
Local
PC
"
%}"
class=
"btn btn-default
btn-xs"
type=
"submit"
><i
class=
"icon-chevron-right"
></i></button>
</form>
<div
id=
"ops"
>
{% include "dashboard/vm-detail/_operations.html" %}
</div>
</div>
<h1>
<div
id=
"vm-details-rename"
>
...
...
@@ -111,5 +119,6 @@
<script
src=
"{{ STATIC_URL }}dashboard/vm-details.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/vm-common.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/vm-console.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/client-gui.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/disk-list.js"
></script>
{% endblock %}
circle/dashboard/views.py
View file @
1abc2a1f
...
...
@@ -239,6 +239,7 @@ class VmDetailView(CheckedDetailView):
'change_password'
:
self
.
__change_password
,
'new_name'
:
self
.
__set_name
,
'new_tag'
:
self
.
__add_tag
,
'deploy_local'
:
self
.
__deploy_local
,
'to_remove'
:
self
.
__remove_tag
,
'port'
:
self
.
__add_port
,
'new_network_vlan'
:
self
.
__new_network
,
...
...
@@ -247,6 +248,15 @@ class VmDetailView(CheckedDetailView):
if
request
.
POST
.
get
(
k
)
is
not
None
:
return
v
(
request
)
def
__deploy_local
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
return
HttpResponse
(
json
.
dumps
(
self
.
object
.
deploy_local
(
request
.
user
)),
content_type
=
"application/json"
)
def
__change_password
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
...
...
circle/vm/models/instance.py
View file @
1abc2a1f
...
...
@@ -29,6 +29,10 @@ from .common import BaseResourceConfigModel, Lease
from
.network
import
Interface
from
.node
import
Node
,
Trait
import
os
import
random
import
string
logger
=
getLogger
(
__name__
)
pre_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
post_state_changed
=
Signal
(
providing_args
=
[
"new_state"
])
...
...
@@ -180,6 +184,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
(
'NOSTATE'
,
_
(
'no state'
)),
(
'RUNNING'
,
_
(
'running'
)),
(
'STOPPED'
,
_
(
'stopped'
)),
(
'LOCAL_RUNNING'
,
_
(
'local_running'
)),
(
'SUSPENDED'
,
_
(
'suspended'
)),
(
'ERROR'
,
_
(
'error'
)),
(
'PENDING'
,
_
(
'pending'
)),
...
...
@@ -788,6 +793,50 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
__deploy_local_vm
(
self
,
act
,
timeout
=
15
):
"""Local deploy the virtual machine.
:param self: The virtual machine.
:param act: Parent activity.
"""
descriptor
=
self
.
get_vm_desc
()
# create hardlink
hlinkname
=
''
.
join
(
random
.
choice
(
string
.
ascii_uppercase
+
string
.
digits
)
for
_
in
range
(
20
))
remotedest
=
'/mnt/vmdisks/'
+
hlinkname
localdest
=
'/home/cloud/nfs/'
+
hlinkname
localsrc
=
'/home/cloud'
+
descriptor
[
'disk_list'
][
0
][
'source'
]
os
.
link
(
localsrc
,
localdest
)
descriptor
[
'disk_list'
][
0
][
'source'
]
=
remotedest
return
descriptor
def
deploy_local
(
self
,
user
=
None
,
task_uuid
=
None
):
"""Deploy new virtual machine with network
:param self: The virtual machine to deploy.
:type self: vm.models.Instance
:param user: The user who's issuing the command.
:type user: django.contrib.auth.models.User
:param task_uuid: The task's UUID, if the command is being ex
ecuted
asynchronously.
:type task_uuid: str
"""
if
self
.
destroyed_at
:
raise
self
.
InstanceDestroyedError
(
self
)
def
__on_commit
(
activity
):
activity
.
resultant_state
=
'LOCAL_RUNNING'
with
instance_activity
(
code_suffix
=
'local_deploy'
,
instance
=
self
,
on_commit
=
__on_commit
,
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
return
self
.
__deploy_local_vm
(
act
)
def
migrate_vm
(
self
,
to_node
,
timeout
=
120
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
return
vm_tasks
.
migrate
.
apply_async
(
args
=
[
self
.
vm_name
,
...
...
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