Ejemplo n.º 1
0
 def walk_phynetset(key,value,walk,save):
     for weak_phynet in value.set.dataset():
         try:
             phynetobj = walk(weak_phynet.getkey())
         except KeyError:
             pass
         else:
             phynetmapkey = PhysicalNetworkMap.default_key(phynetobj.id)
             try:
                 phynetmapobj = walk(phynetmapkey)
             except KeyError:
                 pass
             else:
                 save(phynetmapobj.getkey())
                 saved_phymap_keys.append(phynetmapobj.getkey())
                 saved_physicalnetworkmap_to_logicalnetwork[phynetmapobj.getkey()] = []
                 for lgnet in phynetmapobj.logicnetworks.dataset():
                     try:
                         lgnetobj = walk(lgnet.getkey())
                     except KeyError:
                         pass
                     else:
                         if not lgnetobj:
                             save(lgnet.getkey())
                             saved_lgnet_keys.append(lgnet.getkey())
                             saved_physicalnetworkmap_to_logicalnetwork[phynetmapobj.getkey()]\
                                 .append(lgnet.getkey())
Ejemplo n.º 2
0
 def walker(walk, write, timestamp, parameters_dict):
     for key, parameters in reorder_dict(parameters_dict):
         try:
             value = walk(key)
         except KeyError:
             pass
         else:
             id_ = parameters['id']
             try:
                 phy_map = walk(PhysicalNetworkMap.default_key(id_))
             except KeyError:
                 pass
             else:
                 check_processor(value,
                                 phy_map,
                                 walk,
                                 write,
                                 parameters=parameters)
                 write(phy_map.getkey(), None)
             try:
                 phynetset = walk(PhysicalNetworkSet.default_key())
             except KeyError:
                 pass
             else:
                 phynetset.set.dataset().discard(
                     value.create_weakreference())
                 write(phynetset.getkey(), phynetset)
             write(key, None)
Ejemplo n.º 3
0
    def walker(walk, write, timestamp, parameters_dict):
        for key, parameters in reorder_dict(parameters_dict):
            try:
                value = walk(key)
            except KeyError:
                pass
            else:
                id_ = parameters['id']
                new_network = create_new(PhysicalNetwork, value, id_)
                new_network.type = type

                create_processor(new_network,
                                 walk,
                                 write,
                                 parameters=parameters)
                write(key, new_network)
                new_networkmap = PhysicalNetworkMap.create_instance(id_)
                new_networkmap.network = new_network.create_weakreference()
                write(new_networkmap.getkey(), new_networkmap)

                # Save into network set
                try:
                    physet = walk(PhysicalNetworkSet.default_key())
                except KeyError:
                    pass
                else:
                    physet.set.dataset().add(
                        new_network.create_weakreference())
                    write(physet.getkey(), physet)
Ejemplo n.º 4
0
 def walk_phynetset(key, value, walk, save):
     for weak_phynet in value.set.dataset():
         try:
             phynetobj = walk(weak_phynet.getkey())
         except KeyError:
             pass
         else:
             phynetmapkey = PhysicalNetworkMap.default_key(phynetobj.id)
             try:
                 phynetmapobj = walk(phynetmapkey)
             except KeyError:
                 pass
             else:
                 save(phynetmapobj.getkey())
                 saved_phymap_keys.append(phynetmapobj.getkey())
                 saved_physicalnetworkmap_to_logicalnetwork[
                     phynetmapobj.getkey()] = []
                 for lgnet in phynetmapobj.logicnetworks.dataset():
                     try:
                         lgnetobj = walk(lgnet.getkey())
                     except KeyError:
                         pass
                     else:
                         if not lgnetobj:
                             save(lgnet.getkey())
                             saved_lgnet_keys.append(lgnet.getkey())
                             saved_physicalnetworkmap_to_logicalnetwork[phynetmapobj.getkey()]\
                                 .append(lgnet.getkey())
Ejemplo n.º 5
0
 def update_physicalnetwork_processor(physicalnetwork, walk, write, *, parameters):
     if 'vnirange' in parameters:
         _check_vnirange(parameters['vnirange'])
         try:
             phymap = walk(PhysicalNetworkMap.default_key(physicalnetwork.id))
         except WalkKeyNotRetrieved:
             pass
         else:
             _check_vnirange_allocation(parameters['vnirange'], phymap.network_allocation)
     return default_processor(physicalnetwork, parameters=parameters, disabled=('type',))
Ejemplo n.º 6
0
 def walk_phynetset(key,value,walk,save):
     del saved_lgnet_keys[:]
     del saved_phymap_keys[:]
     saved_physicalnetworkmap_to_logicalnetwork.clear()
     for weak_phynet in value.set.dataset():
         with suppress(WalkKeyNotRetrieved):
             phynetobj = walk(weak_phynet.getkey())
             phynetmapkey = PhysicalNetworkMap.default_key(phynetobj.id)
             phynetmapobj = walk(phynetmapkey)
             save(phynetmapobj.getkey())
             saved_phymap_keys.append(phynetmapobj.getkey())
             saved_physicalnetworkmap_to_logicalnetwork[phynetmapobj.getkey()] = []
             for lgnet in phynetmapobj.logicnetworks.dataset():
                 with suppress(WalkKeyNotRetrieved):
                     lgnetobj = walk(lgnet.getkey())
                     if not lgnetobj:
                         save(lgnet.getkey())
                         saved_lgnet_keys.append(lgnet.getkey())
                         saved_physicalnetworkmap_to_logicalnetwork[phynetmapobj.getkey()]\
                             .append(lgnet.getkey())
Ejemplo n.º 7
0
 def update_physicalnetwork_keys(id_, parameters):
     if 'vlanrange' in parameters:
         return (PhysicalNetworkMap.default_key(id_), )
     else:
         return ()
Ejemplo n.º 8
0
 def update_logicalnetwork_keys(id_, parameters):
     if 'vlanid' in parameters:
         return (PhysicalNetwork.default_key(id_),
                 PhysicalNetworkMap.default_key(id_))
     else:
         return ()
Ejemplo n.º 9
0
def default_physicalnetwork_update_keys(id_, parameters):
    return (PhysicalNetworkMap.default_key(id_), )
Ejemplo n.º 10
0
def default_physicalnetwork_keys(id_, parameters):
    return (PhysicalNetworkMap.default_key(id_),
            PhysicalNetworkSet.default_key())
Ejemplo n.º 11
0
def default_logicalnetwork_keys(phynet_id, parameters):
    return (PhysicalNetwork.default_key(phynet_id),
            PhysicalNetworkMap.default_key(phynet_id),
            LogicalNetworkSet.default_key(),
            LogicalNetworkMap.default_key(parameters['id']))
Ejemplo n.º 12
0
def default_physicalport_keys(phynet_id, parameters):
    return (PhysicalNetwork.default_key(phynet_id),
            PhysicalNetworkMap.default_key(phynet_id),
            PhysicalPortSet.default_key())