mirror of https://git.48k.eu/ogclient
Make OG_PATH public
This commit changes the OG_PATH to a public varible of the class ogConfig. This way we improve the configurability of the path.more_events
parent
d69841ed97
commit
4cd87e9875
3
main.py
3
main.py
|
|
@ -14,7 +14,8 @@ from signal import signal, SIGPIPE, SIG_DFL
|
||||||
def main():
|
def main():
|
||||||
signal(SIGPIPE, SIG_DFL)
|
signal(SIGPIPE, SIG_DFL)
|
||||||
ogconfig = ogConfig()
|
ogconfig = ogConfig()
|
||||||
if (not ogconfig.parser_file('cfg/ogagent.cfg')):
|
config_path = f'{ogConfig.OG_PATH}ogClient/cfg/ogagent.cfg'
|
||||||
|
if (not ogconfig.parser_file(config_path)):
|
||||||
print ('Error: Parsing configuration file')
|
print ('Error: Parsing configuration file')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from src.ogConfig import *
|
||||||
|
|
||||||
OG_PATH = '/opt/opengnsys/'
|
|
||||||
OG_SHELL = '/bin/bash'
|
OG_SHELL = '/bin/bash'
|
||||||
|
|
||||||
def parseGetConf(out):
|
def parseGetConf(out):
|
||||||
|
|
@ -39,16 +39,16 @@ def parseGetConf(out):
|
||||||
|
|
||||||
def poweroff():
|
def poweroff():
|
||||||
if os.path.exists('/scripts/oginit'):
|
if os.path.exists('/scripts/oginit'):
|
||||||
cmd = f'source {OG_PATH}etc/preinit/loadenviron.sh; ' \
|
cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||||
f'{OG_PATH}scripts/poweroff'
|
f'{ogConfig.OG_PATH}scripts/poweroff'
|
||||||
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
||||||
else:
|
else:
|
||||||
subprocess.call(['/sbin/poweroff'])
|
subprocess.call(['/sbin/poweroff'])
|
||||||
|
|
||||||
def reboot():
|
def reboot():
|
||||||
if os.path.exists('/scripts/oginit'):
|
if os.path.exists('/scripts/oginit'):
|
||||||
cmd = f'source {OG_PATH}etc/preinit/loadenviron.sh; ' \
|
cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||||
f'{OG_PATH}scripts/reboot'
|
f'{ogConfig.OG_PATH}scripts/reboot'
|
||||||
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
||||||
else:
|
else:
|
||||||
subprocess.call(['/sbin/reboot'])
|
subprocess.call(['/sbin/reboot'])
|
||||||
|
|
@ -70,7 +70,7 @@ def execCMD(request, ogRest):
|
||||||
def session(request, ogRest):
|
def session(request, ogRest):
|
||||||
disk = request.getDisk()
|
disk = request.getDisk()
|
||||||
partition = request.getPartition()
|
partition = request.getPartition()
|
||||||
cmd = f'{OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
|
|
@ -88,7 +88,7 @@ def software(request, path, ogRest):
|
||||||
partition = request.getPartition()
|
partition = request.getPartition()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmd = f'{OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||||
f'{partition} {path}'
|
f'{partition} {path}'
|
||||||
|
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
|
|
@ -103,7 +103,7 @@ def software(request, path, ogRest):
|
||||||
|
|
||||||
def hardware(path, ogRest):
|
def hardware(path, ogRest):
|
||||||
try:
|
try:
|
||||||
cmd = f'{OG_PATH}interfaceAdm/InventarioHardware {path}'
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}'
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
|
|
@ -129,7 +129,7 @@ def setup(request, ogRest):
|
||||||
if ogRest.terminated:
|
if ogRest.terminated:
|
||||||
break
|
break
|
||||||
|
|
||||||
cmd = f'{OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
|
||||||
try:
|
try:
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
|
@ -151,7 +151,7 @@ def image_restore(request, ogRest):
|
||||||
ctype = request.getType()
|
ctype = request.getType()
|
||||||
profile = request.getProfile()
|
profile = request.getProfile()
|
||||||
cid = request.getId()
|
cid = request.getId()
|
||||||
cmd = f'{OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
|
||||||
f'{name} {repo} {ctype}'
|
f'{name} {repo} {ctype}'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -170,9 +170,9 @@ def image_create(path, request, ogRest):
|
||||||
partition = request.getPartition()
|
partition = request.getPartition()
|
||||||
name = request.getName()
|
name = request.getName()
|
||||||
repo = request.getRepo()
|
repo = request.getRepo()
|
||||||
cmd_software = f'{OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
cmd_software = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||||
f'{partition} {path}'
|
f'{partition} {path}'
|
||||||
cmd_create_image = f'{OG_PATH}interfaceAdm/CrearImagen {disk} ' \
|
cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
|
||||||
f'{partition} {name} {repo}'
|
f'{partition} {name} {repo}'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -200,7 +200,7 @@ def image_create(path, request, ogRest):
|
||||||
|
|
||||||
def refresh(ogRest):
|
def refresh(ogRest):
|
||||||
try:
|
try:
|
||||||
cmd = f'{OG_PATH}interfaceAdm/getConfiguration'
|
cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
|
||||||
ogRest.proc = subprocess.Popen([cmd],
|
ogRest.proc = subprocess.Popen([cmd],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
class ogConfig:
|
class ogConfig:
|
||||||
|
OG_PATH = '/opt/opengnsys/'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.parser = configparser.ConfigParser()
|
self.parser = configparser.ConfigParser()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue