Exemplo n.º 1
0
    def test_qos_specs_get_all(self):
        value1 = dict(consumer='front-end',
                      key1='v1', key2='v2')
        value2 = dict(consumer='back-end',
                      key3='v3', key4='v4')
        value3 = dict(consumer='back-end',
                      key5='v5', key6='v6')

        spec_id1 = self._create_qos_specs('Name1', value1)
        spec_id2 = self._create_qos_specs('Name2', value2)
        spec_id3 = self._create_qos_specs('Name3', value3)

        specs = db.qos_specs_get_all(self.ctxt)
        self.assertEqual(3, len(specs),
                         "Unexpected number of qos specs records")

        expected1 = dict(name='Name1', id=spec_id1, consumer='front-end')
        expected2 = dict(name='Name2', id=spec_id2, consumer='back-end')
        expected3 = dict(name='Name3', id=spec_id3, consumer='back-end')
        del value1['consumer']
        del value2['consumer']
        del value3['consumer']
        expected1.update(dict(specs=value1))
        expected2.update(dict(specs=value2))
        expected3.update(dict(specs=value3))
        self.assertIn(expected1, specs)
        self.assertIn(expected2, specs)
        self.assertIn(expected3, specs)
Exemplo n.º 2
0
    def test_qos_specs_get_all(self):
        value1 = dict(consumer='front-end', key1='v1', key2='v2')
        value2 = dict(consumer='back-end', key3='v3', key4='v4')
        value3 = dict(consumer='back-end', key5='v5', key6='v6')

        spec_id1 = self._create_qos_specs('Name1', value1)
        spec_id2 = self._create_qos_specs('Name2', value2)
        spec_id3 = self._create_qos_specs('Name3', value3)

        specs = db.qos_specs_get_all(self.ctxt)
        self.assertEqual(len(specs), 3,
                         "Unexpected number of qos specs records")

        expected1 = dict(name='Name1', id=spec_id1, consumer='front-end')
        expected2 = dict(name='Name2', id=spec_id2, consumer='back-end')
        expected3 = dict(name='Name3', id=spec_id3, consumer='back-end')
        del value1['consumer']
        del value2['consumer']
        del value3['consumer']
        expected1.update(dict(specs=value1))
        expected2.update(dict(specs=value2))
        expected3.update(dict(specs=value3))
        self.assertIn(expected1, specs)
        self.assertIn(expected2, specs)
        self.assertIn(expected3, specs)
def get_all_specs(context, filters=None, marker=None, limit=None, offset=None,
                  sort_keys=None, sort_dirs=None):
    """Get all non-deleted qos specs."""
    qos_specs = db.qos_specs_get_all(context, filters=filters, marker=marker,
                                     limit=limit, offset=offset,
                                     sort_keys=sort_keys, sort_dirs=sort_dirs)
    return qos_specs
Exemplo n.º 4
0
    def test_qos_specs_get_all(self):
        qos_list = [{
            'name': 'Name1',
            'consumer': 'front-end',
            'specs': {
                'key1': 'v1',
                'key2': 'v2'
            }
        }, {
            'name': 'Name2',
            'consumer': 'back-end',
            'specs': {
                'key1': 'v3',
                'key2': 'v4'
            }
        }, {
            'name': 'Name3',
            'consumer': 'back-end',
            'specs': {
                'key1': 'v5',
                'key2': 'v6'
            }
        }]

        for qos in qos_list:
            qos['id'] = self._create_qos_specs(qos['name'], qos['consumer'],
                                               qos['specs'])

        specs_list_returned = db.qos_specs_get_all(self.ctxt)
        self.assertEqual(len(qos_list), len(specs_list_returned),
                         "Unexpected number of qos specs records")

        for expected_qos in qos_list:
            self.assertIn(expected_qos, specs_list_returned)
Exemplo n.º 5
0
    def test_qos_specs_get_all(self):
        qos_list = [
            {'name': 'Name1',
             'consumer': 'front-end',
             'specs': {'key1': 'v1', 'key2': 'v2'}},
            {'name': 'Name2',
             'consumer': 'back-end',
             'specs': {'key1': 'v3', 'key2': 'v4'}},
            {'name': 'Name3',
             'consumer': 'back-end',
             'specs': {'key1': 'v5', 'key2': 'v6'}}]

        for index, qos in enumerate(qos_list):
            qos['id'] = self._create_qos_specs(qos['name'],
                                               qos['consumer'],
                                               qos['specs'])
            specs = db.qos_specs_get(self.ctxt, qos['id'])
            qos_list[index]['created_at'] = specs['created_at']

        specs_list_returned = db.qos_specs_get_all(self.ctxt)
        self.assertEqual(len(qos_list), len(specs_list_returned),
                         "Unexpected number of qos specs records")

        for expected_qos in qos_list:
            self.assertIn(expected_qos, specs_list_returned)
Exemplo n.º 6
0
def get_all_specs(context,
                  filters=None,
                  marker=None,
                  limit=None,
                  offset=None,
                  sort_keys=None,
                  sort_dirs=None):
    """Get all non-deleted qos specs."""
    qos_specs = db.qos_specs_get_all(context,
                                     filters=filters,
                                     marker=marker,
                                     limit=limit,
                                     offset=offset,
                                     sort_keys=sort_keys,
                                     sort_dirs=sort_dirs)
    return qos_specs
Exemplo n.º 7
0
    def test_qos_specs_get_all(self):
        value1 = dict(consumer='front-end', key1='v1', key2='v2')
        value2 = dict(consumer='back-end', key3='v3', key4='v4')
        value3 = dict(consumer='back-end', key5='v5', key6='v6')

        spec_id1 = self._create_qos_specs('Name1', value1)
        spec_id2 = self._create_qos_specs('Name2', value2)
        spec_id3 = self._create_qos_specs('Name3', value3)

        specs = db.qos_specs_get_all(self.ctxt)
        self.assertEquals(len(specs), 3,
                          "Unexpected number of qos specs records")

        value1.update({'id': spec_id1})
        value2.update({'id': spec_id2})
        value3.update({'id': spec_id3})
        self.assertDictMatch(specs['Name1'], value1)
        self.assertDictMatch(specs['Name2'], value2)
        self.assertDictMatch(specs['Name3'], value3)
Exemplo n.º 8
0
    def test_qos_specs_get_all(self):
        value1 = dict(consumer='front-end',
                      key1='v1', key2='v2')
        value2 = dict(consumer='back-end',
                      key3='v3', key4='v4')
        value3 = dict(consumer='back-end',
                      key5='v5', key6='v6')

        spec_id1 = self._create_qos_specs('Name1', value1)
        spec_id2 = self._create_qos_specs('Name2', value2)
        spec_id3 = self._create_qos_specs('Name3', value3)

        specs = db.qos_specs_get_all(self.ctxt)
        self.assertEquals(len(specs), 3,
                          "Unexpected number of qos specs records")

        value1.update({'id': spec_id1})
        value2.update({'id': spec_id2})
        value3.update({'id': spec_id3})
        self.assertDictMatch(specs['Name1'], value1)
        self.assertDictMatch(specs['Name2'], value2)
        self.assertDictMatch(specs['Name3'], value3)
Exemplo n.º 9
0
def get_all_specs(context, inactive=False, search_opts=None):
    """Get all non-deleted qos specs.

    Pass inactive=True as argument and deleted volume types would return
    as well.
    """
    search_opts = search_opts or {}
    qos_specs = db.qos_specs_get_all(context, inactive)

    if search_opts:
        LOG.debug("Searching by: %s" % search_opts)

        def _check_specs_match(qos_specs, searchdict):
            for k, v in searchdict.iteritems():
                if ((k not in qos_specs['specs'].keys() or
                     qos_specs['specs'][k] != v)):
                    return False
            return True

        # search_option to filter_name mapping.
        filter_mapping = {'qos_specs': _check_specs_match}

        result = {}
        for name, args in qos_specs.iteritems():
            # go over all filters in the list
            for opt, values in search_opts.iteritems():
                try:
                    filter_func = filter_mapping[opt]
                except KeyError:
                    # no such filter - ignore it, go to next filter
                    continue
                else:
                    if filter_func(args, values):
                        result[name] = args
                        break
        qos_specs = result
    return qos_specs
Exemplo n.º 10
0
def get_all_specs(context, inactive=False, search_opts=None):
    """Get all non-deleted qos specs.

    Pass inactive=True as argument and deleted volume types would return
    as well.
    """
    search_opts = search_opts or {}
    qos_specs = db.qos_specs_get_all(context, inactive)

    if search_opts:
        LOG.debug("Searching by: %s" % search_opts)

        def _check_specs_match(qos_specs, searchdict):
            for k, v in searchdict.iteritems():
                if ((k not in qos_specs['specs'].keys()
                     or qos_specs['specs'][k] != v)):
                    return False
            return True

        # search_option to filter_name mapping.
        filter_mapping = {'qos_specs': _check_specs_match}

        result = {}
        for name, args in qos_specs.iteritems():
            # go over all filters in the list
            for opt, values in search_opts.iteritems():
                try:
                    filter_func = filter_mapping[opt]
                except KeyError:
                    # no such filter - ignore it, go to next filter
                    continue
                else:
                    if filter_func(args, values):
                        result[name] = args
                        break
        qos_specs = result
    return qos_specs
Exemplo n.º 11
0
    def test_qos_specs_get_all(self):
        value1 = dict(consumer="front-end", key1="v1", key2="v2")
        value2 = dict(consumer="back-end", key3="v3", key4="v4")
        value3 = dict(consumer="back-end", key5="v5", key6="v6")

        spec_id1 = self._create_qos_specs("Name1", value1)
        spec_id2 = self._create_qos_specs("Name2", value2)
        spec_id3 = self._create_qos_specs("Name3", value3)

        specs = db.qos_specs_get_all(self.ctxt)
        self.assertEqual(len(specs), 3, "Unexpected number of qos specs records")

        expected1 = dict(name="Name1", id=spec_id1, consumer="front-end")
        expected2 = dict(name="Name2", id=spec_id2, consumer="back-end")
        expected3 = dict(name="Name3", id=spec_id3, consumer="back-end")
        del value1["consumer"]
        del value2["consumer"]
        del value3["consumer"]
        expected1.update(dict(specs=value1))
        expected2.update(dict(specs=value2))
        expected3.update(dict(specs=value3))
        self.assertIn(expected1, specs)
        self.assertIn(expected2, specs)
        self.assertIn(expected3, specs)
Exemplo n.º 12
0
 def get_all(cls, context, *args, **kwargs):
     specs = db.qos_specs_get_all(context, *args, **kwargs)
     return base.obj_make_list(context, cls(context),
                               objects.QualityOfServiceSpecs, specs)
Exemplo n.º 13
0
 def get_all(cls, context, *args, **kwargs):
     specs = db.qos_specs_get_all(context, *args, **kwargs)
     return base.obj_make_list(context, cls(context),
                               objects.QualityOfServiceSpecs, specs)