VMware Cloud Community
rlane
Contributor
Contributor

Announcing RVC - Ruby vSphere Console

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.

0 Kudos
29 Replies
Matthiker
Contributor
Contributor

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

0 Kudos
rlane
Contributor
Contributor

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

0 Kudos
Matthiker
Contributor
Contributor

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.

0 Kudos
rickyhp
Contributor
Contributor

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

0 Kudos
rlane
Contributor
Contributor

I've released 1.4.1 to fix this.

0 Kudos
rickyhp
Contributor
Contributor

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

0 Kudos
woolfie
Contributor
Contributor

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>'

0 Kudos
rlane
Contributor
Contributor

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

0 Kudos
woolfie
Contributor
Contributor

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>'

0 Kudos
woolfie
Contributor
Contributor

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!

0 Kudos