You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by Yaniv Kaul <yk...@redhat.com> on 2017/08/14 10:39:40 UTC

[dev] Guidelines for developing a cloud (compute) driver

Hi,

I was wondering (and could not find in the documentation) if there are
guidelines on what needs to be implemented for a cloud (and specifically
compute) driver. Any 'MUST' functions the driver needs to support? Or can I
start with something minimalist and gradually add more?

I was looking at the libvirt driver[1 and dummy[2] as an example, but
wasn't sure about ex_ functions. For example, ex_start_node() , is
mandatory or not?

I assume those are needed:
list_nodes()
reboot_node()
destroy_node()


What about create_node() ?

What about:
ex_start_node()
ex_shutdown_node()
ex_suspend_node()
ex_resume_node()
ex_get_node_by_uuid()
ex_get_node_by_name()
ex_take_node_screenshot()  (?!)
ex_get_hypervisor_hostname()
ex_get_hypervisor_sysinfo()  (?! - isn't it very driver specific?)

TIA,
Y.

[1]
https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=blob;f=libcloud/compute/drivers/libvirt_driver.py;h=a914c5e613c53d90fbd5b5de6028bd3ae4e643be;hb=HEAD
[2]
https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=blob;f=libcloud/compute/drivers/dummy.py;h=982433525b6ef927115616cf7080c56b53a93499;hb=HEAD

Re: [dev] Guidelines for developing a cloud (compute) driver

Posted by anthony shaw <an...@gmail.com>.
If you want some advice from someone that's written ~10 drivers..

Start with the tests, fixtures and mocks, then build out the methods.
TDD saves so much time going back and forth. Also once you have the test setup you can use PyTest with the --pdb flag.

Anthony Shaw
________________________________
From: Yaniv Kaul <yk...@redhat.com>
Sent: Monday, August 14, 2017 9:00:24 PM
To: dev@libcloud.apache.org
Subject: Re: [dev] Guidelines for developing a cloud (compute) driver

On Mon, Aug 14, 2017 at 1:52 PM, anthony shaw <an...@gmail.com>
wrote:

> Hi,
>
> I wouldn't use that one as an example. Vultr is one of the most minimal and
> clean implementations
> https://github.com/apache/libcloud/blob/trunk/libcloud/
> compute/drivers/vultr.py
>
> Start with the basics, raise a PR and I'll walk you through the process and
> steps. Oh and write lots of tests :0) so you need to record fixtures from a
> real API endpoint, I recommend using Charles proxy or Fiddler2.
>

Thanks for the quick response. The vultr driver seems reasonable.
FWIW, I'm looking at feasibility of writing a driver for oVirt[1] using its
Python SDK[2][3].

The tests against mock is a bit discouraging - as I was about to use the
Python SDK, I'm unsure how much effort it'd take. Need to look at it
further. I guess I'll develop something, test it first, then think of how
to implement the tests.

Thanks again,
Y.

[1] http://www.ovirt.org/
[2] https://github.com/oVirt/ovirt-engine-sdk
[3] https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk/examples


> Anthony
>
> On Mon, Aug 14, 2017 at 8:39 PM, Yaniv Kaul <yk...@redhat.com> wrote:
>
> > Hi,
> >
> > I was wondering (and could not find in the documentation) if there are
> > guidelines on what needs to be implemented for a cloud (and specifically
> > compute) driver. Any 'MUST' functions the driver needs to support? Or
> can I
> > start with something minimalist and gradually add more?
> >
> > I was looking at the libvirt driver[1 and dummy[2] as an example, but
> > wasn't sure about ex_ functions. For example, ex_start_node() , is
> > mandatory or not?
> >
> > I assume those are needed:
> > list_nodes()
> > reboot_node()
> > destroy_node()
> >
> >
> > What about create_node() ?
> >
> > What about:
> > ex_start_node()
> > ex_shutdown_node()
> > ex_suspend_node()
> > ex_resume_node()
> > ex_get_node_by_uuid()
> > ex_get_node_by_name()
> > ex_take_node_screenshot()  (?!)
> > ex_get_hypervisor_hostname()
> > ex_get_hypervisor_sysinfo()  (?! - isn't it very driver specific?)
> >
> > TIA,
> > Y.
> >
> > [1]
> > https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> > blob;f=libcloud/compute/drivers/libvirt_driver.py;h=
> > a914c5e613c53d90fbd5b5de6028bd3ae4e643be;hb=HEAD
> > [2]
> > https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> > blob;f=libcloud/compute/drivers/dummy.py;h=
> 982433525b6ef927115616cf7080c5
> > 6b53a93499;hb=HEAD
> >
>

Re: [dev] Guidelines for developing a cloud (compute) driver

Posted by Yaniv Kaul <yk...@redhat.com>.
On Mon, Aug 14, 2017 at 1:52 PM, anthony shaw <an...@gmail.com>
wrote:

> Hi,
>
> I wouldn't use that one as an example. Vultr is one of the most minimal and
> clean implementations
> https://github.com/apache/libcloud/blob/trunk/libcloud/
> compute/drivers/vultr.py
>
> Start with the basics, raise a PR and I'll walk you through the process and
> steps. Oh and write lots of tests :0) so you need to record fixtures from a
> real API endpoint, I recommend using Charles proxy or Fiddler2.
>

Thanks for the quick response. The vultr driver seems reasonable.
FWIW, I'm looking at feasibility of writing a driver for oVirt[1] using its
Python SDK[2][3].

The tests against mock is a bit discouraging - as I was about to use the
Python SDK, I'm unsure how much effort it'd take. Need to look at it
further. I guess I'll develop something, test it first, then think of how
to implement the tests.

Thanks again,
Y.

[1] http://www.ovirt.org/
[2] https://github.com/oVirt/ovirt-engine-sdk
[3] https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk/examples


> Anthony
>
> On Mon, Aug 14, 2017 at 8:39 PM, Yaniv Kaul <yk...@redhat.com> wrote:
>
> > Hi,
> >
> > I was wondering (and could not find in the documentation) if there are
> > guidelines on what needs to be implemented for a cloud (and specifically
> > compute) driver. Any 'MUST' functions the driver needs to support? Or
> can I
> > start with something minimalist and gradually add more?
> >
> > I was looking at the libvirt driver[1 and dummy[2] as an example, but
> > wasn't sure about ex_ functions. For example, ex_start_node() , is
> > mandatory or not?
> >
> > I assume those are needed:
> > list_nodes()
> > reboot_node()
> > destroy_node()
> >
> >
> > What about create_node() ?
> >
> > What about:
> > ex_start_node()
> > ex_shutdown_node()
> > ex_suspend_node()
> > ex_resume_node()
> > ex_get_node_by_uuid()
> > ex_get_node_by_name()
> > ex_take_node_screenshot()  (?!)
> > ex_get_hypervisor_hostname()
> > ex_get_hypervisor_sysinfo()  (?! - isn't it very driver specific?)
> >
> > TIA,
> > Y.
> >
> > [1]
> > https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> > blob;f=libcloud/compute/drivers/libvirt_driver.py;h=
> > a914c5e613c53d90fbd5b5de6028bd3ae4e643be;hb=HEAD
> > [2]
> > https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> > blob;f=libcloud/compute/drivers/dummy.py;h=
> 982433525b6ef927115616cf7080c5
> > 6b53a93499;hb=HEAD
> >
>

Re: [dev] Guidelines for developing a cloud (compute) driver

Posted by anthony shaw <an...@gmail.com>.
Hi,

I wouldn't use that one as an example. Vultr is one of the most minimal and
clean implementations
https://github.com/apache/libcloud/blob/trunk/libcloud/compute/drivers/vultr.py

Start with the basics, raise a PR and I'll walk you through the process and
steps. Oh and write lots of tests :0) so you need to record fixtures from a
real API endpoint, I recommend using Charles proxy or Fiddler2.

Anthony

On Mon, Aug 14, 2017 at 8:39 PM, Yaniv Kaul <yk...@redhat.com> wrote:

> Hi,
>
> I was wondering (and could not find in the documentation) if there are
> guidelines on what needs to be implemented for a cloud (and specifically
> compute) driver. Any 'MUST' functions the driver needs to support? Or can I
> start with something minimalist and gradually add more?
>
> I was looking at the libvirt driver[1 and dummy[2] as an example, but
> wasn't sure about ex_ functions. For example, ex_start_node() , is
> mandatory or not?
>
> I assume those are needed:
> list_nodes()
> reboot_node()
> destroy_node()
>
>
> What about create_node() ?
>
> What about:
> ex_start_node()
> ex_shutdown_node()
> ex_suspend_node()
> ex_resume_node()
> ex_get_node_by_uuid()
> ex_get_node_by_name()
> ex_take_node_screenshot()  (?!)
> ex_get_hypervisor_hostname()
> ex_get_hypervisor_sysinfo()  (?! - isn't it very driver specific?)
>
> TIA,
> Y.
>
> [1]
> https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> blob;f=libcloud/compute/drivers/libvirt_driver.py;h=
> a914c5e613c53d90fbd5b5de6028bd3ae4e643be;hb=HEAD
> [2]
> https://git-wip-us.apache.org/repos/asf?p=libcloud.git;a=
> blob;f=libcloud/compute/drivers/dummy.py;h=982433525b6ef927115616cf7080c5
> 6b53a93499;hb=HEAD
>