Vsphere Cloning...

208 views
Skip to first unread message

Matthew Barr

unread,
Mar 18, 2013, 6:50:09 PM3/18/13
to ruby...@googlegroups.com
I'm attempting to make heads & tails of the docs, and it's.. not easy as a newer person to Ruby. 

I'm attempting to clone a template into a VM in Vsphere as a first step, and retrieve it's mac address.

I've found a few pointers to such actions online, from different source & era's, and they conflict.

The best I can see is that something like this should clone the machine, and then I can get it's data without issue.
 
I'm not sure how to define which cluster/ host / datastore will receive the new VM, which I'm guessing is part of the problem.    

----
f=Fog::Compute.new(:provider => "Vsphere" )
instance_list = f.servers.all
instance_list.table([:name, :uuid])  #optional
new_vm=f.vm_clone( 'name' => 'NEWVM_NAME', 'datacenter' => 'DCName', 'template_path => '/Datacenter/Name/dir name')
----

Trying to read the rdoc's are leading me in circles.  It might be the collections which I haven't yet wrapped my head around, but I just don't see a list of functions that each object would have anywhere :(

(I'm hoping to add these to the Fog documentation for how to do specific activities in different providers, once I get it working :)


Thanks!

Matthew Barr
AIM: matthewbarr1

Kyle Rames

unread,
Mar 19, 2013, 8:51:25 AM3/19/13
to ruby...@googlegroups.com
I have never used vshere, so I am just guessing here, but could you be looking for resource_pool?

aussielunix

unread,
Apr 1, 2013, 6:32:50 AM4/1/13
to ruby...@googlegroups.com
G`Day all,

I too am looking at being able to clone both VMs and templates in vsphere.
I am little lost reading through code to see how this should work.

The clone method only seems to exist on the Fog::Compute::Vsphere::Server object.
Fog::Compute::Vsphere::Server will only ever point to a VM and never a template due to templates being filtered out.  https://github.com/fog/fog/blob/master/lib/fog/vsphere/requests/compute/list_virtual_machines.rb#L39
Fog::Compute::Vsphere::Template(s) exists but seems to be incomplete and no clone method:  https://github.com/aussielunix/fog/blob/master/lib/fog/vsphere/models/compute/templates.rb#L13   I am unable to find a 'list_templates' method under requests.

I am able to clone an existing VM https://gist.github.com/aussielunix/5283819 but not sure about how to clone a template.

Thoughts are:
Hack Fog::Compute::Vsphere::Servers so it has an extra option to chose to filter out templates or not and then just use the existing clone method.
or
Fill in the missing bits of Fog::Compute::Vsphere::Template(s) and add a clone method to it but this then seems like we have clone declared in two spots.

Comments and pointers please ?


Regards
Mick Pollard
@aussielunix

geemus (Wesley Beary)

unread,
Apr 1, 2013, 4:00:29 PM4/1/13
to ruby...@googlegroups.com
Hmm. Seems like filling in templates might make good sense and be somewhat less confusing? I'm not totally certain as I've not ever used or had access to vsphere. Happy to answer specific questions as best I can given my relative lack of knowledge though. Maybe somebody with more experience can chime in here also (sometimes people have better luck on this via issues than the mailing list though).
Thanks!
wes


--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeff McCune

unread,
Apr 1, 2013, 4:29:41 PM4/1/13
to ruby...@googlegroups.com
On Mon, Apr 1, 2013 at 3:32 AM, aussielunix <aussi...@gmail.com> wrote:

On Tuesday, 19 March 2013 09:50:09 UTC+11, Matthew Barr wrote:
I'm attempting to make heads & tails of the docs, and it's.. not easy as a newer person to Ruby. 

I'm attempting to clone a template into a VM in Vsphere as a first step, and retrieve it's mac address.
I've found a few pointers to such actions online, from different source & era's, and they conflict.
The best I can see is that something like this should clone the machine, and then I can get it's data without issue.
I'm not sure how to define which cluster/ host / datastore will receive the new VM, which I'm guessing is part of the problem.    

----
f=Fog::Compute.new(:provider => "Vsphere" )
instance_list = f.servers.all
instance_list.table([:name, :uuid])  #optional
new_vm=f.vm_clone( 'name' => 'NEWVM_NAME', 'datacenter' => 'DCName', 'template_path => '/Datacenter/Name/dir name')
----


Our code at Puppet Labs uses `template.clone('name' => options[:name], 'wait' => options[:wait])`.  The template variable references the results of connection.servers.find_all which is used to find the template.

This implementation is using a pretty old version of Fog though, the behavior likely has changed between 0.7.2 and now, but it still should work.

Hope this helps,
-Jeff

Ohad Levy

unread,
Apr 2, 2013, 2:15:39 AM4/2/13
to ruby...@googlegroups.com
I would +1 to what @geemus said, adding a proper templates object is properly the right way forward.

it could be that some logic could be shared across requests (e.g. the hw spec stuff).

let us know if you have any questions :)
Reply all
Reply to author
Forward
0 new messages