Final versioning for 2012.1

Change-Id: I4627bc046b8d559921536336ea4483129e0e0a36
API docs: fix typo for network delete

bug 962282

Change-Id: Ic7f633b59d963e8a14a993468048ccbded9aba34
bug 963152: add a few missing files to sdist tarball

Change-Id: I36e98c98e09c8a91f1e2e2e15f833079ea6b377c
Merge "bug 963152: add a few missing files to sdist tarball" into milestone-proposed
fix issue with OVS plugin VLAN allocation after a quantum-server restart

bug 962853

Also use constants for VLAN_MIN/VLAN_MAX and clean-up VlanMap unit tests.

Change-Id: Id7b580d604092b5fc16d4c87ae866d419aad4d1f
plugin/ryu: ryu.ini: introduce configuration to specify ip for gre tunneling

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu: db/model: added tables that is necessary for gre tunnel

new tables are introduced which will be used by gre tunnel support.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu/db/api: v2: db api for gre tunnel support

helper functions for new tables for gre support.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu/ovs_quantum_plugin_base: add more hooks for plugin driver

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu: plugin v2 for gre tunnel

teach ryu plugin mac addresses and tunnel ports.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu: agent: gre tunneling support

- gre tunnel support
- Check openflow port no. OVS may return -1 as openflow port when
  there is something wrong with the port.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugin/ryu/nova/linux_net, vif: teach them gre tunnel. mac address

NOTE: linux_net: always gateway. don't drop the packet.
      prevent plugins/ryu/nova/linux_net from installing undesired flows.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugins/ryu/db/api: fix exception

This patch fixes the following exception.

2012-04-06 14:42:50 DEBUG nova.network.quantum.quantum_connection [req-fe4ad405-54cb-46da-b2c6-5164e47a91fc None None] Quantum Client Reply (code = 500) :
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib/python2.7/dist-packages/paste/urlmap.py", line 203, in __call__
    return app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.7/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/pymodules/python2.7/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/opt/stack/quantum/quantum/wsgi.py", line 748, in __call__
    action_result = self.dispatch(request, action, args)
  File "/opt/stack/quantum/quantum/wsgi.py", line 780, in dispatch
    return controller_method(request=request, **action_args)
  File "/opt/stack/quantum/quantum/api/api_common.py", line 108, in the_func
    return func(*args, **kwargs)
  File "/opt/stack/quantum/quantum/api/networks.py", line 134, in create
    **body)
  File "/opt/stack/quantum/quantum/plugins/ryu/ovs_quantum_plugin_base.py", line 104, in create_network
    self.driver.create_network(net)
  File "/opt/stack/quantum/quantum/plugins/ryu/ryu_quantum_plugin.py", line 76, in create_network
    tunnel_key = ryu_db.tunnel_key_allocate(net.uuid)
  File "/opt/stack/quantum/quantum/plugins/ryu/db/api.py", line 171, in tunnel_key_allocate
    last_key = _tunnel_key_last(session)
  File "/opt/stack/quantum/quantum/plugins/ryu/db/api.py", line 120, in _tunnel_key_last
    session.query(models.TunnelKeyLast).all().delete()
AttributeError: 'list' object has no attribute 'delete'

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugins/ryu/nova/linux_net: typo. s/tenant_id/net_tenant_id/g

This patch fixes the following exception.

TRACE nova.rpc.amqp Traceback (most recent call last):
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/rpc/amqp.py", line 252, in _process_data
TRACE nova.rpc.amqp     rval = node_func(context=ctxt, **node_args)
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/network/quantum/manager.py", line 366, in allocate_for_instance
TRACE nova.rpc.amqp     vif_rec, network['net_tenant_id'])
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/utils.py", line 947, in inner
TRACE nova.rpc.amqp     retval = f(*args, **kwargs)
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/network/quantum/manager.py", line 472, in enable_dhcp
TRACE nova.rpc.amqp     self.l3driver.initialize_gateway(network_ref)
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/network/l3.py", line 98, in initialize_gateway
TRACE nova.rpc.amqp     gateway=(network_ref['gateway'] is not None))
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/network/linux_net.py", line 898, in plug
TRACE nova.rpc.amqp     return _get_interface_driver().plug(network, mac_address, gateway)
TRACE nova.rpc.amqp   File "/opt/stack/quantum/quantum/plugins/ryu/nova/linux_net.py", line 77, in plug
TRACE nova.rpc.amqp     self._set_port_state(network, dev, body)
TRACE nova.rpc.amqp   File "/opt/stack/quantum/quantum/plugins/ryu/nova/linux_net.py", line 57, in _set_port_state
TRACE nova.rpc.amqp     tenant_id = network['tenant_id']
TRACE nova.rpc.amqp   File "/opt/stack/nova/nova/db/sqlalchemy/models.py", line 75, in __getitem__
TRACE nova.rpc.amqp     return getattr(self, key)
TRACE nova.rpc.amqp AttributeError: 'Network' object has no attribute 'tenant_id'
TRACE nova.rpc.amqp

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
plugins/ryu/agent: fix exception

plugins/ryu/agent: fix exception

When starting up, the network is expected to be created by quantum server.
However there is a race between quantum server startup and quantum agent
startup. So have agent also make the network.

Traceback (most recent call last):
  File "/opt/stack/quantum/quantum/plugins/ryu/agent/ryu_quantum_agent.py", line 540, in <module>
    main()
  File "/opt/stack/quantum/quantum/plugins/ryu/agent/ryu_quantum_agent.py", line 534, in main
    plugin.daemon_loop()
  File "/opt/stack/quantum/quantum/plugins/ryu/agent/ryu_quantum_agent.py", line 490, in daemon_loop
    self.gre_ports.update()
  File "/opt/stack/quantum/quantum/plugins/ryu/agent/ryu_quantum_agent.py", line 367, in update
    self._add_port(node)
  File "/opt/stack/quantum/quantum/plugins/ryu/agent/ryu_quantum_agent.py", line 344, in _add_port
    self.int_br.datapath_id, ofport)
  File "/opt/stack/ryu/ryu/app/client.py", line 91, in create_port
    self._do_request('POST', self.path_port % (network_id, dpid, port))
  File "/opt/stack/ryu/ryu/app/client.py", line 55, in _do_request
    res.getheaders(), res.read())
httplib.HTTPException: (<httplib.HTTPResponse instance at 0x25e7a28>, 'code 404 reason Resource not found', [('date', 'Tue, 10 Apr 2012 02:26:03 GMT'), ('content-length', '466'), ('content-type', 'application/json')], '{"displayError": "The server does not have data for the request.", "error": "You submitted the following request.\\n\\n    POST /v1.0/networks/__NW_ID_VPORT_GRE__/00004e7f48e36243_\\n\\nThis request is not valid. The following paths were evaluated and failed\\nfor the indicated reason.\\n\\n    - /networks/{network-id}/{dpid}_{port-id}\\n      Invalid format: 00004e7f48e36243_\\n\\nYou can get a list of all valid requests with the following request.\\n\\n    GET /v1.0/doc"}')

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Fix sqlalchemy operational error

This is a workaround for the following error.

Traceback (most recent call last):
  File "/opt/stack/quantum/bin/quantum-server", line 24, in <module>
    server()
  File "/opt/stack/quantum/quantum/server/__init__.py", line 58, in main
    args=args)
  File "/opt/stack/quantum/quantum/service.py", line 98, in serve_wsgi
    service.start()
  File "/opt/stack/quantum/quantum/service.py", line 43, in start
    self.wsgi_app = _run_wsgi(self.app_name, self.conf, self.conf_file)
  File "/opt/stack/quantum/quantum/service.py", line 107, in _run_wsgi
    None)
  File "/opt/stack/python-quantumclient/quantum/common/config.py", line 319, in load_paste_app
    app = deploy.loadapp("config:%s" % conf_file, name=app_name)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/paste/urlmap.py", line 25, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 203, in invoke
    app = context.app_context.create()
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/usr/lib/python2.7/dist-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/opt/stack/quantum/quantum/wsgi.py", line 639, in factory
    return cls()
  File "/opt/stack/quantum/quantum/api/__init__.py", line 46, in __init__
    self._setup_routes(mapper, options)
  File "/opt/stack/quantum/quantum/api/__init__.py", line 53, in _setup_routes
    self._setup_base_routes(mapper, options, self._version)
  File "/opt/stack/quantum/quantum/api/__init__.py", line 60, in _setup_base_routes
    plugin = manager.QuantumManager.get_plugin(options)
  File "/opt/stack/quantum/quantum/manager.py", line 87, in get_plugin
    cls._instance = cls(options, config_file)
  File "/opt/stack/quantum/quantum/manager.py", line 82, in __init__
    self.plugin = plugin_klass()
  File "/opt/stack/quantum/quantum/plugins/ryu/ryu_quantum_plugin.py", line 119, in __init__
    super(RyuQuantumPlugin, self).__init__(CONF_FILE, __file__, configfile)
  File "/opt/stack/quantum/quantum/plugins/ryu/ovs_quantum_plugin_base.py", line 78, in __init__
    db.configure_db(options)
  File "/opt/stack/quantum/quantum/db/api.py", line 78, in configure_db
    register_models()
  File "/opt/stack/quantum/quantum/db/api.py", line 103, in register_models
    BASE.metadata.create_all(_ENGINE)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 2515, in create_all
    tables=tables)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2234, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1904, in _run_visitor
    **kwargs).traverse_single(element)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 86, in traverse_single
    return meth(obj, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py", line 67, in visit_metadata
    self.traverse_single(table, create_ok=True)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 86, in traverse_single
    return meth(obj, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/ddl.py", line 86, in visit_table
    self.connection.execute(schema.CreateTable(table))
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1405, in execute
    params)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1496, in _execute_ddl
    compiled
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1646, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1639, in _execute_context
    context)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 330, 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.OperationalError: (OperationalError) (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key') '\nCREATE TABLE tunnel_key (\n\tnetwork_id VARCHAR(255) NOT NULL, \n\ttunnel_key INTEGER NOT NULL AUTO_INCREMENT, \n\tPRIMARY KEY (network_id, tunnel_key)\n)\n\n' ()
get tenant id from the instance dict to avoid a patch for nova.