diff options
| author | Ken Pepple <ken.pepple@gmail.com> | 2011-04-22 14:16:16 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-04-22 14:16:16 +0000 |
| commit | 8af2a2d720b97ef17565d57a9b8b028d449a9c84 (patch) | |
| tree | 35f6a6e53d07b90abdba5912e3f7a4fd36b61771 | |
| parent | f72bc1d675e3034882bf901c2fee0491d60ce638 (diff) | |
| parent | f710ad1e3fff16de696f608986f24bdc8ffc3f6b (diff) | |
clarifies error when trying to add duplicate instance_type names or flavorids via nova-manage instance_type
| -rwxr-xr-x | bin/nova-manage | 12 | ||||
| -rw-r--r-- | nova/compute/instance_types.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_instance_types.py | 9 |
3 files changed, 21 insertions, 4 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index 2c06767f1..c8230670a 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -826,11 +826,17 @@ class InstanceTypeCommands(object): instance_types.create(name, memory, vcpus, local_gb, flavorid, swap, rxtx_quota, rxtx_cap) except exception.InvalidInputException: - print "Must supply valid parameters to create instance type" + print "Must supply valid parameters to create instance_type" print e sys.exit(1) - except exception.DBError, e: - print "DB Error: %s" % e + except exception.ApiError, e: + print "\n\n" + print "\n%s" % e + print "Please ensure instance_type name and flavorid are unique." + print "To complete remove a instance_type, use the --purge flag:" + print "\n # nova-manage instance_type delete <name> --purge\n" + print "Currently defined instance_type names and flavorids:" + self.list("--all") sys.exit(2) except: print "Unknown error" diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index 98b4425c8..7e7198b96 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -56,7 +56,9 @@ def create(name, memory, vcpus, local_gb, flavorid, swap=0, rxtx_cap=rxtx_cap)) except exception.DBError, e: LOG.exception(_('DB error: %s') % e) - raise exception.ApiError(_("Cannot create instance type: %s") % name) + raise exception.ApiError(_("Cannot create instance_type with " + "name %(name)s and flavorid %(flavorid)s") + % locals()) def destroy(name): diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py index 5d6d5e1f4..dd7d0737e 100644 --- a/nova/tests/test_instance_types.py +++ b/nova/tests/test_instance_types.py @@ -88,3 +88,12 @@ class InstanceTypeTestCase(test.TestCase): """Ensures that instance type creation fails with invalid args""" self.assertRaises(exception.ApiError, instance_types.destroy, "sfsfsdfdfs") + + def test_repeated_inst_types_should_raise_api_error(self): + """Ensures that instance duplicates raises ApiError""" + new_name = self.name + "dup" + instance_types.create(new_name, 256, 1, 120, self.flavorid + 1) + instance_types.destroy(new_name) + self.assertRaises( + exception.ApiError, + instance_types.create, new_name, 256, 1, 120, self.flavorid) |
