<div dir="ltr"><div class="gmail_default" style="font-size:small">My preferences:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For where, I'd go with Gary's recommendation (A) for two reasons (1) Consistency and (2) I don't think it will create any boilerplate requirements since the abstract class provides the default implementation.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">For naming, I'd prefer to go with ML2 terminology for two reasons (1) Again Consistency, and (2) it is then clear what actions are happening within a transaction or outside of it. With a "validation function" no "transaction fence" is implied by it's name - but for any validation that depends on what currently exists in the database, these transaction semantics are important.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Regards,</div><div class="gmail_default" style="font-size:small">Mandeep</div><div class="gmail_default" style="font-size:small">
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 23, 2014 at 4:25 PM, Paul Michali (pcm) <span dir="ltr"><<a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Thanks for the comment Carl. See @PCM inline<div><br></div><div><div class=""><br><div>
<div><div>PCM (Paul Michali)</div><div><br></div><div>MAIL …..…. <a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a></div><div>IRC ……..… pcm_ (<a href="http://irc.freenode.com" target="_blank">irc.freenode.com</a>)</div>
<div>TW ………... @pmichali</div><div>GPG Key … 4525ECC253E31A83</div><div>Fingerprint .. 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83</div></div><div><br></div><br>
</div>
<br></div><div><div><div class="h5"><div>On May 23, 2014, at 6:09 PM, Carl Baldwin <<a href="mailto:carl@ecbaldwin.net" target="_blank">carl@ecbaldwin.net</a>> wrote:</div><br><blockquote type="cite"><div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Paul,<br><br>On Fri, May 23, 2014 at 8:24 AM, Paul Michali (pcm) <<a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a>> wrote:<br><blockquote type="cite">Hi,<br><br>I’m working on a task for a BP to separate validation from persistence logic<br>
in L3 services code (VPN currently), so that providers can override/extend<br>the validation logic (before persistence).<br><br>So I’ve separated the code for one of the create APIs, placed the default<br>validation into an ABC class (as a non-abstract method) that the service<br>
drivers inherit from, and modified the plugin to invoke the validation<br>function in the service driver, before doing the persistence step.<br><br>The flow goes like this…<br><br> def create_vpnservice(self, context, vpnservice):<br>
driver = self._get_driver_for_vpnservice(vpnservice)<br> driver.validate_create_vpnservice(context, vpnservice)<br> super(VPNDriverPlugin, self).create_vpnservice(context, vpnservice)<br> driver.apply_create_vpnservice(context, vpnservice)<br>
<br>If the service driver has a validation routine, it’ll be invoked, otherwise,<br>the default method in the ABC for the service driver will be called and will<br>handle the “baseline” validation. I also renamed the service driver method<br>
that is used for applying the changes to the device driver as apply_*<br>instead of using the same name as is used for persistence (e.g.<br>create_vpnservice -> apply_create_vpnservice).<br><br>The questions I have is…<br>
<br>1) Should I create new validation methods A) for every create (and update?)<br>API (regardless of whether they currently have any validation logic, B) for<br>resources that have some validation logic already, or C) only for resources<br>
where there are providers with different validation needs? I was thinking<br>(B), but would like to hear peoples’ thoughts.<br></blockquote><br>I think B. C may leave a little too much inconsistency. A feels like<br>extra boiler-plate. Would there be any benefit to creating a higher<br>
level abstraction for the create/update API calls? I'm not suggesting<br>you do so but if you did then you could add a validation method to<br>that interface with a default pass. Otherwise, I'd stick with B until<br>
there is a need for more.<br></div></blockquote><div><br></div></div></div>@PCM Yeah, there is somewhat of an abstraction. In VPN, for the service drivers, they all inherit from an ABC. For the apply, there are already abstract methods in the ABC, so that the service driver is forced to provide a function (of course it is inconsistent currently - they are there for VPN services, but not for IPSec connections, which are provided in the service driver). For the validation, I was creating methods in the ABC, with implementations, but not abstract, so that the service driver could provide a function, if it wanted to extend or override (and call super, if desired), or leave it out and the base class function would be used.</div>
<div><br></div><div>So, I guess it’s at two points, the validate and apply methods, where we should probably be consistent with providing base class methods for all that present in the service driver.</div><div><br></div>
<div><br></div><div><div class=""><blockquote type="cite"><div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br><blockquote type="cite">2) I’ve added validation_* and modified the other service driver call to<br>apply_*. Should I instead, use the ML2 terminology of pre commit_* and post<br>commit_*? I personally favor the former, as it is more descriptive of what<br>
is happening in the methods, but I understand the desire for consistency<br>with other code.<br></blockquote><br>I'm on the fence. ML2 is not where I'm most familiar and I don't know<br>the history behind that design. Without considering ML2 and<br>
consistency, I think I like your terminology better.<br></div></blockquote><div><br></div></div>@PCM I’m in the same camp. I don’t know ML2 well, and I like the explicit terminology. It *seems* like ML2 is dealing with this all at the same level of abstraction (pre-commit, commit, post-commit all for the same plugin or driver), whereas with L3 services, it is at two levels (validate at service driver and then plugin, commit at plugin, apply at service driver only). I guess I can leave it and see what happens at review…I have some asbestos here somewhere.</div>
<div><br></div><div><br></div><div><div class=""><blockquote type="cite"><div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br><blockquote type="cite">3) Should I create validation methods for code, where defaults are being set<br>for missing (optional) information? For example, VPN IKE Policy lifetime<br>being set to units=seconds, value=3600, if not set. Currently, provider<br>
implementations have same defaults, but could potentially use different<br>defaults. The alternative is to leave this in the persistence code and not<br>allow it to be changed. This could be deferred, if 1C is chosen above.<br>
</blockquote><br>I'm tempted to say punt on this until there is a need for it.<br></div></blockquote><div><br></div></div>@PCM I think you’re right. It may turn out to be YAGNI.</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div>PCM</div></font></span><div class=""><div><br></div><div><br><blockquote type="cite"><div style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br>Carl<br><br><blockquote type="cite">Looking forward to your thoughts...<br><br><br>Thanks!<br><br>PCM (Paul Michali)<br><br>MAIL …..….<span> </span><a href="mailto:pcm@cisco.com" target="_blank">pcm@cisco.com</a><br>IRC ……..… pcm_ (<a href="http://irc.freenode.com/" target="_blank">irc.freenode.com</a>)<br>
TW ………... @pmichali<br>GPG Key … 4525ECC253E31A83<br>Fingerprint .. 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83<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></blockquote><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></div>
</blockquote></div><br></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>