refs #1978 change imgname in ogagent.cfg
parent
24f5461860
commit
b9a2c58c96
|
@ -200,7 +200,7 @@ def ogAddCmd (disk, par, cmdfile, cmd):
|
|||
#@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#*/ ##
|
||||
def ogConfigureOgagent (disk, par):
|
||||
def ogConfigureOgagent (disk, par, imgname=''):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir:
|
||||
return
|
||||
|
@ -217,19 +217,22 @@ def ogConfigureOgagent (disk, par):
|
|||
ogcore_ip = NetLib.ogGetServerIp()
|
||||
ogcore_port = NetLib.ogGetServerPort()
|
||||
cfgfile_patched = cfgfile + '.patched'
|
||||
in_opengnsys_section = False
|
||||
cur_section = ''
|
||||
with open (cfgfile, 'r') as fdin:
|
||||
with open (cfgfile_patched, 'w') as fdout:
|
||||
while True:
|
||||
lineout = linein = fdin.readline()
|
||||
if not linein: break
|
||||
if in_opengnsys_section:
|
||||
if 'remote' == linein[0:6]:
|
||||
lineout = f'remote={ogcore_scheme}://{ogcore_ip}:{ogcore_port}/opengnsys/rest/\n'
|
||||
if '[' == linein[0:1]:
|
||||
in_opengnsys_section = False
|
||||
if '[opengnsys]' == linein[0:11]:
|
||||
in_opengnsys_section = True
|
||||
m = re.match (r'\[(.*)] *$', linein)
|
||||
|
||||
if m:
|
||||
cur_section = m.groups()[0]
|
||||
else:
|
||||
if 'opengnsys' == cur_section:
|
||||
if re.match (r'remote *=', linein):
|
||||
lineout = f'remote={ogcore_scheme}://{ogcore_ip}:{ogcore_port}/opengnsys/rest/\n'
|
||||
elif re.match ('imgname *=', linein):
|
||||
lineout = f'imgname={imgname}\n'
|
||||
fdout.write (lineout)
|
||||
os.rename (cfgfile_patched, cfgfile)
|
||||
|
||||
|
|
Loading…
Reference in New Issue