Project: ovfparse
Website: github.com/ruby-ovf/ovfparse License: GPLv3 Mailing list: [email protected] Source Code: git://github.com/ruby-ovf/ovfparse.git
Requirements
- ruby
- net/ftp
- net/http
- net/https
- nokogiri xml parser (native gem)
Install
From inside your ovfparse directory: $ rake gem $ cd pkg $ gem install ovfparse
Or from RubyGems: $ gem install ovfparse
Example1
uri = “file://../test_files” vmRepo = VmRepository.create(uri) #use factory method to get repo class puts “nn****************************n” puts “protocol: ” + vmRepo.protocol + “n” puts “url: ” + vmRepo.url + “n” puts “uri: ” + vmRepo.uri + “n” puts vmRepo.fetch #shows all the packages available at the repo
Example2
# use factory method to get correct package type package = VmPackage.create(“ambrosia/repo/someOVF.ovf”) # retrieve package package.fetch # spit out package xml puts package.xml
Example3
# use factory method to get correct package type package = VmPackage.create(“ambrosia/repo/someOVF.ovf”) # retrieve package package.fetch # spit out specific xml section puts package.ProductSection
Useful tips
‘method_missing’ is implemented to return xml nodes of the section that is named like the missing method. For example, if your xml has a section called <FirstName>some data</FirstName> you can simply request the object through any of the following methods:
node = package.first_name()
node = package.first_name
node = package.FirstName()
node = package.FirstName