Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.toolbox
Commits
6f907b4f
Commit
6f907b4f
authored
Jun 01, 2017
by
Hardik Juneja
Committed by
Rafael Monnerat
Jun 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: allow to view and modify empty monitor config parameter
parent
45de1258
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
33 deletions
+37
-33
slapos/monitor/monitor.py
slapos/monitor/monitor.py
+29
-23
slapos/monitor/monitor_config_write.py
slapos/monitor/monitor_config_write.py
+8
-10
No files found.
slapos/monitor/monitor.py
View file @
6f907b4f
...
@@ -136,29 +136,35 @@ class Monitoring(object):
...
@@ -136,29 +136,35 @@ class Monitoring(object):
title
=
config_list
[
1
],
title
=
config_list
[
1
],
value
=
' '
.
join
(
config_list
[
2
:])
value
=
' '
.
join
(
config_list
[
2
:])
))
))
elif
(
config_list
[
0
]
==
'file'
or
config_list
[
0
]
==
'htpasswd'
)
and
\
elif
(
config_list
[
0
]
==
'file'
or
config_list
[
0
]
==
'htpasswd'
):
os
.
path
.
exists
(
config_list
[
2
])
and
os
.
path
.
isfile
(
config_list
[
2
]):
directory
=
os
.
path
.
dirname
(
config_list
[
2
])
try
:
if
not
os
.
path
.
exists
(
directory
)
or
not
os
.
access
(
directory
,
os
.
W_OK
):
with
open
(
config_list
[
2
])
as
cfile
:
raise
OSError
(
"Directory does not exists or does not have write acess"
)
parameter
=
dict
(
if
os
.
path
.
exists
(
config_list
[
2
])
and
os
.
path
.
isfile
(
config_list
[
2
]):
key
=
config_list
[
1
],
try
:
title
=
config_list
[
1
],
with
open
(
config_list
[
2
])
as
cfile
:
value
=
cfile
.
read
(),
param_value
=
cfile
.
read
()
description
=
{
except
OSError
,
e
:
"type"
:
config_list
[
0
],
print
'Cannot read file %s, Error is: %s'
%
(
config_list
[
2
],
str
(
e
))
"file"
:
config_list
[
2
]
pass
}
else
:
)
param_value
=
""
if
config_list
[
0
]
==
'htpasswd'
:
parameter
=
dict
(
if
len
(
config_list
)
!=
5
or
not
os
.
path
.
exists
(
config_list
[
4
]):
key
=
config_list
[
1
],
print
'htpasswd file is not specified: %s'
%
str
(
config_list
)
title
=
config_list
[
1
],
continue
value
=
param_value
,
parameter
[
'description'
][
'user'
]
=
config_list
[
3
]
description
=
{
parameter
[
'description'
][
'htpasswd'
]
=
config_list
[
4
]
"type"
:
config_list
[
0
],
configuration_list
.
append
(
parameter
)
"file"
:
config_list
[
2
]
except
OSError
,
e
:
}
print
'Cannot read file %s, Error is: %s'
%
(
config_list
[
2
],
str
(
e
))
)
pass
if
config_list
[
0
]
==
'htpasswd'
:
if
len
(
config_list
)
!=
5
or
not
os
.
path
.
exists
(
config_list
[
4
]):
print
'htpasswd file is not specified: %s'
%
str
(
config_list
)
continue
parameter
[
'description'
][
'user'
]
=
config_list
[
3
]
parameter
[
'description'
][
'htpasswd'
]
=
config_list
[
4
]
configuration_list
.
append
(
parameter
)
elif
config_list
[
0
]
==
'httpdcors'
and
os
.
path
.
exists
(
config_list
[
2
])
and
\
elif
config_list
[
0
]
==
'httpdcors'
and
os
.
path
.
exists
(
config_list
[
2
])
and
\
os
.
path
.
exists
(
config_list
[
3
]):
os
.
path
.
exists
(
config_list
[
3
]):
old_cors_file
=
os
.
path
.
join
(
old_cors_file
=
os
.
path
.
join
(
...
...
slapos/monitor/monitor_config_write.py
View file @
6f907b4f
...
@@ -36,18 +36,16 @@ class MonitorConfigWrite(object):
...
@@ -36,18 +36,16 @@ class MonitorConfigWrite(object):
self
.
monitor_https_cors
=
monitor_https_cors
self
.
monitor_https_cors
=
monitor_https_cors
def
_fileWrite
(
self
,
file_path
,
content
):
def
_fileWrite
(
self
,
file_path
,
content
):
if
os
.
path
.
exists
(
file_path
)
:
try
:
try
:
with
open
(
file_path
,
'w'
)
as
wf
:
with
open
(
file_path
,
'w'
)
as
wf
:
print
file_path
,
content
wf
.
write
(
content
)
wf
.
write
(
content
.
strip
()
)
return
True
return
True
except
OSError
,
e
:
except
OSError
,
e
:
print
"ERROR while writing changes to %s.
\
n
%s"
%
(
file_path
,
str
(
e
))
print
"ERROR while writing changes to %s.
\
n
%s"
%
(
file_path
,
str
(
e
))
return
False
return
False
def
_htpasswdWrite
(
self
,
htpasswd_bin
,
parameter_dict
,
value
):
def
_htpasswdWrite
(
self
,
htpasswd_bin
,
parameter_dict
,
value
):
if
not
os
.
path
.
exists
(
parameter_dict
[
'file'
]):
return
False
command
=
[
htpasswd_bin
,
'-cb'
,
parameter_dict
[
'htpasswd'
],
parameter_dict
[
'user'
],
value
]
command
=
[
htpasswd_bin
,
'-cb'
,
parameter_dict
[
'htpasswd'
],
parameter_dict
[
'user'
],
value
]
process
=
subprocess
.
Popen
(
process
=
subprocess
.
Popen
(
command
,
command
,
...
...
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