rbovirt 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rbovirt might be problematic. Click here for more details.
- data/Gemfile +1 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/lib/ovirt/cluster.rb +1 -1
- data/lib/ovirt/datacenter.rb +1 -1
- data/lib/ovirt/{nic.rb → interface.rb} +1 -1
- data/lib/ovirt/template.rb +18 -4
- data/lib/ovirt/vm.rb +24 -11
- data/lib/ovirt/{disk.rb → volume.rb} +1 -1
- data/lib/rbovirt.rb +41 -27
- data/rbovirt.gemspec +11 -6
- data/spec/integration/api_spec.rb +55 -0
- data/spec/integration/vm_crud_spec.rb +74 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/vm_spec.rb +88 -0
- metadata +25 -8
- data/test/helper.rb +0 -18
- data/test/test_rbovirt.rb +0 -112
    
        data/Gemfile
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -32,6 +32,13 @@ Rake::TestTask.new(:test) do |test| | |
| 32 32 | 
             
              test.verbose = true
         | 
| 33 33 | 
             
            end
         | 
| 34 34 |  | 
| 35 | 
            +
            require 'rspec/core/rake_task'
         | 
| 36 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |test|
         | 
| 37 | 
            +
              #test.libs << 'lib' << 'spec'
         | 
| 38 | 
            +
              test.pattern = 'spec/**/*_spec.rb'
         | 
| 39 | 
            +
              test.verbose = true
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 35 42 | 
             
            require 'rcov/rcovtask'
         | 
| 36 43 | 
             
            Rcov::RcovTask.new do |test|
         | 
| 37 44 | 
             
              test.libs << 'test'
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.0. | 
| 1 | 
            +
            0.0.4
         | 
    
        data/lib/ovirt/cluster.rb
    CHANGED
    
    | @@ -12,7 +12,7 @@ module OVIRT | |
| 12 12 |  | 
| 13 13 | 
             
                def parse_xml_attributes!(xml)
         | 
| 14 14 | 
             
                  @description = ((xml/'description').first.text rescue nil)
         | 
| 15 | 
            -
                  @version =( | 
| 15 | 
            +
                  @version = parse_version(xml)
         | 
| 16 16 | 
             
                  unless (xml/'data_center').empty?
         | 
| 17 17 | 
             
                    @datacenter = Link::new(@client, (xml/'data_center').first[:id], (xml/'data_center').first[:href])
         | 
| 18 18 | 
             
                  end
         | 
    
        data/lib/ovirt/datacenter.rb
    CHANGED
    
    | @@ -15,7 +15,7 @@ module OVIRT | |
| 15 15 | 
             
                  @description = (xml/'description').first.text rescue nil
         | 
| 16 16 | 
             
                  @status = (xml/'status').first.text.strip
         | 
| 17 17 | 
             
                  @storage_type = (xml/'storage_type').first.text
         | 
| 18 | 
            -
                  @storage_format = (xml/'storage_format').first.text
         | 
| 18 | 
            +
                  @storage_format = (xml/'storage_format').first.text rescue nil
         | 
| 19 19 | 
             
                  @supported_versions = (xml/'supported_versions').collect { |v|
         | 
| 20 20 | 
             
                    parse_version v
         | 
| 21 21 | 
             
                  }
         | 
    
        data/lib/ovirt/template.rb
    CHANGED
    
    | @@ -8,12 +8,12 @@ module OVIRT | |
| 8 8 | 
             
                  self
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 | 
            -
                def self.to_xml( | 
| 11 | 
            +
                def self.to_xml(opts={})
         | 
| 12 12 | 
             
                  builder = Nokogiri::XML::Builder.new do
         | 
| 13 13 | 
             
                    template_ {
         | 
| 14 14 | 
             
                      name_ opts[:name] || "t-#{Time.now.to_i}"
         | 
| 15 15 | 
             
                      description opts[:description] || ''
         | 
| 16 | 
            -
                      vm(:id =>  | 
| 16 | 
            +
                      vm(:id => opts[:vm])
         | 
| 17 17 | 
             
                    }
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                  Nokogiri::XML(builder.to_xml).root.to_s
         | 
| @@ -22,9 +22,23 @@ module OVIRT | |
| 22 22 | 
             
                private
         | 
| 23 23 |  | 
| 24 24 | 
             
                def parse_xml_attributes!(xml)
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                  @ | 
| 25 | 
            +
             | 
| 26 | 
            +
                  @description = ((xml/'description').first.text rescue '')
         | 
| 27 | 
            +
                  @status = ((xml/'status').first.text rescue 'unknown')
         | 
| 28 | 
            +
                  @memory = (xml/'memory').first.text
         | 
| 29 | 
            +
                  @profile = (xml/'type').first.text
         | 
| 27 30 | 
             
                  @cluster = Link::new(@client, (xml/'cluster').first[:id], (xml/'cluster').first[:href])
         | 
| 31 | 
            +
                  @display = {
         | 
| 32 | 
            +
                    :type => (xml/'display/type').first.text,
         | 
| 33 | 
            +
                    :monitors => (xml/'display/monitors').first.text
         | 
| 34 | 
            +
                  }
         | 
| 35 | 
            +
                  @cores = ((xml/'cpu/topology').first[:cores] rescue nil)
         | 
| 36 | 
            +
                  @storage = ((xml/'disks/disk/size').first.text rescue nil)
         | 
| 37 | 
            +
                  @creation_time = (xml/'creation_time').text
         | 
| 38 | 
            +
                  @os = {
         | 
| 39 | 
            +
                      :type => (xml/'os').first[:type],
         | 
| 40 | 
            +
                      :boot => (xml/'os/boot').collect {|boot| boot[:dev] }
         | 
| 41 | 
            +
                  }
         | 
| 28 42 | 
             
                end
         | 
| 29 43 | 
             
              end
         | 
| 30 44 | 
             
            end
         | 
    
        data/lib/ovirt/vm.rb
    CHANGED
    
    | @@ -4,30 +4,43 @@ module OVIRT | |
| 4 4 | 
             
                FILEINJECT_PATH = "user-data.txt"
         | 
| 5 5 |  | 
| 6 6 | 
             
              class VM < BaseObject
         | 
| 7 | 
            -
                attr_reader :description, :status, :memory, :profile, :display, :host, :cluster, :template | 
| 7 | 
            +
                attr_reader :description, :status, :memory, :profile, :display, :host, :cluster, :template
         | 
| 8 8 | 
             
                attr_reader :storage, :cores, :creation_time, :os, :ip, :vnc
         | 
| 9 | 
            -
                attr_accessor : | 
| 9 | 
            +
                attr_accessor :interfaces, :volumes
         | 
| 10 10 |  | 
| 11 11 | 
             
                def initialize(client, xml)
         | 
| 12 12 | 
             
                  super(client, xml[:id], xml[:href], (xml/'name').first.text)
         | 
| 13 13 | 
             
                  parse_xml_attributes!(xml)
         | 
| 14 | 
            -
                  self
         | 
| 15 14 | 
             
                end
         | 
| 16 15 |  | 
| 17 16 | 
             
                def running?
         | 
| 18 | 
            -
                  @status =~ / | 
| 17 | 
            +
                  !(@status =~ /down/i)
         | 
| 19 18 | 
             
                end
         | 
| 20 19 |  | 
| 21 | 
            -
                def  | 
| 20 | 
            +
                def interfaces
         | 
| 21 | 
            +
                  @interfaces ||= @client.interfaces(id)
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def disks
         | 
| 25 | 
            +
                  @disks ||= @client.disks(id)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def self.to_xml( opts={})
         | 
| 22 29 | 
             
                  builder = Nokogiri::XML::Builder.new do
         | 
| 23 30 | 
             
                    vm{
         | 
| 24 31 | 
             
                      name_ opts[:name] || "i-#{Time.now.to_i}"
         | 
| 25 | 
            -
                       | 
| 26 | 
            -
                         | 
| 27 | 
            -
                       | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 32 | 
            +
                      if opts[:template]
         | 
| 33 | 
            +
                        template_ :id => (opts[:template])
         | 
| 34 | 
            +
                      elsif opts[:template_name]
         | 
| 35 | 
            +
                        template_{ name_(opts[:template_name])}
         | 
| 36 | 
            +
                      else
         | 
| 37 | 
            +
                        template_{name_('Blank')}
         | 
| 38 | 
            +
                      end
         | 
| 39 | 
            +
                      if opts[:cluster]
         | 
| 40 | 
            +
                        cluster_( :id => opts[:cluster])
         | 
| 41 | 
            +
                      elsif opts[:cluster_name]
         | 
| 42 | 
            +
                        cluster_{ name_(opts[:cluster_name])}
         | 
| 43 | 
            +
                      end
         | 
| 31 44 | 
             
                      type_ opts[:hwp_id] || 'Server'
         | 
| 32 45 | 
             
                      memory opts[:hwp_memory] ? (opts[:hwp_memory].to_i*1024*1024).to_s : (512*1024*1024).to_s
         | 
| 33 46 | 
             
                      cpu {
         | 
    
        data/lib/rbovirt.rb
    CHANGED
    
    | @@ -5,8 +5,8 @@ require "ovirt/host" | |
| 5 5 | 
             
            require "ovirt/storage_domain"
         | 
| 6 6 | 
             
            require "ovirt/template"
         | 
| 7 7 | 
             
            require "ovirt/vm"
         | 
| 8 | 
            -
            require "ovirt/ | 
| 9 | 
            -
            require "ovirt/ | 
| 8 | 
            +
            require "ovirt/volume"
         | 
| 9 | 
            +
            require "ovirt/interface"
         | 
| 10 10 |  | 
| 11 11 | 
             
            require "nokogiri"
         | 
| 12 12 | 
             
            require "rest_client"
         | 
| @@ -27,26 +27,36 @@ module OVIRT | |
| 27 27 |  | 
| 28 28 | 
             
              class Client
         | 
| 29 29 |  | 
| 30 | 
            -
                attr_reader :credentials, :api_entrypoint, :datacenter_id
         | 
| 30 | 
            +
                attr_reader :credentials, :api_entrypoint, :datacenter_id, :cluster_id
         | 
| 31 31 |  | 
| 32 | 
            -
                def initialize(username, password, api_entrypoint, datacenter_id=nil)
         | 
| 32 | 
            +
                def initialize(username, password, api_entrypoint, datacenter_id=nil, cluster_id=nil)
         | 
| 33 33 | 
             
                  @credentials = { :username => username, :password => password }
         | 
| 34 34 | 
             
                  @datacenter_id = datacenter_id
         | 
| 35 | 
            +
                  @cluster_id = cluster_id
         | 
| 35 36 | 
             
                  @api_entrypoint = api_entrypoint
         | 
| 36 37 | 
             
                end
         | 
| 37 38 |  | 
| 38 39 | 
             
                def vm(vm_id, opts={})
         | 
| 39 40 | 
             
                  headers = {:accept => "application/xml; detail=disks; detail=nics; detail=hosts"}
         | 
| 40 41 | 
             
                  vm = OVIRT::VM::new(self,  http_get("/vms/%s" % vm_id, headers).root)
         | 
| 41 | 
            -
                   | 
| 42 | 
            -
             | 
| 43 | 
            -
                   | 
| 44 | 
            -
                  vm.disks = http_get("/vms/%s/disks" % vm_id, headers).xpath('/disks/disk').collect do |disk|
         | 
| 45 | 
            -
                    OVIRT::Disk::new(self, disk)
         | 
| 46 | 
            -
                  end if opts[:disks]
         | 
| 42 | 
            +
                  # optional eager loading
         | 
| 43 | 
            +
                  vm.interfaces = interfaces(vm_id) if opts[:include] && opts[:include].include?(:interfaces)
         | 
| 44 | 
            +
                  vm.volumes = volumes(vm_id) if opts[:include] && opts[:include].include?(:volumes)
         | 
| 47 45 | 
             
                  vm
         | 
| 48 46 | 
             
                end
         | 
| 49 47 |  | 
| 48 | 
            +
                def interfaces vm_id
         | 
| 49 | 
            +
                  http_get("/vms/%s/nics" % vm_id, http_headers).xpath('/nics/nic').collect do |nic|
         | 
| 50 | 
            +
                    OVIRT::Interface::new(self, nic)
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def volumes vm_id
         | 
| 55 | 
            +
                  http_get("/vms/%s/disks" % vm_id, http_headers).xpath('/disks/disk').collect do |disk|
         | 
| 56 | 
            +
                    OVIRT::Volume::new(self, disk)
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 50 60 | 
             
                def vms(opts={})
         | 
| 51 61 | 
             
                  headers = {:accept => "application/xml; detail=disks; detail=nics; detail=hosts"}
         | 
| 52 62 | 
             
                  search= opts[:search] || ("datacenter=%s" % current_datacenter.name)
         | 
| @@ -65,37 +75,37 @@ module OVIRT | |
| 65 75 | 
             
                end
         | 
| 66 76 |  | 
| 67 77 | 
             
                def api_version
         | 
| 68 | 
            -
                   | 
| 69 | 
            -
                  ( | 
| 78 | 
            +
                  xml = http_get("/")/'/api/product_info/version'
         | 
| 79 | 
            +
                  (xml/'version').first[:major] +"."+ (xml/'version').first[:minor]
         | 
| 70 80 | 
             
                end
         | 
| 71 81 |  | 
| 72 82 | 
             
                def api_version?(major)
         | 
| 73 | 
            -
                  api_version. | 
| 83 | 
            +
                  api_version.split('.')[0] == major
         | 
| 74 84 | 
             
                end
         | 
| 75 85 |  | 
| 76 86 | 
             
                def cluster_version?(cluster_id, major)
         | 
| 77 | 
            -
                   | 
| 78 | 
            -
                  ( | 
| 87 | 
            +
                  c = cluster(cluster_id)
         | 
| 88 | 
            +
                  c.version.split('.')[0] == major
         | 
| 79 89 | 
             
                end
         | 
| 80 90 |  | 
| 81 | 
            -
                def create_vm( | 
| 82 | 
            -
                   | 
| 83 | 
            -
                  result_xml = http_post("/vms",OVIRT::VM.to_xml( | 
| 91 | 
            +
                def create_vm(opts)
         | 
| 92 | 
            +
                  opts[:cluster_name] ||= clusters.first.name
         | 
| 93 | 
            +
                  result_xml = http_post("/vms",OVIRT::VM.to_xml(opts))
         | 
| 84 94 | 
             
                  OVIRT::VM::new(self, result_xml.root)
         | 
| 85 95 | 
             
                end
         | 
| 86 96 |  | 
| 87 | 
            -
                def  | 
| 97 | 
            +
                def add_volume(vm_id, opts={})
         | 
| 88 98 | 
             
                  storage_domain_id = opts[:storage_domain] || storagedomains.first.id
         | 
| 89 | 
            -
                  result_xml = http_post("/vms/%s/disks" % vm_id, OVIRT:: | 
| 99 | 
            +
                  result_xml = http_post("/vms/%s/disks" % vm_id, OVIRT::Volume.to_xml(storage_domain_id, opts))
         | 
| 90 100 | 
             
                end
         | 
| 91 101 |  | 
| 92 102 |  | 
| 93 | 
            -
                def  | 
| 94 | 
            -
                  http_post("/vms/%s/nics" % vm_id, OVIRT:: | 
| 103 | 
            +
                def add_interface(vm_id, opts={})
         | 
| 104 | 
            +
                  http_post("/vms/%s/nics" % vm_id, OVIRT::Interface.to_xml( opts))
         | 
| 95 105 | 
             
                end
         | 
| 96 106 |  | 
| 97 | 
            -
                def create_template( | 
| 98 | 
            -
                  template = http_post("/templates", Template.to_xml( | 
| 107 | 
            +
                def create_template(opts)
         | 
| 108 | 
            +
                  template = http_post("/templates", Template.to_xml(opts))
         | 
| 99 109 | 
             
                  OVIRT::Template::new(self, template.root)
         | 
| 100 110 | 
             
                end
         | 
| 101 111 |  | 
| @@ -104,7 +114,7 @@ module OVIRT | |
| 104 114 | 
             
                end
         | 
| 105 115 |  | 
| 106 116 | 
             
                def templates(opts={})
         | 
| 107 | 
            -
                  search= opts[:search] || ("datacenter | 
| 117 | 
            +
                  search= opts[:search] || ("datacenter=%s" % current_datacenter.name)
         | 
| 108 118 | 
             
                  http_get("/templates?search=%s" % CGI.escape(search)).xpath('/templates/template').collect do |t|
         | 
| 109 119 | 
             
                    OVIRT::Template::new(self, t)
         | 
| 110 120 | 
             
                  end.compact
         | 
| @@ -125,7 +135,7 @@ module OVIRT | |
| 125 135 |  | 
| 126 136 | 
             
                def clusters(opts={})
         | 
| 127 137 | 
             
                  headers = {:accept => "application/xml; detail=datacenters"}
         | 
| 128 | 
            -
                  search= opts[:search] || ("datacenter | 
| 138 | 
            +
                  search= opts[:search] || ("datacenter=%s" % current_datacenter.name)
         | 
| 129 139 | 
             
                  http_get("/clusters?search=%s" % CGI.escape(search), headers).xpath('/clusters/cluster').collect do |cl|
         | 
| 130 140 | 
             
                    OVIRT::Cluster.new(self, cl)
         | 
| 131 141 | 
             
                  end
         | 
| @@ -141,6 +151,10 @@ module OVIRT | |
| 141 151 | 
             
                  @current_datacenter ||= self.datacenter_id ? datacenter(self.datacenter_id) : datacenters.first
         | 
| 142 152 | 
             
                end
         | 
| 143 153 |  | 
| 154 | 
            +
                def current_cluster
         | 
| 155 | 
            +
                  @current_cluster ||= self.cluster_id ? cluster(self.cluster_id) : clusters.first
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
             | 
| 144 158 | 
             
                def datacenter(datacenter_id)
         | 
| 145 159 | 
             
                  begin
         | 
| 146 160 | 
             
                    datacenter = http_get("/datacenters/%s" % datacenter_id)
         | 
| @@ -156,7 +170,7 @@ module OVIRT | |
| 156 170 | 
             
                end
         | 
| 157 171 |  | 
| 158 172 | 
             
                def hosts(opts={})
         | 
| 159 | 
            -
                  search= opts[:search] || ("datacenter | 
| 173 | 
            +
                  search= opts[:search] || ("datacenter=%s" % current_datacenter.name)
         | 
| 160 174 | 
             
                  http_get("/hosts?search=%s" % CGI.escape(search)).xpath('/hosts/host').collect do |h|
         | 
| 161 175 | 
             
                    OVIRT::Host::new(self, h)
         | 
| 162 176 | 
             
                  end
         | 
    
        data/rbovirt.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{rbovirt}
         | 
| 8 | 
            -
              s.version = "0.0. | 
| 8 | 
            +
              s.version = "0.0.4"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Amos Benari"]
         | 
| 12 | 
            -
              s.date = %q{2012-01- | 
| 12 | 
            +
              s.date = %q{2012-01-30}
         | 
| 13 13 | 
             
              s.description = %q{A Ruby client for oVirt REST API}
         | 
| 14 14 | 
             
              s.email = %q{abenari@redhat.com}
         | 
| 15 15 | 
             
              s.extra_rdoc_files = [
         | 
| @@ -26,16 +26,18 @@ Gem::Specification.new do |s| | |
| 26 26 | 
             
                "lib/ovirt/base_object.rb",
         | 
| 27 27 | 
             
                "lib/ovirt/cluster.rb",
         | 
| 28 28 | 
             
                "lib/ovirt/datacenter.rb",
         | 
| 29 | 
            -
                "lib/ovirt/disk.rb",
         | 
| 30 29 | 
             
                "lib/ovirt/host.rb",
         | 
| 31 | 
            -
                "lib/ovirt/ | 
| 30 | 
            +
                "lib/ovirt/interface.rb",
         | 
| 32 31 | 
             
                "lib/ovirt/storage_domain.rb",
         | 
| 33 32 | 
             
                "lib/ovirt/template.rb",
         | 
| 34 33 | 
             
                "lib/ovirt/vm.rb",
         | 
| 34 | 
            +
                "lib/ovirt/volume.rb",
         | 
| 35 35 | 
             
                "lib/rbovirt.rb",
         | 
| 36 36 | 
             
                "rbovirt.gemspec",
         | 
| 37 | 
            -
                " | 
| 38 | 
            -
                " | 
| 37 | 
            +
                "spec/integration/api_spec.rb",
         | 
| 38 | 
            +
                "spec/integration/vm_crud_spec.rb",
         | 
| 39 | 
            +
                "spec/spec_helper.rb",
         | 
| 40 | 
            +
                "spec/unit/vm_spec.rb"
         | 
| 39 41 | 
             
              ]
         | 
| 40 42 | 
             
              s.homepage = %q{http://github.com/abenari/rbovirt}
         | 
| 41 43 | 
             
              s.licenses = ["MIT"]
         | 
| @@ -54,6 +56,7 @@ Gem::Specification.new do |s| | |
| 54 56 | 
             
                  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 55 57 | 
             
                  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
         | 
| 56 58 | 
             
                  s.add_development_dependency(%q<rcov>, [">= 0"])
         | 
| 59 | 
            +
                  s.add_development_dependency(%q<rspec-rails>, ["~> 2.6"])
         | 
| 57 60 | 
             
                else
         | 
| 58 61 | 
             
                  s.add_dependency(%q<nokogiri>, [">= 0"])
         | 
| 59 62 | 
             
                  s.add_dependency(%q<rest-client>, [">= 0"])
         | 
| @@ -61,6 +64,7 @@ Gem::Specification.new do |s| | |
| 61 64 | 
             
                  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 62 65 | 
             
                  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
         | 
| 63 66 | 
             
                  s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 67 | 
            +
                  s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
         | 
| 64 68 | 
             
                end
         | 
| 65 69 | 
             
              else
         | 
| 66 70 | 
             
                s.add_dependency(%q<nokogiri>, [">= 0"])
         | 
| @@ -69,6 +73,7 @@ Gem::Specification.new do |s| | |
| 69 73 | 
             
                s.add_dependency(%q<bundler>, ["~> 1.0.0"])
         | 
| 70 74 | 
             
                s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
         | 
| 71 75 | 
             
                s.add_dependency(%q<rcov>, [">= 0"])
         | 
| 76 | 
            +
                s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
         | 
| 72 77 | 
             
              end
         | 
| 73 78 | 
             
            end
         | 
| 74 79 |  | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            require "#{File.dirname(__FILE__)}/../spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe OVIRT, "API" do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              # This spec requires the API to be stable, so that projects using
         | 
| 6 | 
            +
              # OVIRT do not have to update their code if a new (minor)
         | 
| 7 | 
            +
              # version is released.
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              # API compatibility is only guaranteed for minor version changes;
         | 
| 10 | 
            +
              # New major versions may change the API and require code changes
         | 
| 11 | 
            +
              # in projects using this plugin.
         | 
| 12 | 
            +
              #
         | 
| 13 | 
            +
              # Because of the API stability guarantee, these spec's may only
         | 
| 14 | 
            +
              # be changed for new major releases.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              before(:all) do
         | 
| 17 | 
            +
                user="admin@internal"
         | 
| 18 | 
            +
                password="123123"
         | 
| 19 | 
            +
                hostname = "ovirt.sat.lab.tlv.redhat.com"
         | 
| 20 | 
            +
                port = "8080"
         | 
| 21 | 
            +
                url = "http://#{hostname}:#{port}/api"
         | 
| 22 | 
            +
                @blank_template_id = "00000000-0000-0000-0000-000000000000"
         | 
| 23 | 
            +
                @client = ::OVIRT::Client.new(user, password, url)
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              after(:all) do
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              context 'basic api and listing' do
         | 
| 30 | 
            +
                it "test_should_return_a_version" do
         | 
| 31 | 
            +
                  @client.api_version.should eql('3.0')
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it "test_should_return_datacenters" do
         | 
| 35 | 
            +
                  @client.datacenters.class.should eql(Array)
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                it "test_should_return_clusters" do
         | 
| 39 | 
            +
                  @client.clusters.class.should eql(Array)
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "test_should_return_templates" do
         | 
| 43 | 
            +
                  @client.templates.class.should eql(Array)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it "test_should_return_vms" do
         | 
| 47 | 
            +
                  @client.vms.class.should eql(Array)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
                it "test_should_return_storage" do
         | 
| 50 | 
            +
                  @client.storagedomains.class.should eql(Array)
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            end
         | 
| @@ -0,0 +1,74 @@ | |
| 1 | 
            +
            require "#{File.dirname(__FILE__)}/../spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "VM Life cycle" do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              before(:all) do
         | 
| 6 | 
            +
               user="admin@internal"
         | 
| 7 | 
            +
                password="123123"
         | 
| 8 | 
            +
                hostname = "ovirt.sat.lab.tlv.redhat.com"
         | 
| 9 | 
            +
                port = "8080"
         | 
| 10 | 
            +
                url = "http://#{hostname}:#{port}/api"
         | 
| 11 | 
            +
                @blank_template_id = "00000000-0000-0000-0000-000000000000"
         | 
| 12 | 
            +
                @client = ::OVIRT::Client.new(user, password, url)
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              context 'basic vm and templates operations' do
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                before(:all) do
         | 
| 18 | 
            +
                  name = 'vm-'+Time.now.to_i.to_s
         | 
| 19 | 
            +
                  params = {}
         | 
| 20 | 
            +
                  params[:name] = name
         | 
| 21 | 
            +
                  params[:cluster_name] = "test"
         | 
| 22 | 
            +
                  @vm = @client.create_vm(params)
         | 
| 23 | 
            +
                  @client.add_volume(@vm.id)
         | 
| 24 | 
            +
                  @client.add_interface(@vm.id)
         | 
| 25 | 
            +
                  while @client.vm(@vm.id).status !~ /down/i do
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                after(:all) do
         | 
| 30 | 
            +
                  @client.destroy_vm(@vm.id)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                it "test_should_create_template" do
         | 
| 34 | 
            +
                  template_name = "test_template"
         | 
| 35 | 
            +
                  template = @client.create_template(:vm => @vm.id, :name => template_name, :description => "test_template")
         | 
| 36 | 
            +
                  template.class.to_s.should eql("OVIRT::Template")
         | 
| 37 | 
            +
                  while @client.vm(@vm.id).status !~ /down/i do
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                  @client.destroy_template(template.id)
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                it "test_should_return_a_template" do
         | 
| 43 | 
            +
                  @client.template(@blank_template_id).id.should eql(@blank_template_id)
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                it "test_should_return_a_vm" do
         | 
| 47 | 
            +
                  @client.vm(@vm.id).id.should eql(@vm.id)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                it "test_should_start_and_stop_vm" do
         | 
| 51 | 
            +
                  @client.vm_action(@vm.id, :start)
         | 
| 52 | 
            +
                  @client.vm_action(@vm.id, :shutdown)
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                it "test_should_destroy_vm" do
         | 
| 56 | 
            +
                  name = 'd-'+Time.now.to_i.to_s
         | 
| 57 | 
            +
                  params = {}
         | 
| 58 | 
            +
                  params[:name] = name
         | 
| 59 | 
            +
                  params[:cluster_name] = "test"
         | 
| 60 | 
            +
                  vm = @client.create_vm(params)
         | 
| 61 | 
            +
                  @client.destroy_vm(vm.id)
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                it "test_should_create_a_vm" do
         | 
| 65 | 
            +
                  name = 'c-'+Time.now.to_i.to_s
         | 
| 66 | 
            +
                  params = {}
         | 
| 67 | 
            +
                  params[:name] = name
         | 
| 68 | 
            +
                  params[:cluster_name] = "test"
         | 
| 69 | 
            +
                  vm = @client.create_vm(params)
         | 
| 70 | 
            +
                  vm.class.to_s.should eql("OVIRT::VM")
         | 
| 71 | 
            +
                  @client.destroy_vm(vm.id)
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
| @@ -0,0 +1,88 @@ | |
| 1 | 
            +
            require "#{File.dirname(__FILE__)}/../spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe OVIRT::VM do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              context 'xml parsing' do
         | 
| 7 | 
            +
                before(:all) do
         | 
| 8 | 
            +
                  @xml = <<END_HEREDOC
         | 
| 9 | 
            +
            <vm id="76d29095-bc27-4cd0-8178-07e942aea549" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549">
         | 
| 10 | 
            +
            <name>c-1326980484</name>
         | 
| 11 | 
            +
            <actions>
         | 
| 12 | 
            +
            <link rel="shutdown" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/shutdown"/>
         | 
| 13 | 
            +
            <link rel="start" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/start"/>
         | 
| 14 | 
            +
            <link rel="stop" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/stop"/>
         | 
| 15 | 
            +
            <link rel="suspend" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/suspend"/>
         | 
| 16 | 
            +
            <link rel="detach" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/detach"/>
         | 
| 17 | 
            +
            <link rel="export" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/export"/>
         | 
| 18 | 
            +
            <link rel="move" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/move"/>
         | 
| 19 | 
            +
            <link rel="ticket" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/ticket"/>
         | 
| 20 | 
            +
            <link rel="migrate" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/migrate"/>
         | 
| 21 | 
            +
            <link rel="cancelmigration" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/cancelmigration"/>
         | 
| 22 | 
            +
            </actions>
         | 
| 23 | 
            +
            <link rel="disks" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/disks"/>
         | 
| 24 | 
            +
            <link rel="nics" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/nics"/>
         | 
| 25 | 
            +
            <link rel="cdroms" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/cdroms"/>
         | 
| 26 | 
            +
            <link rel="snapshots" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/snapshots"/>
         | 
| 27 | 
            +
            <link rel="tags" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/tags"/>
         | 
| 28 | 
            +
            <link rel="permissions" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/permissions"/>
         | 
| 29 | 
            +
            <link rel="statistics" href="/api/vms/76d29095-bc27-4cd0-8178-07e942aea549/statistics"/>
         | 
| 30 | 
            +
            <type>server</type>
         | 
| 31 | 
            +
            <status>
         | 
| 32 | 
            +
            <state>up</state>
         | 
| 33 | 
            +
            </status>
         | 
| 34 | 
            +
            <memory>536870912</memory>
         | 
| 35 | 
            +
            <cpu>
         | 
| 36 | 
            +
            <topology cores="1" sockets="1"/>
         | 
| 37 | 
            +
            </cpu>
         | 
| 38 | 
            +
            <os type="unassigned">
         | 
| 39 | 
            +
            <boot dev="network"/>
         | 
| 40 | 
            +
            <boot dev="hd"/>
         | 
| 41 | 
            +
            </os>
         | 
| 42 | 
            +
            <high_availability>
         | 
| 43 | 
            +
            <enabled>false</enabled>
         | 
| 44 | 
            +
            <priority>0</priority>
         | 
| 45 | 
            +
            </high_availability>
         | 
| 46 | 
            +
            <display>
         | 
| 47 | 
            +
            <type>vnc</type>
         | 
| 48 | 
            +
            <monitors>1</monitors>
         | 
| 49 | 
            +
            </display>
         | 
| 50 | 
            +
            <cluster id="b68980dc-3ab8-11e1-bcbf-5254005f0f6f" href="/api/clusters/b68980dc-3ab8-11e1-bcbf-5254005f0f6f"/>
         | 
| 51 | 
            +
            <template id="00000000-0000-0000-0000-000000000000" href="/api/templates/00000000-0000-0000-0000-000000000000"/>
         | 
| 52 | 
            +
            <start_time>2012-01-19T14:41:58.428Z</start_time>
         | 
| 53 | 
            +
            <creation_time>2012-01-19T13:41:24.405Z</creation_time>
         | 
| 54 | 
            +
            <origin>rhev</origin>
         | 
| 55 | 
            +
            <stateless>false</stateless>
         | 
| 56 | 
            +
            <placement_policy>
         | 
| 57 | 
            +
            <affinity>migratable</affinity>
         | 
| 58 | 
            +
            </placement_policy>
         | 
| 59 | 
            +
            <memory_policy>
         | 
| 60 | 
            +
            <guaranteed>536870912</guaranteed>
         | 
| 61 | 
            +
            </memory_policy>
         | 
| 62 | 
            +
            <usb>
         | 
| 63 | 
            +
            <enabled>true</enabled>
         | 
| 64 | 
            +
            </usb>
         | 
| 65 | 
            +
            </vm>
         | 
| 66 | 
            +
            END_HEREDOC
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                it "should parse VM xml" do
         | 
| 70 | 
            +
                  vm = OVIRT::VM.new(nil, Nokogiri::XML(@xml).xpath('/'))
         | 
| 71 | 
            +
                  vm.class.should eql(OVIRT::VM)
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                it "create vm xml" do
         | 
| 75 | 
            +
                  opts = {:cluster_name=>'cluster', :template_name =>'template'}
         | 
| 76 | 
            +
                  xml = OVIRT::VM.to_xml(opts)
         | 
| 77 | 
            +
                  xml.nil?.should eql(false)
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                it "should be running" do
         | 
| 81 | 
            +
                  vm = OVIRT::VM.new(nil, Nokogiri::XML(@xml).xpath('/'))
         | 
| 82 | 
            +
                  vm.running?.should eql(true)
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
             | 
| 86 | 
            +
              end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: rbovirt
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 23
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 4
         | 
| 10 | 
            +
              version: 0.0.4
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Amos Benari
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2012-01- | 
| 18 | 
            +
            date: 2012-01-30 00:00:00 +02:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -106,6 +106,21 @@ dependencies: | |
| 106 106 | 
             
                    version: "0"
         | 
| 107 107 | 
             
              requirement: *id006
         | 
| 108 108 | 
             
              type: :development
         | 
| 109 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 110 | 
            +
              prerelease: false
         | 
| 111 | 
            +
              name: rspec-rails
         | 
| 112 | 
            +
              version_requirements: &id007 !ruby/object:Gem::Requirement 
         | 
| 113 | 
            +
                none: false
         | 
| 114 | 
            +
                requirements: 
         | 
| 115 | 
            +
                - - ~>
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 117 | 
            +
                    hash: 15
         | 
| 118 | 
            +
                    segments: 
         | 
| 119 | 
            +
                    - 2
         | 
| 120 | 
            +
                    - 6
         | 
| 121 | 
            +
                    version: "2.6"
         | 
| 122 | 
            +
              requirement: *id007
         | 
| 123 | 
            +
              type: :development
         | 
| 109 124 | 
             
            description: A Ruby client for oVirt REST API
         | 
| 110 125 | 
             
            email: abenari@redhat.com
         | 
| 111 126 | 
             
            executables: []
         | 
| @@ -125,16 +140,18 @@ files: | |
| 125 140 | 
             
            - lib/ovirt/base_object.rb
         | 
| 126 141 | 
             
            - lib/ovirt/cluster.rb
         | 
| 127 142 | 
             
            - lib/ovirt/datacenter.rb
         | 
| 128 | 
            -
            - lib/ovirt/disk.rb
         | 
| 129 143 | 
             
            - lib/ovirt/host.rb
         | 
| 130 | 
            -
            - lib/ovirt/ | 
| 144 | 
            +
            - lib/ovirt/interface.rb
         | 
| 131 145 | 
             
            - lib/ovirt/storage_domain.rb
         | 
| 132 146 | 
             
            - lib/ovirt/template.rb
         | 
| 133 147 | 
             
            - lib/ovirt/vm.rb
         | 
| 148 | 
            +
            - lib/ovirt/volume.rb
         | 
| 134 149 | 
             
            - lib/rbovirt.rb
         | 
| 135 150 | 
             
            - rbovirt.gemspec
         | 
| 136 | 
            -
            -  | 
| 137 | 
            -
            -  | 
| 151 | 
            +
            - spec/integration/api_spec.rb
         | 
| 152 | 
            +
            - spec/integration/vm_crud_spec.rb
         | 
| 153 | 
            +
            - spec/spec_helper.rb
         | 
| 154 | 
            +
            - spec/unit/vm_spec.rb
         | 
| 138 155 | 
             
            has_rdoc: true
         | 
| 139 156 | 
             
            homepage: http://github.com/abenari/rbovirt
         | 
| 140 157 | 
             
            licenses: 
         | 
    
        data/test/helper.rb
    DELETED
    
    | @@ -1,18 +0,0 @@ | |
| 1 | 
            -
            require 'rubygems'
         | 
| 2 | 
            -
            require 'bundler'
         | 
| 3 | 
            -
            begin
         | 
| 4 | 
            -
              Bundler.setup(:default, :development)
         | 
| 5 | 
            -
            rescue Bundler::BundlerError => e
         | 
| 6 | 
            -
              $stderr.puts e.message
         | 
| 7 | 
            -
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 8 | 
            -
              exit e.status_code
         | 
| 9 | 
            -
            end
         | 
| 10 | 
            -
            require 'test/unit'
         | 
| 11 | 
            -
            require 'shoulda'
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         | 
| 14 | 
            -
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         | 
| 15 | 
            -
            require 'rbovirt'
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            class Test::Unit::TestCase
         | 
| 18 | 
            -
            end
         | 
    
        data/test/test_rbovirt.rb
    DELETED
    
    | @@ -1,112 +0,0 @@ | |
| 1 | 
            -
            require 'helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            class TestRbovirt < Test::Unit::TestCase
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              def setup
         | 
| 6 | 
            -
                user="admin@internal"
         | 
| 7 | 
            -
                password="123123"
         | 
| 8 | 
            -
                hostname = "ovirt.sat.lab.tlv.redhat.com"
         | 
| 9 | 
            -
                port = "8080"
         | 
| 10 | 
            -
                url = "http://#{hostname}:#{port}/api"
         | 
| 11 | 
            -
                @blank_template_id = "00000000-0000-0000-0000-000000000000"
         | 
| 12 | 
            -
                @client = ::OVIRT::Client.new(user, password, url)
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              def test_should_return_a_version
         | 
| 16 | 
            -
                assert @client.api_version
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              def test_should_return_datacenters
         | 
| 20 | 
            -
                assert @client.datacenters
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              def test_should_return_clusters
         | 
| 24 | 
            -
                assert @client.clusters
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              def test_should_return_templates
         | 
| 28 | 
            -
                assert @client.templates
         | 
| 29 | 
            -
              end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              def test_should_create_template
         | 
| 32 | 
            -
                name = 't'+Time.now.to_i.to_s
         | 
| 33 | 
            -
                params = {}
         | 
| 34 | 
            -
                params[:name] = name
         | 
| 35 | 
            -
                params[:cluster_name] = "test"
         | 
| 36 | 
            -
                vm = @client.create_vm("Blank",params)
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                @client.add_disk(vm.id)
         | 
| 39 | 
            -
                @client.add_nic(vm.id)
         | 
| 40 | 
            -
                while @client.vm(vm.id).status !~ /down/i do
         | 
| 41 | 
            -
                end
         | 
| 42 | 
            -
                template_name = "test_template"
         | 
| 43 | 
            -
                assert template = @client.create_template(vm.id, :name => template_name, :description => "test_template")
         | 
| 44 | 
            -
                while @client.vm(vm.id).status !~ /down/i do
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
                assert @client.destroy_template(template.id)
         | 
| 47 | 
            -
                @client.destroy_vm(vm.id)
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              def test_should_return_a_template
         | 
| 51 | 
            -
                assert @client.template(@blank_template_id)
         | 
| 52 | 
            -
              end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
              def test_should_return_vms
         | 
| 56 | 
            -
                assert @client.vms
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              def test_should_return_a_vm
         | 
| 60 | 
            -
                name = 'a'+Time.now.to_i.to_s
         | 
| 61 | 
            -
                params = {}
         | 
| 62 | 
            -
                params[:name] = name
         | 
| 63 | 
            -
                params[:cluster_name] = "test"
         | 
| 64 | 
            -
                vm = @client.create_vm("Blank",params)
         | 
| 65 | 
            -
                assert @client.vm(vm.id)
         | 
| 66 | 
            -
                @client.destroy_vm(vm.id)
         | 
| 67 | 
            -
              end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
              def test_should_start_vm
         | 
| 70 | 
            -
                name = 'r'+Time.now.to_i.to_s
         | 
| 71 | 
            -
                params = {}
         | 
| 72 | 
            -
                params[:name] = name
         | 
| 73 | 
            -
                params[:cluster_name] = "test"
         | 
| 74 | 
            -
                vm = @client.create_vm("Blank",params)
         | 
| 75 | 
            -
                @client.add_disk(vm.id)
         | 
| 76 | 
            -
                @client.add_nic(vm.id)
         | 
| 77 | 
            -
                while @client.vm(vm.id).status !~ /down/i do
         | 
| 78 | 
            -
                end  
         | 
| 79 | 
            -
                assert @client.vm_action(vm.id, :start)
         | 
| 80 | 
            -
                @client.vm_action(vm.id, :shutdown)
         | 
| 81 | 
            -
                while @client.vm(vm.id).status !~ /down/i do
         | 
| 82 | 
            -
                end
         | 
| 83 | 
            -
                @client.destroy_vm(vm.id)
         | 
| 84 | 
            -
              end
         | 
| 85 | 
            -
             | 
| 86 | 
            -
              def test_should_stop_vm
         | 
| 87 | 
            -
             | 
| 88 | 
            -
              end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
              def test_should_destroy_vm
         | 
| 91 | 
            -
                name = 'd'+Time.now.to_i.to_s
         | 
| 92 | 
            -
                params = {}
         | 
| 93 | 
            -
                params[:name] = name
         | 
| 94 | 
            -
                params[:cluster_name] = "test"
         | 
| 95 | 
            -
                vm = @client.create_vm("Blank",params)
         | 
| 96 | 
            -
                assert @client.destroy_vm(vm.id)
         | 
| 97 | 
            -
              end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
              def test_should_return_storage
         | 
| 100 | 
            -
                assert @client.storagedomains
         | 
| 101 | 
            -
              end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
              def test_should_create_a_vm
         | 
| 104 | 
            -
                name = 'c'+Time.now.to_i.to_s
         | 
| 105 | 
            -
                params = {}
         | 
| 106 | 
            -
                params[:name] = name
         | 
| 107 | 
            -
                params[:cluster_name] = "test"
         | 
| 108 | 
            -
                assert vm = @client.create_vm("Blank",params)
         | 
| 109 | 
            -
                @client.destroy_vm(vm.id)
         | 
| 110 | 
            -
              end
         | 
| 111 | 
            -
             | 
| 112 | 
            -
            end
         |