<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 class="" name="911" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#911">911</a> <b>def</b> <a class="" name="create_network"></a><a href="http://www.xrefs.info/neutron-icehouse-3/s?refs=create_network" class="">create_network</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self">self</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context">context</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network">network</a>):
<a class="" name="912" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#912">912</a> <span class="">"""Handle creation of a single network."""</span>
<a class="" name="913" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#913">913</a> <span class=""># single request processing</span>
<a class="" name="914" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#914">914</a> n = <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network">network</a>[<span class="">'network'</span>] <b><<<<<<<<==== 'n' has all the network info (including extensions)</b>
<a class="" name="915" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#915">915</a> <span class=""># NOTE(jkoelker) Get the tenant_id outside of the session to avoid</span>
<a class="" name="916" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#916">916</a> <span class=""># unneeded db action if the operation raises</span>
<a class="" name="917" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#917">917</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=tenant_id">tenant_id</a> = <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self">self</a>.<a class="" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#_get_tenant_id_for_create">_get_tenant_id_for_create</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context">context</a>, n)
<a class="" name="918" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#918">918</a> <b>with</b> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context">context</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=session">session</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=begin">begin</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=subtransactions">subtransactions</a>=<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=True">True</a>):
<a class="" name="919" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#919">919</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=args">args</a> = {<span class="">'tenant_id'</span>: <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=tenant_id">tenant_id</a>,
<a class="" name="920" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#920">920</a> <span class="">'id'</span>: n.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=get">get</a>(<span class="">'id'</span>) <b>or</b> <a class="" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#uuidutils">uuidutils</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=generate_uuid">generate_uuid</a>(),
<a class="" name="921" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#921">921</a> <span class="">'name'</span>: n[<span class="">'name'</span>],
<a class="" name="922" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#922">922</a> <span class="">'admin_state_up'</span>: n[<span class="">'admin_state_up'</span>],
<a class="" name="923" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#923">923</a> <span class="">'shared'</span>: n[<span class="">'shared'</span>],
<a class="" name="924" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#924">924</a> <span class="">'status'</span>: n.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=get">get</a>(<span class="">'status'</span>, <a class="" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#constants">constants</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=NET_STATUS_ACTIVE">NET_STATUS_ACTIVE</a>)}
<a class="" name="925" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#925">925</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network">network</a> = <a class="" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#models_v2">models_v2</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=Network">Network</a>(**<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=args">args</a>) <<<b style="font-family:arial">= 'network' does not include extensions.</b>
<a class="" name="926" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#926">926</a> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=context">context</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=session">session</a>.<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=add">add</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network">network</a>)
<a class="" name="927" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#927">927</a> <b>return</b> <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=self">self</a>.<a class="" href="http://www.xrefs.info/neutron-icehouse-3/xref/neutron/db/db_base_plugin_v2.py#_make_network_dict">_make_network_dict</a>(<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=network">network</a>, <a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=process_extensions">process_extensions</a>=<a href="http://www.xrefs.info/neutron-icehouse-3/s?defs=False">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 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 class="">For instance I added 'config_profile' as an extensions to network resource and get this error.</p><p class="">2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource File </p><p class="">
"/opt/stack/neutron/neutron/api/v2/base.py", line 273, in index</p><p class="">2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource ret</p><p class="">urn self._items(request, True, parent_id)</p>
<p class="">2014-03-28 12:27:02.495 TRACE resource.py: neutron.api.v2.resource File </p><p class=""><b>"/opt/stack/neutron/neutron/api/v2/base.py", line 226, in _items</b></p><p class=""><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 class=""><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 class="">
</p><p class=""><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 class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">
Thanks,</div><div class="gmail_extra">Nader.</div><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>