Esempio n. 1
0
def destroy(context, id):
    """Marks volume types as deleted."""
    if id is None:
        msg = _("id cannot be None")
        raise exception.InvalidVolumeType(reason=msg)
    else:
        db.volume_type_destroy(context, id)
Esempio n. 2
0
def get_volume_type_by_name(context, name):
    """Retrieves single volume type by name."""
    if name is None:
        msg = _("name cannot be None")
        raise exception.InvalidVolumeType(reason=msg)

    return db.volume_type_get_by_name(context, name)
Esempio n. 3
0
def get_volume_type(ctxt, id):
    """Retrieves single volume type by id."""
    if id is None:
        msg = _("id cannot be None")
        raise exception.InvalidVolumeType(reason=msg)

    if ctxt is None:
        ctxt = context.get_admin_context()

    return db.volume_type_get(ctxt, id)
Esempio n. 4
0
 def test_invalid_volume_type(self):
     # Verify response code for exception.InvalidVolumeType
     reason = "fake_reason"
     e = exception.InvalidVolumeType(reason=reason)
     self.assertEqual(e.code, 400)
     self.assertIn(reason, e.msg)