labmanager 0.0.1 → 0.0.2
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.
- data/lib/labmanager/constants.rb +41 -34
- data/lib/labmanager/labmanager_service.rb +52 -5
- data/lib/labmanager/net_http_driver.rb +96 -0
- data/test/test_helper.rb +61 -1
- data/test/test_machines.rb +22 -2
- metadata +8 -21
- data/README +0 -3
- data/test/12test_labmanager_proxy.rb +0 -67
    
        data/lib/labmanager/constants.rb
    CHANGED
    
    | @@ -1,37 +1,44 @@ | |
| 1 | 
            -
            module  | 
| 1 | 
            +
            module VmWare
         | 
| 2 | 
            +
              module Constants
         | 
| 2 3 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 25 | 
            -
              CONFIGURATION_ACTION_POWERON=1;
         | 
| 26 | 
            -
              CONFIGURATION_ACTION_POWEROFF=2;
         | 
| 27 | 
            -
              CONFIGURATION_ACTION_SUSPEND=3;
         | 
| 28 | 
            -
              CONFIGURATION_ACTION_RESUME=4;
         | 
| 29 | 
            -
              CONFIGURATION_ACTION_RESET=5;
         | 
| 30 | 
            -
              CONFIGURATION_ACTION_SNAPSHOT=6;
         | 
| 31 | 
            -
              CONFIGURATION_ACTION_REVERT=7;
         | 
| 32 | 
            -
              CONFIGURATION_ACTION_SHUTDOWN=8;
         | 
| 33 | 
            -
              
         | 
| 34 | 
            -
              
         | 
| 35 | 
            -
              FENCE_MODE_UNFENCED = 1;
         | 
| 4 | 
            +
                MACHINE_ACTION_POWERON =1;
         | 
| 5 | 
            +
                MACHINE_ACTION_POWEROFF =2;
         | 
| 6 | 
            +
                MACHINE_ACTION_SUSPEND =3;
         | 
| 7 | 
            +
                MACHINE_ACTION_RESUME =4;
         | 
| 8 | 
            +
                MACHINE_ACTION_RESET =5;
         | 
| 9 | 
            +
                MACHINE_ACTION_SNAPSHOT =6;
         | 
| 10 | 
            +
                MACHINE_ACTION_REVERT =7;
         | 
| 11 | 
            +
                MACHINE_ACTION_SHUTDOWN =8;
         | 
| 12 | 
            +
                MACHINE_ACTION_CONSOLIDATE =9;
         | 
| 13 | 
            +
                MACHINE_ACTION_EJECTCD =10;
         | 
| 14 | 
            +
                MACHINE_ACTION_EJECTFLOPPY =11;
         | 
| 15 | 
            +
                MACHINE_ACTION_DEPLOY =12;
         | 
| 16 | 
            +
                MACHINE_ACTION_UNDEPLOY =13;
         | 
| 17 | 
            +
                MACHINE_ACTION_FORCEUNDEPLOY =14;
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                MACHINE_STATUS_UNDEPLOYED =0;
         | 
| 20 | 
            +
                MACHINE_STATUS_OFF =1;
         | 
| 21 | 
            +
                MACHINE_STATUS_ON =2;
         | 
| 22 | 
            +
                MACHINE_STATUS_SUSPENDED =3;
         | 
| 23 | 
            +
                MACHINE_STATUS_STUCK =4;
         | 
| 24 | 
            +
                MACHINE_STATUS_INVALID =128;
         | 
| 25 | 
            +
                MACHINE_STATUS_DELETED =999;
         | 
| 36 26 |  | 
| 27 | 
            +
                
         | 
| 28 | 
            +
                CONFIGURATION_ACTION_POWERON=1;
         | 
| 29 | 
            +
                CONFIGURATION_ACTION_POWEROFF=2;
         | 
| 30 | 
            +
                CONFIGURATION_ACTION_SUSPEND=3;
         | 
| 31 | 
            +
                CONFIGURATION_ACTION_RESUME=4;
         | 
| 32 | 
            +
                CONFIGURATION_ACTION_RESET=5;
         | 
| 33 | 
            +
                CONFIGURATION_ACTION_SNAPSHOT=6;
         | 
| 34 | 
            +
                CONFIGURATION_ACTION_REVERT=7;
         | 
| 35 | 
            +
                CONFIGURATION_ACTION_SHUTDOWN=8;
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                
         | 
| 38 | 
            +
                IP_ADDRESSSING_STATIC_MANUAL="STATIC_MANUAL"
         | 
| 39 | 
            +
                IP_ADDRESSSING_STATIC_AUTOMATIC="STATIC_AUTOMATIC"
         | 
| 40 | 
            +
                
         | 
| 41 | 
            +
                FENCE_MODE_UNFENCED = 1;
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
              end
         | 
| 37 44 | 
             
            end
         | 
| @@ -1,14 +1,21 @@ | |
| 1 1 | 
             
            require "handsoap"
         | 
| 2 | 
            +
            require "handsoap/http"
         | 
| 2 3 | 
             
            require "labmanager/constants"
         | 
| 4 | 
            +
            require "labmanager/net_http_driver"
         | 
| 3 5 |  | 
| 4 6 | 
             
            class LabmanagerService < Handsoap::Service
         | 
| 5 7 |  | 
| 6 | 
            -
              include Constants
         | 
| 8 | 
            +
              include VmWare::Constants
         | 
| 7 9 |  | 
| 8 10 | 
             
              @@workspace =''
         | 
| 9 11 | 
             
              @@username =''
         | 
| 10 12 | 
             
              @@password =''
         | 
| 11 13 | 
             
              @@pragmatic=false
         | 
| 14 | 
            +
              @@testmode=false
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              Handsoap.http_driver = :custom
         | 
| 12 19 |  | 
| 13 20 |  | 
| 14 21 | 
             
              def self.configure(config)
         | 
| @@ -18,8 +25,11 @@ class LabmanagerService < Handsoap::Service | |
| 18 25 | 
             
                @@password = config[:password]
         | 
| 19 26 | 
             
                @@workspace = config[:workspace]
         | 
| 20 27 | 
             
                @@pragmatic = config[:pragmatic]
         | 
| 21 | 
            -
             | 
| 28 | 
            +
                  
         | 
| 22 29 | 
             
                endpoint :uri => @@wsdl, :version => 2
         | 
| 30 | 
            +
                
         | 
| 31 | 
            +
                
         | 
| 32 | 
            +
                
         | 
| 23 33 | 
             
              end
         | 
| 24 34 |  | 
| 25 35 | 
             
              # Register namespaces for request
         | 
| @@ -56,11 +66,12 @@ class LabmanagerService < Handsoap::Service | |
| 56 66 | 
             
                    message.add('labmanager:desc',args[:description])
         | 
| 57 67 | 
             
                  end
         | 
| 58 68 |  | 
| 59 | 
            -
                  puts "create Document 2"
         | 
| 60 69 |  | 
| 61 70 | 
             
                  (response/"//labmanager:ConfigurationCreateExResponse/labmanager:ConfigurationCreateExResult").to_i
         | 
| 62 71 |  | 
| 63 72 | 
             
                rescue Handsoap::Fault => error
         | 
| 73 | 
            +
                 
         | 
| 74 | 
            +
                  
         | 
| 64 75 | 
             
                  if @@pragmatic then
         | 
| 65 76 | 
             
                    config = getConfigurationByName(args[:name])
         | 
| 66 77 | 
             
                    config[:id]
         | 
| @@ -191,6 +202,7 @@ class LabmanagerService < Handsoap::Service | |
| 191 202 | 
             
                        network.add('labmanager:networkId',config[:network_id])
         | 
| 192 203 | 
             
                        network.add('labmanager:ipAddress',config[:ipaddress])
         | 
| 193 204 | 
             
                        network.add('labmanager:ipAddressingMode',config[:ipaddressingmode])
         | 
| 205 | 
            +
                        network.add('labmanager:isConnected',true)
         | 
| 194 206 | 
             
                      end
         | 
| 195 207 | 
             
                    end
         | 
| 196 208 |  | 
| @@ -244,7 +256,20 @@ class LabmanagerService < Handsoap::Service | |
| 244 256 | 
             
              end
         | 
| 245 257 |  | 
| 246 258 | 
             
              def getMachine(id)
         | 
| 247 | 
            -
             | 
| 259 | 
            +
                  response = invoke('labmanager:GetMachine') do |message|
         | 
| 260 | 
            +
                    message.add('labmanager:machineId',id)
         | 
| 261 | 
            +
                  end
         | 
| 262 | 
            +
              
         | 
| 263 | 
            +
                  machine =
         | 
| 264 | 
            +
                  {
         | 
| 265 | 
            +
                    :id => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:id").to_s,
         | 
| 266 | 
            +
                    :name => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:name").to_s,
         | 
| 267 | 
            +
                    :description => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:description").to_s,
         | 
| 268 | 
            +
                    :ipaddress => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:internalIP").to_s,
         | 
| 269 | 
            +
                    :memory => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:memory").to_s,
         | 
| 270 | 
            +
                    :deployed => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:isDeployed").to_s,
         | 
| 271 | 
            +
                    :status => (response/"//labmanager:GetMachineResponse/labmanager:GetMachineResult/labmanager:status").to_s,
         | 
| 272 | 
            +
                  }
         | 
| 248 273 | 
             
              end
         | 
| 249 274 |  | 
| 250 275 | 
             
              def getMachineByName(config_id,name)
         | 
| @@ -257,11 +282,33 @@ class LabmanagerService < Handsoap::Service | |
| 257 282 | 
             
                {
         | 
| 258 283 | 
             
                  :id => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:id").to_s,
         | 
| 259 284 | 
             
                  :name => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:name").to_s,
         | 
| 260 | 
            -
                  :description => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:description").to_s
         | 
| 285 | 
            +
                  :description => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:description").to_s,
         | 
| 286 | 
            +
                  :ipaddress => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:internalIP").to_s,
         | 
| 287 | 
            +
                  :memory => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:memory").to_s,
         | 
| 288 | 
            +
                  :deployed => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:isDeployed").to_s,
         | 
| 289 | 
            +
                  :status => (response/"//labmanager:GetMachineByNameResponse/labmanager:GetMachineByNameResult/labmanager:status").to_s,
         | 
| 290 | 
            +
             | 
| 261 291 | 
             
                }
         | 
| 262 292 |  | 
| 263 293 | 
             
              end
         | 
| 264 294 |  | 
| 295 | 
            +
              def listMachines(config_id)
         | 
| 296 | 
            +
                response = invoke('labmanager:GetTemplateByName') do |message|
         | 
| 297 | 
            +
                  message.add('labmanager:configurationId',config_id)
         | 
| 298 | 
            +
                end
         | 
| 299 | 
            +
             | 
| 300 | 
            +
                hashes = (response/"//labmanager:ListMachinesResponse/labmanager:ListMachinesResult/labmanager:Machine").map do |machine|
         | 
| 301 | 
            +
                  {
         | 
| 302 | 
            +
                    :id => (machine/"labmanager:id").to_s,
         | 
| 303 | 
            +
                    :name => (machine/"labmanager:name").to_s,
         | 
| 304 | 
            +
                    :description => (machine/"labmanager:description").to_s
         | 
| 305 | 
            +
                  }
         | 
| 306 | 
            +
                end
         | 
| 307 | 
            +
             | 
| 308 | 
            +
                return hashes
         | 
| 309 | 
            +
              end  
         | 
| 310 | 
            +
              
         | 
| 311 | 
            +
              
         | 
| 265 312 | 
             
              private
         | 
| 266 313 |  | 
| 267 314 | 
             
            end
         | 
| @@ -0,0 +1,96 @@ | |
| 1 | 
            +
            require "handsoap"
         | 
| 2 | 
            +
            require "handsoap/http"
         | 
| 3 | 
            +
            require "handsoap/http"
         | 
| 4 | 
            +
            require "handsoap/http/drivers"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Handsoap
         | 
| 7 | 
            +
              module Http
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                
         | 
| 10 | 
            +
                module Drivers
         | 
| 11 | 
            +
                  
         | 
| 12 | 
            +
                  class CustomDriver < Handsoap::Http::Drivers::AbstractDriver
         | 
| 13 | 
            +
                    
         | 
| 14 | 
            +
                    def self.load!
         | 
| 15 | 
            +
                      require 'net/http'
         | 
| 16 | 
            +
                      require 'uri'
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    def send_http_request(request)
         | 
| 20 | 
            +
                      url = request.url
         | 
| 21 | 
            +
                      unless url.kind_of? ::URI::Generic
         | 
| 22 | 
            +
                        url = ::URI.parse(url)
         | 
| 23 | 
            +
                      end
         | 
| 24 | 
            +
                      ::URI::Generic.send(:public, :path_query) # hackety hack
         | 
| 25 | 
            +
                      path = url.path_query
         | 
| 26 | 
            +
                      http_request = case request.http_method
         | 
| 27 | 
            +
                                     when :get
         | 
| 28 | 
            +
                                       Net::HTTP::Get.new(path)
         | 
| 29 | 
            +
                                     when :post
         | 
| 30 | 
            +
                                       Net::HTTP::Post.new(path)
         | 
| 31 | 
            +
                                     when :put
         | 
| 32 | 
            +
                                       Net::HTTP::Put.new(path)
         | 
| 33 | 
            +
                                     when :delete
         | 
| 34 | 
            +
                                       Net::HTTP::Delete.new(path)
         | 
| 35 | 
            +
                                     else
         | 
| 36 | 
            +
                                       raise "Unsupported request method #{request.http_method}"
         | 
| 37 | 
            +
                                     end
         | 
| 38 | 
            +
                                     
         | 
| 39 | 
            +
                      http_client = Net::HTTP.new(url.host, url.port)
         | 
| 40 | 
            +
                      
         | 
| 41 | 
            +
                   
         | 
| 42 | 
            +
                      
         | 
| 43 | 
            +
                      http_client.verify_mode = OpenSSL::SSL::VERIFY_NONE
         | 
| 44 | 
            +
                      
         | 
| 45 | 
            +
                      #http_client.read_timeout = 120
         | 
| 46 | 
            +
                      http_client.open_timeout = Handsoap.timeout
         | 
| 47 | 
            +
                      http_client.read_timeout = Handsoap.timeout
         | 
| 48 | 
            +
                      
         | 
| 49 | 
            +
                      http_client.use_ssl = true if url.scheme == 'https'
         | 
| 50 | 
            +
                      
         | 
| 51 | 
            +
                      if request.username && request.password
         | 
| 52 | 
            +
                        # TODO: http://codesnippets.joyent.com/posts/show/1075
         | 
| 53 | 
            +
                        http_request.basic_auth request.username, request.password
         | 
| 54 | 
            +
                      end
         | 
| 55 | 
            +
                      request.headers.each do |k, values|
         | 
| 56 | 
            +
                        values.each do |v|
         | 
| 57 | 
            +
                          http_request.add_field(k, v)
         | 
| 58 | 
            +
                        end
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
                      http_request.body = request.body
         | 
| 61 | 
            +
                      # require 'stringio'
         | 
| 62 | 
            +
                      # debug_output = StringIO.new
         | 
| 63 | 
            +
                      # http_client.set_debug_output debug_output
         | 
| 64 | 
            +
                      http_response = http_client.start do |client|
         | 
| 65 | 
            +
                        client.request(http_request)
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                      # puts debug_output.string
         | 
| 68 | 
            +
                      # hacky-wacky
         | 
| 69 | 
            +
                      def http_response.get_headers
         | 
| 70 | 
            +
                        @header.inject({}) do |h, (k, v)|
         | 
| 71 | 
            +
                          h[k.downcase] = v
         | 
| 72 | 
            +
                          h
         | 
| 73 | 
            +
                        end
         | 
| 74 | 
            +
                      end
         | 
| 75 | 
            +
                      # net/http only supports basic auth. We raise a warning if the server requires something else.
         | 
| 76 | 
            +
                      if http_response.code == 401 && http_response.get_headers['www-authenticate']
         | 
| 77 | 
            +
                        auth_type = http_response.get_headers['www-authenticate'].chomp.match(/\w+/)[0].downcase
         | 
| 78 | 
            +
                        if auth_type != "basic"
         | 
| 79 | 
            +
                          raise "Authentication type #{auth_type} is unsupported by net/http"
         | 
| 80 | 
            +
                        end
         | 
| 81 | 
            +
                      end
         | 
| 82 | 
            +
                      parse_http_part(http_response.get_headers, http_response.body, http_response.code)
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
                
         | 
| 87 | 
            +
                @@drivers = {
         | 
| 88 | 
            +
                  :custom => Drivers::CustomDriver
         | 
| 89 | 
            +
                }
         | 
| 90 | 
            +
                
         | 
| 91 | 
            +
                def self.drivers
         | 
| 92 | 
            +
                  @@drivers
         | 
| 93 | 
            +
                end    
         | 
| 94 | 
            +
                 
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
            end
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -310,6 +310,29 @@ ENV_GET_TEMPLATES_BYNAME = '<?xml version="1.0" encoding="UTF-8"?> | |
| 310 310 | 
             
              '
         | 
| 311 311 |  | 
| 312 312 | 
             
              ENV_GET_MACHINE = '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 313 | 
            +
              <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         | 
| 314 | 
            +
                <soap:Body>
         | 
| 315 | 
            +
                  <GetMachineResponse xmlns="http://vmware.com/labmanager">
         | 
| 316 | 
            +
                    <GetMachineResult>
         | 
| 317 | 
            +
                      <id>1</id>
         | 
| 318 | 
            +
                      <name>machine1</name>
         | 
| 319 | 
            +
                      <description>Machine 1</description>
         | 
| 320 | 
            +
                      <internalIP>10.0.0.1</internalIP>
         | 
| 321 | 
            +
                      <macAddress>00:50:56:20:03:06</macAddress>
         | 
| 322 | 
            +
                      <memory>2048</memory>
         | 
| 323 | 
            +
                      <status>0</status>
         | 
| 324 | 
            +
                      <isDeployed>false</isDeployed>
         | 
| 325 | 
            +
                      <configID>1</configID>
         | 
| 326 | 
            +
                      <DatastoreNameResidesOn>test1</DatastoreNameResidesOn>
         | 
| 327 | 
            +
                      <OwnerFullName>Owner</OwnerFullName>
         | 
| 328 | 
            +
                    </GetMachineResult>
         | 
| 329 | 
            +
                  </GetMachineResponse>
         | 
| 330 | 
            +
                </soap:Body>
         | 
| 331 | 
            +
              </soap:Envelope>      
         | 
| 332 | 
            +
              ' 
         | 
| 333 | 
            +
              
         | 
| 334 | 
            +
              
         | 
| 335 | 
            +
              ENV_GET_MACHINE_BY_NAME = '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 313 336 | 
             
              <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         | 
| 314 337 | 
             
                <soap:Body>
         | 
| 315 338 | 
             
                  <GetMachineByNameResponse xmlns="http://vmware.com/labmanager">
         | 
| @@ -346,5 +369,42 @@ ENV_GET_TEMPLATES_BYNAME = '<?xml version="1.0" encoding="UTF-8"?> | |
| 346 369 | 
             
                   <MachineDeleteResponse xmlns="http://vmware.com/labmanager"/>
         | 
| 347 370 | 
             
                 </soap:Body>
         | 
| 348 371 | 
             
               </soap:Envelope>
         | 
| 349 | 
            -
               ' | 
| 372 | 
            +
               '
         | 
| 373 | 
            +
              
         | 
| 374 | 
            +
              ENV_LIST_MACHINES = '<?xml version="1.0" encoding="UTF-8"?>
         | 
| 375 | 
            +
              <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         | 
| 376 | 
            +
                <soap:Body>
         | 
| 377 | 
            +
                  <ListMachinesResponse xmlns="http://vmware.com/labmanager">
         | 
| 378 | 
            +
                    <ListMachinesResult>
         | 
| 379 | 
            +
                      <Machine>
         | 
| 380 | 
            +
                        <id>1</id>
         | 
| 381 | 
            +
                        <name>machine1</name>
         | 
| 382 | 
            +
                        <description>Machine 1</description>
         | 
| 383 | 
            +
                        <internalIP>10.0.0.1</internalIP>
         | 
| 384 | 
            +
                        <macAddress>00:50:56:20:03:06</macAddress>
         | 
| 385 | 
            +
                        <memory>2048</memory>
         | 
| 386 | 
            +
                        <status>0</status>
         | 
| 387 | 
            +
                        <isDeployed>false</isDeployed>
         | 
| 388 | 
            +
                        <configID>1</configID>
         | 
| 389 | 
            +
                        <DatastoreNameResidesOn>test1</DatastoreNameResidesOn>
         | 
| 390 | 
            +
                        <OwnerFullName>Owner</OwnerFullName>
         | 
| 391 | 
            +
                      </Machine>
         | 
| 392 | 
            +
                      <Machine>
         | 
| 393 | 
            +
                        <id>2</id>
         | 
| 394 | 
            +
                        <name>machine1</name>
         | 
| 395 | 
            +
                        <description>Machine 2</description>
         | 
| 396 | 
            +
                        <internalIP>10.0.0.2</internalIP>
         | 
| 397 | 
            +
                        <macAddress>00:50:56:20:03:06</macAddress>
         | 
| 398 | 
            +
                        <memory>2048</memory>
         | 
| 399 | 
            +
                        <status>0</status>
         | 
| 400 | 
            +
                        <isDeployed>false</isDeployed>
         | 
| 401 | 
            +
                        <configID>1</configID>
         | 
| 402 | 
            +
                        <DatastoreNameResidesOn>test1</DatastoreNameResidesOn>
         | 
| 403 | 
            +
                        <OwnerFullName>Owner</OwnerFullName>
         | 
| 404 | 
            +
                      </Machine>
         | 
| 405 | 
            +
                      </ListMachinesResult>
         | 
| 406 | 
            +
                  </ListMachinesResponse>
         | 
| 407 | 
            +
                </soap:Body>
         | 
| 408 | 
            +
              </soap:Envelope>'   
         | 
| 409 | 
            +
                     
         | 
| 350 410 | 
             
            end
         | 
    
        data/test/test_machines.rb
    CHANGED
    
    | @@ -20,13 +20,25 @@ class TestMachines < Test::Unit::TestCase | |
| 20 20 | 
             
                result = LabmanagerService.createMachine({:configuration_id =>1,:template_id=>1,:name=>"testing",:description=>"testing"})
         | 
| 21 21 |  | 
| 22 22 | 
             
                assert_equal result,1
         | 
| 23 | 
            -
             | 
| 23 | 
            +
                
         | 
| 24 24 | 
             
              end
         | 
| 25 25 |  | 
| 26 | 
            -
               | 
| 26 | 
            +
              
         | 
| 27 | 
            +
              def test_getMachineById
         | 
| 27 28 | 
             
                Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_MACHINE, :status => 200
         | 
| 28 29 | 
             
                Handsoap.http_driver = :mock
         | 
| 29 30 |  | 
| 31 | 
            +
                driver = Handsoap::Http.drivers[:mock].new
         | 
| 32 | 
            +
                result = LabmanagerService.getMachine("1")
         | 
| 33 | 
            +
                
         | 
| 34 | 
            +
                assert_equal result[:id],"1"
         | 
| 35 | 
            +
                assert_equal result[:name],"machine1"
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
              
         | 
| 38 | 
            +
              def test_getMachineByName
         | 
| 39 | 
            +
                Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_GET_MACHINE_BY_NAME, :status => 200
         | 
| 40 | 
            +
                Handsoap.http_driver = :mock
         | 
| 41 | 
            +
             | 
| 30 42 | 
             
                driver = Handsoap::Http.drivers[:mock].new
         | 
| 31 43 | 
             
                result = LabmanagerService.getMachineByName("1","testing")
         | 
| 32 44 |  | 
| @@ -60,5 +72,13 @@ class TestMachines < Test::Unit::TestCase | |
| 60 72 | 
             
                result = LabmanagerService.deleteMachine(1)
         | 
| 61 73 |  | 
| 62 74 | 
             
              end
         | 
| 75 | 
            +
              def test_listMachines
         | 
| 76 | 
            +
                Handsoap::Http.drivers[:mock] = Handsoap::Http::Drivers::MockDriver.new :headers => REQUEST_HEADERS, :content => ENV_LIST_MACHINES, :status => 200
         | 
| 77 | 
            +
                Handsoap.http_driver = :mock
         | 
| 63 78 |  | 
| 79 | 
            +
                driver = Handsoap::Http.drivers[:mock].new
         | 
| 80 | 
            +
                result = LabmanagerService.listMachines(1)
         | 
| 81 | 
            +
                assert_equal result.length,2
         | 
| 82 | 
            +
                
         | 
| 83 | 
            +
              end
         | 
| 64 84 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            name: labmanager
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0.0. | 
| 5 | 
            +
              version: 0.0.2
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors: 
         | 
| 8 8 | 
             
            - Andrew Battye
         | 
| @@ -10,7 +10,7 @@ autorequire: name | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2011- | 
| 13 | 
            +
            date: 2011-05-09 00:00:00 Z
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 16 | 
             
              name: handsoap
         | 
| @@ -23,47 +23,35 @@ dependencies: | |
| 23 23 | 
             
                    version: 1.1.8
         | 
| 24 24 | 
             
              type: :runtime
         | 
| 25 25 | 
             
              version_requirements: *id001
         | 
| 26 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 27 | 
            -
              name: curb
         | 
| 28 | 
            -
              prerelease: false
         | 
| 29 | 
            -
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 30 | 
            -
                none: false
         | 
| 31 | 
            -
                requirements: 
         | 
| 32 | 
            -
                - - ">="
         | 
| 33 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 34 | 
            -
                    version: 0.7.15
         | 
| 35 | 
            -
              type: :runtime
         | 
| 36 | 
            -
              version_requirements: *id002
         | 
| 37 26 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 38 27 | 
             
              name: nokogiri
         | 
| 39 28 | 
             
              prerelease: false
         | 
| 40 | 
            -
              requirement: & | 
| 29 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 41 30 | 
             
                none: false
         | 
| 42 31 | 
             
                requirements: 
         | 
| 43 32 | 
             
                - - ">="
         | 
| 44 33 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 45 34 | 
             
                    version: 1.4.4
         | 
| 46 35 | 
             
              type: :runtime
         | 
| 47 | 
            -
              version_requirements: * | 
| 36 | 
            +
              version_requirements: *id002
         | 
| 48 37 | 
             
            description: 
         | 
| 49 38 | 
             
            email: andrew@battye.com
         | 
| 50 39 | 
             
            executables: []
         | 
| 51 40 |  | 
| 52 41 | 
             
            extensions: []
         | 
| 53 42 |  | 
| 54 | 
            -
            extra_rdoc_files: 
         | 
| 55 | 
            -
             | 
| 43 | 
            +
            extra_rdoc_files: []
         | 
| 44 | 
            +
             | 
| 56 45 | 
             
            files: 
         | 
| 57 46 | 
             
            - lib/labmanager/constants.rb
         | 
| 58 47 | 
             
            - lib/labmanager/labmanager_service.rb
         | 
| 59 | 
            -
            -  | 
| 48 | 
            +
            - lib/labmanager/net_http_driver.rb
         | 
| 60 49 | 
             
            - test/test_configuration.rb
         | 
| 61 50 | 
             
            - test/test_framework.rb
         | 
| 62 51 | 
             
            - test/test_helper.rb
         | 
| 63 52 | 
             
            - test/test_machines.rb
         | 
| 64 53 | 
             
            - test/test_networks.rb
         | 
| 65 54 | 
             
            - test/test_templates.rb
         | 
| 66 | 
            -
            - README
         | 
| 67 55 | 
             
            homepage: ""
         | 
| 68 56 | 
             
            licenses: []
         | 
| 69 57 |  | 
| @@ -87,12 +75,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 87 75 | 
             
            requirements: []
         | 
| 88 76 |  | 
| 89 77 | 
             
            rubyforge_project: 
         | 
| 90 | 
            -
            rubygems_version: 1. | 
| 78 | 
            +
            rubygems_version: 1.8.1
         | 
| 91 79 | 
             
            signing_key: 
         | 
| 92 80 | 
             
            specification_version: 3
         | 
| 93 81 | 
             
            summary: Ruby SOAP proxy for VMware Lab Manager
         | 
| 94 82 | 
             
            test_files: 
         | 
| 95 | 
            -
            - test/12test_labmanager_proxy.rb
         | 
| 96 83 | 
             
            - test/test_configuration.rb
         | 
| 97 84 | 
             
            - test/test_framework.rb
         | 
| 98 85 | 
             
            - test/test_helper.rb
         | 
    
        data/README
    DELETED
    
    
| @@ -1,67 +0,0 @@ | |
| 1 | 
            -
            require "test/unit"
         | 
| 2 | 
            -
            require "labmanager/labmanager_service"
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            class TestLabmanagerProxy < Test::Unit::TestCase
         | 
| 5 | 
            -
              
         | 
| 6 | 
            -
              
         | 
| 7 | 
            -
              
         | 
| 8 | 
            -
              def test_configuration
         | 
| 9 | 
            -
             
         | 
| 10 | 
            -
                 setupProxy
         | 
| 11 | 
            -
                   
         | 
| 12 | 
            -
                 id1 = LabmanagerService.createConfiguration(:name => 'ajb1', :description => 'ajb1')
         | 
| 13 | 
            -
                
         | 
| 14 | 
            -
                 configuration = LabmanagerService.getConfigurationByName("ajb1")
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                 configurations = LabmanagerService.getConfigurations()
         | 
| 17 | 
            -
                 
         | 
| 18 | 
            -
                 template = LabmanagerService.getTemplateByName("RedHat.5.WDF.external.V1.0")
         | 
| 19 | 
            -
                 
         | 
| 20 | 
            -
                 network = LabmanagerService.getNetworkByName("BSS General")
         | 
| 21 | 
            -
                 
         | 
| 22 | 
            -
                 machine = LabmanagerService.createMachine({:configuration_id =>id1,:template_id=>602,:network_id=>network[:id],:ipaddressingmode=>'STATIC_AUTOMATIC',:name=>"andrew",:description=>"testing"})
         | 
| 23 | 
            -
                 
         | 
| 24 | 
            -
                 LabmanagerService.deployMachine(machine)
         | 
| 25 | 
            -
               
         | 
| 26 | 
            -
                 LabmanagerService.undeployMachine(machine)
         | 
| 27 | 
            -
                
         | 
| 28 | 
            -
                 LabmanagerService.deleteMachine(machine)
         | 
| 29 | 
            -
                    
         | 
| 30 | 
            -
                 LabmanagerService.deleteConfiguration(id1)
         | 
| 31 | 
            -
                
         | 
| 32 | 
            -
              end
         | 
| 33 | 
            -
             
         | 
| 34 | 
            -
              def test_templates
         | 
| 35 | 
            -
                 setupProxy
         | 
| 36 | 
            -
                 
         | 
| 37 | 
            -
                 templates = LabmanagerService.listTemplates()
         | 
| 38 | 
            -
                 
         | 
| 39 | 
            -
                 template = LabmanagerService.getTemplate(206)
         | 
| 40 | 
            -
                 
         | 
| 41 | 
            -
                template = LabmanagerService.getTemplateByName("W2008_64_Monsoon_v1.0")
         | 
| 42 | 
            -
                 
         | 
| 43 | 
            -
                 
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
              
         | 
| 46 | 
            -
              
         | 
| 47 | 
            -
              def test_networks
         | 
| 48 | 
            -
                setupProxy
         | 
| 49 | 
            -
                networks = LabmanagerService.listNetworks()
         | 
| 50 | 
            -
                 
         | 
| 51 | 
            -
                network = LabmanagerService.getNetworkByName("BSS Corp")
         | 
| 52 | 
            -
                 
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
              
         | 
| 55 | 
            -
              
         | 
| 56 | 
            -
              
         | 
| 57 | 
            -
              private
         | 
| 58 | 
            -
               def setupProxy
         | 
| 59 | 
            -
             | 
| 60 | 
            -
                 config = {:pragmatic=>true,:wsdl =>"https://localhost:8080/LabManager/SOAP/LabManagerInternal.asmx?wsdl",:username=>"apiuser",:password =>"api4testing",:workspace=>"Officelan CPS Dev"} 
         | 
| 61 | 
            -
                 
         | 
| 62 | 
            -
                 proxy = LabmanagerService.configure(config)   
         | 
| 63 | 
            -
                 
         | 
| 64 | 
            -
               end
         | 
| 65 | 
            -
              
         | 
| 66 | 
            -
               
         | 
| 67 | 
            -
            end
         |