Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] Diff of /ea/xml_conv.py
[bonfiredemokit] / ea / xml_conv.py Repository:
ViewVC logotype

Diff of /ea/xml_conv.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9, Thu Aug 30 12:48:07 2012 UTC revision 15, Tue Oct 9 14:42:19 2012 UTC
# Line 3  Line 3 
3  #  #
4  # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012  # Copyright (c) Fundacion Centro Tecnologico de Supercomputacion de Galicia 2012
5  #  #
6  # License GPL Version 3  # License Apache Software
7  #  #
8  # The research leading to these results has received funding from  # The research leading to these results has received funding from
9  # the European Community's Seventh Frameqork Programme (FP7/2007-2013)  # the European Community's Seventh Framework Programme (FP7/2007-2013)
10  # under agreement number 257386  # under agreement number 257386
11  #  #
12  # This software is provided with ABSOLUTELY NO WARRANTY  # This software is provided with ABSOLUTELY NO WARRANTY
# Line 32  Line 32 
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
# Line 67  Line 67 
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
# Line 80  Line 79 
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
# Line 113  Line 112 
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
# Line 142  Line 141 
141    
142      return log      return log
143    
 #code="""<?xml version="1.0" encoding="UTF-8"?>  
 #<compute xmlns="http://api.bonfire-project.eu/doc/schemas/occi" href="/locations/fr-inria/computes/21474">  
 #  <id>21474</id>  
 #  <cpu>1</cpu>  
 #  <memory>1024</memory>  
 #  <name>JSON-COMPUTE-TEST</name>  
 #  <instance_type>small</instance_type>  
 #  <state>RUNNING</state>  
 #  <disk id="0">  
 #    <storage href="/locations/fr-inria/storages/3" name="BonFIRE Debian Squeeze v3"/>  
 #    <type>DISK</type>  
 #    <target>xvda</target>  
 #  </disk>  
 #  <nic>  
 #    <network href="/locations/fr-inria/networks/4" name="BonFIRE WAN"/>  
 #    <ip>172.18.7.87</ip>  
 #    <mac>02:00:ac:12:07:57</mac>  
 #  </nic>  
 #  <context>  
 #    <authorized_keys>ssh-dss AAAAB3NzaC1kc3MAAACBAPhVbbL4qAcvyuvlVdd3QUQnJzzKL2N92wH33mS10HAzfRF7a40iW31+PT7IBLnPalwg7yRPNcGLfXIrtqBjlVZLynzCwP1JH3Z6diokMjukMbNX/rXe/TeIIzWI7BLJeLXPuXBrm/oW97RN+s8fYetnDHhxclgo8+J27K80Qe5FAAAAFQCweWyZxWYlaUuN8vr+Bxcaj23l1wAAAIEA17Wq9yd0mHpnAympsQZmKUtFiRuLr0OHYmI4XV6+Av+2f2wrvlNTgpr4A2Tr0E1I/utUqkt38dzTU6sOFfau0y5tNkrWu5r33nrmPdCSRAlNybU1yFgFp5CNEG8QKjikXhIrpo35WLy+Y6JuoBtOp3+BDTTsZhMFxIAPyNzu4XYAAACBAKKcf9owhthEpx+9t6a8o8EoCfmcpF/jU2Ml3Ia291cn0MUo798xLXoTOPIxivcA/VJe7EPUEKcVxc0och0e0UuzGT3dUEfVRlfZnERBkdZHWSZT7a+BKESTnV5xBMi2Q2wWQrPbYhXd0+zYg5Zm5/Qcd8Ou3Tu+cFTvKMtDZ1Iq cesga@anzol</authorized_keys>  
 #    <bonfire_credentials>rvalin:t87rgt8sjm23yzcuhwvws</bonfire_credentials>  
 #    <bonfire_experiment_expiration_date>1327934238</bonfire_experiment_expiration_date>  
 #    <bonfire_experiment_id>130</bonfire_experiment_id>  
 #    <bonfire_experiment_routing_key>a5b4c4ec82c53fbe63b7</bonfire_experiment_routing_key>  
 #    <bonfire_provider>fr-inria</bonfire_provider>  
 #    <bonfire_resource_id>21474</bonfire_resource_id>  
 #    <bonfire_resource_name>JSON-COMPUTE-TEST</bonfire_resource_name>  
 #    <bonfire_uri>https://api.integration.bonfire.grid5000.fr</bonfire_uri>  
 #    <cluster>default</cluster>  
 #    <dns_servers>131.254.204.4</dns_servers>  
 #    <files>/srv/cloud/context /srv/cloud/context/lib /srv/cloud/context/distributions /srv/cloud/context/sites /srv/cloud/context/common /srv/cloud/context/init.sh</files>  
 #    <hostname>JSON-COMPUTE-TEST-21474</hostname>  
 #    <metrics>PG1ldHJpYz5ib25maXJlLmNvdW50MTBbL3RtcC90ZXN0RmlsZS50eHRdLHdjIC1sICQxIHwgY3V0IC1kIiAiIC1mMTwvbWV0cmljPjxtZXRyaWM+Ym9uZmlyZS5jb3VudDlbL3RtcC90ZXN0RmlsZS50eHRdLHdjIC1sICQxIHwgY3V0IC1kIiAiIC1mMTwvbWV0cmljPg==</metrics>  
 #    <ntp_servers>ntp.rennes.grid5000.fr</ntp_servers>  
 #    <public_gateway>131.254.204.8</public_gateway>  
 #    <target>xvdb</target>  
 #    <usage>zabbix-agent</usage>  
 #    <wan_ip>172.18.7.87</wan_ip>  
 #    <wan_mac>02:00:ac:12:07:57</wan_mac>  
 #  </context>  
 #  <host>node-1.integration</host>  
 #<link rel="experiment" href="/experiments/130" type="application/vnd.bonfire+xml"/></compute>"""  
144    
145    
146  def xml_compute_parse(code):  def xml_compute_parse(code):
# Line 193  Line 150 
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
# Line 235  Line 191 
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()
# Line 291  Line 247 
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

Legend:
Removed from v.9  
changed lines
  Added in v.15

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge