def test_volume_type_create_then_destroy(self): """Ensure volume types can be created and deleted""" prev_all_vtypes = volume_types.get_all_types(self.ctxt) volume_types.create(self.ctxt, self.vol_type1_name, self.vol_type1_specs) new = volume_types.get_volume_type_by_name(self.ctxt, self.vol_type1_name) LOG.info(_("Given data: %s"), self.vol_type1_specs) LOG.info(_("Result data: %s"), new) for k, v in self.vol_type1_specs.iteritems(): self.assertEqual(v, new['extra_specs'][k], 'one of fields doesnt match') new_all_vtypes = volume_types.get_all_types(self.ctxt) self.assertEqual( len(prev_all_vtypes) + 1, len(new_all_vtypes), 'drive type was not created') volume_types.destroy(self.ctxt, self.vol_type1_name) new_all_vtypes = volume_types.get_all_types(self.ctxt) self.assertEqual(prev_all_vtypes, new_all_vtypes, 'drive type was not deleted')
def test_volume_type_create_then_purge(self): """Ensure volume types can be created and deleted""" prev_all_vtypes = volume_types.get_all_types(self.ctxt, inactive=1) volume_types.create(self.ctxt, self.vol_type1_name, self.vol_type1_specs) new = volume_types.get_volume_type_by_name(self.ctxt, self.vol_type1_name) for k, v in self.vol_type1_specs.iteritems(): self.assertEqual(v, new['extra_specs'][k], 'one of fields doesnt match') new_all_vtypes = volume_types.get_all_types(self.ctxt, inactive=1) self.assertEqual( len(prev_all_vtypes) + 1, len(new_all_vtypes), 'drive type was not created') volume_types.destroy(self.ctxt, self.vol_type1_name) new_all_vtypes2 = volume_types.get_all_types(self.ctxt, inactive=1) self.assertEqual(len(new_all_vtypes), len(new_all_vtypes2), 'drive type was incorrectly deleted') volume_types.purge(self.ctxt, self.vol_type1_name) new_all_vtypes2 = volume_types.get_all_types(self.ctxt, inactive=1) self.assertEqual( len(new_all_vtypes) - 1, len(new_all_vtypes2), 'drive type was not purged')
def test_volume_type_search_by_extra_spec(self): """Ensure volume types get by extra spec returns correct type""" volume_types.create(self.ctxt, "type1", {"key1": "val1", "key2": "val2"}) volume_types.create(self.ctxt, "type2", {"key2": "val2", "key3": "val3"}) volume_types.create(self.ctxt, "type3", {"key3": "another_value", "key4": "val4"}) vol_types = volume_types.get_all_types(self.ctxt, search_opts={'extra_specs': {"key1": "val1"}}) LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 1) self.assertTrue("type1" in vol_types.keys()) self.assertEqual(vol_types['type1']['extra_specs'], {"key1": "val1", "key2": "val2"}) vol_types = volume_types.get_all_types(self.ctxt, search_opts={'extra_specs': {"key2": "val2"}}) LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 2) self.assertTrue("type1" in vol_types.keys()) self.assertTrue("type2" in vol_types.keys()) vol_types = volume_types.get_all_types(self.ctxt, search_opts={'extra_specs': {"key3": "val3"}}) LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 1) self.assertTrue("type2" in vol_types.keys())
def test_get_all_volume_types(self): """Ensures that all volume types can be retrieved""" session = get_session() total_volume_types = session.query(models.VolumeTypes).\ count() vol_types = volume_types.get_all_types(self.ctxt) self.assertEqual(total_volume_types, len(vol_types))
def index(self, req): """ Returns the list of volume types """ context = req.environ['nova.context'] return volume_types.get_all_types(context)
def index(self, req): """ Returns the list of volume types """ context = req.environ['nova.context'] authorize(context) return {'volume_types': volume_types.get_all_types(context).values()}
def index(self, req): """ Returns the list of volume types """ context = req.environ['nova.context'] vol_types = volume_types.get_all_types(context).values() return self._view_builder.index(req, vol_types)