Exemple #1
0
    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')
Exemple #2
0
    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')
Exemple #3
0
 def test_repeated_vol_types_should_raise_api_error(self):
     """Ensures that volume duplicates raises ApiError"""
     new_name = self.vol_type1_name + "dup"
     volume_types.create(self.ctxt, new_name)
     volume_types.destroy(self.ctxt, new_name)
     self.assertRaises(
             exception.ApiError,
             volume_types.create, self.ctxt, new_name)
    def delete(self, req, id):
        """ Deletes an existing volume type """
        context = req.environ['engine.context']

        try:
            vol_type = volume_types.get_volume_type(context, id)
            volume_types.destroy(context, vol_type['name'])
        except exception.NotFound:
            raise exc.HTTPNotFound()
Exemple #5
0
    def delete(self, req, id):
        """ Deletes an existing volume type """
        context = req.environ['engine.context']

        try:
            vol_type = volume_types.get_volume_type(context, id)
            volume_types.destroy(context, vol_type['name'])
        except exception.NotFound:
            raise exc.HTTPNotFound()