Commit 896412ac by Szabolcs Gelencser

Implement floating IP remove operation

parent 02238427
......@@ -39,8 +39,38 @@
<file leaf-file-name="vm.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/vm.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="293">
<caret line="182" column="81" lean-forward="false" selection-start-line="182" selection-start-column="81" selection-end-line="182" selection-end-column="81" />
<state relative-caret-position="148">
<caret line="586" column="0" lean-forward="false" selection-start-line="586" selection-start-column="0" selection-end-line="586" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="operations.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/common/operations.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="148">
<caret line="69" column="0" lean-forward="false" selection-start-line="69" selection-start-column="0" selection-end-line="69" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="util.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/util.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="148">
<caret line="296" column="19" lean-forward="true" selection-start-line="296" selection-start-column="19" selection-end-line="296" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="urls.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="614">
<caret line="228" column="22" lean-forward="true" selection-start-line="228" selection-start-column="22" selection-end-line="228" selection-end-column="22" />
<folding />
</state>
</provider>
......@@ -49,30 +79,30 @@
<file leaf-file-name="forms.py" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/forms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="1018" column="40" lean-forward="false" selection-start-line="1018" selection-start-column="40" selection-end-line="1018" selection-end-column="40" />
<state relative-caret-position="259">
<caret line="1040" column="31" lean-forward="false" selection-start-line="1040" selection-start-column="31" selection-end-line="1040" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="operations.py" pinned="false" current-in-tab="false">
<file leaf-file-name="operations.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/circle/vm/operations.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="465" column="0" lean-forward="true" selection-start-line="465" selection-start-column="0" selection-end-line="465" selection-end-column="0" />
<state relative-caret-position="148">
<caret line="472" column="55" lean-forward="false" selection-start-line="472" selection-start-column="55" selection-end-line="472" selection-end-column="55" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="network.html" pinned="false" current-in-tab="true">
<file leaf-file-name="network.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/network.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="64" column="20" lean-forward="true" selection-start-line="64" selection-start-column="20" selection-end-line="64" selection-end-column="20" />
<state relative-caret-position="357">
<caret line="63" column="24" lean-forward="false" selection-start-line="63" selection-start-column="20" selection-end-line="63" selection-end-column="24" />
<folding>
<marker date="1524051869354" expanded="false" signature="3016:3034" ph="..." />
<marker date="1524052679121" expanded="false" signature="3492:3510" ph="..." />
</folding>
</state>
</provider>
......@@ -90,9 +120,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>LocalClient</find>
<find>trait</find>
<find>class NodeActivity</find>
<find>compileless</find>
<find>less</find>
<find>installed</find>
......@@ -102,7 +129,6 @@
<find>DEFAULT_SUBNETPOOL_NAME_FOR_USER</find>
<find>get_id</find>
<find>add_port</find>
<find>vm_ops</find>
<find>VmPortAddView</find>
<find>VmPortAddForm</find>
<find>vm_opts</find>
......@@ -120,6 +146,10 @@
<find>publicip</find>
<find>portadd</find>
<find>vmdeta</find>
<find>vm_ops</find>
<find>vm_</find>
<find>detailview</find>
<find>vmdetailview</find>
</findStrings>
<replaceStrings>
<replace>'ACTIVE'</replace>
......@@ -186,11 +216,11 @@
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-plain-image-create.html" />
<option value="$PROJECT_DIR$/circle/circle/settings/base.py" />
<option value="$PROJECT_DIR$/circle/network/models.py" />
<option value="$PROJECT_DIR$/circle/vm/operations.py" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/_network-public-ip-add.html" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/network.html" />
<option value="$PROJECT_DIR$/circle/dashboard/forms.py" />
<option value="$PROJECT_DIR$/circle/dashboard/views/vm.py" />
<option value="$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/network.html" />
<option value="$PROJECT_DIR$/circle/vm/operations.py" />
</list>
</option>
</component>
......@@ -457,7 +487,7 @@
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32492113" sideWeight="0.50745475" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.43023255" sideWeight="0.43610224" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32769555" sideWeight="0.49574015" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.5674653" sideWeight="0.5058573" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.47568712" sideWeight="0.5058573" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.20074548" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
......@@ -556,7 +586,7 @@
</properties>
</breakpoint>
</default-breakpoints>
<option name="time" value="329" />
<option name="time" value="331" />
</breakpoint-manager>
<watches-manager />
</component>
......@@ -624,6 +654,11 @@ certifi.where()</expression-string>
</expressions>
<expressions id="evaluateExpression">
<expression>
<expression-string>self.get_op()</expression-string>
<language-id>Python</language-id>
<evaluation-mode>EXPRESSION</evaluation-mode>
</expression>
<expression>
<expression-string>openstack_api.neutron.tenant_floating_ip_list(self.request)</expression-string>
<language-id>Python</language-id>
<evaluation-mode>EXPRESSION</evaluation-mode>
......@@ -663,11 +698,6 @@ certifi.where()</expression-string>
<language-id>Python</language-id>
<evaluation-mode>EXPRESSION</evaluation-mode>
</expression>
<expression>
<expression-string>openstack_api.neutron.float</expression-string>
<language-id>Python</language-id>
<evaluation-mode>EXPRESSION</evaluation-mode>
</expression>
</expressions>
</component>
<component name="editorHistoryManager">
......@@ -948,16 +978,6 @@ certifi.where()</expression-string>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="590">
<caret line="228" column="19" lean-forward="true" selection-start-line="228" selection-start-column="19" selection-end-line="228" selection-end-column="19" />
<folding>
<element signature="e#732#770#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/_network-port-add.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="238">
......@@ -989,7 +1009,7 @@ certifi.where()</expression-string>
<state relative-caret-position="-357">
<caret line="36" column="6" lean-forward="false" selection-start-line="36" selection-start-column="6" selection-end-line="36" selection-end-column="6" />
<folding>
<element signature="e#731#787#0" expanded="true" />
<element signature="e#731#787#0" expanded="false" />
</folding>
</state>
</provider>
......@@ -1018,61 +1038,69 @@ certifi.where()</expression-string>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/common/operations.py">
<entry file="file://$USER_HOME$/.virtualenvs/cloud/local/lib/python2.7/site-packages/django/views/generic/base.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="182">
<caret line="93" column="0" lean-forward="true" selection-start-line="93" selection-start-column="0" selection-end-line="93" selection-end-column="0" />
<state relative-caret-position="156">
<caret line="87" column="0" lean-forward="false" selection-start-line="87" selection-start-column="0" selection-end-line="87" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.virtualenvs/cloud/local/lib/python2.7/site-packages/django/views/generic/base.py">
<entry file="file://$PROJECT_DIR$/circle/dashboard/urls.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="156">
<caret line="87" column="0" lean-forward="false" selection-start-line="87" selection-start-column="0" selection-end-line="87" selection-end-column="0" />
<state relative-caret-position="614">
<caret line="228" column="22" lean-forward="true" selection-start-line="228" selection-start-column="22" selection-end-line="228" selection-end-column="22" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/util.py">
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/network.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="530">
<caret line="306" column="39" lean-forward="false" selection-start-line="306" selection-start-column="24" selection-end-line="306" selection-end-column="39" />
<folding />
<state relative-caret-position="357">
<caret line="63" column="24" lean-forward="false" selection-start-line="63" selection-start-column="20" selection-end-line="63" selection-end-column="24" />
<folding>
<marker date="1524052679121" expanded="false" signature="3492:3510" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/vm.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="293">
<caret line="182" column="81" lean-forward="false" selection-start-line="182" selection-start-column="81" selection-end-line="182" selection-end-column="81" />
<state relative-caret-position="148">
<caret line="586" column="0" lean-forward="false" selection-start-line="586" selection-start-column="0" selection-end-line="586" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/forms.py">
<entry file="file://$PROJECT_DIR$/circle/dashboard/views/util.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="1018" column="40" lean-forward="false" selection-start-line="1018" selection-start-column="40" selection-end-line="1018" selection-end-column="40" />
<state relative-caret-position="148">
<caret line="296" column="19" lean-forward="true" selection-start-line="296" selection-start-column="19" selection-end-line="296" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/vm/operations.py">
<entry file="file://$PROJECT_DIR$/circle/common/operations.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="306">
<caret line="465" column="0" lean-forward="true" selection-start-line="465" selection-start-column="0" selection-end-line="465" selection-end-column="0" />
<state relative-caret-position="148">
<caret line="69" column="0" lean-forward="false" selection-start-line="69" selection-start-column="0" selection-end-line="69" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/dashboard/templates/dashboard/vm-detail/network.html">
<entry file="file://$PROJECT_DIR$/circle/dashboard/forms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="323">
<caret line="64" column="20" lean-forward="true" selection-start-line="64" selection-start-column="20" selection-end-line="64" selection-end-column="20" />
<folding>
<marker date="1524051869354" expanded="false" signature="3016:3034" ph="..." />
</folding>
<state relative-caret-position="259">
<caret line="1040" column="31" lean-forward="false" selection-start-line="1040" selection-start-column="31" selection-end-line="1040" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/circle/vm/operations.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="148">
<caret line="472" column="55" lean-forward="false" selection-start-line="472" selection-start-column="55" selection-end-line="472" selection-end-column="55" />
<folding />
</state>
</provider>
</entry>
......
......@@ -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
......
......@@ -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 %}
......
......@@ -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(
......
......@@ -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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment