Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
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
d84501eb
authored
Jun 06, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove old disk add implementation
parent
e87a615d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
4 additions
and
119 deletions
+4
-119
circle/dashboard/forms.py
+2
-16
circle/dashboard/templates/dashboard/template-edit.html
+0
-11
circle/dashboard/templates/dashboard/vm-detail/resources.html
+0
-14
circle/dashboard/urls.py
+1
-3
circle/dashboard/views.py
+1
-55
circle/vm/operations.py
+0
-20
No files found.
circle/dashboard/forms.py
View file @
d84501eb
...
...
@@ -40,9 +40,9 @@ from django.utils.translation import ugettext as _
from
sizefield.widgets
import
FileSizeWidget
from
firewall.models
import
Vlan
,
Host
from
storage.models
import
Disk
,
DataStore
from
storage.models
import
Disk
from
vm.models
import
(
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
,
Instance
InstanceTemplate
,
Lease
,
InterfaceTemplate
,
Node
,
Trait
)
from
.models
import
Profile
,
GroupProfile
...
...
@@ -846,20 +846,6 @@ class LeaseForm(forms.ModelForm):
model
=
Lease
class
DiskAddForm
(
forms
.
Form
):
name
=
forms
.
CharField
()
size
=
forms
.
CharField
(
widget
=
FileSizeWidget
,
required
=
False
)
url
=
forms
.
CharField
(
required
=
False
)
is_template
=
forms
.
CharField
()
object_pk
=
forms
.
CharField
()
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
is_template
=
kwargs
.
pop
(
"is_template"
)
self
.
object_pk
=
kwargs
.
pop
(
"object_pk"
)
self
.
user
=
kwargs
.
pop
(
"user"
)
super
(
DiskAddForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
initial
[
'is_template'
]
=
1
if
self
.
is_template
else
0
self
.
initial
[
'object_pk'
]
=
self
.
object_pk
def
clean_size
(
self
):
size_in_bytes
=
self
.
cleaned_data
.
get
(
"size"
)
...
...
circle/dashboard/templates/dashboard/template-edit.html
View file @
d84501eb
...
...
@@ -105,17 +105,6 @@
</ul>
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<h4
class=
"no-margin"
><i
class=
"icon-folder-open"
></i>
{% trans "Create new disk" %}
</h4>
</div>
<div
class=
"panel-body"
>
<form
action=
"{% url "
dashboard
.
views
.
disk-add
"
%}"
method=
"POST"
>
{% crispy disk_add_form %}
</form>
</div>
</div>
</div>
<!-- .col-md-4 -->
</div>
<!-- .row -->
...
...
circle/dashboard/templates/dashboard/vm-detail/resources.html
View file @
d84501eb
...
...
@@ -47,9 +47,6 @@
<h3>
{% trans "Disks" %}
<div
class=
"pull-right"
>
<a
href=
"#"
id=
"vm-details-disk-add"
class=
"btn btn-success btn-xs"
>
<i
class=
"icon-plus"
></i>
{% trans "Add new disk" %}
</a>
</div>
</h3>
...
...
@@ -68,17 +65,6 @@
</div>
</div>
<div
class=
"js-hidden row"
id=
"vm-details-disk-add-form"
>
<div
class=
"col-md-12"
>
<div>
<hr
/>
<form
method=
"POST"
action=
"{% url "
dashboard
.
views
.
disk-add
"
%}"
style=
"max-width: 350px;"
>
{% crispy forms.disk_add_form %}
</form>
<hr
/>
</div>
</div>
</div>
{% block extra_js %}
<style>
...
...
circle/dashboard/urls.py
View file @
d84501eb
...
...
@@ -20,7 +20,7 @@ from django.conf.urls import patterns, url, include
from
vm.models
import
Instance
from
.views
import
(
AclUpdateView
,
DiskAddView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDelete
,
AclUpdateView
,
FavouriteView
,
GroupAclUpdateView
,
GroupDelete
,
GroupDetailView
,
GroupList
,
IndexView
,
InstanceActivityDetail
,
LeaseCreate
,
LeaseDelete
,
LeaseDetail
,
MyPreferencesView
,
NodeAddTraitView
,
NodeCreate
,
NodeDelete
,
...
...
@@ -128,8 +128,6 @@ urlpatterns = patterns(
url
(
r'^notifications/$'
,
NotificationView
.
as_view
(),
name
=
"dashboard.views.notifications"
),
url
(
r'^disk/add/$'
,
DiskAddView
.
as_view
(),
name
=
"dashboard.views.disk-add"
),
url
(
r'^disk/(?P<pk>\d+)/remove/$'
,
DiskRemoveView
.
as_view
(),
name
=
"dashboard.views.disk-remove"
),
url
(
r'^disk/(?P<pk>\d+)/status/$'
,
get_disk_download_status
,
...
...
circle/dashboard/views.py
View file @
d84501eb
...
...
@@ -45,7 +45,6 @@ from django.views.generic import (TemplateView, DetailView, View, DeleteView,
from
django.contrib
import
messages
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ungettext
as
__
from
django.template.defaultfilters
import
title
as
title_filter
from
django.template.loader
import
render_to_string
from
django.template
import
RequestContext
from
django.templatetags.static
import
static
...
...
@@ -57,7 +56,7 @@ from braces.views import (LoginRequiredMixin, SuperuserRequiredMixin,
from
braces.views._access
import
AccessMixin
from
.forms
import
(
CircleAuthenticationForm
,
DiskAddForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
CircleAuthenticationForm
,
HostForm
,
LeaseForm
,
MyProfileForm
,
NodeForm
,
TemplateForm
,
TraitForm
,
VmCustomizeForm
,
GroupCreateForm
,
UserCreationForm
,
GroupProfileUpdateForm
,
UnsubscribeForm
,
CirclePasswordChangeForm
,
VmSaveForm
,
...
...
@@ -277,12 +276,6 @@ class VmDetailView(CheckedDetailView):
instance
=
self
.
get_object
())
.
values_list
(
"vlan"
,
flat
=
True
)
)
.
all
()
context
[
'acl'
]
=
get_vm_acl_data
(
instance
)
context
[
'forms'
]
=
{
'disk_add_form'
:
DiskAddForm
(
user
=
self
.
request
.
user
,
is_template
=
False
,
object_pk
=
self
.
get_object
()
.
pk
,
prefix
=
"disk"
),
}
context
[
'os_type_icon'
]
=
instance
.
os_type
.
replace
(
"unknown"
,
"question"
)
# ipv6 infos
...
...
@@ -1066,12 +1059,6 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
context
=
super
(
TemplateDetail
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'acl'
]
=
get_vm_acl_data
(
obj
)
context
[
'disks'
]
=
obj
.
disks
.
all
()
context
[
'disk_add_form'
]
=
DiskAddForm
(
user
=
self
.
request
.
user
,
is_template
=
True
,
object_pk
=
obj
.
pk
,
prefix
=
"disk"
,
)
return
context
def
get_success_url
(
self
):
...
...
@@ -2525,47 +2512,6 @@ def circle_login(request):
return
response
class
DiskAddView
(
TemplateView
):
def
post
(
self
,
*
args
,
**
kwargs
):
is_template
=
self
.
request
.
POST
.
get
(
"disk-is_template"
)
object_pk
=
self
.
request
.
POST
.
get
(
"disk-object_pk"
)
is_template
=
int
(
is_template
)
==
1
if
is_template
:
obj
=
InstanceTemplate
.
objects
.
get
(
pk
=
object_pk
)
else
:
obj
=
Instance
.
objects
.
get
(
pk
=
object_pk
)
if
not
obj
.
has_level
(
self
.
request
.
user
,
'owner'
):
raise
PermissionDenied
()
form
=
DiskAddForm
(
self
.
request
.
POST
,
user
=
self
.
request
.
user
,
is_template
=
is_template
,
object_pk
=
object_pk
,
prefix
=
"disk"
)
if
form
.
is_valid
():
if
form
.
cleaned_data
.
get
(
"size"
):
messages
.
success
(
self
.
request
,
_
(
"Disk successfully added."
))
else
:
messages
.
success
(
self
.
request
,
_
(
"Disk download started."
))
form
.
save
()
else
:
error
=
"<br /> "
.
join
([
"<strong>
%
s</strong>:
%
s"
%
(
title_filter
(
i
[
0
]),
i
[
1
][
0
])
for
i
in
form
.
errors
.
items
()])
messages
.
error
(
self
.
request
,
error
)
if
is_template
:
r
=
obj
.
get_absolute_url
()
else
:
r
=
obj
.
get_absolute_url
()
r
=
"
%
s#resources"
%
r
return
redirect
(
r
)
class
MyPreferencesView
(
UpdateView
):
model
=
Profile
...
...
circle/vm/operations.py
View file @
d84501eb
...
...
@@ -100,26 +100,6 @@ class AddInterfaceOperation(InstanceOperation):
register_operation
(
AddInterfaceOperation
)
class
AddDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'add_disk'
id
=
'add_disk'
name
=
_
(
"add disk"
)
description
=
_
(
"Add the specified disk to the VM."
)
def
check_precond
(
self
):
super
(
AddDiskOperation
,
self
)
.
check_precond
()
# TODO remove check when hot-attach is implemented
if
self
.
instance
.
status
not
in
[
'STOPPED'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
activity
,
user
,
system
,
disk
):
# TODO implement with hot-attach when it'll be available
return
self
.
instance
.
disks
.
add
(
disk
)
register_operation
(
AddDiskOperation
)
class
CreateDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'create_disk'
id
=
'create_disk'
...
...
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