Automation

 View Only
Expand all | Collapse all

Announcing RVC - Ruby vSphere Console

Matthiker

MatthikerMar 31, 2011 02:10 AM

  • 1.  Announcing RVC - Ruby vSphere Console

    Posted Mar 26, 2011 08:41 PM

    http://github.com/vmware/rvc

    I'm pleased to announce the first public release of RVC, a Linux shell-like interface to ESX and VirtualCenter which presents the vSphere inventory as a virtual filesystem.

    Many useful commands are already implemented, like VM power operations, connecting a VMRC or VNC session (to view your virtual machines' consoles), and vMotion. RVC is designed to make it easy for users to add commands of their own, so I'm counting on the community to contribute commands that I (as an ESX kernel developer at VMware) haven't needed yet.

    RVC is written in Ruby, so you will need a Ruby interpreter and RubyGems installed, which you can find in your system's package manager. From there it should be a simple "gem install rvc". If you run into any installation problems please let me know. RVC might even work on OS X but I have not tested it there.

    More documentation is available in the GitHub repository README. To get started, run "rvc user@host" and try the "help", "ls", "cd", and "info" commands.

    This project is also being released as a VMware Labs Fling, so the same disclaimers apply.

    Screencast showing how to run RVC on Windows by Eric Sloof: http://www.ntpro.nl/blog/archives/1738-Video-Latest-fling-from-VMware-Labs-Ruby-vSphere-Console.html. Windows support is a work in progress and has been improved since this screencast.

    Packages needed:

    FC14: ruby ruby-devel rubygems kernel-devel libxml2 libxml2-devel libxslt libxslt-devel libffi libffi-devel

    Changelog:

    2011-06-09: 1.4.0 released. Added OS X keychain support, permissions commands, shared sessions, and more.

    2011-04-19: 1.3.0 released. Added aggregate marks, datastore.edit, and improved Windows compatibility.

    2011-04-12: 1.2.0 released. Added wildcards, guest power ops, and ssh enhancements.

    2011-04-05: 1.1.0 released. Added support for linked clones and host maintenance mode operations.

    2011-03-26: Initial release.



  • 2.  RE: Announcing RVC - Ruby vSphere Console

    Broadcom Employee
    Posted Mar 26, 2011 10:06 PM

    Very cool fling, was able to get this running on my Mac without too much issue.

    I noticed that rvc only accepts IP Address of the ESX(i)/vCenter host, even with FQDN it fails, I assume this is expected?

    I also found that the "help" operation always throws the following error no matter at what level of the inventory:

    /172.30.0.66/ha-datacenter/host> help
    All commands:
    NoMethodError: undefined method `keys' for [["destroy", "basic.destroy"]]:Array
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/modules/basic.rb:60:in `help'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/modules/basic.rb:57:in `each'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/modules/basic.rb:57:in `help'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/modules/basic.rb:53:in `each'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/modules/basic.rb:53:in `help'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/shell.rb:109:in `send'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/shell.rb:109:in `eval_command'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/lib/rvc/shell.rb:56:in `eval_input'
    /usr/local/rvm/gems/ruby-1.8.7-p334/gems/rvc-1.0.1/bin/rvc:100
    /usr/local/rvm/gems/ruby-1.8.7-p334/bin/rvc:19:in `load'
    /usr/local/rvm/gems/ruby-1.8.7-p334/bin/rvc:19
    /172.30.0.66/ha-datacenter/host> ls
    0 vesxi41-1. (standalone): cpu 5 GHz, memory 4294254 GB

    The environment is a standalone ESXi 4.1 Update 1 host

    OSX 10.5.8

    ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin9.8.0]

    Gem 1.6.2



  • 3.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 26, 2011 10:19 PM

    Thanks for the bug report, I've fixed the help command (it was using a Ruby 1.9 feature). RVC supports DNS hostnames - what error did you get? Can you ping using the same hostname?



  • 4.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 02:10 PM

    I am trying to get this installed on FC 14 (64 bit).  Installed Ruby 1.8.7.334-1.fc14, Gems 1.3.7-2.fc14 as well as libxml2, libxslt and devel packages.

    I get the foolowing error:

    [root@myPC etc]# gem install rvc
    Building native extensions.  This could take a while...
    ..
    .
    ERROR:  Error installing rvc:
        ERROR: Failed to build gem native extension.

    /usr/bin/ruby extconf.rb
    checking for ffi.h in /usr/local/include... no
    checking for rb_thread_blocking_region()... no
    checking for ruby_thread_has_gvl_p()... no
    checking for ruby_native_thread_p()... no
    checking for rb_thread_call_with_gvl()... no
    creating extconf.h
    creating Makefile

    make
    Configuring libffi
    /usr/lib/ruby/gems/1.8/gems/ffi-1.0.7/ext/ffi_c/libffi/configure: line 725: 0: Bad file descriptor
    make: *** [/usr/lib/ruby/gems/1.8/gems/ffi-1.0.7/ext/ffi_c/libffi/.libs/libffi_convenience.a] Error 1


    Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/ffi-1.0.7 for inspection.
    Results logged to /usr/lib/ruby/gems/1.8/gems/ffi-1.0.7/ext/ffi_c/gem_make.out

    I am a total nob when it comes to ruby so any help would be appreciated.

    Thanks.

    Tim



  • 5.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 03:29 PM

    The FFI gem isn't actually required for RVC to work, so you can run "gem install rbvmomi trollop backports && gem install --no-dependencies rvc".



  • 6.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 03:41 PM

    Thanks, there was an error of invalid option for --no-dependencies so I used --igonore-dependencies and got it installed but the following error when I run rvc:

    /usr/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem ffi (>= 1.0.7) (Gem::LoadError)
        from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
        from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
        from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
        from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
        from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
        from /usr/bin/rvc:18

    Any ideas?  Thnaks agin.

    Tim



  • 7.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 04:05 PM

    Sorry, replying to my own post.  Needed to install libffi-devel then all worked, did a gem install rvc and it is working now.

    Time to start exploring.

    Thanks for writing this.

    Tim



  • 8.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 04:29 PM

    I've pushed rvc-1.0.3, which makes the FFI dependency optional. You'll still want to install it if you can since it enables useful tab-completion features.

    Tim, could you post the Fedora packages you needed to install?



  • 9.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 04:45 PM

    I started with a base FC14 install and installed the following via 'yum install':

    ruby

    ruby-devel

    rubygems

    kernel-devel

    libxml2

    libxml2-devel

    libxslt

    libxslt-devel

    libffi

    libffi-devel

    I was able to get ffi installed after using 'gem install ffi' and tab completion is working.

    How would I got about updating rvc to I do a gem uninstall download latest and then gem instll again?

    Thanks.

    Tim



  • 10.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 28, 2011 05:36 PM

    Use "gem update rvc" to get the latest version.



  • 11.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 31, 2011 02:10 AM

    A great tool, must try.



  • 12.  RE: Announcing RVC - Ruby vSphere Console

    Posted Mar 31, 2011 08:21 AM

    Just for anyone who might get this issue too:

    On Ubuntu 10.04 64-bit after installing all the mentioned packages, when connecting I got the following:

    # rvc 10.21.65.41
    /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/lib/rvc/modules/vim.rb:64:in `connect': uninitialized constant RVC::CmdModule::OpenSSL (NameError)
                    from /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/lib/rvc/modules/vim.rb:54:in `loop'
                    from /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/lib/rvc/modules/vim.rb:54:in `connect'
                    from /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/bin/rvc:63
                    from /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/bin/rvc:60:in `each'
                    from /home/eamon/.gem/ruby/1.8/gems/rvc-1.0.3/bin/rvc:60
                    from /home/eamon/.gem/ruby/1.8/bin/rvc:19:in `load'
                    from /home/eamon/.gem/ruby/1.8/bin/rvc:19

    Solution (given by rlane) is to install the package libopenssl-ruby1.x (1.8 for me). Works now :-)



  • 13.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 04, 2011 06:37 AM

    Hi,

    THANKS for this awesome tool. I'm one of the members of the "give us a Linux client" choir. Installed this on an openSUSE 11.4 64-Bit - and it works perfectly out of the box.

    Now my only question is: WHY does this have to be done by ESX developers on their own as only a VMware-the-company halfheartedly supported project - this is so great, release it as a proper VMWare Product!

    Now off to enjoy VMRCs in RVC! :-)

    Stefan



  • 14.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 06, 2011 12:28 AM

    Wow, interesting project.  If this project continues to grow I wonder if there's a possibilty to include it in the vMA? and wondering why its not added yet to the VMware Flings area?  Wondering what other commands you will add next?   svmotion, editing properties of the vms?  connecting/disconnecting floppies/cdroms etc. ?



  • 15.  RE: Announcing RVC - Ruby vSphere Console

    Broadcom Employee
    Posted Apr 06, 2011 06:01 AM

    This would indeed be a neat utility to add to vMA, for now, you'll have to manually install but here is a quick blog post on how to do so - http://www.virtuallyghetto.com/2011/04/how-to-install-ruby-vsphere-console-on.html



  • 16.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 06, 2011 06:46 AM

    I'll talk with the vMA developers and see what we can do; I think I'd need to support the vMA's fastpass authentication mechanism. The Flings post is coming soon.

    For dealing with virtual devices, check out the vm.devices, vm.connect, vm.disconnect, and vm.insert_cdrom commands. Storage vMotion is a good idea, I'll add that. I'm also wondering what commands I'll add next - send me suggestions (or patches)!



  • 17.  RE: Announcing RVC - Ruby vSphere Console

    Broadcom Employee
    Posted Apr 06, 2011 07:02 AM

    You don't necessary need to support vi-fastpass, as it's jus another authentication mechanisms, but it would be neat if you could integrate with vifp library.

    Regarding other commands, some operations at the cluster would be nice such as creating, deleting and modifying clusters and also ability to add/remove hosts from a cluster.

    Have you had any thoughts about bulk operations and how that could/might work? That would be an extremely useful feature to have to somehow bulk operations based on some type of regex for an object, say power on all VMs that start with A*



  • 18.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 06, 2011 07:06 AM

    After running this past my colleagues: a command to show host/cluster resource usage would be nice (x of y GHz used, x of y GB RAM in use would be good enough for a start).

    Stefan



  • 19.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 06, 2011 01:52 PM

    This may be a stupid question but I did not see a method for doing a graceful guest shutdown.  Am I missing it?

    Thanks, this is a great alternative, who knows maybe it will put some pressure VMWare to officially roll out a Linux vSphere client.

    Tim



  • 20.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 08, 2011 07:55 PM

    RVC has been officially released as a Fling: http://labs.vmware.com/flings/rvc

    I've added guest power operations, globbing (wildcards), and an enhancement to the ssh command from Doug MacEachern to the git repo. I'll release a new version with these features early next week.



  • 21.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 14, 2011 04:48 AM

    It is really great!

    Now I can control VM IO through scripts.

    But one question, why extraConfig command doesn't work?

    /10.30.151.221> vm.extraConfig "VM name"
    NoMethodError: undefined method `map' for nil:NilClass
    /usr/lib/ruby/gems/1.8/gems/rvc-1.2.1/lib/rvc/modules/vm.rb:338:in `extraConfig'
    /usr/lib/ruby/gems/1.8/gems/rvc-1.2.1/lib/rvc/shell.rb:109:in `send'
    /usr/lib/ruby/gems/1.8/gems/rvc-1.2.1/lib/rvc/shell.rb:109:in `eval_command'
    /usr/lib/ruby/gems/1.8/gems/rvc-1.2.1/lib/rvc/shell.rb:56:in `eval_input'
    /usr/lib/ruby/gems/1.8/gems/rvc-1.2.1/bin/rvc:108
    /usr/bin/rvc:19:in `load'
    /usr/bin/rvc:19



  • 22.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 15, 2011 05:16 PM

    Thanks for the bug report, I've pushed a new version that fixes that and other bugs.



  • 23.  RE: Announcing RVC - Ruby vSphere Console

    Posted Apr 18, 2011 03:59 AM

    Good, vm.extraConfig works now.

    I have to use 'quit' command when I script rvc with shell everytime. Is is possible to add feature like vmware-cmd.

    e.g. I have to use rvc like this:

    rvc -k "domain\username":"pass"@10.10.10.10 -c 'command' -c 'quit'

    Is it possbile to quit automatically?

    Also, I couldn't figure out how to get a list of all VMs by one command due to many folers we created on our vCenter.

    Folder1/sub-folder1/vm1

    Folder1/sub-folder2/vm2

    Folder2/sub-folder1/sub-folder1/vm1

    Never tried ruby or I might wirte some for myself.



  • 24.  RE: Announcing RVC - Ruby vSphere Console

    Posted Jun 09, 2011 10:22 AM

    Hi,

    after installing through gem install rvc on Fedora 14 when I try to connect I get:

    [root@rbarisonlinux ~]# rvc 192.168.222.30
    Error loading readline-ffi: Could not open library 'readline.so': readline.so: cannot open shared object file: No such file or directory. Could not open library 'libreadline.so': libreadline.so: cannot open shared object file: No such file or directory. Tab completion will be limited.
    /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/lib/rvc/modules/role.rb:116:in `reload_modules': compile error (SyntaxError)
    /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/lib/rvc/modules/role.rb:39: syntax error, unexpected ':', expecting ')'
    ...etrieveRolePermissions(roleId: role.roleId).each do |perm|
                                  ^
    /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/lib/rvc/modules/role.rb:39: syntax error, unexpected ')', expecting kEND
    ...rmissions(roleId: role.roleId).each do |perm|
                                  ^
        from /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/lib/rvc/modules.rb:65:in `glob'
        from /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/lib/rvc/modules.rb:65:in `reload_modules'
        from /usr/lib/ruby/gems/1.8/gems/rvc-1.4.0/bin/rvc:58
        from /usr/bin/rvc:19:in `load'
        from /usr/bin/rvc:19

    Is there anything I can do to address this?

    Thanks,

    Riccardo



  • 25.  RE: Announcing RVC - Ruby vSphere Console

    Posted Jun 09, 2011 05:50 PM

    I've released 1.4.1 to fix this.



  • 26.  RE: Announcing RVC - Ruby vSphere Console

    Posted Jun 10, 2011 07:56 AM

    Hi,

    thank you very much.

    Now the readline.so error still appears:

    Error loading readline-ffi: Could not open library 'readline.so': readline.so: cannot open shared object file: No such file or directory. Could not open library 'libreadline.so': libreadline.so: cannot open shared object file: No such file or directory. Tab completion will be limited.

    but rvc allows me to login.

    Riccardo



  • 27.  RE: Announcing RVC - Ruby vSphere Console

    Posted Aug 09, 2011 05:39 PM

    Ruby, hmm OK. I'm completely new to that, but I followed the instructions at http://www.ruby-lang.org/en/downloads/ and installed rvm and ruby 1.9.2 and then used this to install rvc 1.4.1:

    ~> rvm gem install rvc
    Building native extensions.  This could take a while...
    Successfully installed nokogiri-1.5.0
    Successfully installed builder-3.0.0
    Successfully installed trollop-1.16.2
    Successfully installed rbvmomi-1.2.3
    Successfully installed backports-2.3.0
    Successfully installed highline-1.6.2
    Successfully installed zip-2.0.2
    Successfully installed rvc-1.4.1
    8 gems installed
    Installing ri documentation for nokogiri-1.5.0...
    Installing ri documentation for builder-3.0.0...
    Installing ri documentation for trollop-1.16.2...
    Installing ri documentation for rbvmomi-1.2.3...
    Installing ri documentation for backports-2.3.0...
    Installing ri documentation for highline-1.6.2...
    Installing ri documentation for zip-2.0.2...
    Installing ri documentation for rvc-1.4.1...
    Installing RDoc documentation for nokogiri-1.5.0...
    Installing RDoc documentation for builder-3.0.0...
    Installing RDoc documentation for trollop-1.16.2...
    Installing RDoc documentation for rbvmomi-1.2.3...
    Installing RDoc documentation for backports-2.3.0...
    Installing RDoc documentation for highline-1.6.2...
    Installing RDoc documentation for zip-2.0.2...
    Installing RDoc documentation for rvc-1.4.1...

    ~> rvm list

    rvm rubies

       ruby-1.9.2-p290 [ i386 ]

    ~> rvm use ruby-1.9.2-p290
    Using /home/iainw/.rvm/gems/ruby-1.9.2-p290

    However, I get the following error when trying to run rvc. Is there some set-up or dependency that I'm missing?

    ~> rvc 1.2.3.4
    /home/iainw/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- readline (LoadError)
            from /home/iainw/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/bin/rvc:21:in `<top (required)>'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/bin/rvc:19:in `load'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/bin/rvc:19:in `<main>'



  • 28.  RE: Announcing RVC - Ruby vSphere Console

    Posted Aug 09, 2011 08:23 PM

    Follow the RVM documentation for installing readline: http://beginrescueend.com/packages/readline/



  • 29.  RE: Announcing RVC - Ruby vSphere Console

    Posted Aug 09, 2011 08:50 PM

    rlane wrote:

    Follow the RVM documentation for installing readline: http://beginrescueend.com/packages/readline/

    Thanks. That certainly eliminated the readline error, but now I get:


    ~> rvc 10.2.3.4
    /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/lib/rvc/modules/vim.rb:66:in `rescue in block in connect': no such file to load -- openssl (LoadError)
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/lib/rvc/modules/vim.rb:57:in `block in connect'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/lib/rvc/modules/vim.rb:56:in `loop'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/lib/rvc/modules/vim.rb:56:in `connect'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/bin/rvc:88:in `block in <top (required)>'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/bin/rvc:85:in `each'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/gems/rvc-1.4.1/bin/rvc:85:in `<top (required)>'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/bin/rvc:19:in `load'
            from /home/iainw/.rvm/gems/ruby-1.9.2-p290/bin/rvc:19:in `<main>'



  • 30.  RE: Announcing RVC - Ruby vSphere Console

    Posted Aug 09, 2011 09:09 PM

    OK, I fixed that one with some help from http://beginrescueend.com/packages/openssl/

    In case anyone else finds this thread and has the same issues, I used:

    rvm remove 1.9.2

    rvm install 1.9.2 --with-readline-dir=$rvm_path/usr --with-openssl-dir=/usr

    After that, the previously installed rvc works.

    Thanks!