#NEWLINE# @ auth #NEWLINE# def _GET( self , * param , **params ) : #NEWLINE# #INDENT# host_id = self . chk_hostby1 ( param ) #NEWLINE# if ( host_id is None ) : #NEWLINE# #INDENT# return web . notfound ( ) #NEWLINE# #UNINDENT# target = param [ 1 ] #NEWLINE# if ( target is None ) : #NEWLINE# #INDENT# return web . notfound ( ) #NEWLINE# #UNINDENT# dev = param [ 2 ] #NEWLINE# if ( dev is None ) : #NEWLINE# #INDENT# return web . notfound ( ) #NEWLINE# #UNINDENT# if ( not validates_report ( self ) ) : #NEWLINE# #INDENT# self . logger . debug ( 'Get report failed. Did not validate.' ) #NEWLINE# return web . badrequest ( self . view . alert ) #NEWLINE# #UNINDENT# today = datetime . datetime . today ( ) #NEWLINE# if ( is_param ( self . input , 'report_start_day' ) and ( not is_empty ( self . input . report_start_day ) ) ) : #NEWLINE# #INDENT# start_day = str2datetime ( self . input . report_start_day , DEFAULT_LANGS [ self . me . languages ] [ 'DATE_FORMAT' ] [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start_day = ( today - datetime . timedelta ( 1 ) ) #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'report_start_time' ) and ( not is_empty ( self . input . report_start_time ) ) ) : #NEWLINE# #INDENT# ( start_hour , start_minute ) = self . input . report_start_time . split ( ':' , 2 ) #NEWLINE# start_hour = int ( start_hour ) #NEWLINE# start_minute = int ( start_minute ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start_hour = today . hour #NEWLINE# start_minute = today . minute #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'report_end_day' ) and ( not is_empty ( self . input . report_end_day ) ) ) : #NEWLINE# #INDENT# end_day = str2datetime ( self . input . report_end_day , DEFAULT_LANGS [ self . me . languages ] [ 'DATE_FORMAT' ] [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# end_day = today #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'report_end_time' ) and ( not is_empty ( self . input . report_end_time ) ) ) : #NEWLINE# #INDENT# ( end_hour , end_minute ) = self . input . report_end_time . split ( ':' , 2 ) #NEWLINE# end_hour = int ( end_hour ) #NEWLINE# end_minute = int ( end_minute ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# end_hour = today . hour #NEWLINE# end_minute = today . minute #NEWLINE# #UNINDENT# start_time = create_epochsec ( start_day . year , start_day . month , start_day . day , start_hour , start_minute ) #NEWLINE# end_time = create_epochsec ( end_day . year , end_day . month , end_day . day , end_hour , end_minute ) #NEWLINE# if ( int ( start_time ) > int ( end_time ) ) : #NEWLINE# #INDENT# self . logger . error ( 'Getting reports failed. Start time > end time.' ) #NEWLINE# return web . badrequest ( _ ( 'Getting reports failed. Start time > end time.' ) ) #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'type' ) and ( not is_empty ( self . input . type ) ) ) : #NEWLINE# #INDENT# type = self . input . type #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# type = 'default' #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'host' ) and ( not is_empty ( self . input . host ) ) ) : #NEWLINE# #INDENT# host = self . input . host #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# host = None #NEWLINE# #UNINDENT# if ( is_param ( self . input , 'libvirt_target' ) and ( not is_empty ( self . input . libvirt_target ) ) ) : #NEWLINE# #INDENT# libvirt_target = self . input . libvirt_target #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# libvirt_target = None #NEWLINE# #UNINDENT# rrd = RRD ( self . _ , self . me . languages ) #NEWLINE# if ( host is not None ) : #NEWLINE# #INDENT# if ( rrd . set_rrd_dir_host ( host ) is False ) : #NEWLINE# #INDENT# self . logger . debug ( 'Get report failed. Target host not found.' ) #NEWLINE# return web . notfound ( ) #NEWLINE# #UNINDENT# #UNINDENT# filepath = rrd . create_graph ( target , dev , type , start_time , end_time , libvirt_target ) #NEWLINE# if ( filepath != '' ) : #NEWLINE# #INDENT# self . download . type = OUTPUT_TYPE_FILE #NEWLINE# self . download . file = filepath #NEWLINE# self . download . once = True #NEWLINE# #UNINDENT# return True