Adds Flow Specification route from VRF identified by *route_dist*.
353527
def add_flowspec_local(flowspec_family, route_dist, rules, **kwargs):
    
    try:
        # Create new path and insert into appropriate VRF table.
        tm = CORE_MANAGER.get_core_service().table_manager
        tm.update_flowspec_vrf_table(
            flowspec_family=flowspec_family, route_dist=route_dist,
            rules=rules, **kwargs)

        # Send success response.
        return [{FLOWSPEC_FAMILY: flowspec_family,
                 ROUTE_DISTINGUISHER: route_dist,
                 FLOWSPEC_RULES: rules}.update(kwargs)]

    except BgpCoreError as e:
        raise PrefixError(desc=e)
35148
def setup(self):
        """"""
        # get all routes from submodules
        for prefix, routes in self.sub_rt:
            routes.prefix = self.prefix + prefix
            routes.setup()

            fn_name_prefixes = {}
            for fn_key, fn in routes.fn_namespace.items():
                self.fn_namespace[routes.name + '.' + fn_key] = fn
                fn_prefix = routes.name
                if '.' in fn_key:
                    fn_prefix += '.' + fn_key.rsplit('.', 1)[0]
                fn_name_prefixes[fn] = fn_prefix

            for key in self:
                funcs = set(rule[1] for rule in self[key])
                for route, route_module, module, fn in routes.get(key, []):
                    if fn not in funcs:
                        new_route = Route(prefix + route.path)
                        fn.rw_route = new_route
                        fn_name_prefix = fn_name_prefixes[fn]
                        data = (new_route, fn_name_prefix, module, fn)
                        self[key].append(data)

        # sort all rules
        for key in self:
            self[key].sort(key=lambda rule: rule[0])
358490
def import_single_vpn_path_to_all_vrfs(self, vpn_path, path_rts=None):
        
        LOG.debug('Importing path %s to qualifying VRFs', vpn_path)

        # If this path has no RTs we are done.
        if not path_rts:
            LOG.info('Encountered a path with no RTs: %s', vpn_path)
            return

        # We match path RTs with all VRFs that are interested in them.
        interested_tables = set()

        # Get route family of VRF to when this VPN Path can be imported to
        if vpn_path.route_family == RF_IPv4_VPN:
            route_family = RF_IPv4_UC
        elif vpn_path.route_family == RF_IPv6_VPN:
            route_family = RF_IPv6_UC
        elif vpn_path.route_family == RF_L2_EVPN:
            route_family = RF_L2_EVPN
        elif vpn_path.route_family == RF_VPNv4_FLOWSPEC:
            route_family = RF_IPv4_FLOWSPEC
        elif vpn_path.route_family == RF_VPNv6_FLOWSPEC:
            route_family = RF_IPv6_FLOWSPEC
        elif vpn_path.route_family == RF_L2VPN_FLOWSPEC:
            route_family = RF_L2VPN_FLOWSPEC
        else:
            raise ValueError('Unsupported route family for VRF: %s' %
                             vpn_path.route_family)

        for rt in path_rts:
            rt_rf_id = rt + ':' + str(route_family)
            vrf_rt_tables = self._tables_for_rt.get(rt_rf_id)
            if vrf_rt_tables:
                interested_tables.update(vrf_rt_tables)

        if interested_tables:
            # We iterate over all VRF tables that are interested in the RT
            # of the given path and import this path into them.
            route_dist = vpn_path.nlri.route_dist
            for vrf_table in interested_tables:
                if (vpn_path.source is not None or
                        route_dist != vrf_table.vrf_conf.route_dist):
                    update_vrf_dest = vrf_table.import_vpn_path(vpn_path)
                    # Queue the destination for further processing.
                    if update_vrf_dest is not None:
                        self._signal_bus.\
                            dest_changed(update_vrf_dest)
        else:
            # If we do not have any VRF with import RT that match with path RT
            LOG.debug('No VRF table found that imports RTs: %s', path_rts)
567738
def modify_vrf(arg, opts, shell_opts):
    

    res = VRF.list({ 'rt': arg })
    if len(res) < 1:
        print("VRF with [RT: %s] not found." % arg, file=sys.stderr)
        sys.exit(1)

    v = res[0]

    if 'rt' in opts:
        v.rt = opts['rt']
    if 'name' in opts:
        v.name = opts['name']
    if 'description' in opts:
        v.description = opts['description']
    if 'tags' in opts:
        tags = list(csv.reader([opts.get('tags', '')], escapechar='\\'))[0]
        v.tags = {}
        for tag_name in tags:
            tag = Tag()
            tag.name = tag_name
            v.tags[tag_name] = tag

    for avp in opts.get('extra-attribute', []):
        try:
            key, value = avp.split('=', 1)
        except ValueError:
            print("ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp, file=sys.stderr)
            return
        v.avps[key] = value

    v.save()

    print("%s saved." % vrf_format(v))
870833
def add_info_from_hv(self):
        
        # Router Image
        if 'image' in self.hypervisor:
            self.node['properties']['image'] = \
                os.path.basename(self.hypervisor['image'])
        # IDLE-PC
        if 'idlepc' in self.hypervisor:
            self.node['properties']['idlepc'] = self.hypervisor['idlepc']
        # Router RAM
        if 'ram' in self.hypervisor:
            self.node['properties']['ram'] = self.hypervisor['ram']
        # 7200 NPE
        if 'npe' in self.hypervisor:
            self.device_info['npe'] = self.hypervisor['npe']
        # Device Chassis
        if 'chassis' in self.hypervisor:
            self.device_info['chassis'] = self.hypervisor['chassis']
            if self.device_info['model'] == 'c3600':
                self.node['properties']['chassis'] = \
                    self.device_info['chassis']
734800
def traceroute(self,
                   destination,
                   source=C.TRACEROUTE_SOURCE,
                   ttl=C.TRACEROUTE_TTL,
                   timeout=C.TRACEROUTE_TIMEOUT,
                   vrf=C.TRACEROUTE_VRF):
        """"""
        traceroute_result = {}

        # calling form RPC does not work properly :(
        # but defined junos_route_instance_table just in case

        source_str = ''
        maxttl_str = ''
        wait_str = ''
        vrf_str = ''

        if source:
            source_str = ' source {source}'.format(source=source)
        if ttl:
            maxttl_str = ' ttl {ttl}'.format(ttl=ttl)
        if timeout:
            wait_str = ' wait {timeout}'.format(timeout=timeout)
        if vrf:
            vrf_str = ' routing-instance {vrf}'.format(vrf=vrf)

        traceroute_command = 'traceroute {destination}{source}{maxttl}{wait}{vrf}'.format(
            destination=destination,
            source=source_str,
            maxttl=maxttl_str,
            wait=wait_str,
            vrf=vrf_str
        )

        traceroute_rpc = E('command', traceroute_command)
        rpc_reply = self.device._conn.rpc(traceroute_rpc)._NCElement__doc
        # make direct RPC call via NETCONF
        traceroute_results = rpc_reply.find('.//traceroute-results')

        traceroute_failure = napalm_base.helpers.find_txt(
            traceroute_results, 'traceroute-failure', '')
        error_message = napalm_base.helpers.find_txt(
            traceroute_results, 'rpc-error/error-message', '')

        if traceroute_failure and error_message:
            return {'error': '{}: {}'.format(traceroute_failure, error_message)}

        traceroute_result['success'] = {}
        for hop in traceroute_results.findall('hop'):
            ttl_value = napalm_base.helpers.convert(
                int, napalm_base.helpers.find_txt(hop, 'ttl-value'), 1)
            if ttl_value not in traceroute_result['success']:
                traceroute_result['success'][ttl_value] = {'probes': {}}
            for probe in hop.findall('probe-result'):
                probe_index = napalm_base.helpers.convert(
                    int, napalm_base.helpers.find_txt(probe, 'probe-index'), 0)
                ip_address = napalm_base.helpers.convert(
                    napalm_base.helpers.ip, napalm_base.helpers.find_txt(probe, 'ip-address'), '*')
                host_name = py23_compat.text_type(
                    napalm_base.helpers.find_txt(probe, 'host-name', '*'))
                rtt = napalm_base.helpers.convert(
                    float, napalm_base.helpers.find_txt(probe, 'rtt'), 0) * 1e-3  # ms
                traceroute_result['success'][ttl_value]['probes'][probe_index] = {
                    'ip_address': ip_address,
                    'host_name': host_name,
                    'rtt': rtt
                }

        return traceroute_result
441258
def _add_route(self, method, path, middleware=None):
        """"""
        if middleware is not None:
            self.add(method, path, middleware)
            return self
        else:
            # return a lambda that will return the 'func' argument
            return lambda func: (
                self.add(method, path, func),
                func
            )[1]
411491
def add(self, method, path_settings, target):
        
        self.routes.append(Route(method, path_settings, target))
        return
185576
def create_api_vrf(self):
        """"""
        return ApiVrf(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
1136250
private void addTrafficSource() {
    VectorSource trafficSource = new VectorSource(TrafficData.SOURCE_ID, TrafficData.SOURCE_URL);
    style.addSource(trafficSource);
  }
863639
def cli(env):
    """"""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    routing_methods = mgr.get_routing_methods()
    table = formatting.KeyValueTable(['ID', 'Name'])
    table.align['ID'] = 'l'
    table.align['Name'] = 'l'
    table.sortby = 'ID'
    for routing_method in routing_methods:
        table.add_row([routing_method['id'], routing_method['name']])

    env.fout(table)
179306
def add_vrf(arg, opts, shell_opts):
    

    v = VRF()
    v.rt = opts.get('rt')
    v.name = opts.get('name')
    v.description = opts.get('description')
    v.tags = list(csv.reader([opts.get('tags', '')], escapechar='\\'))[0]

    for avp in opts.get('extra-attribute', []):
        try:
            key, value = avp.split('=', 1)
        except ValueError:
            print("ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp, file=sys.stderr)
            return
        v.avps[key] = value

    try:
        v.save()
    except pynipap.NipapError as exc:
        print("Could not add VRF to NIPAP: %s" % str(exc), file=sys.stderr)
        sys.exit(1)

    print("Added %s" % (vrf_format(v)))
581301
def _apply_dvs_infrastructure_traffic_resources(infra_traffic_resources,
                                                resource_dicts):
    '''
    
    '''
    for res_dict in resource_dicts:
        filtered_traffic_resources = \
                [r for r in infra_traffic_resources if r.key == res_dict['key']]
        if filtered_traffic_resources:
            traffic_res = filtered_traffic_resources[0]
        else:
            traffic_res = vim.DvsHostInfrastructureTrafficResource()
            traffic_res.key = res_dict['key']
            traffic_res.allocationInfo = \
                    vim.DvsHostInfrastructureTrafficResourceAllocation()
            infra_traffic_resources.append(traffic_res)
        if res_dict.get('limit'):
            traffic_res.allocationInfo.limit = res_dict['limit']
        if res_dict.get('reservation'):
            traffic_res.allocationInfo.reservation = res_dict['reservation']
        if res_dict.get('num_shares') or res_dict.get('share_level'):
            if not traffic_res.allocationInfo.shares:
                traffic_res.allocationInfo.shares = vim.SharesInfo()
        if res_dict.get('share_level'):
            traffic_res.allocationInfo.shares.level = \
                    vim.SharesLevel(res_dict['share_level'])
        if res_dict.get('num_shares'):
            #XXX Even though we always set the number of shares if provided,
            #the vCenter will ignore it unless the share level is 'custom'.
            traffic_res.allocationInfo.shares.shares = res_dict['num_shares']
987379
function AddRoutes (routes, kind) {

		function AddRoute (route, name, kind) {
			let root 	= '/'+name.toLowerCase(),
				router 	= Express.Router({ mergeParams: true }),
				hroute 	= Express.Router({ mergeParams: true }),
				lstore  = Session.Stores.Limits,
				point 	= null, limiters = { 
					root: Session.Limiter(router, lstore), 
					help: Session.Limiter(hroute, lstore)
				}, 	hlimit;

			// Instantiate Route
				REST[kind](name, route);
				point = REST.Points[name];

			// Handle Validation
				if ('Validate' in REST.Points[name])
					Valid = REST.Points[name].Validate;	
				hlimit  = ReqHandle.Limit('help',limiters.help,point,'/',`${root}/`);

			// Handle Documentation (root); if applicable
				if (!Object.keys(route.Actions).has('/')) PushRoute(
					hroute, 'all', '/', ReqHandle.Errs(point, '/'), 
					hlimit, ReqHandle.Valid(true)
				);

			// Handle Errors
				Imm.Map(route.Errors).map((paths, which) => {
					paths.map((scheme, i) => { PushRoute(
						router, 'all', scheme, ReqHandle.Errs(point, MSG[which]), 
						ReqHandle.Limit('erro',limiters.root,point,'/',`${root}${scheme}/`.replace(/[/]+$/,'/'))
					);	});
				});

			// Handle Points
				Imm.OrderedMap(route.Actions).map((act, pth) => {
					try {
						let allowd = act.Doc.Methods,
							denied = HTTPREQ.filter((v,i)=>allowd.indexOf(v)<0),
							isMdle = allowd.has('MIDDLEWARE');
						// Omit Middleware
							let scheme 	= ReqPattern(pth, act),
								key 	= ReqPattern(pth, act, true),
								dir 	= `${root}${ReqPattern(pth, act, true)}`,
								lmt 	= ReqHandle.Limit('endp',limiters.root, point, pth, dir),
								vld 	= !isMdle ? ReqHandle.Valid(act.Doc.Headers) : null;

							// Handle Douchebag Requests
								!isMdle && denied.map(M => {
									let func = M.toLowerCase(), err = MSG['NO_'+M];
									PushRoute(router, func, scheme, ReqHandle.Errs(point, err), lmt, vld);
								});
							// Handle Good-Guy Requests
								allowd.map(M => {
									let func = 	M.toLowerCase(),
										main = 	ReqHandle.Main(point, pth),
										upld =	ReqHandle.Upload(M,act.Doc.Files),
										schm = 	new RegExp([
													name.toLowerCase(),
													scheme.slice(1,-1)
														.replace(/\/{2,}/g,'')
														.replace(/([^\\])\//g,'$1\\/')
														.replace(/(^|[\/(]|[|]):\w+(?=[(])/g,'$1')
														.replace(/^(.+)$/,'(?:$1)')
												].join('\\/'));
									// ----
									SockRoute(name, pth, key, lmt, vld, upld, schm); 	// Socket
									!isMdle && PushRoute(
										router, func, scheme, main, lmt, vld, upld		// HTTP
									);
								});
							// Handle Documentation (sub)
								!isMdle && PushRoute(
									hroute, 'all', key, ReqHandle.Errs(point, pth), hlimit, vld
								);
					} catch(e) {
						console.log(act)
						throw e;
					}
				});

			// Mount Router
				API.use(root, router); // Requests Path
				HLP.use(root, hroute); // Document Path

			// Return to Initialize
				return point;
		}

		// Create each Point
		if (!!routes) 
			Imm .OrderedMap(routes)
				.filter((v,k)=>k!="__DEFAULTS")
				.map((route, name)=>AddRoute(route, name, kind))
				.map(route=>route.Init());
	}
862001
def _add_flow_v1_0(self, src, port, timeout, datapath):
        """"""
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        match = parser.OFPMatch(
            in_port=port, dl_src=addrconv.mac.text_to_bin(src),
            dl_type=ether.ETH_TYPE_SLOW)
        actions = [parser.OFPActionOutput(
            ofproto.OFPP_CONTROLLER, 65535)]
        mod = parser.OFPFlowMod(
            datapath=datapath, match=match, cookie=0,
            command=ofproto.OFPFC_ADD, idle_timeout=timeout,
            priority=65535, flags=ofproto.OFPFF_SEND_FLOW_REM,
            actions=actions)
        datapath.send_msg(mod)
993208
def add(routes_refine)
			routes.deep_merge! routes_refine.routes
			reverse_routes.merge! routes_refine.reverse_routes
		end
771840
def add_current_vrf(self):
        

        vrf_id = request.json['vrf_id']

        if vrf_id is not None:

            if vrf_id == 'null':
                vrf = VRF()
            else:
                vrf_id = int(vrf_id)
                vrf = VRF.get(vrf_id)

            session['current_vrfs'][vrf_id] = { 'id': vrf.id, 'rt': vrf.rt,
                    'name': vrf.name, 'description': vrf.description }
            session.save()

        return json.dumps(session.get('current_vrfs', {}))