From b2fd0b5fffbd60e986eebc03c3a24f06194b4368 Mon Sep 17 00:00:00 2001 From: Alvaro Neira Ayuso Date: Thu, 16 Jan 2020 19:59:23 +0100 Subject: Add image/create command for creating a new image This patch allows us to use a new support for creating images using ogClient. ogClient receives from the server a message which json body must be: {"disk" : "1", "partition" : "1", "code" : "1", "id" : "1", "name" : "test", "repository" : "192.168.2.4" } ogClient returns to the server the software inventory executed before create the image. The message for the server is: { "disk" : "0", "partition" : "1", "software" : "xyz" } "xyz" will be the output saved during the execution of InventarioSoftware in a specific path. --- src/linux/ogOperations.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/linux') diff --git a/src/linux/ogOperations.py b/src/linux/ogOperations.py index 829af2f..1788b1a 100644 --- a/src/linux/ogOperations.py +++ b/src/linux/ogOperations.py @@ -118,3 +118,26 @@ def procirestore(httpparser, ogRest): raise ValueError('Error: Incorrect command value') return output.decode('utf-8') + +def procicreate(path, httpparser, ogRest): + disk = httpparser.getDisk() + partition = httpparser.getPartition() + name = httpparser.getName() + repo = httpparser.getRepo() + + try: + ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/InventarioSoftware', disk, partition, path], stdout=subprocess.PIPE, shell=True) + (output, error) = ogRest.proc.communicate() + except: + raise ValueError('Error: Incorrect command value') + + if ogRest.terminated: + return + + try: + ogRest.proc = subprocess.Popen([OG_PATH + 'interfaceAdm/CrearImagen', disk, partition, name, repo], stdout=subprocess.PIPE, shell=True) + ogRest.proc.communicate() + except: + raise ValueError('Error: Incorrect command value') + + return output.decode('utf-8') -- cgit v1.2.3-18-g5258