vmware-archive / vcloud-rest

Unofficial ruby bindings for VMware vCloud Director®
Apache License 2.0
29 stars 37 forks source link

vApp IP Address parsing "undefined method 'value' " #20

Closed brettswift closed 10 years ago

brettswift commented 10 years ago

Great API so far. I have found a bug in the vApp section, and it may be due to how I've assigned the vApp a static IP? I'm new to ruby, but will attempt to build your gem locally and test this. Just putting this issue up for visibility.

Using the progression from your example.rb, after getting a vcd I call this: vApp = connection.get_vapp(vdc[:vapps]["Dev Sandbox"])

sanitized result from VDC:

### Fetch and Show  vDC
{
             :id => "5b10045c-f43c-44ec-b30f-1aa745fd2cba",
           :name => "vdc",
    :description => "CG-NO resources",
          :vapps => {
...
                          "Dev Sandbox" => "e453c846-bf36-4bd7-9e52-255d718df601" 
....
    },
       :networks => {
       ....
    }
}

Stack:

/Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/vcloud-rest-1.1.0/lib/vcloud-rest/vcloud/vapp.rb:92:in `block (2 levels) in get_vapp': undefined method `value' for "10.191.101.118":String (NoMethodError)
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/vcloud-rest-1.1.0/lib/vcloud-rest/vcloud/vapp.rb:89:in `collect'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/vcloud-rest-1.1.0/lib/vcloud-rest/vcloud/vapp.rb:89:in `block in get_vapp'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
    from /Users/bswift/.rvm/gems/ruby-2.0.0-p353/gems/vcloud-rest-1.1.0/lib/vcloud-rest/vcloud/vapp.rb:87:in `get_vapp'
    from runvCloud.rb:57:in `<main>'
astratto commented 10 years ago

@brettswift thanks! Could you checkout the version I've just pushed to branch ip_address?

brettswift commented 10 years ago

I guess you beat me to it. Comments on the PR would be good too - it seems like we fixed it a bit of a different way.

brettswift commented 10 years ago

I closed pr #21

the vms_hash was being set to nil in my PR:

"devprovepzl100 - Ad-hoc Sandbox" => {
                       :addresses => [
                [0] nil
            ],
                          :status => "running",
                              :id => "867e5e4e-389b-42d5-a2ec-da229856f90a",
            :vapp_scoped_local_id => "4b2f88ec-6a71-49ff-9825-bf5bef7f11b3"
        },

The ip_address branch fixes this:

:vms_hash => {
             "devprovepzl101 - deploy test server" => {
                       :addresses => [
                [0] "10.191.101.118"
            ],
                          :status => "running",
                              :id => "8eb169b2-7792-446d-8bcb-4ac7d324d579",
            :vapp_scoped_local_id => "1794e6cd-091d-47ad-820a-6fc0af70d8ab"
        },
brettswift commented 10 years ago

ps. incredible response time .. thank you!

brettswift commented 10 years ago

Hey @astratto - do you have plans to re-publish this to a version 1.1.1 ? I don't see this on rugygems yet, I can only get the code with a git pull in my gemfile :)

astratto commented 10 years ago

Hi @brettswift, I usually wait for a couple of days because other bugs might crop up. This is not the case, so I've just released v.1.1.1.

Thanks again!

brettswift commented 10 years ago

No prob @astratto ! On Thursday when I'm back at work, if I don't have time beforehand - I'll probably throw in a couple other features. (Snapshot, and restore snapshot for vm's).

I really appreciate this library.. I'm new to ruby and it made it really simple to make a little command line app, and i've already used it to manipulate my vm's. (just power on and power off.. but the proof of concept is there at least).

https://github.com/brettswift/bird

If you want to see it in action, I used this cool app "showterm" to do a little demo: http://showterm.io/5629ef26bcca4500afe02

astratto commented 10 years ago

@brettswift I'm glad it works fine for you!

You could take a peek at knife-vcloud that uses this library to manage vcloud instances using Chef's knife.

Btw, showterm seems very useful, thanks!

brettswift commented 10 years ago

knife-cloud - interesting. I'd be curious to compare notes on your workflow. Are you using knife-cloud as a part of a continuous delivery (CD) model? I'm a tech lead on an software team, and the goal of 'bird' is to help our CD flows - so when there's a new deployment ready, or git branch, or git tag or whatever we decide - the build pipeline (teamcity for us) will be able to call out to bird and have a machine ready for it to deploy to. We're using the concept of "immutable servers" and "phoenix servers" - new buzzwords you'll find on Martin Fowlers blog.

Brett

On Fri, Jan 3, 2014 at 6:15 AM, Stefano Tortarolo notifications@github.comwrote:

@brettswift https://github.com/brettswift I'm glad it works fine for you!

You could take a peek at knife-vcloudhttps://github.com/astratto/knife-vcloudthat uses this library to manage vcloud instances using Chef's knife.

Btw, showterm seems very useful, thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/astratto/vcloud-rest/issues/20#issuecomment-31521594 .

brettswift commented 10 years ago

Oh and another question I have.. maybe it's obvious from one of the networking API's in vcloud-rest, but do you know a way of listing used IP's in a vOrg, that is less tedious than looping through all your vApps ? We don't use DHCP, because we don't have DNS working in our vCloud (which is a PaaS given to me).

Ie: I know I have IP's available to me from .90 --> .120, and I assign them statically. So to get a list of either available or allocated IP's would be awesome. If you have any thoughts I'd appreciate the tip.

I'll get to the deprecation today..thanks!

Brett

On Fri, Jan 3, 2014 at 6:57 AM, Brett Swift brettswift@gmail.com wrote:

knife-cloud - interesting. I'd be curious to compare notes on your workflow. Are you using knife-cloud as a part of a continuous delivery (CD) model? I'm a tech lead on an software team, and the goal of 'bird' is to help our CD flows - so when there's a new deployment ready, or git branch, or git tag or whatever we decide - the build pipeline (teamcity for us) will be able to call out to bird and have a machine ready for it to deploy to. We're using the concept of "immutable servers" and "phoenix servers" - new buzzwords you'll find on Martin Fowlers blog.

Brett

On Fri, Jan 3, 2014 at 6:15 AM, Stefano Tortarolo < notifications@github.com> wrote:

@brettswift https://github.com/brettswift I'm glad it works fine for you!

You could take a peek at knife-vcloudhttps://github.com/astratto/knife-vcloudthat uses this library to manage vcloud instances using Chef's knife.

Btw, showterm seems very useful, thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/astratto/vcloud-rest/issues/20#issuecomment-31521594 .

astratto commented 10 years ago

@brettswift feel free to write me a direct email. I'm still on vacation, so my answer might not be very quick :D