<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string>def compareAndUpdateAddressList(document, address_list, additional_dict=None):\n
  if additional_dict is None:\n
    additional_dict = {}\n
  to_delete_ip_id_list = []\n
  to_add_ip_dict_list = address_list[:]\n
  for address in document.contentValues(portal_type=\'Internet Protocol Address\'):\n
    current_dict = {\n
      \'addr\': address.getIpAddress(),\n
      \'netmask\': address.getNetmask()\n
    }\n
    if not current_dict in to_add_ip_dict_list:\n
      to_delete_ip_id_list.append(address.getId())\n
    else:\n
      to_add_ip_dict_list.remove(current_dict)\n
  \n
  for address in to_add_ip_dict_list:\n
    if to_delete_ip_id_list:\n
      id = to_delete_ip_id_list.pop()\n
      address_document = getattr(document, id)\n
    else:\n
      kw = {\'portal_type\': \'Internet Protocol Address\'}\n
      if len(document.objectIds(portal_type=\'Internet Protocol Address\')):\n
        kw.update(id=\'default_network_address\')\n
      address_document = document.newContent(**kw)\n
    address_document.edit(\n
      ip_address=address[\'addr\'],\n
      netmask=address[\'netmask\'],\n
      **additional_dict\n
    )\n
  if to_delete_ip_id_list:\n
    document.deleteContent(to_delete_ip_id_list)\n
\n
\n
# Getting existing partitions\n
existing_partition_dict = {}\n
for c in context.contentValues():\n
  existing_partition_dict[c.getReference()] = c\n
\n
# update computer data\n
context.edit(\n
  quantity = len(computer_dict[\'partition_list\']),\n
)\n
\n
compareAndUpdateAddressList(context, [{\'addr\': computer_dict[\'address\'], \'netmask\': computer_dict[\'netmask\']}])\n
for send_partition in computer_dict[\'partition_list\']:\n
  partition = existing_partition_dict.get(send_partition[\'reference\'], None)\n
  if partition is None:\n
    partition = context.newContent(portal_type=\'Computer Partition\')\n
    partition.validate()\n
    partition.markFree()\n
  partition.edit(reference=send_partition[\'reference\'])\n
  network_interface = send_partition[\'tap\'][\'name\']\n
  compareAndUpdateAddressList(partition, send_partition[\'address_list\'], {\'network_interface\': network_interface})\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>computer_dict</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Computer_updateFromDict</string> </value>
        </item>
        <item>
            <key> <string>title</string> </key>
            <value> <string></string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
