Changeset 3553

Show
Ignore:
Timestamp:
10/22/2009 09:17:09 AM (1 month ago)
Author:
magini
Message:

Updating DDT tools to use PhEDEx (pre-prod) DataSvc? for link status

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GraphUsers/ddt/calculate_links.py

    r3295 r3553  
    22 
    33import sys, time, datetime, logging 
    4 from phedex_monitor.service.calculate_links import DDTLinkStatusParser, DDTCommissionCalculator 
     4from phedex_monitor.service.calculate_links import DDTCommissionCalculator 
    55from phedex_monitor.model.state import State 
    66from phedex_monitor.service.data_parser import DDTDataParser 
     7from phedex_monitor.service.link_status_parser import DDTLinkStatusParser 
    78 
    89log = logging.getLogger() 
     
    7475 
    7576    
    76     surl = 'http://t2.unl.edu/phedex/xml/enabled?from_node=.*&excludefrom=XT%7CCH_CAF&excludeto=XT%7CCH_CAF&to_node=.*&conn=Prod%2FNEBRASKA' 
     77    #surl = 'http://t2.unl.edu/phedex/xml/enabled?from_node=.*&excludefrom=XT%7CCH_CAF&excludeto=XT%7CCH_CAF&to_node=.*&conn=Prod%2FNEBRASKA' 
     78    surl='http://cmsweb-int.cern.ch/phedex/datasvc/xml/prod/links' 
    7779    durl2='http://cmsweb.cern.ch/phedex/datasvc/xml/debug/transferhistory?binwidth=%s&starttime=%s&endtime=%s' 
    7880        
  • GraphUsers/ddt/phedex_monitor/service/calculate_links.py

    r3306 r3553  
    4141 
    4242default_status_url='http://t2.unl.edu/phedex/xml/enabled?from_node=.*&excludefrom=T3%7CMSS%7CT0%7CPIC_Disk%7CXT2%7CCH_CAF&excludeto=T3%7CMSS%7CT0%7CPIC_Disk%7CXT2%7CCH_CAF&to_node=.*&conn=Prod%2FNEBRASKA' 
    43  
    44 class DDTLinkStatusParser(handler.ContentHandler): 
    45  
    46     """ 
    47     Retrieve the current link status from the PhEDEx XML data. 
    48     """ 
    49  
    50     default_pivot = "Unknown" 
    51     default_group = "Unknown" 
    52     default_datum = "n" 
    53  
    54     def __init__( self, url ): 
    55         self.url = url 
    56         self.parser = make_parser() 
    57         self.parser.setContentHandler( self ) 
    58         self.in_data = False 
    59         self.cur_pivot_str = None 
    60         self.cur_group_str = None 
    61         self.cur_pivot_obj = None 
    62         self.cur_group_obj = None 
    63         self.in_datum = False 
    64         self.cur_datum_obj = None 
    65          
    66         self.links = set() 
    67  
    68     def run( self, debug_links = [] ): 
    69         self.debug_links = debug_links 
    70         self.parser.parse( self.url ) 
    71   
    72     def pivot_group_str_to_link( self, pivot_str, group_str ): 
    73         from_node, to_node = Node(pivot_str), Node(group_str) 
    74         link = Link( from_node, to_node ) 
    75         return link 
    76  
    77     def startElement( self, name, attrs ): 
    78         if name == 'data': 
    79             log.debug("Started parsing data.") 
    80             self.in_data = True 
    81         elif self.in_data == False: 
    82            return 
    83         elif name == 'pivot': 
    84            self.cur_pivot_str = str( attrs.get('name',self.default_pivot) ) 
    85 #           if self.cur_pivot_str in self.debug_links: 
    86 #               self.do_debug = True 
    87 #               log.debug("Starting processing of link %s" % self.cur_pivot_str) 
    88 #           else: 
    89 #               self.do_debug = False 
    90            self.cur_pivot_obj = self.cur_pivot_str 
    91            self.cur_group_obj = self.default_group 
    92         elif name == 'group': 
    93            self.cur_group_str = str( attrs.get('value','None') ) 
    94            if self.cur_group_str == 'None': 
    95                self.cur_group_obj = self.default_group 
    96            else: 
    97                self.cur_group_obj = self.pivot_group_str_to_link(self.cur_pivot_obj,self.cur_group_str) 
    98            self.cur_datum_obj = self.default_datum 
    99         elif name == 'd': 
    100            self.in_datum = True  
    101  
    102     def endElement( self, name ): 
    103         if name == 'group': 
    104             #            if self.do_debug: 
    105             #                log.debug("Link had %.3fTB of data on date %s" % \ 
    106             #                    (self.cur_datum_obj, self.cur_group_obj.strftime('%x'))) 
    107             if (self.cur_datum_obj == "y" ): 
    108                 self.cur_group_obj.set_state(State.COMMISSIONED) 
    109             elif (self.cur_datum_obj == "n" ): 
    110                 self.cur_group_obj.set_state(State.NOT_TESTED) 
    111             self.links.add(self.cur_group_obj)  
    112         elif name == 'd': 
    113             self.in_datum = False 
    114         elif name == 'data': 
    115             log.debug("Finished parsing data.") 
    116             self.in_data = False 
    117  
    118     def characters( self, content ): 
    119         if self.in_datum: 
    120            self.cur_datum_obj = content.strip() 
    121  
    122     def getData( self ): 
    123         """ Returns the set of all links with their status. """ 
    124         return self.links 
    125  
    126     def getCommissionedLinks( self ): 
    127         """ Returns the set of commissioned links only. """ 
    128         commissioned_links = set() 
    129         for link in self.links: 
    130             if link.get_state() == "COMMISSIONED": 
    131                 commissioned_links.add(link) 
    132         return commissioned_links 
    133  
    134     def print_all_links_in_state( self, match_state ): 
    135         counter = 0 
    136         filtered_links = [] 
    137         for link in self.links: 
    138             if link.state == match_state: 
    139                 filtered_links.append( str(link) ) 
    140         filtered_links.sort() 
    141         for link in filtered_links: 
    142             counter += 1 
    143             from_site, dummy, to_site = link.split() 
    144             print '%20s %20s' % (from_site, to_site) 
    145         print "(%i links in state %s total)" % (counter, match_state) 
    146  
    147  
    14843 
    14944class DDTCommissionCalculator: