Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
583f2684
authored
Apr 20, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement interface detach
parent
d90e9949
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
43 deletions
+9
-43
.idea/workspace.xml
+0
-0
circle/dashboard/forms.py
+3
-16
circle/dashboard/templates/dashboard/vm-detail/network.html
+1
-1
circle/dashboard/views/vm.py
+2
-13
circle/vm/operations.py
+3
-13
No files found.
.idea/workspace.xml
View file @
583f2684
This diff is collapsed.
Click to expand it.
circle/dashboard/forms.py
View file @
583f2684
...
@@ -863,30 +863,17 @@ class VmDownloadDiskForm(OperationForm):
...
@@ -863,30 +863,17 @@ class VmDownloadDiskForm(OperationForm):
class
VmRemoveInterfaceForm
(
OperationForm
):
class
VmRemoveInterfaceForm
(
OperationForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
port_id
=
kwargs
.
pop
(
'port_id'
)
self
.
interface
=
kwargs
.
pop
(
'default'
)
super
(
VmRemoveInterfaceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
VmRemoveInterfaceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'interface'
]
=
forms
.
ModelChoiceField
(
self
.
fields
[
'port_id'
]
=
forms
.
CharField
(
widget
=
forms
.
HiddenInput
(),
initial
=
port_id
)
queryset
=
choices
,
initial
=
self
.
interface
,
required
=
True
,
empty_label
=
None
,
label
=
_
(
'Interface'
))
if
self
.
interface
:
self
.
fields
[
'interface'
]
.
widget
=
HiddenInput
()
@property
@property
def
helper
(
self
):
def
helper
(
self
):
helper
=
super
(
VmRemoveInterfaceForm
,
self
)
.
helper
helper
=
super
(
VmRemoveInterfaceForm
,
self
)
.
helper
if
self
.
interface
:
helper
.
layout
=
Layout
(
helper
.
layout
=
Layout
(
AnyTag
(
Field
(
"port_id"
),
"div"
,
HTML
(
format_html
(
_
(
"<label>Vlan:</label> {0}"
),
self
.
interface
.
vlan
)),
css_class
=
"form-group"
,
),
Field
(
"interface"
),
)
)
return
helper
return
helper
...
...
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
583f2684
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
{% with op=op.remove_interface %}{% if op %}
{% with op=op.remove_interface %}{% if op %}
<span
class=
"operation-wrapper"
>
<span
class=
"operation-wrapper"
>
<a
href=
"{{op.get_url}}?
interface={{ i.pk
}}"
<a
href=
"{{op.get_url}}?
port_id={{ i.port_id
}}"
class=
"btn btn-{{op.effect}} btn-xs operation interface-remove"
class=
"btn btn-{{op.effect}} btn-xs operation interface-remove"
{%
if
op
.
disabled
%}
disabled
{%
endif
%}
>
{% trans "remove" %}
{%
if
op
.
disabled
%}
disabled
{%
endif
%}
>
{% trans "remove" %}
</a>
</a>
...
...
circle/dashboard/views/vm.py
View file @
583f2684
...
@@ -366,25 +366,14 @@ class VmRemoveInterfaceView(FormOperationMixin, VmOperationView):
...
@@ -366,25 +366,14 @@ class VmRemoveInterfaceView(FormOperationMixin, VmOperationView):
op
=
'remove_interface'
op
=
'remove_interface'
form_class
=
VmRemoveInterfaceForm
form_class
=
VmRemoveInterfaceForm
show_in_toolbar
=
False
show_in_toolbar
=
False
wait_for_result
=
0.5
icon
=
'times'
icon
=
'times'
effect
=
"danger"
effect
=
"danger"
with_reload
=
True
def
get_form_kwargs
(
self
):
def
get_form_kwargs
(
self
):
instance
=
self
.
get_op
()
.
instance
port_id
=
self
.
request
.
GET
.
get
(
'port_id'
)
choices
=
instance
.
interface_set
.
all
()
interface_pk
=
self
.
request
.
GET
.
get
(
'interface'
)
if
interface_pk
:
try
:
default
=
choices
.
get
(
pk
=
interface_pk
)
except
(
ValueError
,
Interface
.
DoesNotExist
):
raise
Http404
()
else
:
default
=
None
val
=
super
(
VmRemoveInterfaceView
,
self
)
.
get_form_kwargs
()
val
=
super
(
VmRemoveInterfaceView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'
choices'
:
choices
,
'default'
:
default
})
val
.
update
({
'
port_id'
:
port_id
})
return
val
return
val
...
...
circle/vm/operations.py
View file @
583f2684
...
@@ -403,21 +403,11 @@ class RemoveInterfaceOperation(InstanceOperation):
...
@@ -403,21 +403,11 @@ class RemoveInterfaceOperation(InstanceOperation):
description
=
_
(
"Remove the specified network interface and erase IP "
description
=
_
(
"Remove the specified network interface and erase IP "
"address allocations, related firewall rules and "
"address allocations, related firewall rules and "
"hostnames."
)
"hostnames."
)
required_perms
=
()
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'ACTIVE'
)
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'ACTIVE'
)
os_policy_actions
=
((
"compute"
,
"compute:detach_interface"
),)
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
def
_operation
(
self
,
request
,
port_id
):
if
self
.
instance
.
is_running
:
openstack_api
.
nova
.
interface_detach
(
request
,
self
.
instance
.
id
,
port_id
)
self
.
instance
.
_detach_network
(
interface
=
interface
,
parent_activity
=
activity
)
interface
.
shutdown
()
interface
.
destroy
()
interface
.
delete
()
def
get_activity_name
(
self
,
kwargs
):
return
create_readable
(
ugettext_noop
(
"remove
%(vlan)
s interface"
),
vlan
=
kwargs
[
'interface'
]
.
vlan
)
@register_operation
@register_operation
...
...
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