it possible to reuse the id of a deleted flavor but it's not possible to create a flavor with the name of a deleted one.
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-list
+-----+-----------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+-----+-----------+-----------+------+----------+-------+-------------+
| 100 | test | 100 | | 100 | 100 | 1.0 |
| 2 | m1.small | 2048 | | 10 | 1 | 1.0 |
| 3 | m1.medium | 4096 | | 10 | 2 | 1.0 |
| 4 | m1.large | 8192 | | 10 | 4 | 1.0 |
| 5 | m1.xlarge | 16384 | | 10 | 8 | 1.0 |
+-----+-----------+-----------+------+----------+-------+-------------+
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-delete 100
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 100 100 100 100
+-----+----------+-----------+------+----------+-------+-------------+
| ID | Name | Memory_MB | Swap | Local_GB | VCPUs | RXTX_Factor |
+-----+----------+-----------+------+----------+-------+-------------+
| 100 | testtest | 100 | | 100 | 100 | 1 |
+-----+----------+-----------+------+----------+-------+-------------+
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-delete 100
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 100 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create testtest 101 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
stack@devstack001:~/devstack$ nova --username admin --password testing flavor-create test 101 100 100 100
ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)
this is the stacktrace on nova-api:
2012-02-15 17:26:16,932 ERROR nova.exception [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] DB exception wrapped.
(nova.exception): TRACE: Traceback (most recent call last):
(nova.exception): TRACE: File "/opt/stack/nova/nova/exception.py", line 103, in _wrap
(nova.exception): TRACE: return f(*args, **kwargs)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1400, in flush
(nova.exception): TRACE: self._flush(objects)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 1481, in _flush
(nova.exception): TRACE: flush_context.execute()
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 302, in execute
(nova.exception): TRACE: rec.execute(self)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 446, in execute
(nova.exception): TRACE: uow
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 1887, in _save_obj
(nova.exception): TRACE: execute(statement, params)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1191, in execute
(nova.exception): TRACE: params)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
(nova.exception): TRACE: return self.__execute_context(context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
(nova.exception): TRACE: context.parameters[0], context=context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
(nova.exception): TRACE: context)
(nova.exception): TRACE: File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 299, in do_execute
(nova.exception): TRACE: cursor.execute(statement, parameters)
(nova.exception): TRACE: File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 174, in execute
(nova.exception): TRACE: self.errorhandler(self, exc, value)
(nova.exception): TRACE: File "/usr/lib/pymodules/python2.7/MySQLdb/connections.py", line 36, in defaulterrorhandler
(nova.exception): TRACE: raise errorclass, errorvalue
(nova.exception): TRACE: IntegrityError: (IntegrityError) (1062, "Duplicate entry 'test' for key 'instance_types_name_key'") 'INSERT INTO instance_types (created_at, updated_at, deleted_at, deleted, name, memory_mb, vcpus, root_gb, ephemeral_gb, flavorid, swap, rxtx_factor, vcpu_weight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2012, 2, 15, 16, 26, 16, 931158), None, None, 0, u'test', 100, 100, 100, 100, 101, 0, 1, None)
(nova.exception): TRACE:
2012-02-15 17:26:16,936 ERROR nova.compute.instance_types [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] DB error: (IntegrityError) (1062, "Duplicate entry 'test' for key 'instance_types_name_key'") 'INSERT INTO instance_types (created_at, updated_at, deleted_at, deleted, name, memory_mb, vcpus, root_gb, ephemeral_gb, flavorid, swap, rxtx_factor, vcpu_weight) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)' (datetime.datetime(2012, 2, 15, 16, 26, 16, 931158), None, None, 0, u'test', 100, 100, 100, 100, 101, 0, 1, None)
2012-02-15 17:26:16,937 ERROR nova.api.openstack [req-7a175400-9aa5-4272-ac17-8fa66ebaf1f3 4599637aa20740d2a59a2621948bcdea 0f0bbc8563a44a6a880c0c1ad85d5e79] Caught error: Unable to create instance type
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/__init__.py", line 41, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1053, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/request.py", line 1022, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 345, in __call__
(nova.api.openstack): TRACE: return self._forward_request(env, start_response, proxy_headers)
(nova.api.openstack): TRACE: File "/opt/stack/keystone/keystone/middleware/auth_token.py", line 608, in _forward_request
(nova.api.openstack): TRACE: return self.app(env, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.7/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 786, in __call__
(nova.api.openstack): TRACE: content_type, body, accept)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 834, in _process_stack
(nova.api.openstack): TRACE: action_result = self.dispatch(meth, request, action_args)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 910, in dispatch
(nova.api.openstack): TRACE: return method(req=request, **action_args)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/api/openstack/compute/contrib/flavormanage.py", line 71, in _create
(nova.api.openstack): TRACE: swap, rxtx_factor)
(nova.api.openstack): TRACE: File "/opt/stack/nova/nova/compute/instance_types.py", line 75, in create
(nova.api.openstack): TRACE: raise exception.InstanceTypeCreateFailed()
(nova.api.openstack): TRACE: InstanceTypeCreateFailed: Unable to create instance type
(nova.api.openstack): TRACE:
Can you verify your db type and the version of nova that you are using?
This migration is supposed to remove that key:
nova/db/ sqlalchemy/ migrate_ repo/versions/ 076_remove_ unique_ constraints. py
in my testing that constraint was called 'name' but it looks like for you it is called 'instance_ types_name_ key'
we might need to update migration 76 further.