<div dir="auto">Hi, <div dir="auto"><br></div><div dir="auto">Agree with the simplicity that Renat has shown. I would not want to change the base class as well as the way of mistral created up to now. </div><div dir="auto"><br></div><div dir="auto">Br, </div><div dir="auto"><br></div><div dir="auto">Tuan/Nokia </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 14, 2017 6:29 AM, "Renat Akhmerov" <<a href="mailto:renat.akhmerov@gmail.com">renat.akhmerov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">So again, I’m for simplicity but that kind of simplicity that also allows flexibility in the future.<div><br></div><div>There’s one principle that I usually follow in programming that says:</div><div><br></div><div>“<i>Space around code (absence of code) has more potential than the code itself.</i>”</div><div><br></div><div>That means that it’s better to get rid of any stuff that’s not currently needed and add things</div><div>as requirements change. However, that doesn’t always work well in framework development</div><div>because the cost of initial inflexibility may become too high in future, that comes from the</div><div>need to stay backwards compatible. What I’m trying to say is that IMO it’s ok just to keep</div><div>it as simple as just a base class with method run() for now and think how we can add more</div><div>things in the future, if we need to, using mixin approach. So seems like it’s going to be:</div><div><br></div><div>class Action(object):</div><div><br></div><div> def run(ctx):</div><div> …</div><div><br></div><div><br></div><div>class Mixin1(object):</div><div> </div><div> def method11():</div><div> …</div><div><br></div><div><div> def method12():</div><div> …</div></div><div><br></div><div><br></div><div><div>class Mixin2(object):</div><div> </div><div> def method21():</div><div> …</div><div><br></div></div><div><div> def method22():</div><div> …</div></div><div><br></div><div><br></div><div>Then my concrete action could use a combination of Action and any of the mixin:</div><div><br></div><div>class MyAction(Action, Mixin1):</div><div> …</div><div><br></div><div><br></div><div><div>class MyAction(Action, Mixin2):</div><div> …</div></div><div><br></div><div>or just</div><div><br></div><div><br></div><div><div>class MyAction(Action):</div><div> …</div></div><div><br></div><div>Is this flexible enough or does it have any potential issues?</div><div><br></div><div>IMO, base class is still needed to define the contract that all actions should follow. So that</div><div>a runner knew what’s possible to do with actions.</div><div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div>Renat Akhmerov</div><div>@Nokia</div></div>
</div>
<br><div><blockquote type="cite"><div>On 13 Mar 2017, at 16:49, lương hữu tuấn <<a href="mailto:tuantuluong@gmail.com" target="_blank">tuantuluong@gmail.com</a>> wrote:</div><br class="m_-8383025133064418651Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 13, 2017 at 9:34 AM, Thomas Herve <span dir="ltr"><<a href="mailto:therve@redhat.com" target="_blank">therve@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Fri, Mar 10, 2017 at 9:52 PM, Ryan Brady <<a href="mailto:rbrady@redhat.com" target="_blank">rbrady@redhat.com</a>> wrote:<br>
><br>
> One of the pain points for me as an action developer is the OpenStack<br>
> actions[1]. Since they all use the same method name to retrieve the<br>
> underlying client, you cannot simply inherit from more than one so you are<br>
> forced to rewrite the client access methods. We saw this in creating<br>
> actions for TripleO[2]. In the base action in TripleO, we have actions that<br>
> make calls to more than one OpenStack client and so we end up re-writing and<br>
> maintaining code. IMO the idea of using multiple inheritance there would be<br>
> helpful. It may not require the mixin approach here, but rather a design<br>
> change in the generator to ensure the method names don't match.<br>
<br>
</span>Is there any reason why those methods aren't functions? AFAICT they<br>
don't use the instance, they could live top level in the action module<br>
and be accessible by all actions. If you can avoid multiple<br>
inheritance (or inheritance!) you'll simplify the design. You could<br>
also do client = NovaAction().get_client() in your own action (if<br>
get_client was a public method).<br>
<span class="m_-8383025133064418651HOEnZb"><font color="#888888"><br>
--<br>
Thomas<br>
</font></span><div class="m_-8383025133064418651HOEnZb"><div class="m_-8383025133064418651h5"><br></div></div></blockquote><div>If you want to do that, you need to change the whole structure of base action and the whole way of creating an action</div><div>as you have described and IMHO, i myself do not like this idea:<br><br>1. Mistral is working well (at the standpoint of creating action) and changing it is not a short term work.</div><div>2. Using base class to create base action is actually a good idea in order to control and make easy to action developers. </div><div>The base class will define the whole mechanism to execute an action, developers do not need to take care of it, just only</div><div>providing OpenStack clients (the _create_client() method).</div><div>3. From the #2 point of view, the alternative to NovaAction().get_client() does not make sense since the problem here is subclass mechanism,</div><div>not the way to call get_client().<br><br>@Renat: I myself not against to multiple inheritance too, the only thing is if we want to make it multiple inheritance, we should think about it more thoroughly for the hierarchy of inheritance, what each inheritance layer does, etc. These work will make the multiple inheritance easy to understand and for action developers as well easy to develop. So, IMHO, i vote for make it simple, easy to understand first (if you continue with mistral-lib) and then do the next thing later.<br></div><div><br></div><div>Br,</div><div><br></div><div>Tuan/Nokia</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-8383025133064418651HOEnZb"><div class="m_-8383025133064418651h5">
______________________________<wbr>______________________________<wbr>______________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org/?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.op<wbr>enstack.org?subject:unsubscrib<wbr>e</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/cgi<wbr>-bin/mailman/listinfo/openstac<wbr>k-dev</a><br>
</div></div></blockquote></div><br></div></div>
______________________________<wbr>______________________________<wbr>______________<br>OpenStack Development Mailing List (not for usage questions)<br>Unsubscribe: <a href="mailto:OpenStack-dev-request@lists.openstack.org" target="_blank">OpenStack-dev-request@lists.<wbr>openstack.org</a>?subject:<wbr>unsubscribe<br><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/<wbr>cgi-bin/mailman/listinfo/<wbr>openstack-dev</a><br></div></blockquote></div><br></div></div></div><br>______________________________<wbr>______________________________<wbr>______________<br>
OpenStack Development Mailing List (not for usage questions)<br>
Unsubscribe: <a href="http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe" rel="noreferrer" target="_blank">OpenStack-dev-request@lists.<wbr>openstack.org?subject:<wbr>unsubscribe</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" rel="noreferrer" target="_blank">http://lists.openstack.org/<wbr>cgi-bin/mailman/listinfo/<wbr>openstack-dev</a><br>
<br></blockquote></div></div>