Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
97100ecb
Commit
97100ecb
authored
5 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
randomize netcapture api password, refs
#27505
parent
0524de58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
12.Netcapture/1.Install_Netcapture/0_setup.py
+38
-10
38 additions, 10 deletions
12.Netcapture/1.Install_Netcapture/0_setup.py
with
38 additions
and
10 deletions
12.Netcapture/1.Install_Netcapture/0_setup.py
+
38
−
10
View file @
97100ecb
#!/usr/bin/env python3
#!/usr/bin/env python3
import
utils
import
utils
import
json
import
json
import
random
import
string
def
write_conf
():
class
JsonConfig
:
with
open
(
'
/etc/miris/netcapture.json.example
'
,
'
r
'
)
as
f
:
def
__init__
(
self
,
path
):
default_conf
=
json
.
load
(
f
)
self
.
path
=
path
default_conf
[
'
docker_registry_login
'
]
=
utils
.
get_conf
(
'
NETCAPTURE_DOCKER_LOGIN
'
,
''
)
with
open
(
path
,
'
r
'
)
as
f
:
default_conf
[
'
docker_registry_password
'
]
=
utils
.
get_conf
(
'
NETCAPTURE_DOCKER_PWD
'
,
''
)
self
.
conf
=
json
.
load
(
f
)
default_conf
[
'
campusmanager_url
'
]
=
'
https://%s
'
%
utils
.
get_conf
(
'
CM_SERVER_NAME
'
,
''
)
with
open
(
'
/etc/miris/netcapture.json
'
,
'
w
'
)
as
f
:
def
write
(
self
):
json
.
dump
(
default_conf
,
f
,
indent
=
2
,
sort_keys
=
True
)
with
open
(
self
.
path
,
'
w
'
)
as
f
:
return
default_conf
json
.
dump
(
self
.
conf
,
f
,
indent
=
2
,
sort_keys
=
True
)
def
set
(
self
,
key
,
val
):
self
.
conf
[
key
]
=
val
def
get
(
self
):
return
self
.
conf
def
get_random_id
(
length
=
12
):
return
''
.
join
(
random
.
SystemRandom
().
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
range
(
length
))
def
write_netcapture_conf
():
conf
=
JsonConfig
(
'
/etc/miris/netcapture.json.example
'
)
conf
.
set
(
'
docker_registry_login
'
,
utils
.
get_conf
(
'
NETCAPTURE_DOCKER_LOGIN
'
,
''
))
conf
.
set
(
'
docker_registry_password
'
,
utils
.
get_conf
(
'
NETCAPTURE_DOCKER_PWD
'
,
''
))
conf
.
set
(
'
campusmanager_url
'
,
'
https://%s
'
%
utils
.
get_conf
(
'
CM_SERVER_NAME
'
,
''
))
conf
.
write
()
return
conf
.
get
()
def
write_miris_conf
():
conf
=
JsonConfig
(
'
/etc/miris/conf/api.json
'
)
conf
.
set
(
'
auth_user_password
'
,
get_random_id
())
conf
.
write
()
def
setup
(
interactive
=
True
):
def
setup
(
interactive
=
True
):
...
@@ -26,7 +53,8 @@ def setup(interactive=True):
...
@@ -26,7 +53,8 @@ def setup(interactive=True):
try
:
try
:
utils
.
run_commands
(
cmds
)
utils
.
run_commands
(
cmds
)
conf
=
write_conf
()
conf
=
write_netcapture_conf
()
write_miris_conf
()
cmds_post
=
list
()
cmds_post
=
list
()
for
f
in
[
'
media
'
,
'
conf
'
]:
for
f
in
[
'
media
'
,
'
conf
'
]:
cmds_post
.
extend
([
cmds_post
.
extend
([
...
...
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