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
63501e0a
authored
Mar 13, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add initial attached networks implementation
parent
344674c6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
19 deletions
+21
-19
.idea/workspace.xml
+0
-0
circle/dashboard/templates/dashboard/vm-detail/network.html
+3
-19
circle/dashboard/views/util.py
+1
-0
circle/dashboard/views/vm.py
+17
-0
No files found.
.idea/workspace.xml
View file @
63501e0a
This diff is collapsed.
Click to expand it.
circle/dashboard/templates/dashboard/vm-detail/network.html
View file @
63501e0a
...
...
@@ -12,32 +12,17 @@
{% trans "Interfaces" %}
</h2>
{% for i in instance.interface_set.all %}
{% for i in networks %}
<div>
<h3
class=
"list-group-item-heading dashboard-vm-details-network-h3"
>
<i
class=
"fa fa-{% if i.host %}globe{% else %}link{% endif %}"
></i>
{% if i.vxlan %}
{{ i.vxlan.name }} (user)
{% else %}
{{ i.vlan.name }}
{% if not i.host%}({% trans "unmanaged" %}){% endif %}
{% endif %}
{{ i.name }}
{% if not i.subnets.0.enable_dhcp %}({% trans "unmanaged" %}){% endif %}
{% if user.is_superuser and i.host %}
<a
href=
"{{ i.host.get_absolute_url }}"
class=
"btn btn-default btn-xs"
>
{% trans "edit" %}
</a>
{% endif %}
{% if i.vxlan %}
{% with op=op.remove_user_interface %}{% if op %}
<span
class=
"operation-wrapper"
>
<a
href=
"{{op.get_url}}?interface={{ i.pk }}"
class=
"btn btn-{{op.effect}} btn-xs operation interface-remove"
{%
if
op
.
disabled
%}
disabled
{%
endif
%}
>
{% trans "remove" %}
</a>
</span>
{% endif %}{% endwith %}
{% else %}
{% with op=op.remove_interface %}{% if op %}
<span
class=
"operation-wrapper"
>
<a
href=
"{{op.get_url}}?interface={{ i.pk }}"
...
...
@@ -46,7 +31,6 @@
</a>
</span>
{% endif %}{% endwith %}
{% endif %}
</h3>
{% if i.host %}
<div
class=
"row"
>
...
...
circle/dashboard/views/util.py
View file @
63501e0a
...
...
@@ -387,6 +387,7 @@ class FormOperationMixin(object):
def
post
(
self
,
request
,
extra
=
None
,
*
args
,
**
kwargs
):
if
extra
is
None
:
extra
=
{}
self
.
object
=
self
.
get_object
()
form
=
self
.
form_class
(
self
.
request
.
POST
,
**
self
.
get_form_kwargs
())
if
form
.
is_valid
():
extra
.
update
(
form
.
cleaned_data
)
...
...
circle/dashboard/views/vm.py
View file @
63501e0a
...
...
@@ -142,6 +142,23 @@ class VmDetailView(LoginRequiredMixin, GraphMixin, DetailView):
activities
=
openstack_api
.
nova
.
instance_action_list
(
self
.
request
,
instance
.
id
)
ports
=
openstack_api
.
neutron
.
port_list
(
self
.
request
)
instance_net_ids
=
[
p
.
network_id
for
p
in
ports
if
p
.
device_id
==
self
.
object
.
id
]
all_networks
=
openstack_api
.
neutron
.
network_list
(
self
.
request
)
instance_networks
=
[
n
for
n
in
all_networks
if
n
.
id
in
instance_net_ids
and
len
(
n
.
subnets
)
>
0
]
router_ports
=
[
p
for
p
in
ports
if
p
.
device_owner
==
'network:router_interface'
]
routers
=
openstack_api
.
neutron
.
router_list
(
self
.
request
)
router_by_id
=
{
r
.
id
:
r
for
r
in
routers
}
for
n
in
instance_networks
:
n
.
subnet
=
n
.
subnets
[
0
]
#TODO: mark network public if it is based on router ports and router
context
[
'networks'
]
=
instance_networks
# context['vlans'] = Vlan.get_objects_with_level(
# 'user', self.request.user
# ).exclude( # exclude already added interfaces
...
...
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