Returns filtered list of all instances in the neutron db
341803
def get_instances(device_owners=None, vnic_type=None, instance_id=None):
    """"""
    session = db.get_reader_session()
    with session.begin():
        port_model = models_v2.Port
        binding_model = ml2_models.PortBinding
        instances = (session
                     .query(port_model,
                            binding_model)
                     .outerjoin(
                         binding_model,
                         port_model.id == binding_model.port_id)
                     .distinct(port_model.device_id)
                     .group_by(port_model.device_id)
                     .filter_unnecessary_ports(device_owners, vnic_type))
        if instance_id:
            instances = instances.filter(port_model.device_id == instance_id)
    return instances.all()
1157925
def all_group_experiments(self):
        
        from db.models.experiments import Experiment

        if self.is_selection:
            return Experiment.all.filter(selections=self)
        return Experiment.all.filter(experiment_group=self)
238729
def list_instance_profiles(path_prefix='/', region=None, key=None,
                           keyid=None, profile=None):
    '''
    
    '''
    p = get_all_instance_profiles(path_prefix, region, key, keyid, profile)
    return [i['instance_profile_name'] for i in p]
1370111
def get_attr_filters(self):
        
        for f in self.data.keys():
            if f not in self.multi_attrs:
                continue
            fv = self.data[f]
            if isinstance(fv, dict):
                fv['key'] = f
            else:
                fv = {f: fv}
            vf = ValueFilter(fv)
            vf.annotate = False
            yield vf
558438
def list_instances(self):
        
        # Server does not do pagination on listings of this resource.
        # Return an iterator anyway for similarity with other API methods
        response = self.get_proto(path='/instances')
        message = rest_pb2.ListInstancesResponse()
        message.ParseFromString(response.content)
        instances = getattr(message, 'instance')
        return iter([Instance(instance) for instance in instances])
569065
def get_instances(self):
        
        if self._update_members: self.update()
        return iter(sorted(self.members.iteritems()))
360436
def events(self, all_instances=None, instance_ids=None, filters=None):
        """"""
        params = {}
        if filters:
            params["filters"] = make_filters(filters)
        if instance_ids:
            params['InstanceIds'] = instance_ids
        statuses = self.status(all_instances, **params)
        event_list = []
        for status in statuses:
            if status.get("Events"):
                for event in status.get("Events"):
                    event[u"InstanceId"] = status.get('InstanceId')
                    event_list.append(event)
        return event_list
548716
def list_extensions(request):
    
    neutron_api = neutronclient(request)
    try:
        extensions_list = neutron_api.list_extensions()
    except exceptions.ServiceCatalogException:
        return {}
    if 'extensions' in extensions_list:
        return tuple(extensions_list['extensions'])
    else:
        return ()
1169224
def _find_usage_instances(self):
        """"""
        paginator = self.conn.get_paginator('describe_db_instances')
        for page in paginator.paginate():
            for instance in page['DBInstances']:
                self.limits['Read replicas per master']._add_current_usage(
                    len(instance['ReadReplicaDBInstanceIdentifiers']),
                    aws_type='AWS::RDS::DBInstance',
                    resource_id=instance['DBInstanceIdentifier']
                )
84539
def all(self):
        
        logger.debug(f'Query `{self.__class__.__name__}` objects with filters {self}')

        # Destroy any cached results
        self._result_cache = None

        # Fetch Model class and connected repository from Repository Factory
        model_cls = repo_factory.get_model(self._entity_cls)
        repository = repo_factory.get_repository(self._entity_cls)

        # order_by clause must be list of keys
        order_by = self._entity_cls.meta_.order_by if not self._order_by else self._order_by

        # Call the read method of the repository
        results = repository.filter(self._criteria, self._offset, self._limit, order_by)

        # Convert the returned results to entity and return it
        entity_items = []
        for item in results.items:
            entity = model_cls.to_entity(item)
            entity.state_.mark_retrieved()
            entity_items.append(entity)
        results.items = entity_items

        # Cache results
        self._result_cache = results

        return results
1163056
def all_experiments(self):
        
        try:
            return [
                self.experiment_factory(e)
                for e in model.Experiment.query.all()
            ]
        finally:
            self.Session.close()
398825
def instances(cls):
        
        l = [i for i in cls.allinstances() if isinstance(i, cls)]
        return l
337216
def retrieve_list(self, parsed_args):
        """"""
        neutron_client = self.get_client()
        _extra_values = parse_args_to_dict(self.values_specs)
        _merge_args(self, parsed_args, _extra_values,
                    self.values_specs)
        search_opts = self.args2search_opts(parsed_args)
        search_opts.update(_extra_values)
        if self.pagination_support:
            page_size = parsed_args.page_size
            if page_size:
                search_opts.update({'limit': page_size})
        if self.sorting_support:
            keys = parsed_args.sort_key
            if keys:
                search_opts.update({'sort_key': keys})
            dirs = parsed_args.sort_dir
            len_diff = len(keys) - len(dirs)
            if len_diff > 0:
                dirs += ['asc'] * len_diff
            elif len_diff < 0:
                dirs = dirs[:len(keys)]
            if dirs:
                search_opts.update({'sort_dir': dirs})
        data = self.call_server(neutron_client, search_opts, parsed_args)
        collection = _get_resource_plural(self.resource, neutron_client)
        return data.get(collection, [])
396005
def _filter_classes(cls_list, cls_type):
    """"""
    for cls in cls_list:
        if isinstance(cls, type) and issubclass(cls, cls_type):
            if cls_type == TempyPlace and cls._base_place:
                pass
            else:
                yield cls
160846
def list_(saltenv='base', test=None):
    '''
    
    '''
    sevent = salt.utils.event.get_event(
            'master',
            __opts__['sock_dir'],
            __opts__['transport'],
            opts=__opts__,
            listen=True)

    master_key = salt.utils.master.get_master_key('root', __opts__)

    __jid_event__.fire_event({'key': master_key}, 'salt/reactors/manage/list')

    results = sevent.get_event(wait=30, tag='salt/reactors/manage/list-results')
    reactors = results['reactors']
    return reactors
1173460
def filtered_entries
      return [] unless exists?

      @filtered_entries ||=
        Dir.chdir(directory) do
          entry_filter.filter(entries).reject do |f|
            path = collection_dir(f)
            File.directory?(path) || entry_filter.symlink?(f)
          end
        end
    end
321146
def registered_filters_list(self):
        
        return [filter_name for filter_name in self.__jinja2_environment.filters.keys() if filter_name not in self.__jinja2_predefined_filters ]