devstack neutron problem

When you meet the following error when starting devtsack with neutron, add “enable_service q-lbaas” in your localrc.

Error:

   mod = imp.load_source(module_id, path, fp)
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 105, in
    run_migrations_online()
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/env.py", line 89, in run_migrations_online
    options=build_options())
  File "", line 7, in run_migrations
  File "/usr/local/lib/python2.7/dist-packages/alembic/environment.py", line 652, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/usr/local/lib/python2.7/dist-packages/alembic/migration.py", line 225, in run_migrations
    change(**kw)
  File "/opt/stack/neutron/neutron/db/migration/alembic_migrations/versions/1fcfc149aca4_agents_unique_by_type_and_host.py", line 50, in upgrade
    local_cols=['agent_type', 'host']
  File "", line 7, in create_unique_constraint
  File "/usr/local/lib/python2.7/dist-packages/alembic/operations.py", line 544, in create_unique_constraint
    schema=schema, **kw)
  File "/usr/local/lib/python2.7/dist-packages/alembic/ddl/impl.py", line 135, in add_constraint
    self._exec(schema.AddConstraint(const))
  File "/usr/local/lib/python2.7/dist-packages/alembic/ddl/impl.py", line 76, in _exec
    conn.execute(construct, *multiparams, **params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute
    params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1542, in _execute_ddl
    compiled
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1698, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1691, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 331, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1146, "Table 'neutron_ml2.agents' doesn't exist") 'ALTER TABLE agents ADD CONSTRAINT uniq_agents0agent_type0host UNIQUE (agent_type, host)' ()
++ failed
++ local r=1
+++ jobs -p
++ kill
++ set +o xtrace

My localrc

DATABASE_PASSWORD=123456
RABBIT_PASSWORD=123456
SERVICE_TOKEN=123456
SERVICE_PASSWORD=123456
ADMIN_PASSWORD=123456

disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service neutron
enable_service q-lbaas
# Optional, to enable tempest configuration as part of devstack
#enable_service tempest

After the fix, my neutron is running

/root>keystone service-list
+----------------------------------+----------+-----------+---------------------------+
|                id                |   name   |    type   |        description        |
+----------------------------------+----------+-----------+---------------------------+
| 4a20abbac9144556b24a09b1f49d537e |  cinder  |  volumev2 |  Cinder Volume Service V2 |
| 5de3083f702647b7bdee345170d625c5 |  cinder  |   volume  |   Cinder Volume Service   |
| 7061e82a8ee64dfe93a6350830a0a2b8 |   ec2    |    ec2    |  EC2 Compatibility Layer  |
| f540e854d72647e59cdf5519cbc1c5d4 |  glance  |   image   |    Glance Image Service   |
| 31a825f0b21c472b80d7d2d388ffbe5b | keystone |  identity | Keystone Identity Service |
| cc14b963113149fba3606ff413334128 | neutron  |  network  |      Neutron Service      |
| 15c3204709884e638478f835dc0ed6fb |   nova   |  compute  |    Nova Compute Service   |
| e36c8a8f06a742ffb1e336fc04d4fd69 |   nova   | computev3 |  Nova Compute Service V3  |
| bfba1eafd5e9411484e587a736017ddf |    s3    |     s3    |             S3            |
+----------------------------------+----------+-----------+---------------------------+
/root>keystone endpoint-list
+----------------------------------+-----------+--------------------------------------------+--------------------------------------------+--------------------------------------------+----------------------------------+
|                id                |   region  |                 publicurl                  |                internalurl                 |                  adminurl                  |            service_id            |
+----------------------------------+-----------+--------------------------------------------+--------------------------------------------+--------------------------------------------+----------------------------------+
| 21c0fa2efe5d4b948c8e67adcc229508 | RegionOne |         http://192.168.100.9:3333          |         http://192.168.100.9:3333          |         http://192.168.100.9:3333          | bfba1eafd5e9411484e587a736017ddf |
| 2e8ed4da5dfc46909c581efa5624fa72 | RegionOne | http://192.168.100.9:8776/v1/$(tenant_id)s | http://192.168.100.9:8776/v1/$(tenant_id)s | http://192.168.100.9:8776/v1/$(tenant_id)s | 5de3083f702647b7bdee345170d625c5 |
| 3ca0ce043a394668b94590cc37f9ff20 | RegionOne |  http://192.168.100.9:8773/services/Cloud  |  http://192.168.100.9:8773/services/Cloud  |  http://192.168.100.9:8773/services/Admin  | 7061e82a8ee64dfe93a6350830a0a2b8 |
| 6fcc13f5dffa495795928c09f9992058 | RegionOne |         http://192.168.100.9:9696/         |         http://192.168.100.9:9696/         |         http://192.168.100.9:9696/         | cc14b963113149fba3606ff413334128 |
| 7b7fe89091c34b31a85dcbb7c272c6fa | RegionOne |         http://192.168.100.9:9292          |         http://192.168.100.9:9292          |         http://192.168.100.9:9292          | f540e854d72647e59cdf5519cbc1c5d4 |
| 8d7541779f484af193b95626639fac07 | RegionOne |        http://192.168.100.9:8774/v3        |        http://192.168.100.9:8774/v3        |        http://192.168.100.9:8774/v3        | e36c8a8f06a742ffb1e336fc04d4fd69 |
| a237ad3aa87b440fb20a7440b3aa1979 | RegionOne | http://192.168.100.9:8776/v2/$(tenant_id)s | http://192.168.100.9:8776/v2/$(tenant_id)s | http://192.168.100.9:8776/v2/$(tenant_id)s | 4a20abbac9144556b24a09b1f49d537e |
| a5147a55c5a444f4936accf5f8639dc1 | RegionOne |       http://192.168.100.9:5000/v2.0       |       http://192.168.100.9:5000/v2.0       |      http://192.168.100.9:35357/v2.0       | 31a825f0b21c472b80d7d2d388ffbe5b |
| d13e9a6a79784eb2b37a311dc507bfe4 | RegionOne | http://192.168.100.9:8774/v2/$(tenant_id)s | http://192.168.100.9:8774/v2/$(tenant_id)s | http://192.168.100.9:8774/v2/$(tenant_id)s | 15c3204709884e638478f835dc0ed6fb |
+----------------------------------+-----------+--------------------------------------------+--------------------------------------------+--------------------------------------------+----------------------------------+