Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
David Schmitz
FoD
Commits
a5c4f266
Commit
a5c4f266
authored
6 years ago
by
Tomáš Čejka
Browse files
Options
Downloads
Patches
Plain Diff
setup: improved - add NETCONF info (appended into settings_local.py), create peer
parent
2a653989
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
flowspec/forms.py
+5
-1
5 additions, 1 deletion
flowspec/forms.py
flowspec/views.py
+17
-1
17 additions, 1 deletion
flowspec/views.py
templates/flowspy/setup.html
+2
-0
2 additions, 0 deletions
templates/flowspy/setup.html
with
24 additions
and
2 deletions
flowspec/forms.py
+
5
−
1
View file @
a5c4f266
...
@@ -273,5 +273,9 @@ def get_matchingprotocol_route_pks(protocolist, routes):
...
@@ -273,5 +273,9 @@ def get_matchingprotocol_route_pks(protocolist, routes):
class
SetupForm
(
forms
.
Form
):
class
SetupForm
(
forms
.
Form
):
password
=
forms
.
CharField
(
widget
=
forms
.
PasswordInput
(),
label
=
"
Password
"
)
password
=
forms
.
CharField
(
widget
=
forms
.
PasswordInput
(),
label
=
"
Password
"
)
netconf_device
=
forms
.
CharField
(
label
=
"
Router host (NETCONF)
"
)
netconf_port
=
forms
.
IntegerField
(
label
=
"
Router port (NETCONF)
"
,
min_value
=
0
,
max_value
=
65535
)
netconf_user
=
forms
.
CharField
(
label
=
"
Router user (NETCONF)
"
)
netconf_pass
=
forms
.
CharField
(
widget
=
forms
.
PasswordInput
(),
label
=
"
Router password (NETCONF)
"
)
test_peer_addr
=
forms
.
CharField
(
label
=
"
Test peer IP subnet
"
)
This diff is collapsed.
Click to expand it.
flowspec/views.py
+
17
−
1
View file @
a5c4f266
...
@@ -921,7 +921,7 @@ def routestats(request, route_slug):
...
@@ -921,7 +921,7 @@ def routestats(request, route_slug):
return
HttpResponse
(
json
.
dumps
({
"
error
"
:
"
No data available. %s
"
%
e
}),
mimetype
=
"
application/json
"
,
status
=
404
)
return
HttpResponse
(
json
.
dumps
({
"
error
"
:
"
No data available. %s
"
%
e
}),
mimetype
=
"
application/json
"
,
status
=
404
)
def
setup
(
request
):
def
setup
(
request
):
if
not
User
.
objects
.
filter
(
username
=
"
admin
"
)
:
if
User
.
objects
.
count
()
==
0
:
if
request
.
method
==
"
POST
"
:
if
request
.
method
==
"
POST
"
:
form
=
SetupForm
(
request
.
POST
)
form
=
SetupForm
(
request
.
POST
)
if
form
.
is_valid
():
if
form
.
is_valid
():
...
@@ -929,6 +929,22 @@ def setup(request):
...
@@ -929,6 +929,22 @@ def setup(request):
u
.
is_superuser
=
True
u
.
is_superuser
=
True
u
.
is_staff
=
True
u
.
is_staff
=
True
u
.
save
()
u
.
save
()
pr
=
PeerRange
(
network
=
form
.
cleaned_data
[
"
test_peer_addr
"
])
pr
.
save
()
p
=
Peer
(
peer_name
=
"
testpeer
"
,
peer_tag
=
"
testpeer
"
)
p
.
save
()
p
.
networks
.
add
(
pr
)
ua
=
UserProfile
()
ua
.
user
=
u
ua
.
save
()
ua
.
peers
.
add
(
p
)
with
open
(
"
flowspy/settings_local.py
"
,
"
a
"
)
as
f
:
f
.
write
(
"
NETCONF_DEVICE =
\"
%s
\"\n
"
%
form
.
cleaned_data
[
"
netconf_device
"
])
f
.
write
(
"
NETCONF_USER =
\"
%s
\"\n
"
%
form
.
cleaned_data
[
"
netconf_port
"
])
f
.
write
(
"
NETCONF_PASS =
\"
%s
\"\n
"
%
form
.
cleaned_data
[
"
netconf_user
"
])
f
.
write
(
"
NETCONF_PORT = %s
\n
"
%
form
.
cleaned_data
[
"
netconf_pass
"
])
logger
.
error
(
'
TODO REMOVE: password: %s
'
%
form
.
cleaned_data
[
"
password
"
])
logger
.
error
(
'
TODO REMOVE: password: %s
'
%
form
.
cleaned_data
[
"
password
"
])
return
HttpResponseRedirect
(
reverse
(
"
welcome
"
))
return
HttpResponseRedirect
(
reverse
(
"
welcome
"
))
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
templates/flowspy/setup.html
+
2
−
0
View file @
a5c4f266
...
@@ -6,7 +6,9 @@
...
@@ -6,7 +6,9 @@
Set the password of admin user:
Set the password of admin user:
<form
action=
"{% url setup %}"
method=
"post"
>
<form
action=
"{% url setup %}"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
<table>
{{ form }}
{{ form }}
</table>
<input
type=
"submit"
value=
"Set"
>
<input
type=
"submit"
value=
"Set"
>
</form>
</form>
</div>
</div>
...
...
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