File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ def get_conf():
3333 parser .read ('/etc/osacc.conf' )
3434 ev = {}
3535 ev ['out_dir' ] = parser .get ('DEFAULT' , 'OUT_DIR' )
36+ ev ['openstack_host' ] = parser .get ('DEFAULT' , 'OPENSTACK_HOST' )
3637 ev ['month_ini' ] = parser .getint ('DEFAULT' , 'MONTH_INI' )
3738 ev ['year_ini' ] = parser .getint ('DEFAULT' , 'YEAR_INI' )
3839 ev ['delta_time' ] = parser .getfloat ('DEFAULT' , 'DELTA_TIME' )
Original file line number Diff line number Diff line change 6868import os
6969import json
7070from datetime import datetime , timezone
71+ import osacc_functions as oaf
7172
7273if __name__ == '__main__' :
7374 if len (sys .argv ) < 3 :
7475 print (f'Error json file not specified: { sys .argv [0 ]} <data.json> <output_dir>' )
7576 sys .exit (1 )
7677
77- osdashconf = "/etc/openstack-dashboard/local_settings"
78- osinfra = ''
79- if os .path .isfile (osdashconf ):
80- with open (osdashconf , 'r' , encoding = 'utf-8' ) as fp :
81- for l_no , line in enumerate (fp ):
82- if 'OPENSTACK_HOST' in line :
83- osinfra = line .split ('\" ' )[1 ]
84- break
85-
86- if os .path .isfile (osdashconf + '.py' ):
87- with open (osdashconf + '.py' , 'r' , encoding = 'utf-8' ) as fp :
88- for l_no , line in enumerate (fp ):
89- if 'OPENSTACK_HOST' in line :
90- osinfra = line .split ('\" ' )[1 ]
91- break
92-
78+ ev = oaf .get_conf ()
79+ osinfra = ev ['openstack_host' ]
9380 json_file = sys .argv [1 ]
9481 out_dir = sys .argv [2 ] + '/'
9582 if not os .path .isdir (out_dir ):
Original file line number Diff line number Diff line change 33# the filenames are <YEAR>.hdf
44OUT_DIR = /var/log/osacc
55
6+ # Openstack public hostname
7+ OPENSTACK_HOST = myos.com
8+
69# (Mandatory) Month and Year to start the accounting
710MONTH_INI = 1
811YEAR_INI = 2016
You can’t perform that action at this time.
0 commit comments