Add VRF to filter list session variable
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', {}))
476778
def add_filter(self, filter_id, description):
        
        filter_line = '##FILTER=<ID={0},Description="{1}">'.format(
            filter_id, description
        )
        logger.info("Adding filter line to vcf: {0}".format(filter_line))
        self.parse_meta_data(filter_line)
        return
953188
def view_vrf(arg, opts, shell_opts):
    

    if arg is None:
        print("ERROR: Please specify the RT of the VRF to view.", file=sys.stderr)
        sys.exit(1)

    # interpret as default VRF (ie, RT = None)
    if arg.lower() in ('-', 'none'):
        arg = None

    try:
        v = VRF.search({
            'val1': 'rt',
            'operator': 'equals',
            'val2': arg }
            )['result'][0]
    except (KeyError, IndexError):
        print("VRF with [RT: %s] not found." % str(arg), file=sys.stderr)
        sys.exit(1)

    print("-- VRF")
    print("  %-26s : %d" % ("ID", v.id))
    print("  %-26s : %s" % ("RT", v.rt))
    print("  %-26s : %s" % ("Name", v.name))
    print("  %-26s : %s" % ("Description", v.description))

    print("-- Extra Attributes")
    if v.avps is not None:
        for key in sorted(v.avps, key=lambda s: s.lower()):
            print("  %-26s : %s" % (key, v.avps[key]))

    print("-- Tags")
    for tag_name in sorted(v.tags, key=lambda s: s.lower()):
        print("  %s" % tag_name)
    # statistics
    if v.total_addresses_v4 == 0:
        used_percent_v4 = 0
    else:
        used_percent_v4 = (float(v.used_addresses_v4)/v.total_addresses_v4)*100
    if v.total_addresses_v6 == 0:
        used_percent_v6 = 0
    else:
        used_percent_v6 = (float(v.used_addresses_v6)/v.total_addresses_v6)*100
    print("-- Statistics")
    print("  %-26s : %s" % ("IPv4 prefixes", v.num_prefixes_v4))
    print("  %-26s : %.0f / %.0f (%.2f%% of %.0f)" % ("IPv4 addresses Used / Free",
            v.used_addresses_v4, v.free_addresses_v4, used_percent_v4,
            v.total_addresses_v4))
    print("  %-26s : %s" % ("IPv6 prefixes", v.num_prefixes_v6))
    print("  %-26s : %.4e / %.4e (%.2f%% of %.4e)" % ("IPv6 addresses Used / Free",
            v.used_addresses_v6, v.free_addresses_v6, used_percent_v6,
            v.total_addresses_v6))
898081
def add_filter_by_client(self, query, out_params):
        
        current_client = logged_in_client(self.context)
        if current_client:
            query['getClientUID'] = api.get_uid(current_client)
        elif self.request.form.get("ClientUID", ""):
            query['getClientUID'] = self.request.form['ClientUID']
            client = api.get_object_by_uid(query['getClientUID'])
            out_params.append({'title': _('Client'),
                               'value': client.Title(),
                               'type': 'text'})
1080500
def filter(self, table, snapshots, filter_string):
        """"""
        query = filter_string.lower()
        return [snapshot for snapshot in snapshots
                if query in snapshot.name.lower()]
309859
def list_sessions(self) -> List[Session]:
        """"""
        data = self._client.get("/sessions")
        return [Session.from_json(item) for item in data["sessions"]]
424202
def vrf_attr_add(arg, opts, shell_opts):
    

    if arg is None:
        print("ERROR: Please specify the RT of the VRF to view.", file=sys.stderr)
        sys.exit(1)

    # interpret as default VRF (ie, RT = None)
    if arg.lower() in ('-', 'none'):
        arg = None

    try:
        v = VRF.search({
            'val1': 'rt',
            'operator': 'equals',
            'val2': arg }
            )['result'][0]
    except (KeyError, IndexError):
        print("VRF with [RT: %s] not found." % str(arg), file=sys.stderr)
        sys.exit(1)

    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)
            sys.exit(1)

        if key in v.avps:
            print("Unable to add extra-attribute: '%s' already exists." % key, file=sys.stderr)
            sys.exit(1)

        v.avps[key] = value

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

    print("%s saved." % vrf_format(v))
266940
def listVars(prefix="", equals="\t= ", **kw):
    """"""

    keylist = getVarList()
    if len(keylist) == 0:
        print('No IRAF variables defined')
    else:
        keylist.sort()
        for word in keylist:
            print("%s%s%s%s" % (prefix, word, equals, envget(word)))
1264890
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws ServletException, IOException
	{
		servletRequest.setCharacterEncoding("UTF-8");
		httpRequest.set(servletRequest);
		httpResponse.set(servletResponse);

		Request appRequest = null;
		try
		{
//			String sessionToken = ServletSupport.getSessionTokenFromCookie(servletRequest);
			String sessionToken = ServletSupport.getCookieValue(servletRequest, SESSION_TOKEN_KEY);
			String userId = ServletSupport.getCookieValue(servletRequest, USER_ID_KEY);
			if("".equals(sessionToken))
			{
				sessionToken = null;
			}
			if("".equals(userId))
			{
				userId = null;
			}
 			if(accessManager != null) {
				appRequest = accessManager.bindRequest(this);
//				System.out.println("request bound!! " + appRequest);
				Session session = appRequest.resolveSession(sessionToken, userId);
			}

			if (this.syncUserPrefs &&  appRequest.getTimesEntered() == 0)
			{
				//pass user preferences here
				ServletSupport.importCookieValues(servletRequest,  appRequest.getUserSettings());
				ServletSupport.exportCookieValues(servletResponse,  appRequest.getUserSettings(), "/", userPrefsMaxAge, Arrays.asList(new String[]{SESSION_TOKEN_KEY}));
			}

			//if a user logged in, the user id must be stored
			if(userId == null)
			{
				User user = appRequest.getUser();
				if(user != null)
				{
					storeSessionDataInCookie(USER_ID_KEY, user.getId(), servletResponse);
				}
			}

			//role based access control
	//		checkAccess(servletRequest,  appRequest);

			//delegate request
			chain.doFilter(servletRequest, servletResponse);
		}
		catch (Throwable t)//make sure user gets a controlled response
		{
			//is this the actual entry point or is this entry point wrapped?
			if ( appRequest != null &&  appRequest.getTimesEntered() > 1)
			{
				//it's wrapped, so the exception must be thrown at the top entry point
				ServletSupport.rethrow(t);
			}
			handleException(servletRequest, servletResponse, t);
		}
		finally
		{
/*			if(loggingEnabled)
			{
				application.log(new PageVisitLogEntry((HttpServletRequest) servletRequest));
			}
			application.releaseRequest();  */
			if(accessManager != null) {
				accessManager.releaseRequest();
			}
		}
	}
708861
def handle_server_filter(self, request, table=None):
        
        if not table:
            table = self.get_table()
        filter_info = self.get_server_filter_info(request, table)
        if filter_info is None:
            return False
        request.session[filter_info['value_param']] = filter_info['value']
        if filter_info['field_param']:
            request.session[filter_info['field_param']] = filter_info['field']
        return filter_info['changed']
534123
public static aaasession[] get_filtered(nitro_service service, String filter) throws Exception{
		aaasession obj = new aaasession();
		options option = new options();
		option.set_filter(filter);
		aaasession[] response = (aaasession[]) obj.getfiltered(service, option);
		return response;
	}
777146
def complete_vrf(arg):
    

    search_string = ''
    if arg is not None:
        search_string = '^%s' % arg

    res = VRF.search({
        'operator': 'regex_match',
        'val1': 'rt',
        'val2':  search_string
        }, { 'max_result': 100000 } )

    ret = []

    for v in res['result']:
        ret.append(v.rt)
    if re.match(search_string, 'none'):
        ret.append('none')

    return ret
463756
private void listStatus(ArrayList<FileStatus> results, Path f,
      PathFilter filter) throws IOException {
    FileStatus listing[] = listStatus(f);
    if (listing == null) {
      throw new FileNotFoundException("File " + f + " does not exist");
    }
    for (int i = 0; i < listing.length; i++) {
      if (filter.accept(listing[i].getPath())) {
        results.add(listing[i]);
      }
    }
  }
856483
def filter(self, *args):
    '''

    '''
    if len(args) == 1 and isinstance(args[0], Filter):
      filter = args[0]
    else:
      filter = Filter(*args)

    # ensure filter gets attr values the same way the rest of the query does.
    filter.object_getattr = self.object_getattr
    self.filters.append(filter)
    return self
621714
public static vpntrafficpolicy[] get_filtered(nitro_service service, String filter) throws Exception{
		vpntrafficpolicy obj = new vpntrafficpolicy();
		options option = new options();
		option.set_filter(filter);
		vpntrafficpolicy[] response = (vpntrafficpolicy[]) obj.getfiltered(service, option);
		return response;
	}
153821
def add_vrf(self):
        

        v = VRF()
        if 'rt' in request.json:
            v.rt = validate_string(request.json, 'rt')
        if 'name' in request.json:
            v.name = validate_string(request.json, 'name')
        if 'description' in request.json:
            v.description = validate_string(request.json, 'description')
        if 'tags' in request.json:
            v.tags = request.json['tags']
        if 'avps' in request.json:
            v.avps = request.json['avps']

        try:
            v.save()
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

        return json.dumps(v, cls=NipapJSONEncoder)
716285
def as_list(self, fs_type=None):
        """"""
        entries = self._entries
        if fs_type:
            entries = filter(lambda a: a.fs_type == fs_type, entries)
        return entries