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
896412ac
authored
Apr 18, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement floating IP remove operation
parent
02238427
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
2 deletions
+54
-2
.idea/workspace.xml
+0
-0
circle/dashboard/forms.py
+15
-0
circle/dashboard/templates/dashboard/vm-detail/network.html
+11
-1
circle/dashboard/views/vm.py
+19
-1
circle/vm/operations.py
+9
-0
No files found.
.idea/workspace.xml
View file @
896412ac
This diff is collapsed.
Click to expand it.
circle/dashboard/forms.py
View file @
896412ac
...
...
@@ -1027,6 +1027,21 @@ class VmPublicIpAddForm(OperationForm):
)
return
helper
class
VmPublicIpRemoveForm
(
OperationForm
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
public_ip_id
=
kwargs
.
pop
(
'public_ip_id'
)
super
(
VmPublicIpRemoveForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'public_ip_id'
]
=
forms
.
CharField
(
widget
=
forms
.
HiddenInput
(),
initial
=
public_ip_id
)
@property
def
helper
(
self
):
helper
=
super
(
VmPublicIpRemoveForm
,
self
)
.
helper
helper
.
layout
=
Layout
(
Field
(
"public_ip_id"
),
)
return
helper
class
CircleAuthenticationForm
(
AuthenticationForm
):
# fields: username, password
...
...
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
896412ac
...
...
@@ -53,7 +53,17 @@
<span
class=
"pull-right"
>
{% if i.public_ip %}
<dl>
<dt>
{% trans "Public IP address" %}:
</dt>
<dt>
{% trans "Public IP address" %}
{% with op=op.remove_public_ip %}{% if op %}
<span
class=
"operation-wrapper"
>
<a
href=
"{{op.get_url}}?public_ip_id={{ i.public_ip_id }}"
class=
"btn btn-{{op.effect}} btn-xs operation"
{%
if
op
.
disabled
%}
disabled
{%
endif
%}
>
{% trans "remove" %}
</a>
</span>
{% endif %}{% endwith %}
</dt>
<dd>
{{ i.public_ip }}
</dd>
</dl>
{% else %}
...
...
circle/dashboard/views/vm.py
View file @
896412ac
...
...
@@ -63,7 +63,7 @@ from .util import (
)
from
..forms
import
(
AclUserOrGroupAddForm
,
VmResourcesForm
,
VmCustomizeForm
,
VmDeployForm
,
VmFromPlainImageForm
,
VmRemoveInterfaceForm
,
VmAddInterfaceForm
,
VmSaveForm
,
VmPortAddForm
,
VmPublicIpAddForm
)
VmAddInterfaceForm
,
VmSaveForm
,
VmPortAddForm
,
VmPublicIpAddForm
,
VmPublicIpRemoveForm
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -185,6 +185,7 @@ class VmDetailView(LoginRequiredMixin, GraphMixin, DetailView):
if
floating_ip
.
port_id
in
instance_ports_by_id
.
keys
():
port
=
instance_ports_by_id
[
floating_ip
.
port_id
]
instance_networks
[
port
.
network_id
]
.
public_ip
=
floating_ip
.
ip
instance_networks
[
port
.
network_id
]
.
public_ip_id
=
floating_ip
.
id
context
[
'networks'
]
=
instance_networks
.
values
()
...
...
@@ -571,6 +572,22 @@ class VmPublicIpAddView(FormOperationMixin, VmOperationView):
return
val
class
VmPublicIpRemoveView
(
FormOperationMixin
,
VmOperationView
):
op
=
'remove_public_ip'
show_in_toolbar
=
False
icon
=
'times'
effect
=
"danger"
form_class
=
VmPublicIpRemoveForm
def
get_form_kwargs
(
self
):
public_ip_id
=
self
.
request
.
GET
.
get
(
'public_ip_id'
)
val
=
super
(
VmPublicIpRemoveView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'public_ip_id'
:
public_ip_id
})
return
val
class
VmSaveView
(
FormOperationMixin
,
VmOperationView
):
op
=
'save_as_template'
...
...
@@ -837,6 +854,7 @@ vm_ops = OrderedDict([
# ('remove_port', VmPortRemoveView),
# ('add_port', VmPortAddView),
(
'add_public_ip'
,
VmPublicIpAddView
),
(
'remove_public_ip'
,
VmPublicIpRemoveView
),
# ('renew', VmRenewView),
# ('resources_change', VmResourcesChangeView),
# ('password_reset', VmOperationView.factory(
...
...
circle/vm/operations.py
View file @
896412ac
...
...
@@ -465,6 +465,15 @@ class AddPublicIPOperation(InstanceOperation):
openstack_api
.
neutron
.
floating_ip_associate
(
request
,
floating_ip
.
id
,
port_id
)
@register_operation
class
RemovePublicIPOperation
(
InstanceOperation
):
id
=
'remove_public_ip'
name
=
_
(
"remove public ip"
)
def
_operation
(
self
,
request
,
public_ip_id
):
openstack_api
.
neutron
.
floating_ip_disassociate
(
request
,
public_ip_id
)
openstack_api
.
neutron
.
tenant_floating_ip_release
(
request
,
public_ip_id
)
@register_operation
class
RemoveDiskOperation
(
InstanceOperation
):
id
=
'remove_disk'
name
=
_
(
"remove 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