Add/update references to routers.
355631
def add_router_references(self, snet, address, dnets):
        """"""
        if _debug: NetworkServiceAccessPoint._debug("add_router_references %r %r %r", snet, address, dnets)

        # see if we have an adapter for the snet
        if snet not in self.adapters:
            raise RuntimeError("no adapter for network: %d" % (snet,))

        # pass this along to the cache
        self.router_info_cache.update_router_info(snet, address, dnets)
616846
def update(self):
        """"""

        if self.device_time_check():

            if not self.in_process:
                outlets, switches, fans = self.get_devices()

                self.outlets = helpers.resolve_updates(self.outlets, outlets)
                self.switches = helpers.resolve_updates(
                    self.switches, switches)
                self.fans = helpers.resolve_updates(self.fans, fans)

                self.last_update_ts = time.time()
1259029
def update(cls, domain, source, dest_add, dest_del):
        """"""
        result = None

        if dest_add or dest_del:
            current_destinations = cls.get_destinations(domain, source)
            fwds = current_destinations[:]
            if dest_add:
                for dest in dest_add:
                    if dest not in fwds:
                        fwds.append(dest)
            if dest_del:
                for dest in dest_del:
                    if dest in fwds:
                        fwds.remove(dest)

            if ((len(current_destinations) != len(fwds))
                    or (current_destinations != fwds)):
                cls.echo('Updating mail forward %s@%s' % (source, domain))
                options = {'destinations': fwds}
                result = cls.call('domain.forward.update', domain, source,
                                  options)

        return result
845593
def update_ports(self) -> None:
        """"""
        self.update(path=URL_GET + GROUP.format(group=INPUT))
        self.update(path=URL_GET + GROUP.format(group=IOPORT))
        self.update(path=URL_GET + GROUP.format(group=OUTPUT))
1154375
def add_routes(self, routes: Iterable[AbstractRouteDef]) -> None:
        
        for route_def in routes:
            route_def.register(self)
457706
def add(self, *args, **kargs):
        
        self.invalidate_cache()
        self.routes.append(self.make_route(*args, **kargs))
1340778
def merge(database=None, directory=None, verbose=None):
    """"""
    router = get_router(directory, database, verbose)
    router.merge()
1247716
def update_attributes(self, **kwargs):
        """"""
        attrs = self.attributes.values() + self.lists.values() \
                + self.references.values()
        for att in attrs:
            if att.name in kwargs:
                att.__set__(self, kwargs[att.name])
329050
def add_interface_router(self, router, subnet):
        '''
        
        '''
        router_id = self._find_router_id(router)
        subnet_id = self._find_subnet_id(subnet)
        return self.network_conn.add_interface_router(
            router=router_id, body={'subnet_id': subnet_id})
622997
def _update_servers(self):
        
        for address, sd in self._description.server_descriptions().items():
            if address not in self._servers:
                monitor = self._settings.monitor_class(
                    server_description=sd,
                    topology=self,
                    pool=self._create_pool_for_monitor(address),
                    topology_settings=self._settings)

                weak = None
                if self._publish_server:
                    weak = weakref.ref(self._events)
                server = Server(
                    server_description=sd,
                    pool=self._create_pool_for_server(address),
                    monitor=monitor,
                    topology_id=self._topology_id,
                    listeners=self._listeners,
                    events=weak)

                self._servers[address] = server
                server.open()
            else:
                self._servers[address].description = sd

        for address, server in list(self._servers.items()):
            if not self._description.has_server(address):
                server.close()
                self._servers.pop(address)
509383
def prepare_network(self):
        """"""
        hydpy.pub.selections = selectiontools.Selections()
        hydpy.pub.selections += hydpy.pub.networkmanager.load_files()
        self.update_devices(hydpy.pub.selections.complete)
324243
def setup_router(self, args, kwargs, **fkwargs):
        
        self._ready = self._setup_router(args=args, kwargs=kwargs, **fkwargs)

        return self._ready
272989
def _add_redundancy_routers(self, context, start_index, stop_index,
                                user_visible_router, ports=None,
                                ha_settings_db=None, create_ha_group=True):
        
        priority = (DEFAULT_MASTER_PRIORITY +
                    (start_index - 1) * PRIORITY_INCREASE_STEP)
        r = copy.deepcopy(user_visible_router)
        # No tenant_id so redundancy routers are hidden from user
        r['tenant_id'] = ''
        name = r['name']
        redundancy_r_ids = []
        for i in range(start_index, stop_index):
            del r['id']
            # We don't replicate the user visible router's routes, instead
            # they are populated to redundancy routers for get router(s) ops
            r.pop('routes', None)
            # Redundancy routers will never have a route spec themselves
            # The redundancy routers must have HA disabled
            r[ha.ENABLED] = False
            r['name'] = name + REDUNDANCY_ROUTER_SUFFIX + str(i)
            # set role so that purpose of this router can be easily determined
            r[routerrole.ROUTER_ROLE_ATTR] = ROUTER_ROLE_HA_REDUNDANCY
            gw_info = r[EXTERNAL_GW_INFO]
            if gw_info and gw_info['external_fixed_ips']:
                # Ensure ip addresses are not specified as they cannot be
                # same as visible router's ip addresses.
                for e_fixed_ip in gw_info['external_fixed_ips']:
                    e_fixed_ip.pop('ip_address', None)
            r = self.create_router(context, {'router': r})
            LOG.debug("Created redundancy router %(index)d with router id "
                      "%(r_id)s", {'index': i, 'r_id': r['id']})
            priority += PRIORITY_INCREASE_STEP
            r_b_b = RouterRedundancyBinding(
                redundancy_router_id=r['id'],
                priority=priority,
                user_router_id=user_visible_router['id'])
            context.session.add(r_b_b)
            redundancy_r_ids.append(r['id'])
        for port_db in ports or []:
            port = self._core_plugin._make_port_dict(port_db)
            self._add_redundancy_router_interfaces(
                context, user_visible_router, None, port,
                redundancy_r_ids, ha_settings_db, create_ha_group)
799784
def route_add_loopback(routes=None, ipv6=False, iflist=None):
    """"""
    if not WINDOWS:
        warning("Not available")
        return
    warning("This will completely mess up the routes. Testing purpose only !")
    # Add only if some adpaters already exist
    if ipv6:
        if not conf.route6.routes:
            return
    else:
        if not conf.route.routes:
            return
    data = {
        'name': scapy.consts.LOOPBACK_NAME,
        'description': "Loopback",
        'win_index': -1,
        'guid': "{0XX00000-X000-0X0X-X00X-00XXXX000XXX}",
        'invalid': True,
        'mac': '00:00:00:00:00:00',
        'ipv4_metric': 0,
        'ipv6_metric': 0,
        'ips': ["127.0.0.1", "::"]
    }
    adapter = NetworkInterface()
    adapter.pcap_name = "\\Device\\NPF_{0XX00000-X000-0X0X-X00X-00XXXX000XXX}"
    adapter.update(data)
    adapter.invalid = False
    adapter.ip = "127.0.0.1"
    if iflist:
        iflist.append(adapter.pcap_name)
        return
    # Remove all LOOPBACK_NAME routes
    for route in list(conf.route.routes):
        iface = route[3]
        if iface.name == scapy.consts.LOOPBACK_NAME:
            conf.route.routes.remove(route)
    # Remove LOOPBACK_NAME interface
    for devname, iface in list(IFACES.items()):
        if iface.name == scapy.consts.LOOPBACK_NAME:
            IFACES.pop(devname)
    # Inject interface
    IFACES["{0XX00000-X000-0X0X-X00X-00XXXX000XXX}"] = adapter
    scapy.consts.LOOPBACK_INTERFACE = adapter
    if isinstance(conf.iface, NetworkInterface):
        if conf.iface.name == scapy.consts.LOOPBACK_NAME:
            conf.iface = adapter
    if isinstance(conf.iface6, NetworkInterface):
        if conf.iface6.name == scapy.consts.LOOPBACK_NAME:
            conf.iface6 = adapter
    conf.netcache.arp_cache["127.0.0.1"] = "ff:ff:ff:ff:ff:ff"
    conf.netcache.in6_neighbor["::1"] = "ff:ff:ff:ff:ff:ff"
    # Build the packed network addresses
    loop_net = struct.unpack("!I", socket.inet_aton("127.0.0.0"))[0]
    loop_mask = struct.unpack("!I", socket.inet_aton("255.0.0.0"))[0]
    # Build the fake routes
    loopback_route = (loop_net, loop_mask, "0.0.0.0", adapter, "127.0.0.1", 1)
    loopback_route6 = ('::1', 128, '::', adapter, ["::1"], 1)
    loopback_route6_custom = ("fe80::", 128, "::", adapter, ["::1"], 1)
    if routes is None:
        # Injection
        conf.route6.routes.append(loopback_route6)
        conf.route6.routes.append(loopback_route6_custom)
        conf.route.routes.append(loopback_route)
        # Flush the caches
        conf.route6.invalidate_cache()
        conf.route.invalidate_cache()
    else:
        if ipv6:
            routes.append(loopback_route6)
            routes.append(loopback_route6_custom)
        else:
            routes.append(loopback_route)
1261696
def updateNetwork(self,
                      dhcp='dhcp',
                      ipaddress=None,
                      netmask=None,
                      gateway=None,
                      dns=None):
        """"""
        return self.__post('/api/updateNetwork',
                           data={
                               'dhcp': dhcp,
                               'ipaddress': ipaddress,
                               'netmask': netmask,
                               'gateway': gateway,
                               'dns': json.dumps(dns)
                           })
535940
def update(self, *args, **kwargs):
        """"""
        for system in self.systems:
            system.update(self, *args, **kwargs)
1343502
def update_router(self, router, name=None, admin_state_up=None, **kwargs):
        '''
        
        '''
        router_id = self._find_router_id(router)
        body = {}

        if 'ext_network' in kwargs:
            if kwargs.get('ext_network') is None:
                body['external_gateway_info'] = None
            else:
                net_id = self._find_network_id(kwargs.get('ext_network'))
                body['external_gateway_info'] = {'network_id': net_id}
        if name is not None:
            body['name'] = name
        if admin_state_up is not None:
            body['admin_state_up'] = admin_state_up
        return self.network_conn.update_router(
            router=router_id, body={'router': body})