Commit d2226d33 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

erp5_computer_immobilisation: Update Compute Node Schema and asJSON

parent fca3b4d1
......@@ -83,21 +83,18 @@ class Computer(Machine, JSONType):
)
for compute_partition in compute_partition_list:
ip_list = []
full_ip_list = []
for internet_protocol_address in compute_partition.contentValues(portal_type='Internet Protocol Address'):
# XXX - There is new values, and we must keep compatibility
address_tuple = (
internet_protocol_address.getNetworkInterface('').decode("UTF-8"),
internet_protocol_address.getIpAddress().decode("UTF-8"))
if internet_protocol_address.getGatewayIpAddress('') and \
internet_protocol_address.getNetmask(''):
address_tuple = address_tuple + (
internet_protocol_address.getGatewayIpAddress().decode("UTF-8"),
internet_protocol_address.getNetmask().decode("UTF-8"),
internet_protocol_address.getNetworkAddress('').decode("UTF-8"))
full_ip_list.append(address_tuple)
else:
ip_list.append(address_tuple)
ip_dict = {
"ip-address": internet_protocol_address.getIpAddress().decode("UTF-8"),
"network-interface": internet_protocol_address.getNetworkInterface('').decode("UTF-8"),
}
if internet_protocol_address.getGatewayIpAddress(''):
ip_dict["gateway-ip-address"] = internet_protocol_address.getGatewayIpAddress('').decode("UTF-8")
if internet_protocol_address.getNetmask(''):
ip_dict["netmask"] = internet_protocol_address.getNetmask('').decode("UTF-8")
if internet_protocol_address.getNetworkAddress(''):
ip_dict["network-address"] = internet_protocol_address.getNetworkAddress('').decode("UTF-8")
ip_list.append(ip_dict)
compute_node_dict["compute_partition_list"].append({
"partition_id": compute_partition.getReference(),
"ip_list": ip_list,
......
......@@ -90,15 +90,38 @@
"ip_list": {\n
"title": "IP List",\n
"type": "array",\n
"descritpion": "List of IPs usable by the Software Instance on the partition",\n
"descritpion": "List of IPs usable by the Software Instance on the partition. Used to configure firewall when necessary and allow only related instances to access it.",\n
"items": {\n
"type": "array",\n
"items": {\n
"type": "object",\n
"title": "Internet Protocol Address",\n
"description": "All element to describe the interface",\n
"properties": {\n
"ip-address": {\n
"title": "IP Address",\n
"type": "string"\n
},\n
"network-interface": {\n
"title": "Network Interface",\n
"type": "string"\n
},\n
"gateway-ip-address": {\n
"title": "Gateway Ip Address",\n
"type": "string"\n
},\n
"netmask": {\n
"title": "Netmask",\n
"type": "string"\n
},\n
"network-address": {\n
"title": "Network Address",\n
"type": "string"\n
}\n
},\n
"required": ["ip-address"]\n
}\n
}\n
}\n
},\n
"required": ["partition_id"]\n
}\n
},\n
"access_token": {\n
......
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