refs #2412 rename variables, add a couple of log messages, move a check
parent
87adfeda1c
commit
588ed96098
|
@ -34,12 +34,12 @@ prog = os.path.basename(__name__)
|
|||
#
|
||||
# El parámetro $2 es el que aporta toda la información y el $1 se queda obsoleto
|
||||
# Formato de entrada:
|
||||
# dis=Número de disco
|
||||
# != caracter de separación
|
||||
# dis=Número de disco
|
||||
# != caracter de separación
|
||||
#
|
||||
# Y un numero indeterminado de cadenas del tipo siguuenteseparadas por el caracter '$':
|
||||
# par=Número de particion*cod=Código de partición*sfi=Sistema de ficheros*tam=Tamaño de la partición*ope=Operación
|
||||
# @= caracter de separación
|
||||
# par=Número de particion*cod=Código de partición*sfi=Sistema de ficheros*tam=Tamaño de la partición*ope=Operación
|
||||
# @= caracter de separación
|
||||
#____________________________________________________________________
|
||||
|
||||
# Captura de parámetros (se ignora el 1er parámetro y se eliminan espacios y tabuladores).
|
||||
|
@ -51,12 +51,13 @@ param = sys.argv[2]
|
|||
tbprm = param.split ('!')
|
||||
pparam = tbprm[0] # General disk parameters
|
||||
sparam = tbprm[1] # Partitioning and formatting parameters
|
||||
is_there_cache = 'CACHE' in sparam
|
||||
|
||||
# Toma valores de disco y caché, separados por "*".
|
||||
# Los valores están en las variables $dis: disco, $che: existe cache (1, 0), $tch: Tamaño de la cache.
|
||||
tbprm = pparam.split ('*')
|
||||
pparams = pparam.split ('*')
|
||||
dis = tch = None
|
||||
for item in tbprm:
|
||||
for item in pparams:
|
||||
if '=' not in item: continue
|
||||
|
||||
k, v = item.split ('=', 1)
|
||||
|
@ -74,10 +75,10 @@ if dis is None:
|
|||
tbp = [] # Valores de configuración (parámetros para ogCreatePartitions)
|
||||
tbf = {} # Tabla de formateo
|
||||
|
||||
tbprm = sparam.split('%')
|
||||
sparams = sparam.split('%')
|
||||
|
||||
maxp=0
|
||||
for item in tbprm:
|
||||
for item in sparams:
|
||||
if not item: continue ## por si nos pasan un '%' al final de todo
|
||||
# Leer datos de la partición, separados por "*".
|
||||
par = cpt = sfi = tam = None
|
||||
|
@ -120,6 +121,18 @@ for item in tbprm:
|
|||
if tch is None:
|
||||
tch = '0'
|
||||
|
||||
|
||||
|
||||
cur_ptt = DiskLib.ogGetPartitionTableType (dis)
|
||||
ptt = 'GPT' if InventoryLib.ogIsEfiActive() else 'MSDOS'
|
||||
recreate_partition_table = False
|
||||
if not cur_ptt:
|
||||
SystemLib.ogEcho (['session', 'log'], None, f'No partition table--will create a "{ptt}" one')
|
||||
recreate_partition_table = True
|
||||
if cur_ptt and ptt != cur_ptt:
|
||||
SystemLib.ogEcho (['session', 'log'], None, f'Current partition table type "{cur_ptt}" is wrong for this system--will replace it for a "{ptt}" one')
|
||||
recreate_partition_table = True
|
||||
|
||||
#____________________________________________________
|
||||
#
|
||||
# Proceso
|
||||
|
@ -133,19 +146,16 @@ SystemLib.ogEcho (['session', 'log'], None, f'[10] {ogGlobals.lang.MSG_HELP_ogUn
|
|||
FileSystemLib.ogUnmountAll (dis)
|
||||
CacheLib.ogUnmountCache()
|
||||
|
||||
# Elimina la tabla de particiones
|
||||
cur_ptt = DiskLib.ogGetPartitionTableType (dis)
|
||||
ptt = 'GPT' if InventoryLib.ogIsEfiActive() else 'MSDOS'
|
||||
if not cur_ptt or ptt != cur_ptt:
|
||||
if recreate_partition_table:
|
||||
DiskLib.ogDeletePartitionTable (dis)
|
||||
SystemLib.ogExecAndLog ('command', [f'{ogGlobals.OGPYFUNCS}/ogUpdatePartitionTable'])
|
||||
DiskLib.ogCreatePartitionTable (dis, ptt)
|
||||
|
||||
# Inicia la cache.
|
||||
if 'CACHE' in sparam:
|
||||
if is_there_cache:
|
||||
SystemLib.ogEcho (['session', 'log'], None, f'[30] {ogGlobals.lang.MSG_HELP_ogCreateCache}')
|
||||
SystemLib.ogEcho (['session', 'log'], None, f' initCache.py {tch}')
|
||||
rc = SystemLib.ogExecAndLog ('command', [f'{ogGlobals.OGSCRIPTS}/initCache.py', tch])
|
||||
rc = SystemLib.ogExecAndLog ('command', [f'{ogGlobals.OGSCRIPTS}/initCache.py', str (tch)])
|
||||
if not rc:
|
||||
SystemLib.ogRaiseError (['log', 'session'], ogGlobals.OG_ERR_CACHE, f'initCache.py failed')
|
||||
sys.exit (1)
|
||||
|
|
Loading…
Reference in New Issue