Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
224cf27c
authored
Dec 18, 2017
by
Barnabás Czémán
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix flake8 warnings
parent
0f41633d
Pipeline
#641
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
14 deletions
+40
-14
circle/network/serializers.py
+7
-1
circle/network/urls.py
+16
-8
circle/network/views.py
+17
-5
No files found.
circle/network/serializers.py
View file @
224cf27c
...
...
@@ -65,6 +65,7 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):
return
''
return
obj
.
owner
.
get_full_name
()
class
HostSerializer
(
serializers
.
HyperlinkedModelSerializer
):
owner_name
=
serializers
.
SerializerMethodField
()
vlan_name
=
serializers
.
SerializerMethodField
()
...
...
@@ -123,7 +124,10 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
model
=
models
.
SwitchPort
fields
=
(
"url"
,
"untagged_vlan"
,
"tagged_vlans"
,
"description"
,
"untagged_vlan_info"
,
"tagged_vlans_name"
)
fields
=
(
"url"
,
"untagged_vlan"
,
"tagged_vlans"
,
"description"
,
"untagged_vlan_info"
,
"tagged_vlans_name"
)
def
get_untagged_vlan_info
(
self
,
obj
):
return
'{}'
.
format
(
obj
.
untagged_vlan
)
...
...
@@ -131,6 +135,7 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
def
get_tagged_vlans_name
(
self
,
obj
):
return
obj
.
tagged_vlans
.
name
class
VlanSerializer
(
serializers
.
HyperlinkedModelSerializer
):
domain_name
=
serializers
.
SerializerMethodField
()
...
...
@@ -150,6 +155,7 @@ class VlanSerializer(serializers.HyperlinkedModelSerializer):
class
VlanGroupSerializer
(
serializers
.
HyperlinkedModelSerializer
):
owner_name
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
models
.
VlanGroup
fields
=
(
"url"
,
"name"
,
"vlans"
,
"description"
,
"owner"
,
"owner_name"
)
...
...
circle/network/urls.py
View file @
224cf27c
...
...
@@ -61,14 +61,17 @@ urlpatterns = [
url
(
'^groups/$'
,
views
.
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/create$'
,
views
.
GroupCreate
.
as_view
(),
name
=
'network.group_create'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
views
.
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
views
.
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
views
.
GroupDelete
.
as_view
(),
name
=
"network.group_delete"
),
# host
url
(
'^hosts/$'
,
views
.
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/create$'
,
views
.
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
views
.
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/create$'
,
views
.
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
views
.
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
views
.
HostDelete
.
as_view
(),
name
=
"network.host_delete"
),
...
...
@@ -83,7 +86,8 @@ urlpatterns = [
# rule
url
(
'^rules/$'
,
views
.
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
url
(
'^rules/create$'
,
views
.
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/create$'
,
views
.
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
views
.
RuleDetail
.
as_view
(),
name
=
'network.rule'
),
...
...
@@ -99,8 +103,10 @@ urlpatterns = [
# vlan
url
(
'^vlans/$'
,
views
.
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/create$'
,
views
.
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
views
.
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/create$'
,
views
.
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
views
.
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/(?P<pk>
\
d+)/acl/$'
,
views
.
VlanAclUpdateView
.
as_view
(),
name
=
'network.vlan-acl'
),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
views
.
VlanDelete
.
as_view
(),
...
...
@@ -119,12 +125,14 @@ urlpatterns = [
name
=
"network.rule_delete"
),
# non class based views
url
(
'^hosts/(?P<pk>
\
d+)/remove/(?P<group_pk>
\
d+)/$'
,
views
.
remove_host_group
,
url
(
'^hosts/(?P<pk>
\
d+)/remove/(?P<group_pk>
\
d+)/$'
,
views
.
remove_host_group
,
name
=
'network.remove_host_group'
),
url
(
'^hosts/(?P<pk>
\
d+)/add/$'
,
views
.
add_host_group
,
name
=
'network.add_host_group'
),
url
(
'^switchports/(?P<pk>
\
d+)/remove/(?P<device_pk>
\
d+)/$'
,
views
.
remove_switch_port_device
,
name
=
'network.remove_switch_port_device'
),
views
.
remove_switch_port_device
,
name
=
'network.remove_switch_port_device'
),
url
(
'^switchports/(?P<pk>
\
d+)/add/$'
,
views
.
add_switch_port_device
,
name
=
'network.add_switch_port_device'
),
]
circle/network/views.py
View file @
224cf27c
...
...
@@ -119,7 +119,11 @@ class BlacklistList(LoginRequiredMixin, SuperuserRequiredMixin,
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
ipv4__icontains
=
search
)
|
Q
(
reason__icontains
=
search
))
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
ipv4__icontains
=
search
)
|
Q
(
reason__icontains
=
search
)
)
return
data
...
...
@@ -452,8 +456,10 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
hostname__icontains
=
search
)
|
Q
(
ipv4
=
search
))
# ipv4 does not work TODO
data
=
data
.
filter
(
Q
(
hostname__icontains
=
search
)
|
Q
(
ipv4__icontains
=
search
)
)
return
data
...
...
@@ -613,7 +619,10 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
domain__name__icontains
=
search
))
data
=
data
.
filter
(
Q
(
host__hostname__icontains
=
search
)
|
Q
(
domain__name__icontains
=
search
)
)
return
data
...
...
@@ -932,7 +941,10 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
data
=
data
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
description__icontains
=
search
))
data
=
data
.
filter
(
Q
(
name__icontains
=
search
)
|
Q
(
description__icontains
=
search
)
)
return
data
...
...
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