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
3787c955
Commit
3787c955
authored
Nov 01, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed all parsing errors
parent
3882fb2b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
43 deletions
+65
-43
DeployService.java
.../main/java/nl/uva/sne/drip/api/service/DeployService.java
+1
-1
Converter.java
...rc/main/java/nl/uva/sne/drip/commons/utils/Converter.java
+44
-35
docker_check.py
drip-deployer/docker_check.py
+18
-5
docker_check.pyc
drip-deployer/docker_check.pyc
+0
-0
rpc_server.py
drip-deployer/rpc_server.py
+2
-2
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/service/DeployService.java
View file @
3787c955
...
@@ -597,7 +597,7 @@ public class DeployService {
...
@@ -597,7 +597,7 @@ public class DeployService {
return
newJa
.
toString
();
return
newJa
.
toString
();
}
}
private
Map
<
String
,
Object
>
buildSwarmInfo
(
List
<
MessageParameter
>
params
)
throws
JSONException
{
private
Map
<
String
,
Object
>
buildSwarmInfo
(
List
<
MessageParameter
>
params
)
throws
JSONException
,
IOException
{
Map
<
String
,
Object
>
info
=
new
HashMap
();
Map
<
String
,
Object
>
info
=
new
HashMap
();
for
(
MessageParameter
param
:
params
)
{
for
(
MessageParameter
param
:
params
)
{
String
jsonResp
=
param
.
getValue
().
replaceAll
(
"^\"|\"$"
,
""
);
String
jsonResp
=
param
.
getValue
().
replaceAll
(
"^\"|\"$"
,
""
);
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/Converter.java
View file @
3787c955
...
@@ -82,52 +82,61 @@ public class Converter {
...
@@ -82,52 +82,61 @@ public class Converter {
return
jsonObject
.
toString
();
return
jsonObject
.
toString
();
}
}
public
static
Map
<
String
,
Object
>
jsonString2Map
(
String
jsonString
)
throws
JSONException
{
public
static
Map
<
String
,
Object
>
jsonString2Map
(
String
jsonString
)
throws
JSONException
,
IOException
{
JSONObject
jsonObject
=
new
JSONObject
(
jsonString
);
// JSONObject jsonObject = new JSONObject(jsonString);
return
jsonObject2Map
(
jsonObject
);
// return jsonObject2Map(jsonObject);
Map
<
String
,
Object
>
result
=
new
ObjectMapper
().
readValue
(
jsonString
,
HashMap
.
class
);
return
result
;
}
}
public
static
List
<
Object
>
jsonString2List
(
String
jsonString
)
throws
JSONException
{
public
static
List
<
Object
>
jsonString2List
(
String
jsonString
)
throws
JSONException
,
IOException
{
JSONArray
jSONArray
=
new
JSONArray
(
jsonString
);
JSONArray
jSONArray
=
new
JSONArray
(
jsonString
);
return
jsonArray2List
(
jSONArray
);
return
jsonArray2List
(
jSONArray
);
}
}
public
static
Map
<
String
,
Object
>
jsonObject2Map
(
JSONObject
object
)
throws
JSONException
{
public
static
Map
<
String
,
Object
>
jsonObject2Map
(
JSONObject
object
)
throws
JSONException
,
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
();
return
new
ObjectMapper
().
readValue
(
object
.
toString
(),
HashMap
.
class
);
// Map<String, Object> map = new HashMap();
Iterator
<
String
>
keysItr
=
object
.
keys
();
//
while
(
keysItr
.
hasNext
())
{
// Iterator<String> keysItr = object.keys();
String
key
=
keysItr
.
next
();
// while (keysItr.hasNext()) {
Object
value
=
object
.
get
(
key
);
// String key = keysItr.next();
// Object value = object.get(key);
if
(
value
instanceof
JSONArray
)
{
//
value
=
jsonArray2List
((
JSONArray
)
value
);
// if (value instanceof JSONArray) {
}
else
if
(
value
instanceof
JSONObject
)
{
// value = jsonArray2List((JSONArray) value);
value
=
jsonObject2Map
((
JSONObject
)
value
);
// } else if (value instanceof JSONObject) {
}
else
if
(
value
.
equals
(
"[]"
))
{
// value = new ObjectMapper().readValue(((JSONObject) value).toString(), HashMap.class);
value
=
new
ArrayList
();
// } else if (value.equals("[]")) {
}
else
if
(
value
.
getClass
().
getName
().
equals
(
"org.json.JSONObject$Null"
))
{
// value = new ArrayList();
value
=
new
String
();
// } else if (value.getClass().getName().equals("org.json.JSONObject$Null")) {
}
// value = new String();
map
.
put
(
key
,
value
);
// }
}
// map.put(key, value);
return
map
;
// }
}
// return map;
}
public
static
List
<
Object
>
jsonArray2List
(
JSONArray
array
)
throws
JSONException
{
public
static
List
<
Object
>
jsonArray2List
(
JSONArray
array
)
throws
JSONException
,
IOException
{
List
<
Object
>
list
=
new
ArrayList
();
List
<
Object
>
list
=
new
ArrayList
();
if
(
array
!=
null
)
{
for
(
int
i
=
0
;
i
<
array
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
array
.
length
();
i
++)
{
Object
value
=
array
.
get
(
i
);
list
.
add
(
array
.
getString
(
i
));
if
(
value
instanceof
JSONArray
)
{
}
value
=
jsonArray2List
((
JSONArray
)
value
);
}
}
else
if
(
value
instanceof
JSONObject
)
{
// for (int i = 0; i < array.length(); i++) {
value
=
jsonObject2Map
((
JSONObject
)
value
);
// Object value = array.get(i);
}
// if (value instanceof JSONArray) {
if
(
value
instanceof
String
)
{
// value = jsonArray2List((JSONArray) value);
System
.
err
.
println
(
value
);
// } else if (value instanceof JSONObject) {
}
// value = jsonObject2Map((JSONObject) value);
list
.
add
(
value
);
// }
}
// if (value instanceof String) {
// System.err.println(value);
// }
// list.add(value);
// }
return
list
;
return
list
;
}
}
...
...
drip-deployer/docker_check.py
View file @
3787c955
...
@@ -23,6 +23,7 @@ import json
...
@@ -23,6 +23,7 @@ import json
import
logging
import
logging
import
linecache
import
linecache
import
sys
import
sys
import
ast
import
re
import
re
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -56,7 +57,10 @@ def docker_check(vm, compose_name):
...
@@ -56,7 +57,10 @@ def docker_check(vm, compose_name):
for
i
in
node_ls_resp
:
for
i
in
node_ls_resp
:
line
=
get_resp_line
(
i
)
line
=
get_resp_line
(
i
)
if
line
:
if
line
:
cluster_node_info
.
append
(
json
.
loads
(
line
))
node_info
=
json
.
loads
(
line
)
if
not
isinstance
(
node_info
,
dict
):
node_info
=
ast
.
literal_eval
(
node_info
)
cluster_node_info
.
append
(
node_info
)
json_response
[
'cluster_node_info'
]
=
cluster_node_info
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}}
\"
}
\'
'
services_format
=
'
\'
{
\"
ID
\"
:
\"
{{.ID}}
\"
,
\"
name
\"
:
\"
{{.Name}}
\"
,
\"
image
\"
:
\"
{{.Image}}
\"
,
\"
node
\"
:
\"
{{.Node}}
\"
,
\"
desired_state
\"
:
\"
{{.DesiredState}}
\"
,
\"
current_state
\"
:
\"
{{.CurrentState}}
\"
,
\"
error
\"
:
\"
{{.Error}}
\"
,
\"
ports
\"
:
\"
{{.Ports}}
\"
}
\'
'
...
@@ -68,6 +72,7 @@ def docker_check(vm, compose_name):
...
@@ -68,6 +72,7 @@ def docker_check(vm, compose_name):
for
i
in
stack_ps_resp
:
for
i
in
stack_ps_resp
:
line
=
get_resp_line
(
i
)
line
=
get_resp_line
(
i
)
if
line
:
if
line
:
json_dict
=
{}
json_dict
=
json
.
loads
(
line
)
json_dict
=
json
.
loads
(
line
)
json_dict
=
json
.
loads
(
json
.
dumps
(
json_dict
))
json_dict
=
json
.
loads
(
json
.
dumps
(
json_dict
))
if
not
isinstance
(
json_dict
,
dict
):
if
not
isinstance
(
json_dict
,
dict
):
...
@@ -89,26 +94,34 @@ def docker_check(vm, compose_name):
...
@@ -89,26 +94,34 @@ def docker_check(vm, compose_name):
for
i
in
stack_resp
:
for
i
in
stack_resp
:
line
=
get_resp_line
(
i
)
line
=
get_resp_line
(
i
)
if
line
:
if
line
:
json_dict
=
{}
json_dict
=
json
.
loads
(
line
)
json_dict
=
json
.
loads
(
line
)
if
not
isinstance
(
json_dict
,
dict
):
json_dict
=
json
.
loads
(
json_dict
)
stack_info
.
append
(
json_dict
)
stack_info
.
append
(
json_dict
)
json_response
[
'stack_info'
]
=
stack_info
json_response
[
'stack_info'
]
=
stack_info
cmd
=
'sudo docker node inspect '
cmd
=
'sudo docker node inspect '
for
hostname
in
nodes_hostname
:
for
hostname
in
nodes_hostname
:
cmd
+=
hostname
cmd
+=
' '
+
hostname
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
cmd
)
stdin
,
stdout
,
stderr
=
ssh
.
exec_command
(
cmd
)
inspect_resp
=
stdout
.
readlines
()
inspect_resp
=
stdout
.
readlines
()
response_str
=
""
response_str
=
""
for
i
in
inspect_resp
:
for
i
in
inspect_resp
:
line
=
get_resp_line
(
i
)
line
=
i
.
rstrip
(
"
\n\r
"
)
.
encode
(
)
if
line
:
if
line
:
response_str
+=
line
response_str
+=
line
json_dict
=
{}
json_dict
=
json
.
loads
(
response_str
.
rstrip
(
"
\n\r
"
)
.
strip
()
.
encode
(
'string_escape'
))
response_str
=
response_str
.
rstrip
(
"
\n\r
"
)
.
strip
(
'
\t\n\r
'
)
.
strip
()
.
encode
(
'string_escape'
)
print
response_str
json_dict
=
json
.
loads
(
response_str
)
json_response
[
'nodes_info'
]
=
json_dict
json_response
[
'nodes_info'
]
=
json_dict
logger
.
info
(
"Finished docker info services on: "
+
vm
.
ip
)
logger
.
info
(
"Finished docker info services on: "
+
vm
.
ip
)
except
Exception
as
e
:
except
Exception
as
e
:
exc_type
,
exc_obj
,
tb
=
sys
.
exc_info
()
exc_type
,
exc_obj
,
tb
=
sys
.
exc_info
()
...
...
drip-deployer/docker_check.pyc
View file @
3787c955
No preview for this file type
drip-deployer/rpc_server.py
View file @
3787c955
...
@@ -170,7 +170,7 @@ def on_request(ch, method, props, body):
...
@@ -170,7 +170,7 @@ def on_request(ch, method, props, body):
response
[
"parameters"
]
.
append
(
par
)
response
[
"parameters"
]
.
append
(
par
)
response
=
json
.
dumps
(
response
)
response
=
json
.
dumps
(
response
)
logger
.
info
(
"Response: "
+
response
)
#
logger.info("Response: " + response)
ch
.
basic_publish
(
exchange
=
''
,
ch
.
basic_publish
(
exchange
=
''
,
...
...
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