Commit e3a9b439 authored by Łukasz Nowak's avatar Łukasz Nowak

- simplify logic

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41376 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4c5e632f
...@@ -51,52 +51,26 @@ ...@@ -51,52 +51,26 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string># Getting existing partitions\n <value> <string># Getting existing partitions\n
computer_partition_list = context.contentValues()\n existing_partition_dict = {}\n
\n for c in context.contentValues():\n
# List of the partitions already treated\n existing_partition_dict[c.getReference()] = c\n
treated_partition_list = []\n
\n \n
# update computer data\n
context.edit(\n context.edit(\n
default_network_address_ip_address = computer_dict[\'address\'],\n default_network_address_ip_address = computer_dict[\'address\'],\n
default_network_address_netmask = computer_dict[\'netmask\'],\n default_network_address_netmask = computer_dict[\'netmask\'],\n
quantity = len(computer_dict[\'partition_list\']),\n quantity = len(computer_dict[\'partition_list\']),\n
)\n )\n
\n \n
# Searching through existing partitions and updating them\n for send_partition in computer_dict[\'partition_list\']:\n
for partition in computer_partition_list:\n partition = existing_partition_dict.get(send_partition[\'reference\'], None)\n
for partition_dict in computer_dict[\'partition_list\']:\n if partition is None:\n
\n partition = context.newContent(portal_type=\'Computer Partition\')\n
if partition_dict[\'reference\'] == partition.getReference():\n partition.markFree()\n
partition.edit(\n partition.edit(default_network_address_ip_address = send_partition[\'addr\'],\n
default_network_address_ip_address = partition_dict[\'addr\'],\n default_network_address_netmask = send_partition[\'netmask\'],)\n
default_network_address_netmask = partition_dict[\'netmask\'],\n partition.getDefaultNetworkAddressValue().edit(\n
)\n network_interface = send_partition[\'tap\'][\'name\'])\n
\n
partition.getDefaultNetworkAddressValue().edit(network_interface = partition_dict[\'tap\'][\'name\'])\n
\n
# Adding the treated partition to the list\n
computer_dict[\'partition_list\'].remove(partition_dict)\n
\n
treated_partition_list.append(partition)\n
\n
# Adding remaining partition listed in the dict to the computer object\n
for partition_dict in computer_dict[\'partition_list\']:\n
partition = context.newContent(\n
portal_type = "Computer Partition",\n
reference = partition_dict[\'reference\'],\n
default_network_address_ip_address = partition_dict[\'addr\'],\n
)\n
partition.getDefaultNetworkAddressValue().edit(network_interface = partition_dict[\'tap\'][\'name\'])\n
\n
partition.markFree()\n
treated_partition_list.append(partition)\n
\n
for partition in computer_partition_list:\n
if partition not in treated_partition_list:\n
# Do something to disable the partition\n
break\n
\n
return True\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -140,16 +114,17 @@ return True\n ...@@ -140,16 +114,17 @@ return True\n
<value> <value>
<tuple> <tuple>
<string>computer_dict</string> <string>computer_dict</string>
<string>existing_partition_dict</string>
<string>_getiter_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>computer_partition_list</string> <string>c</string>
<string>treated_partition_list</string> <string>_write_</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>len</string> <string>len</string>
<string>_getiter_</string> <string>send_partition</string>
<string>None</string>
<string>partition</string> <string>partition</string>
<string>partition_dict</string>
<string>True</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
299 301
\ No newline at end of file \ No newline at end of file
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