Skip to content

Commit c4a99d1

Browse files
committed
add conf for openstack hostname
1 parent 5443d68 commit c4a99d1

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

acc_scripts/osacc_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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')

acc_scripts/osinfo2md.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,15 @@
6868
import os
6969
import json
7070
from datetime import datetime, timezone
71+
import osacc_functions as oaf
7172

7273
if __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):

etc/osacc.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# the filenames are <YEAR>.hdf
44
OUT_DIR = /var/log/osacc
55

6+
# Openstack public hostname
7+
OPENSTACK_HOST = myos.com
8+
69
# (Mandatory) Month and Year to start the accounting
710
MONTH_INI = 1
811
YEAR_INI = 2016

0 commit comments

Comments
 (0)