Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
b38bd2ce
Commit
b38bd2ce
authored
Oct 31, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed encoding error
parent
4826746e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
20 deletions
+42
-20
DeployService.java
.../main/java/nl/uva/sne/drip/api/service/DeployService.java
+2
-1
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+5
-0
docker_check.py
drip-deployer/docker_check.py
+35
-19
docker_check.pyc
drip-deployer/docker_check.pyc
+0
-0
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java
View file @
b38bd2ce
...
...
@@ -601,8 +601,9 @@ public class DeployService {
Map
<
String
,
Object
>
info
=
new
HashMap
();
for
(
MessageParameter
param
:
params
)
{
String
jsonResp
=
param
.
getValue
().
replaceAll
(
"^\"|\"$"
,
""
);
System
.
err
.
println
(
jsonResp
);
Map
<
String
,
Object
>
kv
=
Converter
.
jsonString2Map
(
jsonResp
);
info
.
putAll
(
kv
);
}
return
info
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
b38bd2ce
...
...
@@ -26,6 +26,8 @@ import java.util.Iterator;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.regex.Matcher
;
import
nl.uva.sne.drip.drip.commons.data.v1.external.CloudCredentials
;
import
org.apache.commons.io.FilenameUtils
;
...
...
@@ -102,6 +104,9 @@ public class Converter {
value
=
jsonArray2List
((
JSONArray
)
value
);
}
else
if
(
value
instanceof
JSONObject
)
{
value
=
jsonObject2Map
((
JSONObject
)
value
);
}
else
if
(
value
.
equals
(
"[]"
))
{
Logger
.
getLogger
(
Converter
.
class
.
getName
()).
log
(
Level
.
WARNING
,
"value: {0} is not JSONArray or an JSONObject"
,
value
);
value
=
null
;
}
map
.
put
(
key
,
value
);
}
...
...
drip-deployer/docker_check.py
View file @
b38bd2ce
...
...
@@ -23,10 +23,11 @@ import json
import
logging
import
linecache
import
sys
import
re
logger
=
logging
.
getLogger
(
__name__
)
if
not
getattr
(
logger
,
'handler_set'
,
None
):
logger
.
setLevel
(
logging
.
INFO
)
#
logger.setLevel(logging.INFO)
h
=
logging
.
StreamHandler
()
formatter
=
logging
.
Formatter
(
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s'
)
h
.
setFormatter
(
formatter
)
...
...
@@ -34,6 +35,10 @@ if not getattr(logger, 'handler_set', None):
logger
.
handler_set
=
True
def
get_resp_line
(
line
):
line
=
line
.
encode
(
'utf-8'
)
.
strip
(
'
\n
'
)
.
encode
(
'string_escape'
)
return
json
.
dumps
(
line
)
def
docker_check
(
vm
,
compose_name
):
try
:
...
...
@@ -49,9 +54,9 @@ def docker_check(vm, compose_name):
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
cmd
)
node_ls_resp
=
stdout
.
readlines
()
for
i
in
node_ls_resp
:
if
i
.
encode
():
json_str
=
json
.
loads
(
i
.
encode
()
.
strip
(
'
\n
'
))
cluster_node_info
.
append
(
json
_str
)
line
=
get_resp_line
(
i
)
if
line
:
cluster_node_info
.
append
(
json
.
loads
(
line
)
)
json_response
[
'cluster_node_info'
]
=
cluster_node_info
services_format
=
'
\'
{
\"
ID
\"
:
\"
{{.ID}}
\"
,
\"
name
\"
:
\"
{{.Name}}
\"
,
\"
image
\"
:
\"
{{.Image}}
\"
,
\"
node
\"
:
\"
{{.Node}}
\"
,
\"
desired_state
\"
:
\"
{{.DesiredState}}
\"
,
\"
current_state
\"
:
\"
{{.CurrentState}}
\"
,
\"
error
\"
:
\"
{{.Error}}
\"
,
\"
ports
\"
:
\"
{{.Ports}}
\"
}
\'
'
...
...
@@ -61,21 +66,31 @@ def docker_check(vm, compose_name):
services_info
=
[]
nodes_hostname
=
set
()
for
i
in
stack_ps_resp
:
if
i
.
encode
():
json_str
=
json
.
loads
(
i
.
encode
()
.
strip
(
'
\n
'
))
if
json_str
[
'node'
]
not
in
nodes_hostname
:
nodes_hostname
.
add
(
json_str
[
'node'
])
services_info
.
append
(
json_str
)
line
=
get_resp_line
(
i
)
if
line
:
json_dict
=
json
.
loads
(
line
)
json_dict
=
json
.
loads
(
json
.
dumps
(
json_dict
))
if
not
isinstance
(
json_dict
,
dict
):
try
:
json_dict
=
json
.
loads
(
json_dict
)
except
Exception
as
e
:
json_dict
=
json_dict
.
replace
(
'
\"
ports
\"
:
\"\"
'
,
'
\"
ports
\"
:null'
)
.
replace
(
'
\"\"
'
,
'
\"
'
)
json_dict
=
json_dict
.
replace
(
"
\\
"
,
""
)
.
replace
(
"Noxe2x80xa6"
,
"No..."
)
json_dict
=
json
.
loads
(
json_dict
)
nodes_hostname
.
add
(
json_dict
[
'node'
])
services_info
.
append
(
json_dict
)
json_response
[
'services_info'
]
=
services_info
stack_format
=
'
\'
{"ID":"{{.ID}}","name":"{{.Name}}","mode":"{{.Mode}}","replicas":"{{.Replicas}}","image":"{{.Image}}"}
\'
'
cmd
=
'sudo docker stack services '
+
compose_name
+
' --format '
+
(
stack_format
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
cmd
)
stack_resp
=
stdout
.
readlines
()
stack_info
=
[]
for
i
in
stack_resp
:
if
i
.
encode
():
json_str
=
json
.
loads
(
i
.
encode
()
.
strip
(
'
\n
'
))
stack_info
.
append
(
json_str
)
line
=
get_resp_line
(
i
)
if
line
:
json_dict
=
json
.
loads
(
line
)
stack_info
.
append
(
json_dict
)
json_response
[
'stack_info'
]
=
stack_info
cmd
=
'sudo docker node inspect '
...
...
@@ -87,11 +102,12 @@ def docker_check(vm, compose_name):
response_str
=
""
for
i
in
inspect_resp
:
if
i
.
encode
():
response_str
+=
i
.
encode
()
.
strip
(
'
\n
'
)
line
=
get_resp_line
(
i
)
if
line
:
response_str
+=
line
json_
str
=
json
.
loads
(
response_str
.
rstrip
(
"
\n\r
"
)
.
strip
()
.
encode
(
'string_escape'
))
json_response
[
'nodes_info'
]
=
json_
str
json_
dict
=
json
.
loads
(
response_str
.
rstrip
(
"
\n\r
"
)
.
strip
()
.
encode
(
'string_escape'
))
json_response
[
'nodes_info'
]
=
json_
dict
logger
.
info
(
"Finished docker info services on: "
+
vm
.
ip
)
except
Exception
as
e
:
...
...
@@ -104,7 +120,7 @@ def docker_check(vm, compose_name):
print
'EXCEPTION IN ({}, LINE {} "{}"): {}'
.
format
(
filename
,
lineno
,
line
.
strip
(),
exc_obj
)
logger
.
error
(
vm
.
ip
+
" "
+
str
(
e
)
+
" line:"
+
lineno
)
#
logger.error(vm.ip + " " + str(e)+ " line:" +lineno)
return
"ERROR:"
+
vm
.
ip
+
" "
+
str
(
e
)
ssh
.
close
()
return
json_response
...
...
drip-deployer/docker_check.pyc
View file @
b38bd2ce
No preview for this file type
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