Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Harrisson
csentry
Commits
c7efd3d0
Commit
c7efd3d0
authored
5 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Add broadcast address to network view
JIRA INFRA-1291 #action In Progress
parent
a465e910
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models.py
+5
-0
5 additions, 0 deletions
app/models.py
app/templates/network/view_network.html
+37
-35
37 additions, 35 deletions
app/templates/network/view_network.html
tests/functional/test_api.py
+2
-0
2 additions, 0 deletions
tests/functional/test_api.py
with
44 additions
and
35 deletions
app/models.py
+
5
−
0
View file @
c7efd3d0
...
@@ -868,6 +868,10 @@ class Network(CreatedMixin, db.Model):
...
@@ -868,6 +868,10 @@ class Network(CreatedMixin, db.Model):
def
netmask
(
self
):
def
netmask
(
self
):
return
self
.
network_ip
.
netmask
return
self
.
network_ip
.
netmask
@property
def
broadcast
(
self
):
return
self
.
network_ip
.
broadcast_address
@property
@property
def
first
(
self
):
def
first
(
self
):
return
ipaddress
.
ip_address
(
self
.
first_ip
)
return
ipaddress
.
ip_address
(
self
.
first_ip
)
...
@@ -961,6 +965,7 @@ class Network(CreatedMixin, db.Model):
...
@@ -961,6 +965,7 @@ class Network(CreatedMixin, db.Model):
"
vlan_id
"
:
self
.
vlan_id
,
"
vlan_id
"
:
self
.
vlan_id
,
"
address
"
:
self
.
address
,
"
address
"
:
self
.
address
,
"
netmask
"
:
str
(
self
.
netmask
),
"
netmask
"
:
str
(
self
.
netmask
),
"
broadcast
"
:
str
(
self
.
broadcast
),
"
first_ip
"
:
self
.
first_ip
,
"
first_ip
"
:
self
.
first_ip
,
"
last_ip
"
:
self
.
last_ip
,
"
last_ip
"
:
self
.
last_ip
,
"
gateway
"
:
self
.
gateway
,
"
gateway
"
:
self
.
gateway
,
...
...
This diff is collapsed.
Click to expand it.
app/templates/network/view_network.html
+
37
−
35
View file @
c7efd3d0
...
@@ -4,42 +4,44 @@
...
@@ -4,42 +4,44 @@
{% block title %}View Ansible network - CSEntry{% endblock %}
{% block title %}View Ansible network - CSEntry{% endblock %}
{% block networks_nav %}
{% block networks_nav %}
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link active"
href=
"{{ url_for('network.view_network', vlan_name=network.vlan_name) }}"
>
View network
</a>
<a
class=
"nav-link active"
href=
"{{ url_for('network.view_network', vlan_name=network.vlan_name) }}"
>
View network
</a>
</li>
</li>
{% endblock %}
{% endblock %}
{% block networks_main %}
{% block networks_main %}
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm-9"
>
<div
class=
"col-sm-9"
>
<dl
class=
"row"
>
<dl
class=
"row"
>
<dt
class=
"col-sm-3"
>
Vlan name
</dt>
<dt
class=
"col-sm-3"
>
Vlan name
</dt>
<dd
class=
"col-sm-9"
>
{{ network.vlan_name }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.vlan_name }}
</dd>
<dt
class=
"col-sm-3"
>
Vlan id
</dt>
<dt
class=
"col-sm-3"
>
Vlan id
</dt>
<dd
class=
"col-sm-9"
>
{{ network.vlan_id }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.vlan_id }}
</dd>
<dt
class=
"col-sm-3"
>
Description
</dt>
<dt
class=
"col-sm-3"
>
Description
</dt>
<dd
class=
"col-sm-9"
>
{{ network.description | safe }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.description | safe }}
</dd>
<dt
class=
"col-sm-3"
>
Address
</dt>
<dt
class=
"col-sm-3"
>
Address
</dt>
<dd
class=
"col-sm-9"
>
{{ network.address }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.address }}
</dd>
<dt
class=
"col-sm-3"
>
First IP
</dt>
<dt
class=
"col-sm-3"
>
First IP
</dt>
<dd
class=
"col-sm-9"
>
{{ network.first_ip }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.first_ip }}
</dd>
<dt
class=
"col-sm-3"
>
Last IP
</dt>
<dt
class=
"col-sm-3"
>
Last IP
</dt>
<dd
class=
"col-sm-9"
>
{{ network.last_ip }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.last_ip }}
</dd>
<dt
class=
"col-sm-3"
>
Gateway
</dt>
<dt
class=
"col-sm-3"
>
Gateway
</dt>
<dd
class=
"col-sm-9"
>
{{ network.gateway }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.gateway }}
</dd>
<dt
class=
"col-sm-3"
>
Network Scope
</dt>
<dt
class=
"col-sm-3"
>
Broadcast
</dt>
<dd
class=
"col-sm-9"
>
{{ network.scope }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.broadcast }}
</dd>
<dt
class=
"col-sm-3"
>
Domain
</dt>
<dt
class=
"col-sm-3"
>
Network Scope
</dt>
<dd
class=
"col-sm-9"
>
{{ network.domain }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.scope }}
</dd>
<dt
class=
"col-sm-3"
>
Admin only
</dt>
<dt
class=
"col-sm-3"
>
Domain
</dt>
<dd
class=
"col-sm-9"
>
{{ network.admin_only }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.domain }}
</dd>
<dt
class=
"col-sm-3"
>
Hosts
</dt>
<dt
class=
"col-sm-3"
>
Admin only
</dt>
<dd
class=
"col-sm-9"
>
{{ link_to_interfaces_host(network.interfaces) }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.admin_only }}
</dd>
<dt
class=
"col-sm-3"
>
Created by
</dt>
<dt
class=
"col-sm-3"
>
Hosts
</dt>
<dd
class=
"col-sm-9"
>
{{ network.user }}
</dd>
<dd
class=
"col-sm-9"
>
{{ link_to_interfaces_host(network.interfaces) }}
</dd>
<dt
class=
"col-sm-3"
>
Created at
</dt>
<dt
class=
"col-sm-3"
>
Created by
</dt>
<dd
class=
"col-sm-9"
>
{{ network.created_at }}
</dd>
<dd
class=
"col-sm-9"
>
{{ network.user }}
</dd>
</dl>
<dt
class=
"col-sm-3"
>
Created at
</dt>
</div>
<dd
class=
"col-sm-9"
>
{{ network.created_at }}
</dd>
</dl>
</div>
</div>
{%- endblock %}
</div>
{%- endblock %}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/functional/test_api.py
+
2
−
0
View file @
c7efd3d0
...
@@ -723,6 +723,7 @@ def test_create_network(client, admin_token, network_scope_factory):
...
@@ -723,6 +723,7 @@ def test_create_network(client, admin_token, network_scope_factory):
"
vlan_id
"
,
"
vlan_id
"
,
"
address
"
,
"
address
"
,
"
netmask
"
,
"
netmask
"
,
"
broadcast
"
,
"
first_ip
"
,
"
first_ip
"
,
"
last_ip
"
,
"
last_ip
"
,
"
gateway
"
,
"
gateway
"
,
...
@@ -742,6 +743,7 @@ def test_create_network(client, admin_token, network_scope_factory):
...
@@ -742,6 +743,7 @@ def test_create_network(client, admin_token, network_scope_factory):
assert
response
.
get_json
()[
"
last_ip
"
]
==
"
172.16.1.250
"
assert
response
.
get_json
()[
"
last_ip
"
]
==
"
172.16.1.250
"
assert
response
.
get_json
()[
"
gateway
"
]
==
"
172.16.1.254
"
assert
response
.
get_json
()[
"
gateway
"
]
==
"
172.16.1.254
"
assert
response
.
get_json
()[
"
netmask
"
]
==
"
255.255.255.0
"
assert
response
.
get_json
()[
"
netmask
"
]
==
"
255.255.255.0
"
assert
response
.
get_json
()[
"
broadcast
"
]
==
"
172.16.1.255
"
# Check that address and name shall be unique
# Check that address and name shall be unique
response
=
post
(
client
,
f
"
{
API_URL
}
/network/networks
"
,
data
=
data
,
token
=
admin_token
)
response
=
post
(
client
,
f
"
{
API_URL
}
/network/networks
"
,
data
=
data
,
token
=
admin_token
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment