Commit 604b5108 authored by Rafael Monnerat's avatar Rafael Monnerat

Small styles changes.

parent 0e76f9ec
...@@ -13,7 +13,7 @@ class UnauthorizedError(Exception): ...@@ -13,7 +13,7 @@ class UnauthorizedError(Exception):
pass pass
def partitiondict2partition(partition): def partitiondict2partition(partition):
# XXX-Cedric : change function name, as it does no longer create a # XXX-Cedric : change function name, as it does no longer create a
# Partition instance, but rather create a dict ready to be sent in json # Partition instance, but rather create a dict ready to be sent in json
slap_partition = dict(computer_id = app.config['computer_id'], slap_partition = dict(computer_id = app.config['computer_id'],
computer_partition_id = partition['reference'], computer_partition_id = partition['reference'],
...@@ -70,7 +70,7 @@ def after_request(response): ...@@ -70,7 +70,7 @@ def after_request(response):
g.db.commit() g.db.commit()
g.db.close() g.db.close()
return response return response
@app.route('/<computer_id>', methods=['GET']) @app.route('/<computer_id>', methods=['GET'])
def getComputerInformation(computer_id): def getComputerInformation(computer_id):
"""Returns information about computer""" """Returns information about computer"""
...@@ -88,7 +88,7 @@ def getComputerInformation(computer_id): ...@@ -88,7 +88,7 @@ def getComputerInformation(computer_id):
else: else:
raise UnauthorizedError, "Only accept request for: %s" % \ raise UnauthorizedError, "Only accept request for: %s" % \
app.config['computer_id'] app.config['computer_id']
@app.route('/<computer_id>/partition/<computer_partition_id>', methods=['POST']) @app.route('/<computer_id>/partition/<computer_partition_id>', methods=['POST'])
def setComputerPartitionConnectionJson(computer_id, computer_partition_id): def setComputerPartitionConnectionJson(computer_id, computer_partition_id):
# XXX-Cedric : change connection_xml to connection_json in sql # XXX-Cedric : change connection_xml to connection_json in sql
...@@ -96,7 +96,7 @@ def setComputerPartitionConnectionJson(computer_id, computer_partition_id): ...@@ -96,7 +96,7 @@ def setComputerPartitionConnectionJson(computer_id, computer_partition_id):
argument_list = [request.json, computer_partition_id.encode()] argument_list = [request.json, computer_partition_id.encode()]
execute_db('partition', query, argument_list) execute_db('partition', query, argument_list)
return 'done' return 'done'
@app.route('/buildingSoftwareRelease', methods=['POST']) @app.route('/buildingSoftwareRelease', methods=['POST'])
def buildingSoftwareRelease(): def buildingSoftwareRelease():
return 'Ignored' return 'Ignored'
...@@ -206,7 +206,7 @@ def requestComputerPartition(partition_reference = ''): ...@@ -206,7 +206,7 @@ def requestComputerPartition(partition_reference = ''):
a(partition_id) a(partition_id)
if instance_json: if instance_json:
# XXX-Cedric : change xml to sjon in sql # XXX-Cedric : change xml to sjon in sql
q+= ' ,xml=?' q += ' ,xml=?'
a(instance_json) a(instance_json)
q += ' WHERE reference=?' q += ' WHERE reference=?'
a(partition['reference'].encode()) a(partition['reference'].encode())
...@@ -252,19 +252,17 @@ def loadComputerConfigurationFromXML(): ...@@ -252,19 +252,17 @@ def loadComputerConfigurationFromXML():
xml = request.form['xml'] xml = request.form['xml']
computer_dict = xml_marshaller.xml_marshaller.loads(str(xml)) computer_dict = xml_marshaller.xml_marshaller.loads(str(xml))
if app.config['computer_id'] == computer_dict['reference']: if app.config['computer_id'] == computer_dict['reference']:
args = []
a = args.append
execute_db('computer', 'INSERT OR REPLACE INTO %s values(:address, :netmask)', execute_db('computer', 'INSERT OR REPLACE INTO %s values(:address, :netmask)',
computer_dict) computer_dict)
for partition in computer_dict['partition_list']: for partition in computer_dict['partition_list']:
execute_db('partition', 'INSERT OR IGNORE INTO %s (reference) values(:reference)', partition) execute_db('partition', 'INSERT OR IGNORE INTO %s (reference) values(:reference)', partition)
execute_db('partition_network', 'DELETE FROM %s WHERE partition_reference = ?', [partition['reference']]) execute_db('partition_network', 'DELETE FROM %s WHERE partition_reference = ?', [partition['reference']])
for address in partition['address_list']: for address in partition['address_list']:
address['reference'] = partition['tap']['name'] address['reference'] = partition['tap']['name']
address['partition_reference'] = partition['reference'] address['partition_reference'] = partition['reference']
execute_db('partition_network', 'INSERT OR REPLACE INTO %s (reference, partition_reference, address, netmask) values(:reference, :partition_reference, :addr, :netmask)', address) execute_db('partition_network', 'INSERT OR REPLACE INTO %s (reference, partition_reference, address, netmask) values(:reference, :partition_reference, :addr, :netmask)', address)
return 'done' return 'done'
else: else:
raise UnauthorizedError, "Only accept request for: %s" % \ raise UnauthorizedError, "Only accept request for: %s" % \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment