summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-05 13:08:00 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-06-05 13:08:00 +0200
commitd7b7b0b17571c7e36b69314b28dc1ea3a43c2215 (patch)
tree885a61f6f90b8defbc21be1f37cc21631ff3c6c1 /src
parent3205e0f1e8fde91948b082b3ee0fedfe13b23912 (diff)
Delete ogConfig.py
This file is only used for its OG_PATH variable, this variable is now in ogClient.
Diffstat (limited to 'src')
-rw-r--r--src/linux/ogOperations.py32
-rw-r--r--src/ogClient.py2
-rw-r--r--src/ogConfig.py34
3 files changed, 18 insertions, 50 deletions
diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py
index 88313ba..9a806af 100644
--- a/src/linux/ogOperations.py
+++ b/src/linux/ogOperations.py
@@ -9,7 +9,7 @@
import os
import json
import subprocess
-from src.ogConfig import *
+from src.ogClient import ogClient
OG_SHELL = '/bin/bash'
@@ -52,16 +52,16 @@ class OgLinuxOperations:
def poweroff(self):
if os.path.exists('/scripts/oginit'):
- cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
- f'{ogConfig.OG_PATH}scripts/poweroff'
+ cmd = f'source {ogClient.OG_PATH}etc/preinit/loadenviron.sh; ' \
+ f'{ogClient.OG_PATH}scripts/poweroff'
subprocess.call([cmd], shell=True, executable=OG_SHELL)
else:
subprocess.call(['/sbin/poweroff'])
def reboot(self):
if os.path.exists('/scripts/oginit'):
- cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
- f'{ogConfig.OG_PATH}scripts/reboot'
+ cmd = f'source {ogClient.OG_PATH}etc/preinit/loadenviron.sh; ' \
+ f'{ogClient.OG_PATH}scripts/reboot'
subprocess.call([cmd], shell=True, executable=OG_SHELL)
else:
subprocess.call(['/sbin/reboot'])
@@ -81,7 +81,7 @@ class OgLinuxOperations:
except:
raise ValueError('Error: Incorrect command value')
- cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
+ cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(self._url)
@@ -90,7 +90,7 @@ class OgLinuxOperations:
def session(self, request, ogRest):
disk = request.getDisk()
partition = request.getPartition()
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
try:
ogRest.proc = subprocess.Popen([cmd],
@@ -110,7 +110,7 @@ class OgLinuxOperations:
self._restartBrowser(self._url_log)
try:
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
f'{partition} {path}'
ogRest.proc = subprocess.Popen([cmd],
@@ -132,7 +132,7 @@ class OgLinuxOperations:
self._restartBrowser(self._url_log)
try:
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}'
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioHardware {path}'
ogRest.proc = subprocess.Popen([cmd],
stdout=subprocess.PIPE,
shell=True,
@@ -160,7 +160,7 @@ class OgLinuxOperations:
if ogRest.terminated:
break
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
try:
ogRest.proc = subprocess.Popen([cmd],
stdout=subprocess.PIPE,
@@ -170,7 +170,7 @@ class OgLinuxOperations:
except:
raise ValueError('Error: Incorrect command value')
- cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
+ cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(self._url)
@@ -184,7 +184,7 @@ class OgLinuxOperations:
ctype = request.getType()
profile = request.getProfile()
cid = request.getId()
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
f'{name} {repo} {ctype}'
self._restartBrowser(self._url_log)
@@ -198,7 +198,7 @@ class OgLinuxOperations:
except:
raise ValueError('Error: Incorrect command value')
- cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
+ cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
result = subprocess.check_output([cmd_get_conf], shell=True)
self._restartBrowser(self._url)
@@ -209,9 +209,9 @@ class OgLinuxOperations:
partition = request.getPartition()
name = request.getName()
repo = request.getRepo()
- cmd_software = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
+ cmd_software = f'{ogClient.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
f'{partition} {path}'
- cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
+ cmd_create_image = f'{ogClient.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
f'{partition} {name} {repo}'
self._restartBrowser(self._url_log)
@@ -245,7 +245,7 @@ class OgLinuxOperations:
self._restartBrowser(self._url_log)
try:
- cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
+ cmd = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
ogRest.proc = subprocess.Popen([cmd],
stdout=subprocess.PIPE,
shell=True,
diff --git a/src/ogClient.py b/src/ogClient.py
index 4c0a003..881fd81 100644
--- a/src/ogClient.py
+++ b/src/ogClient.py
@@ -24,6 +24,8 @@ class State(Enum):
FORCE_DISCONNECTED = 2
class ogClient:
+ OG_PATH = '/opt/opengnsys/'
+
def __init__(self, config):
self.CONFIG = config
diff --git a/src/ogConfig.py b/src/ogConfig.py
deleted file mode 100644
index d826835..0000000
--- a/src/ogConfig.py
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (C) 2020 Soleta Networks <info@soleta.eu>
-#
-# This program is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Affero General Public License as published by the
-# Free Software Foundation, version 3.
-#
-
-import configparser
-
-class ogConfig:
- OG_PATH = '/opt/opengnsys/'
-
- def __init__(self):
- self.parser = configparser.ConfigParser()
-
- def parser_file(self, path):
- self.parser.read(path)
- if len(self.parser.sections()) == 0:
- return False
-
- return True
-
- def get_sections(self):
- return self.parser.sections()
-
- def get_contains_section(self, section):
- return section in self.parser
-
- def get_value_section(self, section, key):
- if (not self.get_contains_section(section)):
- return ''
-
- return self.parser[section][key]