Discussion:
Vsphere Cloning...
Matthew Barr
2013-03-18 22:50:09 UTC
Permalink
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
E: mbarr-q2pkGsKyZe6Kf2Id4j40wVaTQe2KTcn/@public.gmane.org
AIM: matthewbarr1
c: (646) 727-0535
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Kyle Rames
2013-03-19 12:51:25 UTC
Permalink
I have never used vshere, so I am just guessing here, but could you be
looking for resource_pool?

https://github.com/fog/fog/blob/master/lib/fog/vsphere/requests/compute/vm_clone.rb#L53-L57
Post by Matthew Barr
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
c: (646) 727-0535
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
aussielunix
2013-04-01 10:32:50 UTC
Permalink
Post by Matthew Barr
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
c: (646) 727-0535
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
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
geemus (Wesley Beary)
2013-04-01 20:00:29 UTC
Permalink
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
Post by aussielunix
Post by Matthew Barr
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
c: (646) 727-0535
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
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.
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
--
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
For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Jeff McCune
2013-04-01 20:29:41 UTC
Permalink
Post by Matthew Barr
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
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Ohad Levy
2013-04-02 06:15:39 UTC
Permalink
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 :)
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...