def test__filter_list_name_or_id_glob_not_found(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto')
     el3 = dict(id=200, name='pluto-2')
     data = [el1, el2, el3]
     ret = _utils._filter_list(data, 'q*', None)
     self.assertEqual([], ret)
Beispiel #2
0
 def test__filter_list_name_or_id_glob_not_found(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto')
     el3 = dict(id=200, name='pluto-2')
     data = [el1, el2, el3]
     ret = _utils._filter_list(data, 'q*', None)
     self.assertEqual([], ret)
 def test__filter_list_dict1(self):
     el1 = dict(id=100, name='donald', last='duck',
                other=dict(category='duck'))
     el2 = dict(id=200, name='donald', last='trump',
                other=dict(category='human'))
     el3 = dict(id=300, name='donald', last='ronald mac',
                other=dict(category='clown'))
     data = [el1, el2, el3]
     ret = _utils._filter_list(
         data, 'donald', {'other': {'category': 'clown'}})
     self.assertEqual([el3], ret)
Beispiel #4
0
 def test__filter_list_dict1(self):
     el1 = dict(id=100, name='donald', last='duck',
                other=dict(category='duck'))
     el2 = dict(id=200, name='donald', last='trump',
                other=dict(category='human'))
     el3 = dict(id=300, name='donald', last='ronald mac',
                other=dict(category='clown'))
     data = [el1, el2, el3]
     ret = _utils._filter_list(
         data, 'donald', {'other': {'category': 'clown'}})
     self.assertEqual([el3], ret)
Beispiel #5
0
    def search_stacks(self, name_or_id=None, filters=None):
        """Search stacks.

        :param name_or_id: Name or ID of the desired stack.
        :param filters: a dict containing additional filters to use. e.g.
                {'stack_status': 'CREATE_COMPLETE'}

        :returns: a list of ``munch.Munch`` containing the stack description.

        :raises: ``OpenStackCloudException`` if something goes wrong during the
            OpenStack API call.
        """
        stacks = self.list_stacks()
        return _utils._filter_list(stacks, name_or_id, filters)
 def _search_one_stack(name_or_id=None, filters=None):
     # stack names are mandatory and enforced unique in the project
     # so a StackGet can always be used for name or ID.
     try:
         stack = self.orchestration.find_stack(
             name_or_id,
             ignore_missing=False,
             resolve_outputs=resolve_outputs)
         if stack.status == 'DELETE_COMPLETE':
             return []
     except exc.OpenStackCloudURINotFound:
         return []
     stack = self._normalize_stack(stack)
     return _utils._filter_list([stack], name_or_id, filters)
 def test__filter_list_unicode(self):
     el1 = dict(id=100, name=u'中文', last='duck',
                other=dict(category='duck', financial=dict(status='poor')))
     el2 = dict(id=200, name=u'中文', last='trump',
                other=dict(category='human', financial=dict(status='rich')))
     el3 = dict(id=300, name='donald', last='ronald mac',
                other=dict(category='clown', financial=dict(status='rich')))
     data = [el1, el2, el3]
     ret = _utils._filter_list(
         data, u'中文',
         {'other': {
             'financial': {'status': 'rich'}
         }})
     self.assertEqual([el2], ret)
Beispiel #8
0
 def test__filter_list_unicode(self):
     el1 = dict(id=100, name=u'中文', last='duck',
                other=dict(category='duck', financial=dict(status='poor')))
     el2 = dict(id=200, name=u'中文', last='trump',
                other=dict(category='human', financial=dict(status='rich')))
     el3 = dict(id=300, name='donald', last='ronald mac',
                other=dict(category='clown', financial=dict(status='rich')))
     data = [el1, el2, el3]
     ret = _utils._filter_list(
         data, u'中文',
         {'other': {
             'financial': {'status': 'rich'}
         }})
     self.assertEqual([el2], ret)
Beispiel #9
0
 def _search_one_stack(name_or_id=None, filters=None):
     # stack names are mandatory and enforced unique in the project
     # so a StackGet can always be used for name or ID.
     try:
         stack = self.orchestration.find_stack(
             name_or_id,
             ignore_missing=False,
             resolve_outputs=resolve_outputs)
         if stack.status == 'DELETE_COMPLETE':
             return []
     except exc.OpenStackCloudURINotFound:
         return []
     stack = self._normalize_stack(stack)
     return _utils._filter_list([stack], name_or_id, filters)
    def search_stacks(self, name_or_id=None, filters=None):
        """Search stacks.

        :param name_or_id: Name or ID of the desired stack.
        :param filters: a dict containing additional filters to use. e.g.
                {'stack_status': 'CREATE_COMPLETE'}

        :returns: a list of ``munch.Munch`` containing the stack description.

        :raises: ``OpenStackCloudException`` if something goes wrong during the
            OpenStack API call.
        """
        stacks = self.list_stacks()
        return _utils._filter_list(stacks, name_or_id, filters)
Beispiel #11
0
    def search_coe_clusters(self, name_or_id=None, filters=None):
        """Search COE cluster.

        :param name_or_id: cluster name or ID.
        :param filters: a dict containing additional filters to use.
        :param detail: a boolean to control if we need summarized or
            detailed output.

        :returns: a list of dict containing the cluster

        :raises: ``OpenStackCloudException``: if something goes wrong during
            the OpenStack API call.
        """
        coe_clusters = self.list_coe_clusters()
        return _utils._filter_list(coe_clusters, name_or_id, filters)
Beispiel #12
0
    def search_containers(self, name=None, filters=None):
        """Search containers.

        :param string name: container name.
        :param filters: a dict containing additional filters to use.
            OR
            A string containing a jmespath expression for further filtering.
            Example:: "[?last_name==`Smith`] | [?other.gender]==`Female`]"

        :returns: a list of ``munch.Munch`` containing the containers.

        :raises: ``OpenStackCloudException``: if something goes wrong during
            the OpenStack API call.
        """
        containers = self.list_containers()
        return _utils._filter_list(containers, name, filters)
Beispiel #13
0
    def search_containers(self, name=None, filters=None):
        """Search containers.

        :param string name: container name.
        :param filters: a dict containing additional filters to use.
            OR
            A string containing a jmespath expression for further filtering.
            Example:: "[?last_name==`Smith`] | [?other.gender]==`Female`]"

        :returns: a list of ``munch.Munch`` containing the containers.

        :raises: ``OpenStackCloudException``: if something goes wrong during
            the OpenStack API call.
        """
        containers = self.list_containers()
        return _utils._filter_list(containers, name, filters)
Beispiel #14
0
 def search_cluster_receivers(self, name_or_id=None, filters=None):
     cluster_receivers = self.list_cluster_receivers()
     return _utils._filter_list(cluster_receivers, name_or_id, filters)
 def test__filter_list_name_or_id(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', None)
     self.assertEqual([el1], ret)
 def test__filter_list_name_or_id_non_glob_glob(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto[2017-01-10]')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'pluto', None)
     self.assertEqual([], ret)
 def test__filter_list_filter_jmespath(self):
     el1 = dict(id=100, name='donald', other='duck')
     el2 = dict(id=200, name='donald', other='trump')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', "[?other == `duck`]")
     self.assertEqual([el1], ret)
Beispiel #18
0
 def search_images(self, name_or_id=None, filters=None):
     images = self.list_images()
     return _utils._filter_list(images, name_or_id, filters)
 def search_volume_types(
         self, name_or_id=None, filters=None, get_extra=True):
     volume_types = self.list_volume_types(get_extra=get_extra)
     return _utils._filter_list(volume_types, name_or_id, filters)
 def test__filter_list_filter(self):
     el1 = dict(id=100, name='donald', other='duck')
     el2 = dict(id=200, name='donald', other='trump')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', {'other': 'duck'})
     self.assertEqual([el1], ret)
Beispiel #21
0
 def test__filter_list_name_or_id(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', None)
     self.assertEqual([el1], ret)
Beispiel #22
0
 def test__filter_list_name_or_id_non_glob_glob(self):
     el1 = dict(id=100, name='donald')
     el2 = dict(id=200, name='pluto[2017-01-10]')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'pluto', None)
     self.assertEqual([], ret)
Beispiel #23
0
 def test__filter_list_filter(self):
     el1 = dict(id=100, name='donald', other='duck')
     el2 = dict(id=200, name='donald', other='trump')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', {'other': 'duck'})
     self.assertEqual([el1], ret)
Beispiel #24
0
 def test__filter_list_filter_jmespath(self):
     el1 = dict(id=100, name='donald', other='duck')
     el2 = dict(id=200, name='donald', other='trump')
     data = [el1, el2]
     ret = _utils._filter_list(data, 'donald', "[?other == `duck`]")
     self.assertEqual([el1], ret)
 def search_volume_backups(self, name_or_id=None, filters=None):
     volume_backups = self.list_volume_backups()
     return _utils._filter_list(
         volume_backups, name_or_id, filters)
Beispiel #26
0
 def search_zones(self, name_or_id=None, filters=None):
     zones = self.list_zones()
     return _utils._filter_list(zones, name_or_id, filters)
Beispiel #27
0
 def search_hosts(self, name_or_id=None, filters=None, expand=True):
     hosts = self.list_hosts(expand=expand)
     return _utils._filter_list(hosts, name_or_id, filters)
Beispiel #28
0
 def search_hosts(self, name_or_id=None, filters=None, expand=True):
     hosts = self.list_hosts(expand=expand)
     return _utils._filter_list(hosts, name_or_id, filters)
 def search_volume_snapshots(self, name_or_id=None, filters=None):
     volumesnapshots = self.list_volume_snapshots()
     return _utils._filter_list(
         volumesnapshots, name_or_id, filters)
Beispiel #30
0
 def search_volume_snapshots(self, name_or_id=None, filters=None):
     volumesnapshots = self.list_volume_snapshots()
     return _utils._filter_list(volumesnapshots, name_or_id, filters)
 def search_security_groups(self, name_or_id=None, filters=None):
     # `filters` could be a dict or a jmespath (str)
     groups = self.list_security_groups(
         filters=filters if isinstance(filters, dict) else None)
     return _utils._filter_list(groups, name_or_id, filters)
Beispiel #32
0
 def search_recordsets(self, zone, name_or_id=None, filters=None):
     recordsets = self.list_recordsets(zone=zone)
     return _utils._filter_list(recordsets, name_or_id, filters)
Beispiel #33
0
 def search_volume_backups(self, name_or_id=None, filters=None):
     volume_backups = self.list_volume_backups()
     return _utils._filter_list(volume_backups, name_or_id, filters)
Beispiel #34
0
 def search_images(self, name_or_id=None, filters=None):
     images = self.list_images()
     return _utils._filter_list(images, name_or_id, filters)
Beispiel #35
0
 def search_volume_types(self,
                         name_or_id=None,
                         filters=None,
                         get_extra=True):
     volume_types = self.list_volume_types(get_extra=get_extra)
     return _utils._filter_list(volume_types, name_or_id, filters)