You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Alireza Eskandari <as...@gmail.com> on 2019/02/22 12:51:55 UTC
hook or callback for CloudStack API
Hi,
I'm looking for a solution to implement hooks or callbacks for CloudStack
API.
For example execute an script when user calls deployVirtualMachine API.
This script could be executed right after user submit his request or after
the request completed successfully or failed.
Maybe some API management solution could help me but the problem is
understanding CS asyncjobs and their status.
Thanks
Re: hook or callback for CloudStack API
Posted by Alireza Eskandari <as...@gmail.com>.
Thank you Ivan!
A novel solution based on existing capabilities!
I'll investigate is for our needs.
On Fri, Feb 22, 2019 at 4:49 PM Ivan Kudryavtsev <ku...@bw-sw.com>
wrote:
> Hi, Alireza. Easy solution is to use Kafka or RMQ event bus, which are
> supported by cloudstack.
>
> Take a look on the article in our blog:
>
> https://bitworks.software/en/2017-07-23-cloudstack-3rd-party-integration-events-subscription-kafka.html
>
> We use it very extensively for accounting, billing, DNS integration, etc.
>
> пт, 22 февр. 2019 г., 7:52 Alireza Eskandari astro.alireza@gmail.com:
>
> > Hi,
> > I'm looking for a solution to implement hooks or callbacks for CloudStack
> > API.
> > For example execute an script when user calls deployVirtualMachine API.
> > This script could be executed right after user submit his request or
> after
> > the request completed successfully or failed.
> > Maybe some API management solution could help me but the problem is
> > understanding CS asyncjobs and their status.
> > Thanks
> >
>
Re: hook or callback for CloudStack API
Posted by Ivan Kudryavtsev <ku...@bw-sw.com>.
Hi, Alireza. Easy solution is to use Kafka or RMQ event bus, which are
supported by cloudstack.
Take a look on the article in our blog:
https://bitworks.software/en/2017-07-23-cloudstack-3rd-party-integration-events-subscription-kafka.html
We use it very extensively for accounting, billing, DNS integration, etc.
пт, 22 февр. 2019 г., 7:52 Alireza Eskandari astro.alireza@gmail.com:
> Hi,
> I'm looking for a solution to implement hooks or callbacks for CloudStack
> API.
> For example execute an script when user calls deployVirtualMachine API.
> This script could be executed right after user submit his request or after
> the request completed successfully or failed.
> Maybe some API management solution could help me but the problem is
> understanding CS asyncjobs and their status.
> Thanks
>
Re: hook or callback for CloudStack API
Posted by Alireza Eskandari <as...@gmail.com>.
I'm using vmware
Some actions such as adding secondary ip doesn't trigger hypervisor hooks
On Mon, Feb 25, 2019, 12:31 Dag Sonstebo <Dag.Sonstebo@shapeblue.com wrote:
> Alireza - which hypervisor do you use? If you use KVM you can use libvirt
> hooks - https://libvirt.org/hooks.html.
>
> Regards,
> Dag Sonstebo
> Cloud Architect
> ShapeBlue
>
>
> On 23/02/2019, 15:27, "Suresh Kumar Anaparti" <
> sureshkumar.anaparti@gmail.com> wrote:
>
> Hi Alireza,
>
> Other approach I can think of is database triggers (can impact
> performance
> based on the jobs frequency).
>
> Take a look at the async_job table's insert and update operations
> which are
> performed on creating a new job (job status 0) and updated when job is
> complete with non-zero job status (1 - success, 2 - failed, 3 -
> cancelled)
> respectively.
>
> https://dev.mysql.com/doc/refman/5.6/en/faqs-triggers.html [a trigger
> could invoke the sys_exec() UDF.]
>
> Some ref for sys_exec UDF implementation below =>
> http://kedar.nitty-witty.com/blog/tag/sys_exec
>
> http://bernardodamele.blogspot.com/2009/01/command-execution-with-mysql-udf.html
>
> - Suresh
>
> On Sat, Feb 23, 2019 at 2:05 AM Alireza Eskandari <
> astro.alireza@gmail.com>
> wrote:
>
> > Async jobs is not my concern.
> > Imagine that you have a firewall that is not integrated with CS and
> you
> > want to insert new roles in it each time a new VM is created.
> > In this case you need a hook that triggers an external script to
> configure
> > the firewall.
> > Pulling is time and resource consuming and its effect is not instant.
> >
> > On Fri, Feb 22, 2019 at 8:02 PM Anurag Awasthi <
> > Anurag.Awasthi@shapeblue.com>
> > wrote:
> >
> > > Hi Alireza,
> > >
> > > Could you elaborate a more on the use case you have in mind? The
> > > description you mention is very generic.
> > >
> > > As far as I know we need to use polling to track the status of any
> async
> > > job (which is another API call) and execute based on response.
> That seems
> > > to be foundation principle behind all async calls. Alternately,
> you can
> > > also use CloudMonkey (
> > >
> >
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+cloudmonkey+CLI
> > )
> > > as a framework or dig a little into code there to implement a
> similar
> > > solution to execute hooks.
> > >
> > > Regards,
> > > Anurag
> > >
> > > On 2/22/19, 6:22 PM, "Alireza Eskandari" <as...@gmail.com>
> > wrote:
> > >
> > > Hi,
> > > I'm looking for a solution to implement hooks or callbacks for
> > > CloudStack
> > > API.
> > > For example execute an script when user calls
> deployVirtualMachine
> > API.
> > > This script could be executed right after user submit his
> request or
> > > after
> > > the request completed successfully or failed.
> > > Maybe some API management solution could help me but the
> problem is
> > > understanding CS asyncjobs and their status.
> > > Thanks
> > >
> > >
> > >
> > > Anurag.Awasthi@shapeblue.com
> > > www.shapeblue.com
> > > Amadeus House, Floral Street, London WC2E 9DPUK
> > > @shapeblue
> > >
> > >
> > >
> > >
> >
>
>
>
> Dag.Sonstebo@shapeblue.com
> www.shapeblue.com
> Amadeus House, Floral Street, London WC2E 9DPUK
> @shapeblue
>
>
>
>
Re: hook or callback for CloudStack API
Posted by Dag Sonstebo <Da...@shapeblue.com>.
Alireza - which hypervisor do you use? If you use KVM you can use libvirt hooks - https://libvirt.org/hooks.html.
Regards,
Dag Sonstebo
Cloud Architect
ShapeBlue
On 23/02/2019, 15:27, "Suresh Kumar Anaparti" <su...@gmail.com> wrote:
Hi Alireza,
Other approach I can think of is database triggers (can impact performance
based on the jobs frequency).
Take a look at the async_job table's insert and update operations which are
performed on creating a new job (job status 0) and updated when job is
complete with non-zero job status (1 - success, 2 - failed, 3 - cancelled)
respectively.
https://dev.mysql.com/doc/refman/5.6/en/faqs-triggers.html [a trigger
could invoke the sys_exec() UDF.]
Some ref for sys_exec UDF implementation below =>
http://kedar.nitty-witty.com/blog/tag/sys_exec
http://bernardodamele.blogspot.com/2009/01/command-execution-with-mysql-udf.html
- Suresh
On Sat, Feb 23, 2019 at 2:05 AM Alireza Eskandari <as...@gmail.com>
wrote:
> Async jobs is not my concern.
> Imagine that you have a firewall that is not integrated with CS and you
> want to insert new roles in it each time a new VM is created.
> In this case you need a hook that triggers an external script to configure
> the firewall.
> Pulling is time and resource consuming and its effect is not instant.
>
> On Fri, Feb 22, 2019 at 8:02 PM Anurag Awasthi <
> Anurag.Awasthi@shapeblue.com>
> wrote:
>
> > Hi Alireza,
> >
> > Could you elaborate a more on the use case you have in mind? The
> > description you mention is very generic.
> >
> > As far as I know we need to use polling to track the status of any async
> > job (which is another API call) and execute based on response. That seems
> > to be foundation principle behind all async calls. Alternately, you can
> > also use CloudMonkey (
> >
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+cloudmonkey+CLI
> )
> > as a framework or dig a little into code there to implement a similar
> > solution to execute hooks.
> >
> > Regards,
> > Anurag
> >
> > On 2/22/19, 6:22 PM, "Alireza Eskandari" <as...@gmail.com>
> wrote:
> >
> > Hi,
> > I'm looking for a solution to implement hooks or callbacks for
> > CloudStack
> > API.
> > For example execute an script when user calls deployVirtualMachine
> API.
> > This script could be executed right after user submit his request or
> > after
> > the request completed successfully or failed.
> > Maybe some API management solution could help me but the problem is
> > understanding CS asyncjobs and their status.
> > Thanks
> >
> >
> >
> > Anurag.Awasthi@shapeblue.com
> > www.shapeblue.com
> > Amadeus House, Floral Street, London WC2E 9DPUK
> > @shapeblue
> >
> >
> >
> >
>
Dag.Sonstebo@shapeblue.com
www.shapeblue.com
Amadeus House, Floral Street, London WC2E 9DPUK
@shapeblue
Re: hook or callback for CloudStack API
Posted by Suresh Kumar Anaparti <su...@gmail.com>.
Hi Alireza,
Other approach I can think of is database triggers (can impact performance
based on the jobs frequency).
Take a look at the async_job table's insert and update operations which are
performed on creating a new job (job status 0) and updated when job is
complete with non-zero job status (1 - success, 2 - failed, 3 - cancelled)
respectively.
https://dev.mysql.com/doc/refman/5.6/en/faqs-triggers.html [a trigger
could invoke the sys_exec() UDF.]
Some ref for sys_exec UDF implementation below =>
http://kedar.nitty-witty.com/blog/tag/sys_exec
http://bernardodamele.blogspot.com/2009/01/command-execution-with-mysql-udf.html
- Suresh
On Sat, Feb 23, 2019 at 2:05 AM Alireza Eskandari <as...@gmail.com>
wrote:
> Async jobs is not my concern.
> Imagine that you have a firewall that is not integrated with CS and you
> want to insert new roles in it each time a new VM is created.
> In this case you need a hook that triggers an external script to configure
> the firewall.
> Pulling is time and resource consuming and its effect is not instant.
>
> On Fri, Feb 22, 2019 at 8:02 PM Anurag Awasthi <
> Anurag.Awasthi@shapeblue.com>
> wrote:
>
> > Hi Alireza,
> >
> > Could you elaborate a more on the use case you have in mind? The
> > description you mention is very generic.
> >
> > As far as I know we need to use polling to track the status of any async
> > job (which is another API call) and execute based on response. That seems
> > to be foundation principle behind all async calls. Alternately, you can
> > also use CloudMonkey (
> >
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+cloudmonkey+CLI
> )
> > as a framework or dig a little into code there to implement a similar
> > solution to execute hooks.
> >
> > Regards,
> > Anurag
> >
> > On 2/22/19, 6:22 PM, "Alireza Eskandari" <as...@gmail.com>
> wrote:
> >
> > Hi,
> > I'm looking for a solution to implement hooks or callbacks for
> > CloudStack
> > API.
> > For example execute an script when user calls deployVirtualMachine
> API.
> > This script could be executed right after user submit his request or
> > after
> > the request completed successfully or failed.
> > Maybe some API management solution could help me but the problem is
> > understanding CS asyncjobs and their status.
> > Thanks
> >
> >
> >
> > Anurag.Awasthi@shapeblue.com
> > www.shapeblue.com
> > Amadeus House, Floral Street, London WC2E 9DPUK
> > @shapeblue
> >
> >
> >
> >
>
Re: hook or callback for CloudStack API
Posted by Alireza Eskandari <as...@gmail.com>.
Async jobs is not my concern.
Imagine that you have a firewall that is not integrated with CS and you
want to insert new roles in it each time a new VM is created.
In this case you need a hook that triggers an external script to configure
the firewall.
Pulling is time and resource consuming and its effect is not instant.
On Fri, Feb 22, 2019 at 8:02 PM Anurag Awasthi <An...@shapeblue.com>
wrote:
> Hi Alireza,
>
> Could you elaborate a more on the use case you have in mind? The
> description you mention is very generic.
>
> As far as I know we need to use polling to track the status of any async
> job (which is another API call) and execute based on response. That seems
> to be foundation principle behind all async calls. Alternately, you can
> also use CloudMonkey (
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+cloudmonkey+CLI)
> as a framework or dig a little into code there to implement a similar
> solution to execute hooks.
>
> Regards,
> Anurag
>
> On 2/22/19, 6:22 PM, "Alireza Eskandari" <as...@gmail.com> wrote:
>
> Hi,
> I'm looking for a solution to implement hooks or callbacks for
> CloudStack
> API.
> For example execute an script when user calls deployVirtualMachine API.
> This script could be executed right after user submit his request or
> after
> the request completed successfully or failed.
> Maybe some API management solution could help me but the problem is
> understanding CS asyncjobs and their status.
> Thanks
>
>
>
> Anurag.Awasthi@shapeblue.com
> www.shapeblue.com
> Amadeus House, Floral Street, London WC2E 9DPUK
> @shapeblue
>
>
>
>
Re: hook or callback for CloudStack API
Posted by Anurag Awasthi <An...@shapeblue.com>.
Hi Alireza,
Could you elaborate a more on the use case you have in mind? The description you mention is very generic.
As far as I know we need to use polling to track the status of any async job (which is another API call) and execute based on response. That seems to be foundation principle behind all async calls. Alternately, you can also use CloudMonkey (https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+cloudmonkey+CLI) as a framework or dig a little into code there to implement a similar solution to execute hooks.
Regards,
Anurag
On 2/22/19, 6:22 PM, "Alireza Eskandari" <as...@gmail.com> wrote:
Hi,
I'm looking for a solution to implement hooks or callbacks for CloudStack
API.
For example execute an script when user calls deployVirtualMachine API.
This script could be executed right after user submit his request or after
the request completed successfully or failed.
Maybe some API management solution could help me but the problem is
understanding CS asyncjobs and their status.
Thanks
Anurag.Awasthi@shapeblue.com
www.shapeblue.com
Amadeus House, Floral Street, London WC2E 9DPUK
@shapeblue