Custom Cloud Plugin for Knife

Ohai, Chefs!

I have my custom private cloud with custom API. I’ve implemented gem for
talking to this api. Now I’m thinking about knife plugin:
knife mycloud server create …
etc…

There is hard to find good guide how to do it. Should I copy-paste existing
project, like https://github.com/opscode/knife-ec2 or start somewhere else?

Also I found https://github.com/opscode/knife-cloud
But it hasn’t any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

You can have a look at
http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your cloud
plugin.
Here is knife-openstack implementation using knife-cloud (fog based) which
can be a good reference.

If you want to write non-fog based implementation, please have a look at

This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem for
talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

Thanks for links!

But I still can't understand how to use knife-cloud framework.
knife-openstack looks like copy-paste from knife-ec2 (and others) BUT there
are no references from knife-openstack to knife-cloud plugin. knife-vcloud
plugin looks same.

For example, to implement this plugin I should do the following steps:

  1. Implement gem fog-or2 (fog plugin for my cloud. or2 is short name for
    this cloud)
  2. Create empty gem knife-or2
  3. Next, looks like I should copy-paste all from knife-ec2 and replace ec2
    to or2

In the these steps knife-cloud missing.

Or may be I missing something?

2014-05-26 14:03 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

You can have a look at
http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your cloud
plugin.
Here is knife-openstack implementation using knife-cloud (fog based) which
can be a good reference.

If you want to write non-fog based implementation, please have a look at
https://github.com/opscode/knife-cloud/blob/master/lib/chef/knife/cloud/service.rb
This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem for
talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

So if you have fog support for your cloud, using knife-cloud would be a lot
easier, although you can also use it without fog support.

case 1: you have fog support
1> you can simply use knife-openstack's *"knife-cloud" branch *as a base
for your new implementation
2> Change all references to openstack in both file names and class names
3> see /knife/cloud/openstack_service.rb
it sets the auth params specific to your cloud. Note since this is fog
based the functionality is already implemented in knife-cloud for reuse.
4> Next implement listing of resource - server, image, flavor etc
see /knife/openstack_flavor_list.rb
You just have to override #before_exec_command method to set labels and
keys, here key are strings id in the hash returned by fog.
If you need any formatting or dig deeper in hash, use value_callback
5> next say create server. see knife/openstack_server_create
Again you override #before_exec_command to setup server_def hash used by
fog for create server. You also have #after_exec_command if you want to
carry out any post server creation steps, say for openstack we assign
floating ip after server creation.

5.1> *bootstrap *- this is really fog independent. see same
openstack_server_create.rb
mainly you just have to set the IP address (bootstrap_ip_address in
#before_bootstrap) of the newly created VM and rest bootstrap functionality
is already in place.

6> you just need file inplace similar to openstack_server_delete with
banner. Again functionality using fog delete is in place.

case 2: you don't have fog support which is mostly your case for now.
Most of the steps above are same. You will need to dig a little deeper in
knife-cloud gem implementation. Say have a look how
knife/cloud/fog/service.rb is implemented, you will have to write a similar
service using your custom APIs (instead of case1 - point 3 above).
Benefit here is you can reuse framework and additionally the bootstrap part
should work as is.

Hope that helps.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 5:59 PM, Jek Sirex jsirex@gmail.com wrote:

Thanks for links!

But I still can't understand how to use knife-cloud framework.
knife-openstack looks like copy-paste from knife-ec2 (and others) BUT there
are no references from knife-openstack to knife-cloud plugin. knife-vcloud
plugin looks same.

For example, to implement this plugin I should do the following steps:

  1. Implement gem fog-or2 (fog plugin for my cloud. or2 is short name for
    this cloud)
  2. Create empty gem knife-or2
  3. Next, looks like I should copy-paste all from knife-ec2 and replace ec2
    to or2

In the these steps knife-cloud missing.

Or may be I missing something?

2014-05-26 14:03 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

You can have a look at

http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your cloud
plugin.
Here is knife-openstack implementation using knife-cloud (fog based)
which can be a good reference.

If you want to write non-fog based implementation, please have a look at
https://github.com/opscode/knife-cloud/blob/master/lib/chef/knife/cloud/service.rb
This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem for
talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

Many thanks, Kaustubh!

This really helped me. Previously I looked at master branch of
knife-openstack. Now I'm going to carefully investigate knife-cloud branch.
Also I started implement fog plugin, so case 1 is my case.

Thanks again!

Yauhen

2014-05-28 10:49 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

So if you have fog support for your cloud, using knife-cloud would be a
lot easier, although you can also use it without fog support.

*case 1: you have fog support *
1> you can simply use knife-openstack's *"knife-cloud" branch *as a base
for your new implementation
2> Change all references to openstack in both file names and class names
3> see /knife/cloud/openstack_service.rb
it sets the auth params specific to your cloud. Note since this is fog
based the functionality is already implemented in knife-cloud for reuse.
4> Next implement listing of resource - server, image, flavor etc
see /knife/openstack_flavor_list.rb
You just have to override #before_exec_command method to set labels and
keys, here key are strings id in the hash returned by fog.
If you need any formatting or dig deeper in hash, use value_callback
5> next say create server. see knife/openstack_server_create
Again you override #before_exec_command to setup server_def hash used by
fog for create server. You also have #after_exec_command if you want to
carry out any post server creation steps, say for openstack we assign
floating ip after server creation.

5.1> *bootstrap *- this is really fog independent. see same
openstack_server_create.rb
mainly you just have to set the IP address (bootstrap_ip_address in
#before_bootstrap) of the newly created VM and rest bootstrap functionality
is already in place.

6> you just need file inplace similar to openstack_server_delete with
banner. Again functionality using fog delete is in place.

*case 2: you don't have fog support which is mostly your case for now. *
Most of the steps above are same. You will need to dig a little deeper in
knife-cloud gem implementation. Say have a look how
knife/cloud/fog/service.rb is implemented, you will have to write a similar
service using your custom APIs (instead of case1 - point 3 above).
Benefit here is you can reuse framework and additionally the bootstrap
part should work as is.

Hope that helps.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 5:59 PM, Jek Sirex jsirex@gmail.com wrote:

Thanks for links!

But I still can't understand how to use knife-cloud framework.
knife-openstack looks like copy-paste from knife-ec2 (and others) BUT there
are no references from knife-openstack to knife-cloud plugin. knife-vcloud
plugin looks same.

For example, to implement this plugin I should do the following steps:

  1. Implement gem fog-or2 (fog plugin for my cloud. or2 is short name
    for this cloud)
  2. Create empty gem knife-or2
  3. Next, looks like I should copy-paste all from knife-ec2 and replace
    ec2 to or2

In the these steps knife-cloud missing.

Or may be I missing something?

2014-05-26 14:03 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

You can have a look at

http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your cloud
plugin.
Here is knife-openstack implementation using knife-cloud (fog based)
which can be a good reference.

If you want to write non-fog based implementation, please have a look at
https://github.com/opscode/knife-cloud/blob/master/lib/chef/knife/cloud/service.rb
This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem
for talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

Hi Jek

We have written a knife-cloud scaffold generator:

You can try using this and let us know if it helps!

Thanks,
Mukta.

On Wed, May 28, 2014 at 5:36 PM, Jek Sirex jsirex@gmail.com wrote:

Many thanks, Kaustubh!

This really helped me. Previously I looked at master branch of
knife-openstack. Now I'm going to carefully investigate knife-cloud branch.
Also I started implement fog plugin, so case 1 is my case.

Thanks again!

Yauhen

2014-05-28 10:49 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

So if you have fog support for your cloud, using knife-cloud would be a

lot easier, although you can also use it without fog support.

*case 1: you have fog support *
1> you can simply use knife-openstack's *"knife-cloud" branch *as a base
for your new implementation
2> Change all references to openstack in both file names and class names
3> see /knife/cloud/openstack_service.rb
it sets the auth params specific to your cloud. Note since this is fog
based the functionality is already implemented in knife-cloud for reuse.
4> Next implement listing of resource - server, image, flavor etc
see /knife/openstack_flavor_list.rb
You just have to override #before_exec_command method to set labels
and keys, here key are strings id in the hash returned by fog.
If you need any formatting or dig deeper in hash, use value_callback
5> next say create server. see knife/openstack_server_create
Again you override #before_exec_command to setup server_def hash used
by fog for create server. You also have #after_exec_command if you want to
carry out any post server creation steps, say for openstack we assign
floating ip after server creation.

5.1> *bootstrap *- this is really fog independent. see same
openstack_server_create.rb
mainly you just have to set the IP address (bootstrap_ip_address in
#before_bootstrap) of the newly created VM and rest bootstrap functionality
is already in place.

6> you just need file inplace similar to openstack_server_delete with
banner. Again functionality using fog delete is in place.

*case 2: you don't have fog support which is mostly your case for now. *
Most of the steps above are same. You will need to dig a little deeper in
knife-cloud gem implementation. Say have a look how
knife/cloud/fog/service.rb is implemented, you will have to write a similar
service using your custom APIs (instead of case1 - point 3 above).
Benefit here is you can reuse framework and additionally the bootstrap
part should work as is.

Hope that helps.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 5:59 PM, Jek Sirex jsirex@gmail.com wrote:

Thanks for links!

But I still can't understand how to use knife-cloud framework.
knife-openstack looks like copy-paste from knife-ec2 (and others) BUT there
are no references from knife-openstack to knife-cloud plugin. knife-vcloud
plugin looks same.

For example, to implement this plugin I should do the following steps:

  1. Implement gem fog-or2 (fog plugin for my cloud. or2 is short name
    for this cloud)
  2. Create empty gem knife-or2
  3. Next, looks like I should copy-paste all from knife-ec2 and replace
    ec2 to or2

In the these steps knife-cloud missing.

Or may be I missing something?

2014-05-26 14:03 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

You can have a look at

http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your cloud
plugin.
Here is knife-openstack implementation using knife-cloud (fog based)
which can be a good reference.

If you want to write non-fog based implementation, please have a look
at
https://github.com/opscode/knife-cloud/blob/master/lib/chef/knife/cloud/service.rb
This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem
for talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen

Thank you!

This is good example how to start/use knife-cloud framework.

2014-06-13 13:33 GMT+03:00 Mukta Aphale mukta.aphale@clogeny.com:

Hi Jek

We have written a knife-cloud scaffold generator:
GitHub - MsysTechnologiesllc/knife-cloud-scaffolder: Code generator for writing knife-cloud based plugins.
You can try using this and let us know if it helps!

Thanks,
Mukta.

On Wed, May 28, 2014 at 5:36 PM, Jek Sirex jsirex@gmail.com wrote:

Many thanks, Kaustubh!

This really helped me. Previously I looked at master branch of
knife-openstack. Now I'm going to carefully investigate knife-cloud branch.
Also I started implement fog plugin, so case 1 is my case.

Thanks again!

Yauhen

2014-05-28 10:49 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com:

So if you have fog support for your cloud, using knife-cloud would be a

lot easier, although you can also use it without fog support.

*case 1: you have fog support *
1> you can simply use knife-openstack's *"knife-cloud" branch *as a
base for your new implementation
2> Change all references to openstack in both file names and class names
3> see /knife/cloud/openstack_service.rb
it sets the auth params specific to your cloud. Note since this is
fog based the functionality is already implemented in knife-cloud for reuse.
4> Next implement listing of resource - server, image, flavor etc
see /knife/openstack_flavor_list.rb
You just have to override #before_exec_command method to set labels
and keys, here key are strings id in the hash returned by fog.
If you need any formatting or dig deeper in hash, use value_callback
5> next say create server. see knife/openstack_server_create
Again you override #before_exec_command to setup server_def hash used
by fog for create server. You also have #after_exec_command if you want to
carry out any post server creation steps, say for openstack we assign
floating ip after server creation.

5.1> *bootstrap *- this is really fog independent. see same
openstack_server_create.rb
mainly you just have to set the IP address (bootstrap_ip_address in
#before_bootstrap) of the newly created VM and rest bootstrap functionality
is already in place.

6> you just need file inplace similar to openstack_server_delete with
banner. Again functionality using fog delete is in place.

*case 2: you don't have fog support which is mostly your case for now. *
Most of the steps above are same. You will need to dig a little deeper
in knife-cloud gem implementation. Say have a look how
knife/cloud/fog/service.rb is implemented, you will have to write a similar
service using your custom APIs (instead of case1 - point 3 above).
Benefit here is you can reuse framework and additionally the bootstrap
part should work as is.

Hope that helps.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 5:59 PM, Jek Sirex jsirex@gmail.com wrote:

Thanks for links!

But I still can't understand how to use knife-cloud framework.
knife-openstack looks like copy-paste from knife-ec2 (and others) BUT there
are no references from knife-openstack to knife-cloud plugin. knife-vcloud
plugin looks same.

For example, to implement this plugin I should do the following steps:

  1. Implement gem fog-or2 (fog plugin for my cloud. or2 is short name
    for this cloud)
  2. Create empty gem knife-or2
  3. Next, looks like I should copy-paste all from knife-ec2 and replace
    ec2 to or2

In the these steps knife-cloud missing.

Or may be I missing something?

2014-05-26 14:03 GMT+03:00 Kaustubh Deorukhkar kaustubh.deo@gmail.com
:

You can have a look at

http://www.slideshare.net/Clogeny/writing-a-knife-cloud-plugin-for-your-shiny-vmware-vcloud-director

knife-cloud is a framework that can help reuse and structure your
cloud plugin.
Here is knife-openstack implementation using knife-cloud (fog based)
which can be a good reference.

If you want to write non-fog based implementation, please have a look
at
https://github.com/opscode/knife-cloud/blob/master/lib/chef/knife/cloud/service.rb
This should give you a feel of what needs to be implemented.

Thanks,
Kaustubh

On Mon, May 26, 2014 at 4:10 PM, Jek Sirex jsirex@gmail.com wrote:

Ohai, Chefs!

I have my custom private cloud with custom API. I've implemented gem
for talking to this api. Now I'm thinking about knife plugin:
knife mycloud server create ...
etc...

There is hard to find good guide how to do it. Should I copy-paste
existing project, like GitHub - chef/knife-ec2: Chef knife plug-in for AWS EC2 or start
somewhere else?

Also I found GitHub - chef/knife-cloud: Library for Chef knife cloud plugins
But it hasn't any documentation or examples about how to use it. Does
anyone have such examples?

Should I first extend gem fog with my cloud?

Thanks!


Yauhen