FOG-VSPHERE add_vm_volume

69 views
Skip to first unread message

Ajmal Ali

unread,
Feb 11, 2016, 10:00:06 AM2/11/16
to ruby-fog
Hey group, Has anyone got an example of how add_vm_volume works? or what the correct format is? or a better way to add storage to a vm


I tried something like compute.add_vm_volume('storage_pod' => 'SL-Dev-Tier1-SPD', 'size' => '5', 'name' => 'var', 'server_id' => 'ae8230bf-d13e-4d8b-82fa-388a18c4813b')
but all i get back is 

NoMethodError: undefined method `server_id' for #<Hash:0x007f7b71d51e40>
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/requests/compute/modify_vm_volume.rb:6:in `add_vm_volume'
        from (irb):27:in `<top (required)>'
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `block in <top (required)>'
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `catch'
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `<top (required)>'
        from /usr/local/bin/fog:23:in `load'
        from /usr/local/bin/fog:23:in `<main>'
        from /usr/local/bin/ruby_executable_hooks:15:in `eval'
        from /usr/local/bin/ruby_executable_hooks:15:in `<main>'

Regards
AJ

Kevin Menard

unread,
Feb 11, 2016, 10:23:03 AM2/11/16
to ruby...@googlegroups.com
Hi AJ,
 
Is there any reason you can't use the model interface? I think it'll make things a bit easier for you. As an example, you can see how we create and attach a volume in Rubber:
 
 
If you do need to use the service methods directly, I'd look at how the models call them. rbvmomi has a bit of an odd API and getting the parameters right can be tricky, as you've seen.
 
If that doesn't get you going, let me know and I can try to help out more.
 
--
Kevin
--
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/d/optout.
 

Ajmal Ali

unread,
Feb 12, 2016, 3:59:58 AM2/12/16
to ruby-fog
I got so carried away with getting the services interface, i didn't go back and check the model. Thanks for getting me back on path

Sooo .. it works for me kind of .. as soon as I get past adding the 6th disk (i'm just playing) i go from:

>> compute.volumes.create('server_id' => '50133300-edc8-2810-b651-6a5beb496afd', 'size_gb' => '2', 'name' => 'var', 'datastore' => 'SL-Dev-Tier1-SPD-02')
  <Fog::Compute::Vsphere::Volume                                                                                                                         
    id="6000C29b-ebe9-0a80-b4ce-43c93dd18f40",                                                                                                           
    datastore="SL-Dev-Tier1-SPD-02",                                                                                                                     
    storage_pod=nil,                                                                                                                                     
    mode="persistent",                                                                                                                                   
    size=2097152,                                                                                                                                        
    thin=true,                                                                                                                                           
    eager_zero=nil,                                                                                                                                      
    name="var",                                                                                                                                          
    filename="[SL-Dev-Tier1-SPD-02] rundecktest01E/rundecktest01E_6.vmdk",                                                                               
    size_gb=2,                                                                                                                                           
    key=2006,                                                                                                                                            
    unit_number=6,                                                                                                                                       
    server_id="50133300-edc8-2810-b651-6a5beb496afd"                                                                                                     
  >     

Which is all good .. to (around the 6th Disk)
>> compute.volumes.create('server_id' => '50133300-edc8-2810-b651-6a5beb496afd', 'size_gb' => '2', 'name' => 'var', 'datastore' => 'SL-Dev-Tier1-SPD-02')
NoMethodError: undefined method `id' for nil:NilClass                                                                                                    
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/models/compute/volume.rb:73:in `save'                                 
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-core-1.35.0/lib/fog/core/collection.rb:51:in `create'                                               
        from (irb):49:in `<top (required)>'                                                                                                              
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `block in <top (required)>'                                                    
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `catch'                                                                        
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `<top (required)>'                                                             
        from /usr/local/bin/fog:23:in `load'                                                                                                             
        from /usr/local/bin/fog:23:in `<main>'                                                                                                           
        from /usr/local/bin/ruby_executable_hooks:15:in `eval'                                                                                           
        from /usr/local/bin/ruby_executable_hooks:15:in `<main>'        

and then onwards to:
compute.volumes.create('server_id' => '50133300-edc8-2810-b651-6a5beb496afd', 'size_gb' => '2', 'name' => 'varg', 'datastore' => 'SL-Dev-Tier1-SPD-02')
NoMethodError: undefined method `exclude?' for [0, 1, 2, 3, 4, 5, 6, 8, 10]:Array                                                                         
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/models/compute/volume.rb:57:in `block in save'                         
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/models/compute/volume.rb:57:in `each'                                  
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/models/compute/volume.rb:57:in `find'                                  
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-vsphere-0.6.0/lib/fog/vsphere/models/compute/volume.rb:57:in `save'                                  
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-core-1.35.0/lib/fog/core/collection.rb:51:in `create'                                                
        from (irb):51:in `<top (required)>'                                                                                                               
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `block in <top (required)>'                                                     
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `catch'                                                                         
        from /usr/local/lib/ruby/gems/2.3.0/gems/fog-1.37.0/bin/fog:76:in `<top (required)>'                                                              
        from /usr/local/bin/fog:23:in `load'                                                                                                              
        from /usr/local/bin/fog:23:in `<main>'                                                                                                            
        from /usr/local/bin/ruby_executable_hooks:15:in `eval'                                                                                            
        from /usr/local/bin/ruby_executable_hooks:15:in `<main>'
                                                  

But the first 10 disks get added, bu as far as concerned, if there's a need to add this many disk to a new build, then someone has some justifying to do ;)

Thanks for your help again :)

Regards
AJ
Reply all
Reply to author
Forward
0 new messages