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):
...
@@ -65,6 +65,7 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):
return
''
return
''
return
obj
.
owner
.
get_full_name
()
return
obj
.
owner
.
get_full_name
()
class
HostSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
HostSerializer
(
serializers
.
HyperlinkedModelSerializer
):
owner_name
=
serializers
.
SerializerMethodField
()
owner_name
=
serializers
.
SerializerMethodField
()
vlan_name
=
serializers
.
SerializerMethodField
()
vlan_name
=
serializers
.
SerializerMethodField
()
...
@@ -123,7 +124,10 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
...
@@ -123,7 +124,10 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
class
Meta
:
model
=
models
.
SwitchPort
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
):
def
get_untagged_vlan_info
(
self
,
obj
):
return
'{}'
.
format
(
obj
.
untagged_vlan
)
return
'{}'
.
format
(
obj
.
untagged_vlan
)
...
@@ -131,6 +135,7 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
...
@@ -131,6 +135,7 @@ class SwitchPortSerializer(serializers.HyperlinkedModelSerializer):
def
get_tagged_vlans_name
(
self
,
obj
):
def
get_tagged_vlans_name
(
self
,
obj
):
return
obj
.
tagged_vlans
.
name
return
obj
.
tagged_vlans
.
name
class
VlanSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
VlanSerializer
(
serializers
.
HyperlinkedModelSerializer
):
domain_name
=
serializers
.
SerializerMethodField
()
domain_name
=
serializers
.
SerializerMethodField
()
...
@@ -150,6 +155,7 @@ class VlanSerializer(serializers.HyperlinkedModelSerializer):
...
@@ -150,6 +155,7 @@ class VlanSerializer(serializers.HyperlinkedModelSerializer):
class
VlanGroupSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
VlanGroupSerializer
(
serializers
.
HyperlinkedModelSerializer
):
owner_name
=
serializers
.
SerializerMethodField
()
owner_name
=
serializers
.
SerializerMethodField
()
class
Meta
:
class
Meta
:
model
=
models
.
VlanGroup
model
=
models
.
VlanGroup
fields
=
(
"url"
,
"name"
,
"vlans"
,
"description"
,
"owner"
,
"owner_name"
)
fields
=
(
"url"
,
"name"
,
"vlans"
,
"description"
,
"owner"
,
"owner_name"
)
...
...
circle/network/urls.py
View file @
224cf27c
...
@@ -61,14 +61,17 @@ urlpatterns = [
...
@@ -61,14 +61,17 @@ urlpatterns = [
url
(
'^groups/$'
,
views
.
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/$'
,
views
.
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/create$'
,
views
.
GroupCreate
.
as_view
(),
url
(
'^groups/create$'
,
views
.
GroupCreate
.
as_view
(),
name
=
'network.group_create'
),
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
(),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
views
.
GroupDelete
.
as_view
(),
name
=
"network.group_delete"
),
name
=
"network.group_delete"
),
# host
# host
url
(
'^hosts/$'
,
views
.
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/$'
,
views
.
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/create$'
,
views
.
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/create$'
,
views
.
HostCreate
.
as_view
(),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
views
.
HostDetail
.
as_view
(),
name
=
'network.host'
),
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
(),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
views
.
HostDelete
.
as_view
(),
name
=
"network.host_delete"
),
name
=
"network.host_delete"
),
...
@@ -83,7 +86,8 @@ urlpatterns = [
...
@@ -83,7 +86,8 @@ urlpatterns = [
# rule
# rule
url
(
'^rules/$'
,
views
.
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
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
(),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
views
.
RuleDetail
.
as_view
(),
name
=
'network.rule'
),
name
=
'network.rule'
),
...
@@ -99,8 +103,10 @@ urlpatterns = [
...
@@ -99,8 +103,10 @@ urlpatterns = [
# vlan
# vlan
url
(
'^vlans/$'
,
views
.
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/$'
,
views
.
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/create$'
,
views
.
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/create$'
,
views
.
VlanCreate
.
as_view
(),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
views
.
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
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
(),
url
(
'^vlans/(?P<pk>
\
d+)/acl/$'
,
views
.
VlanAclUpdateView
.
as_view
(),
name
=
'network.vlan-acl'
),
name
=
'network.vlan-acl'
),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
views
.
VlanDelete
.
as_view
(),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
views
.
VlanDelete
.
as_view
(),
...
@@ -119,12 +125,14 @@ urlpatterns = [
...
@@ -119,12 +125,14 @@ urlpatterns = [
name
=
"network.rule_delete"
),
name
=
"network.rule_delete"
),
# non class based views
# 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'
),
name
=
'network.remove_host_group'
),
url
(
'^hosts/(?P<pk>
\
d+)/add/$'
,
views
.
add_host_group
,
url
(
'^hosts/(?P<pk>
\
d+)/add/$'
,
views
.
add_host_group
,
name
=
'network.add_host_group'
),
name
=
'network.add_host_group'
),
url
(
'^switchports/(?P<pk>
\
d+)/remove/(?P<device_pk>
\
d+)/$'
,
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
,
url
(
'^switchports/(?P<pk>
\
d+)/add/$'
,
views
.
add_switch_port_device
,
name
=
'network.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,
...
@@ -119,7 +119,11 @@ class BlacklistList(LoginRequiredMixin, SuperuserRequiredMixin,
data
=
self
.
model
.
objects
.
all
()
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
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
return
data
...
@@ -452,8 +456,10 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -452,8 +456,10 @@ class HostList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search
=
self
.
request
.
GET
.
get
(
"s"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
if
search
:
data
=
data
.
filter
(
Q
(
hostname__icontains
=
search
)
|
data
=
data
.
filter
(
Q
(
ipv4
=
search
))
# ipv4 does not work TODO
Q
(
hostname__icontains
=
search
)
|
Q
(
ipv4__icontains
=
search
)
)
return
data
return
data
...
@@ -613,7 +619,10 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
...
@@ -613,7 +619,10 @@ class RecordList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
search
=
self
.
request
.
GET
.
get
(
"s"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
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
return
data
...
@@ -932,7 +941,10 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
...
@@ -932,7 +941,10 @@ class VlanGroupList(LoginRequiredMixin, SuperuserRequiredMixin,
data
=
self
.
model
.
objects
.
all
()
data
=
self
.
model
.
objects
.
all
()
search
=
self
.
request
.
GET
.
get
(
"s"
)
search
=
self
.
request
.
GET
.
get
(
"s"
)
if
search
:
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
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