32 |
|
|
33 |
def xml_parse(code): |
def xml_parse(code): |
34 |
"""Input: XML Variable |
"""Input: XML Variable |
35 |
Ouput: lista con ruta_relativa exp, name, description,status,ruta log """ |
Ouput: list with relative URL exp, name, description,status,ruta log """ |
36 |
exp_ref = dict() |
exp_ref = dict() |
37 |
elements = tree.fromstring(code) |
elements = tree.fromstring(code) |
38 |
for sub in elements.iter(): |
for sub in elements.iter(): |
39 |
if(sub.tag == 'managed_experiment'): |
if(sub.tag == 'managed_experiment'): |
40 |
#Imprime atributos de ese tag. Devuelve un diccionario |
#Print attributes. Returns a dictionary |
41 |
exp_ref['experiment'] = sub.attrib['href'] |
exp_ref['experiment'] = sub.attrib['href'] |
42 |
if(sub.tag == 'name'): |
if(sub.tag == 'name'): |
43 |
#Imprime el campo correspondiente al tag |
#Print the field for this tag |
44 |
exp_ref['name'] = sub.text |
exp_ref['name'] = sub.text |
45 |
if(sub.tag == 'description'): |
if(sub.tag == 'description'): |
46 |
exp_ref['descrip'] = sub.text |
exp_ref['descrip'] = sub.text |
67 |
# "All of the resources have been deployed.\n"] |
# "All of the resources have been deployed.\n"] |
68 |
|
|
69 |
def log_parsing(code, raiz, compute): |
def log_parsing(code, raiz, compute): |
70 |
"""Respuesta del log plain text |
"""Output from log plain text. |
|
se le puede pasar a python directamente como lista. |
|
71 |
Error: |
Error: |
72 |
1.- Info the experiment |
1.- Info the experiment |
73 |
2.- Infor broker experiment |
2.- Infor broker experiment |
74 |
3.- URI en el broker experiment |
3.- URI broker experiment |
75 |
4.- Info of deploying network |
4.- Info of deploying network |
76 |
5.- Resource URI network |
5.- Resource URI network |
77 |
6.- Info about deploying storage |
6.- Info about deploying storage |
79 |
8.- Info about deploying compute |
8.- Info about deploying compute |
80 |
9.- Resource URI computes |
9.- Resource URI computes |
81 |
10.- Info about experiment status |
10.- Info about experiment status |
82 |
11.- 7 lineas con info error enactor |
11.- 7 lines with info error enactor |
83 |
|
|
84 |
OK: |
OK: |
85 |
1.- Creation date of logfile |
1.- Creation date of logfile |
86 |
2.- Info about the experiment |
2.- Info about the experiment |
87 |
3.- URI en el broker experiment |
3.- URI broker experiment |
88 |
4.- Info of deploying network |
4.- Info of deploying network |
89 |
5.- Resource URI network |
5.- Resource URI network |
90 |
6.- Info about deploying storage |
6.- Info about deploying storage |
112 |
log['error']=0 |
log['error']=0 |
113 |
#compute=[] |
#compute=[] |
114 |
print 'EM reply:', code |
print 'EM reply:', code |
115 |
#comprobamos antes si hay un error en la respuesta. |
# Check errors in the answer. |
116 |
if 'Error' in str(code): |
if 'Error' in str(code): |
117 |
print 'Broker api error:', code |
print 'Broker api error:', code |
118 |
log['error'] = 1 |
log['error'] = 1 |
150 |
for sub in elements.iter(): |
for sub in elements.iter(): |
151 |
#print sub |
#print sub |
152 |
if('cpu' in sub.tag): |
if('cpu' in sub.tag): |
153 |
#Imprime atributos de ese tag. Devuelve un diccionario |
#Print attributes |
154 |
#print sub.text |
#print sub.text |
155 |
compute_info['cpu'] = sub.text |
compute_info['cpu'] = sub.text |
156 |
if('memory' in sub.tag): |
if('memory' in sub.tag): |
157 |
#Imprime el campo correspondiente al tag |
|
|
#print sub.text |
|
158 |
compute_info['mem'] = sub.text |
compute_info['mem'] = sub.text |
159 |
if('hostname' in sub.tag): |
if('hostname' in sub.tag): |
160 |
compute_info['hostname'] = sub.text |
compute_info['hostname'] = sub.text |
191 |
|
|
192 |
|
|
193 |
def mon_par(mon): |
def mon_par(mon): |
194 |
"""Parseado de la informacion de monitorizacion""" |
"""Parse monitoring info""" |
195 |
histories=dict() |
histories=dict() |
196 |
mean=dict() |
mean=dict() |
197 |
std=dict() |
std=dict() |
247 |
</qhost>""" |
</qhost>""" |
248 |
|
|
249 |
def xml_qhost(code): |
def xml_qhost(code): |
250 |
"Parsea la salida xml del qhost y devuelve los nodos disponibles" |
"Parse qhost xml info and returns available nodes" |
251 |
|
|
252 |
elements = tree.fromstring(code) |
elements = tree.fromstring(code) |
253 |
nodes=0 |
nodes=0 |
254 |
for sub in elements.iter(): |
for sub in elements.iter(): |
255 |
if(sub.tag == 'host'): |
if(sub.tag == 'host'): |
256 |
#Imprime atributos de ese tag. Devuelve un diccionario |
|
257 |
hostname = sub.attrib['name'] |
hostname = sub.attrib['name'] |
258 |
if 'global' not in hostname: |
if 'global' not in hostname: |
259 |
nodes=nodes+1 |
nodes=nodes+1 |