mirror of https://git.48k.eu/ogclient
Add setup command for configuring the machine
ogAdmClient has a support to configure the machines. This new command allows the new ogClient to execute the same script to configure the machine. The json format sent from the server must be: { "disk" : "1", "cache" : "0", "cache_size" : "70000000",\ "partition_setup": [{"partition": "1", "code": "NTFS", "filesystem": "NTFS",\ "size": "11000000", "format": "0"}]}more_events
parent
9fd8f2dbd0
commit
efbe8a7960
|
@ -15,6 +15,9 @@ class HTTPParser:
|
|||
self.cmd = None
|
||||
self.partition = None
|
||||
self.disk = None
|
||||
self.cache = None
|
||||
self.cache_size = None
|
||||
self.partition_setup = None
|
||||
|
||||
def parser(self,data):
|
||||
self.requestLine, self.headersAlone = data.split('\n', 1)
|
||||
|
@ -49,7 +52,17 @@ class HTTPParser:
|
|||
self.disk = jsoncmd["disk"]
|
||||
|
||||
if "partition" in cmd:
|
||||
self.partition = jsoncmd["partition"]
|
||||
if not "partition_setup" in cmd:
|
||||
self.partition = jsoncmd["partition"]
|
||||
|
||||
if "cache" in cmd:
|
||||
self.cache = jsoncmd["cache"]
|
||||
|
||||
if "cache_size" in cmd:
|
||||
self.cache_size = jsoncmd["cache_size"]
|
||||
|
||||
if "partition_setup" in cmd:
|
||||
self.partition_setup = jsoncmd["partition_setup"]
|
||||
|
||||
def getHeaderLine(self):
|
||||
return self.headersAlone
|
||||
|
@ -83,3 +96,12 @@ class HTTPParser:
|
|||
|
||||
def getPartition(self):
|
||||
return self.partition
|
||||
|
||||
def getCache(self):
|
||||
return self.cache
|
||||
|
||||
def getCacheSize(self):
|
||||
return self.cache_size
|
||||
|
||||
def getPartitionSetup(self):
|
||||
return self.partition_setup
|
||||
|
|
|
@ -35,3 +35,8 @@ def procsoftware(disk, partition, path):
|
|||
def prochardware(path):
|
||||
result = subprocess.check_output([OG_PATH + 'interfaceAdm/InventarioHardware', path], shell=True)
|
||||
return result.decode('utf-8')
|
||||
|
||||
def procsetup(disk, cache, cachesize, partlist):
|
||||
for part in partlist:
|
||||
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!par=' + part["partition"] + '*cpt='+part["code"] + '*sfi=' + part['filesystem'] + '*tam=' + part['size'] + '*ope=' + part['format'] + '%'
|
||||
subprocess.check_output([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], shell=True)
|
||||
|
|
|
@ -50,6 +50,10 @@ class ogThread():
|
|||
msgqueue.queue.clear()
|
||||
msgqueue.put(ogOperations.prochardware(path))
|
||||
|
||||
# Process setup
|
||||
def procsetup(msgqueue, disk, cache, cachesize, partlist):
|
||||
ogOperations.procsetup(disk, cache, cachesize, partlist)
|
||||
|
||||
class ogResponses(Enum):
|
||||
BAD_REQUEST=0
|
||||
IN_PROGRESS=1
|
||||
|
@ -103,6 +107,8 @@ class ogRest():
|
|||
self.process_session(client, httpparser.getDisk(), httpparser.getPartition())
|
||||
elif ("software" in URI):
|
||||
self.process_software(client, httpparser.getDisk(), httpparser.getPartition())
|
||||
elif ("setup" in URI):
|
||||
self.process_setup(client, httpparser.getDisk(), httpparser.getCache(), httpparser.getCacheSize(), httpparser.getPartitionSetup())
|
||||
else:
|
||||
client.send(self.getResponse(ogResponses.BAD_REQUEST))
|
||||
else:
|
||||
|
@ -162,3 +168,7 @@ class ogRest():
|
|||
|
||||
def process_schedule(self, client):
|
||||
client.send(self.getResponse(ogResponses.OK))
|
||||
|
||||
def process_setup(self, client, disk, cache, cachesize, partlist):
|
||||
threading.Thread(target=ogThread.procsetup, args=(self.msgqueue, disk, cache, cachesize, partlist,)).start()
|
||||
client.send(self.getResponse(ogResponses.OK))
|
||||
|
|
Loading…
Reference in New Issue