mirror of https://git.48k.eu/ogclient
Improve setup command response
This patch adds a new response support. This way allows us to send a new response message with more information about the partitions already set up. The format of the response is: { "disk" : "1", "cache" : "1", "cache_size" : "0", "partition_setup": [{"partition": "1", "code": "LINUX", "filesystem": "EMPTY", "size": "498688", "format": "0"}...]more_events
parent
a306b8b9d8
commit
38b57c4ae4
|
@ -60,10 +60,31 @@ def procsetup(httpparser):
|
||||||
cache = httpparser.getCache()
|
cache = httpparser.getCache()
|
||||||
cachesize = httpparser.getCacheSize()
|
cachesize = httpparser.getCacheSize()
|
||||||
partlist = httpparser.getPartitionSetup()
|
partlist = httpparser.getPartitionSetup()
|
||||||
|
listConfigs = []
|
||||||
|
|
||||||
for part in partlist:
|
for part in partlist:
|
||||||
|
i = 0
|
||||||
|
json = {}
|
||||||
cfg = 'dis=' + disk + '*che=' + cache + '*tch=' + cachesize + '!par=' + part["partition"] + '*cpt='+part["code"] + '*sfi=' + part['filesystem'] + '*tam=' + part['size'] + '*ope=' + part['format'] + '%'
|
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)
|
try:
|
||||||
|
subprocess.check_output([OG_PATH + 'interfaceAdm/Configurar', disk, cfg], shell=True)
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
|
result = subprocess.check_output([OG_PATH + 'interfaceAdm/getConfiguration'], shell=True)
|
||||||
|
val = result.decode('utf-8').rstrip().split('\t')
|
||||||
|
while i < len(val):
|
||||||
|
val[i] = val[i].split('=')[1]
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
json['partition'] = val[1]
|
||||||
|
json['code'] = val[4]
|
||||||
|
json['filesystem'] = val[2]
|
||||||
|
json['size'] = val[5]
|
||||||
|
json['format'] = val[6]
|
||||||
|
listConfigs.append(json)
|
||||||
|
|
||||||
|
return listConfigs
|
||||||
|
|
||||||
def procirestore(httpparser):
|
def procirestore(httpparser):
|
||||||
disk = httpparser.getDisk()
|
disk = httpparser.getDisk()
|
||||||
|
|
|
@ -102,8 +102,14 @@ class ogThread():
|
||||||
client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
|
client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
|
||||||
|
|
||||||
# Process setup
|
# Process setup
|
||||||
def procsetup(msgqueue, httpparser):
|
def procsetup(client, httpparser):
|
||||||
ogOperations.procsetup(httpparser)
|
jsonResp = jsonResponse()
|
||||||
|
jsonResp.addElement('disk', httpparser.getDisk())
|
||||||
|
jsonResp.addElement('cache', httpparser.getCache())
|
||||||
|
jsonResp.addElement('cache_size', httpparser.getCacheSize())
|
||||||
|
listconfig = ogOperations.procsetup(httpparser)
|
||||||
|
jsonResp.addElement('partition_setup', listconfig)
|
||||||
|
client.send(restResponse.getResponse(ogResponses.OK, jsonResp))
|
||||||
|
|
||||||
# Process image restore
|
# Process image restore
|
||||||
def procirestore(httpparser):
|
def procirestore(httpparser):
|
||||||
|
@ -212,8 +218,7 @@ class ogRest():
|
||||||
client.send(restResponse.getResponse(ogResponses.OK))
|
client.send(restResponse.getResponse(ogResponses.OK))
|
||||||
|
|
||||||
def process_setup(self, client, httpparser):
|
def process_setup(self, client, httpparser):
|
||||||
threading.Thread(target=ogThread.procsetup, args=(self.msgqueue, httpparser,)).start()
|
threading.Thread(target=ogThread.procsetup, args=(client, httpparser,)).start()
|
||||||
client.send(restResponse.getResponse(ogResponses.OK))
|
|
||||||
|
|
||||||
def process_irestore(self, client, httpparser):
|
def process_irestore(self, client, httpparser):
|
||||||
threading.Thread(target=ogThread.procirestore, args=(client, httpparser,)).start()
|
threading.Thread(target=ogThread.procirestore, args=(client, httpparser,)).start()
|
||||||
|
|
Loading…
Reference in New Issue