Example #1
0
    def find(self, **kwargs):
        # Filter by name or label
        label = kwargs.get('label', None)
        # Popped here, not used in the generic find
        owner = kwargs.pop('owners', None)
        extra_args = {}
        if owner:
            extra_args.update(Owners=owner)

        obj_list = []

        # The original list is made by combining both searches by "tag:Name"
        # and "AMI name" to allow for searches of public images
        if label:
            log.debug("Searching for AWS Image Service %s", label)
            obj_list.extend(self.svc.find(filter_name='name',
                                          filter_value=label, **extra_args))
            obj_list.extend(self.svc.find(filter_name='tag:Name',
                                          filter_value=label, **extra_args))

        if not label:
            obj_list = self

        # Add name filter for the generic find method, to allow searching
        # through AMI names for a match (public images will likely have an
        # AMI name and no tag:Name)
        kwargs.update({'name': label})
        filters = ['label', 'name']
        return cb_helpers.generic_find(filters, kwargs, obj_list)
Example #2
0
 def find(self, **kwargs):
     obj_list = self
     filters = [
         'name', 'direction', 'protocol', 'from_port', 'to_port', 'cidr',
         'src_dest_fw', 'src_dest_fw_id'
     ]
     matches = cb_helpers.generic_find(filters, kwargs, obj_list)
     return ClientPagedResultList(self._provider, list(matches))
Example #3
0
 def find(self, **kwargs):
     obj_list = self
     filters = ['name']
     matches = cb_helpers.generic_find(filters, kwargs, obj_list)
     return ClientPagedResultList(self._provider,
                                  list(matches),
                                  limit=None,
                                  marker=None)
Example #4
0
 def find(self, limit=None, marker=None, **kwargs):
     """
     GCE networks are global. There is at most one network with a given
     name.
     """
     obj_list = self
     filters = ['name', 'label']
     matches = cb_helpers.generic_find(filters, kwargs, obj_list)
     return ClientPagedResultList(self._provider, list(matches))
Example #5
0
    def find(self, **kwargs):
        obj_list = self
        filters = ['label']
        matches = cb_helpers.generic_find(filters, kwargs, obj_list)

        # All kwargs should have been popped at this time.
        if len(kwargs) > 0:
            raise TypeError("Unrecognised parameters for search: %s."
                            " Supported attributes: %s" %
                            (kwargs, ", ".join(filters)))

        return ClientPagedResultList(self.provider, matches if matches else [])
Example #6
0
    def find(self, **kwargs):
        # Filter by description or label
        label = kwargs.get('label', None)

        obj_list = []
        if label:
            log.debug("Searching for AWS Snapshot with label %s", label)
            obj_list.extend(self.svc.find(filter_name='tag:Name',
                                          filter_value=label,
                                          OwnerIds=['self']))
        else:
            obj_list = list(self)
        filters = ['label']
        return cb_helpers.generic_find(filters, kwargs, obj_list)
Example #7
0
 def find(self, **kwargs):
     obj_list = self
     filters = ['name', 'public_ip']
     matches = cb_helpers.generic_find(filters, kwargs, obj_list)
     return ClientPagedResultList(self._provider, list(matches))
Example #8
0
 def find(self, **kwargs):
     filters = ['label']
     obj_list = self
     return cb_helpers.generic_find(filters, kwargs, obj_list)
Example #9
0
    def find(self, network=None, **kwargs):
        obj_list = self._list_subnets(network)
        filters = ['label']
        matches = cb_helpers.generic_find(filters, kwargs, obj_list)

        return ClientPagedResultList(self.provider, matches if matches else [])