<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 28, 2014 at 6:44 PM, Nader Lahouti <span dir="ltr"><<a href="mailto:nader.lahouti@gmail.com" target="_blank">nader.lahouti@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Mathieu,<div><br></div><div>Thanks a lot for your reply.</div><div><br></div><div>Even in the neutron/neutron/db/db_base_plugin_v2.py: create_network() passes network object:</div>
<div><pre><a name="1450b84c7704feec_911" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#911" target="_blank">911</a> <b>def</b> <a name="1450b84c7704feec_create_network"></a><a href="http://www.xrefs.info/neutron-icehouse-3/s?refs=create_network" target="_blank">create_network</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self" target="_blank">self</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context" target="_blank">context</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network" target="_blank">network</a>):
<a name="1450b84c7704feec_912" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#912" target="_blank">912</a> <span>"""Handle creation of a single network."""</span>
<a name="1450b84c7704feec_913" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#913" target="_blank">913</a> <span># single request processing</span>
<a name="1450b84c7704feec_914" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#914" target="_blank">914</a> n = <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network" target="_blank">network</a>[<span>'network'</span>] <b><<<<<<<<==== 'n' has all the network info (including extensions)</b>
<a name="1450b84c7704feec_915" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#915" target="_blank">915</a> <span># NOTE(jkoelker) Get the tenant_id outside of the session to avoid</span>
<a name="1450b84c7704feec_916" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#916" target="_blank">916</a> <span># unneeded db action if the operation raises</span>
<a name="1450b84c7704feec_917" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#917" target="_blank">917</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=tenant_id" target="_blank">tenant_id</a> = <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self" target="_blank">self</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#_get_tenant_id_for_create" target="_blank">_get_tenant_id_for_create</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context" target="_blank">context</a>, n)
<a name="1450b84c7704feec_918" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#918" target="_blank">918</a> <b>with</b> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context" target="_blank">context</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=session" target="_blank">session</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=begin" target="_blank">begin</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=subtransactions" target="_blank">subtransactions</a>=<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=True" target="_blank">True</a>):
<a name="1450b84c7704feec_919" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#919" target="_blank">919</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=args" target="_blank">args</a> = {<span>'tenant_id'</span>: <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=tenant_id" target="_blank">tenant_id</a>,
<a name="1450b84c7704feec_920" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#920" target="_blank">920</a> <span>'id'</span>: n.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=get" target="_blank">get</a>(<span>'id'</span>) <b>or</b> <a href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#uuidutils" target="_blank">uuidutils</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=generate_uuid" target="_blank">generate_uuid</a>(),
<a name="1450b84c7704feec_921" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#921" target="_blank">921</a> <span>'name'</span>: n[<span>'name'</span>],
<a name="1450b84c7704feec_922" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#922" target="_blank">922</a> <span>'admin_state_up'</span>: n[<span>'admin_state_up'</span>],
<a name="1450b84c7704feec_923" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#923" target="_blank">923</a> <span>'shared'</span>: n[<span>'shared'</span>],
<a name="1450b84c7704feec_924" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#924" target="_blank">924</a> <span>'status'</span>: n.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=get" target="_blank">get</a>(<span>'status'</span>, <a href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#constants" target="_blank">constants</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=NET_STATUS_ACTIVE" target="_blank">NET_STATUS_ACTIVE</a>)}
<a name="1450b84c7704feec_925" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#925" target="_blank">925</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network" target="_blank">network</a> = <a href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#models_v2" target="_blank">models_v2</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=Network" target="_blank">Network</a>(**<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=args" target="_blank">args</a>) <<<b style="font-family:arial">= 'network' does not include extensions.</b>
<a name="1450b84c7704feec_926" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#926" target="_blank">926</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context" target="_blank">context</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=session" target="_blank">session</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=add" target="_blank">add</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network" target="_blank">network</a>)
<a name="1450b84c7704feec_927" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#927" target="_blank">927</a> <b>return</b> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self" target="_blank">self</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#_make_network_dict" target="_blank">_make_network_dict</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network" target="_blank">network</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=process_extensions" target="_blank">process_extensions</a>=<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=False" target="_blank">False</a>)</pre>
</div><div class="gmail_extra">even if process_extensions set to True, we still have issue.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If using original_network, causes confusion can we add a new parameter and use it in mechanism driver?</div>
<div class="gmail_extra">Also haven't received any reply from <span style="font-family:arial,sans-serif;font-size:13px">salvotore.</span></div></div></blockquote><div><br></div><div>Yes, not re-using original_network would be my preference.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br></div><div class="gmail_extra">* Another issue with the Ml2Plugin regarding the extensions is that neutron api can fail as it cannot find any handler in the plugin for request such as get/update/create/delete.</div>
<div class="gmail_extra">
<p>For instance I added 'config_profile' as an extensions to network resource and get this error.</p><p>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource File </p><p>
"/opt/stack/neutron/neutron/api/v2/base.py", line 273, in index</p><p>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource ret</p><p>urn self._items(request, True, parent_id)</p>
<p>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource File </p><p><b>"/opt/stack/neutron/neutron/api/v2/base.py", line 226, in _items</b></p><p><b>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource obj_getter = getattr(self._plugin, self._plugin_handlers[self.LIST])</b></p>
<p><b>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource AttributeError: 'Ml2Plugin' object has no attribute 'get_config_profiles'</b></p><p>
</p><p><b>2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource</b> </p></div><div class="gmail_extra"><br></div><div class="gmail_extra">We need to add either (1) Make Ml2Plugin code aware of such an attribute (e.g. adding another base class, which may not be a good solution) or (2) make the changes in neutron/neutron/api/v2/base.py to understand if Ml2Plugin is supported then get the attributes from mechanism driver.</div>
<div class="gmail_extra">(3) any other idea?</div><div class="gmail_extra"><br></div><div class="gmail_extra">I already implemented (2) in my private repo, to fix this error.</div><div class="gmail_extra">Also, I have already opened a BP to for supporting extensions in MD, and if it is okay I can include the fix as part of that BP. </div>
</div></blockquote><div><br></div><div>Yes, we don't really have great support for extensions today, so fixing this in the context of making extensions work in general with ML2 and MechanismDrivers, this sounds great.</div>
<div><br></div><div>Thanks for taking this on,</div><div><br></div><div>Andre</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">
Thanks,</div><div class="gmail_extra">Nader.</div><div><div class="h5"><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 28, 2014 at 8:22 AM, Mathieu Rohon <span dir="ltr"><<a href="mailto:mathieu.rohon@gmail.com" target="_blank">mathieu.rohon@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
hi nader,<br>
<br>
I don't think this parameter could be used in this case. As andre said<br>
, tha original-network is usefull for update and delete commands. It<br>
would led to misunderstandings if we use this param in other cases,<br>
and particulary in create commands.<br>
I'm still thinking that the result of super(Ml2Plugin,<br>
self).create_network(context, network), should have network extension<br>
informations[1]. did you talk with salvotore about reverting his<br>
change and using another workaround?<br>
<br>
[1]<a href="https://answers.launchpad.net/neutron/+question/245773" target="_blank">https://answers.launchpad.net/neutron/+question/245773</a><br>
<span><font color="#888888"><br>
Mathieu<br>
</font></span><div><div><br>
On Thu, Mar 27, 2014 at 5:24 PM, Nader Lahouti <<a href="mailto:nader.lahouti@gmail.com" target="_blank">nader.lahouti@gmail.com</a>> wrote:<br>
> Hi Andre,<br>
><br>
> Thans for your reply.<br>
><br>
> There is no existing network. The scenario is for the first time that we<br>
> create a network with an extension. Consider, a mechanism driver adds an<br>
> attribute (through extensions) to the network resource. When user creates a<br>
> network, the attribute is set and it is present in the 'network' parameter,<br>
> when calling create_network() in Ml2Plugin.<br>
> But when create_network_pre/post_commit is called, the attribute won't be<br>
> available to the mechanism driver. Because the attribute is not included in<br>
> network object passed to MD - as I mentioned in previous email, the 'result'<br>
> does not have the new attribute.<br>
><br>
><br>
> Thanks,<br>
> Nader.<br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
><br>
> On Wed, Mar 26, 2014 at 3:52 PM, Andre Pech <<a href="mailto:apech@aristanetworks.com" target="_blank">apech@aristanetworks.com</a>><br>
> wrote:<br>
>><br>
>> Hi Nader,<br>
>><br>
>> When I wrote this, the intention was that original_network only really<br>
>> makes sense during an update_network call (ie when there's an existing<br>
>> network that you are modifying). In a create_network call, the assumption is<br>
>> that no network exists yet, so there is no "original network" to set.<br>
>><br>
>> Can you provide a bit more detail on the case where there's an existing<br>
>> network when create_network is called? Sorry, I didn't totally follow when<br>
>> this would happen.<br>
>><br>
>> Thanks<br>
>> Andre<br>
>><br>
>><br>
>> On Tue, Mar 25, 2014 at 8:45 AM, Nader Lahouti <<a href="mailto:nader.lahouti@gmail.com" target="_blank">nader.lahouti@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Hi All,<br>
>>><br>
>>> In the current Ml2Plugin code when 'create_network' is called, as shown<br>
>>> below:<br>
>>><br>
>>><br>
>>><br>
>>> def create_network(self, context, network)<br>
>>><br>
>>> net_data = network['network']<br>
>>><br>
>>> ...<br>
>>><br>
>>> session = context.session<br>
>>><br>
>>> with session.begin(subtransactions=True):<br>
>>><br>
>>> self._ensure_default_security_group(context, tenant_id)<br>
>>><br>
>>> result = super(Ml2Plugin, self).create_network(context,<br>
>>> network)<br>
>>><br>
>>> ...<br>
>>><br>
>>> mech_context = driver_context.NetworkContext(self, context,<br>
>>> result)<br>
>>><br>
>>> self.mechanism_manager.create_network_precommit(mech_context)<br>
>>><br>
>>> ...<br>
>>><br>
>>><br>
>>><br>
>>> the original_network parameter is not set (the default is None) when<br>
>>> instantiating NetworkContext, and as a result the mech_context has only the<br>
>>> value of network object returned from super(Ml2Plugin,<br>
>>> self).create_network().<br>
>>><br>
>>> This causes issue when a mechanism driver needs to use the original<br>
>>> network parameters (given to the create_network), specially when extension<br>
>>> is used for the network resources.<br>
>>><br>
>>> (The 'result' only has the network attributes without extension which is<br>
>>> used to set the '_network' in the NetwrokContext object).<br>
>>><br>
>>> Even using extension function registration using<br>
>>><br>
>>> db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs(...) won't<br>
>>> help as the network object that is passed to the registered function does<br>
>>> not include the extension parameters.<br>
>>><br>
>>><br>
>>> Is there any reason that the original_network is not set when<br>
>>> initializing the NetworkContext? Would that cause any issue to set it to<br>
>>> 'net_data' so that any mechanism driver can use original network parameters<br>
>>> as they are available when create_network is called?<br>
>>><br>
>>><br>
>>> Appreciate your comments.<br>
>>><br>
>>><br>
>>> Thanks,<br>
>>><br>
>>> Nader.<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> OpenStack-dev mailing list<br>
>>> <a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
>>> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> OpenStack-dev mailing list<br>
>> <a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
>> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> OpenStack-dev mailing list<br>
> <a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
> <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
><br>
<br>
_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
</div></div></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div>