Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
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):
class
VmRemoveInterfaceForm
(
OperationForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
choices
=
kwargs
.
pop
(
'choices'
)
self
.
interface
=
kwargs
.
pop
(
'default'
)
port_id
=
kwargs
.
pop
(
'port_id'
)
super
(
VmRemoveInterfaceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'interface'
]
=
forms
.
ModelChoiceField
(
queryset
=
choices
,
initial
=
self
.
interface
,
required
=
True
,
empty_label
=
None
,
label
=
_
(
'Interface'
))
if
self
.
interface
:
self
.
fields
[
'interface'
]
.
widget
=
HiddenInput
()
self
.
fields
[
'port_id'
]
=
forms
.
CharField
(
widget
=
forms
.
HiddenInput
(),
initial
=
port_id
)
@property
def
helper
(
self
):
helper
=
super
(
VmRemoveInterfaceForm
,
self
)
.
helper
if
self
.
interface
:
helper
.
layout
=
Layout
(
AnyTag
(
"div"
,
HTML
(
format_html
(
_
(
"<label>Vlan:</label> {0}"
),
self
.
interface
.
vlan
)),
css_class
=
"form-group"
,
),
Field
(
"interface"
),
Field
(
"port_id"
),
)
return
helper
...
...
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
583f2684
...
...
@@ -25,7 +25,7 @@
{% with op=op.remove_interface %}{% if op %}
<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"
{%
if
op
.
disabled
%}
disabled
{%
endif
%}
>
{% trans "remove" %}
</a>
...
...
circle/dashboard/views/vm.py
View file @
583f2684
...
...
@@ -366,25 +366,14 @@ class VmRemoveInterfaceView(FormOperationMixin, VmOperationView):
op
=
'remove_interface'
form_class
=
VmRemoveInterfaceForm
show_in_toolbar
=
False
wait_for_result
=
0.5
icon
=
'times'
effect
=
"danger"
with_reload
=
True
def
get_form_kwargs
(
self
):
instance
=
self
.
get_op
()
.
instance
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
port_id
=
self
.
request
.
GET
.
get
(
'port_id'
)
val
=
super
(
VmRemoveInterfaceView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'
choices'
:
choices
,
'default'
:
default
})
val
.
update
({
'
port_id'
:
port_id
})
return
val
...
...
circle/vm/operations.py
View file @
583f2684
...
...
@@ -403,21 +403,11 @@ class RemoveInterfaceOperation(InstanceOperation):
description
=
_
(
"Remove the specified network interface and erase IP "
"address allocations, related firewall rules and "
"hostnames."
)
required_perms
=
()
accept_states
=
(
'STOPPED'
,
'PENDING'
,
'ACTIVE'
)
os_policy_actions
=
((
"compute"
,
"compute:detach_interface"
),)
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
if
self
.
instance
.
is_running
:
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
)
def
_operation
(
self
,
request
,
port_id
):
openstack_api
.
nova
.
interface_detach
(
request
,
self
.
instance
.
id
,
port_id
)
@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