Add a (non-hosted) router to a hosting device.
979159
def add_router_to_hosting_device(self, context, hosting_device_id,
                                     router_id):
        """"""
        e_context = context.elevated()
        r_hd_binding_db = self._get_router_binding_info(e_context, router_id)
        if r_hd_binding_db.hosting_device_id:
            if r_hd_binding_db.hosting_device_id == hosting_device_id:
                return
            raise routertypeawarescheduler.RouterHostedByHostingDevice(
                router_id=router_id, hosting_device_id=hosting_device_id)
        rt_info = self.validate_hosting_device_router_combination(
            context, r_hd_binding_db, hosting_device_id)
        result = self.schedule_router_on_hosting_device(
            e_context, r_hd_binding_db, hosting_device_id,
            rt_info['slot_need'])
        if result:
            # refresh so that we get latest contents from DB
            e_context.session.expire(r_hd_binding_db)
            router = self.get_router(e_context, router_id)
            self.add_type_and_hosting_device_info(
                e_context, router, r_hd_binding_db, schedule=False)
            l3_cfg_notifier = self.agent_notifiers.get(AGENT_TYPE_L3_CFG)
            if l3_cfg_notifier:
                l3_cfg_notifier.router_added_to_hosting_device(context, router)
        else:
            raise routertypeawarescheduler.RouterSchedulingFailed(
                router_id=router_id, hosting_device_id=hosting_device_id)
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)
541321
def connect(self, host, port):
        """"""
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((host, port))
        self._reader = sock.makefile(mode='rb')
        self._writer = sock.makefile(mode='wb')
1293371
def add_airplay_service(self, info, address):
        """"""
        name = info.name.replace('._airplay._tcp.local.', '')
        self._handle_service(address, name, conf.AirPlayService(info.port))
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})
815671
def connect(self, addr):
        """"""
        if _debug: RouterToRouterService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(ROUTER_TO_ROUTER_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
497847
def add_handlers(self, host_pattern: str, host_handlers: _RuleList) -> None:
        
        host_matcher = HostMatches(host_pattern)
        rule = Rule(host_matcher, _ApplicationRouter(self, host_handlers))

        self.default_router.rules.insert(-1, rule)

        if self.default_host is not None:
            self.wildcard_router.add_rules(
                [(DefaultHostMatches(self, host_matcher.host_pattern), host_handlers)]
            )
1204791
def create(name, database=None, auto=False, auto_source=False, directory=None, verbose=None):
    """"""
    router = get_router(directory, database, verbose)
    if auto and auto_source:
        auto = auto_source
    router.create(name, auto=auto)
435698
def add(name, address)
      device = Device.new(name: name, address: address)
      self << device
      device
    end
316847
def AddForwardedIp(self, address, interface):
    
    address = address if IP_ALIAS_REGEX.match(address) else '%s/32' % address
    args = ['add', 'to', 'local', address]
    options = self._CreateRouteOptions(dev=interface)
    self._RunIpRoute(args=args, options=options)
1139482
def nginx(ctx, hostname):
    """"""

    install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname)
112005
def add_ipv4addr(self, ipv4addr):
        
        for addr in self.ipv4addrs:
            if ((isinstance(addr, dict) and addr['ipv4addr'] == ipv4addr) or
                (isinstance(addr, HostIPv4) and addr.ipv4addr == ipv4addr)):
                raise ValueError('Already exists')
        self.ipv4addrs.append({'ipv4addr': ipv4addr})
788743
def add_gateway_router(self, router, body=None):
        """"""
        return self.put((self.router_path % router),
                        body={'router': {'external_gateway_info': body}})
1138373
function addSiteController(router, site, providers) {
  if (site.dir) {
    const controller = files.tryRequire(site.dir);

    if (controller) {
      if (Array.isArray(controller.middleware)) {
        router.use(controller.middleware);
      }

      if (Array.isArray(controller.routes)) {
        attachRoutes(router, controller.routes, site);
      } else {
        log('warn', `There is no router for site: ${site.slug}`);
      }

      // Providers are the same across all sites, but this is a convenient
      // place to store it so that it's available everywhere
      _.set(site, 'providers', providers);
      // things to remember from controller
      _.assign(site, _.pick(controller, 'resolvePublishing'));
      _.assign(site, _.pick(controller, 'resolvePublishUrl'));
      _.assign(site, _.pick(controller, 'modifyPublishedData'));
    }
  }

  return router;
}
722782
def routers_removed_from_hosting_device(self, context, router_ids,
                                            hosting_device):
        
        self._agent_notification_bulk(
            context, 'router_removed_from_hosting_device', router_ids,
            hosting_device, operation=None)
68881
def _add(self, hostport):
        """"""
        peer = self.peer_class(
            tchannel=self.tchannel,
            hostport=hostport,
            on_conn_change=self._update_heap,
        )
        peer.rank = self.rank_calculator.get_rank(peer)
        self._peers[peer.hostport] = peer

        self.peer_heap.add_and_shuffle(peer)
143166
def update_router(self, context, router_id, router):
        """"""

        # Read existing router record from DB
        original_router = self.get_router(context, router_id)
        # Update router DB
        new_router = super(AristaL3ServicePlugin, self).update_router(
            context, router_id, router)

        # Modify router on the Arista Hw
        try:
            self.driver.update_router(context, router_id,
                                      original_router, new_router)
            return new_router
        except Exception:
            LOG.error(_LE("Error updating router on Arista HW router=%s "),
                      new_router)