deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/2] git commit: VSphere: Minor tweaks to the driver
Date Fri, 24 Aug 2012 13:36:14 GMT
Updated Branches:
  refs/heads/master 9cef49486 -> 71f746eba


VSphere: Minor tweaks to the driver

* Removed unused local variables and methods
* Fixed way how we require client lib


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/71f746eb
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/71f746eb
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/71f746eb

Branch: refs/heads/master
Commit: 71f746eba46695aeef41be31ddf0dfc3672bb3e5
Parents: 417cace
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Fri Aug 24 12:17:59 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Aug 24 12:17:59 2012 +0200

----------------------------------------------------------------------
 .../deltacloud/drivers/vsphere/vsphere_driver.rb   |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/71f746eb/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 2e868ca..43818fe 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -15,7 +15,7 @@
 #
 
 require 'rbvmomi'
-require 'deltacloud/drivers/vsphere/vsphere_client'
+require_relative './vsphere_client.rb'
 
 module Deltacloud::Drivers::Vsphere
 
@@ -74,7 +74,6 @@ module Deltacloud::Drivers::Vsphere
     # Images are virtual machines with 'template' flag set to be true.
     # Thus we're getting them using find_vm and list_virtual_machines
     def images(credentials, opts={})
-      cloud = new_client(credentials)
       img_arr = []
       profiles = hardware_profiles(credentials)
       # Skip traversing through all instances in all datacenters when ID
@@ -86,9 +85,8 @@ module Deltacloud::Drivers::Vsphere
           template_vms = list_virtual_machines(credentials).select { |vm| vm[:instance] &&
vm[:instance].summary.config[:template] }
         end
         img_arr = template_vms.collect do |image_hash|
-          image, realm = image_hash[:instance], image_hash[:datastore]
+          image = image_hash[:instance]
           config = image.summary.config
-          instance_state = convert_state(:instance, image.summary.runtime[:powerState])
           # Preload all properties to save multiple SOAP calls to vSphere
           properties = {
             :name => config[:name],
@@ -115,7 +113,6 @@ module Deltacloud::Drivers::Vsphere
     end
 
     def create_image(credentials, opts={})
-      vsphere = new_client(credentials)
       safely do
         find_vm(credentials, opts[:id])[:instance].MarkAsTemplate
       end
@@ -132,7 +129,7 @@ module Deltacloud::Drivers::Vsphere
         else
           rootFolder = vsphere.serviceInstance.content.rootFolder
           rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).collect do |dc|
-            dc.datastoreFolder.childEntity.collect { |datastore| convert_realm(datastore)
}
+            dc.datastoreFolder.childEntity.collect { |ds| convert_realm(ds) }
           end.flatten
         end
       end
@@ -141,7 +138,6 @@ module Deltacloud::Drivers::Vsphere
     # List all running instances, across all datacenters. DeltaCloud API does
     # not yet support filtering instances by realm.
     def instances(credentials, opts={})
-      cloud = new_client(credentials)
       inst_arr, machine_vms, pending_vms = [], [], []
       safely do
         # Using find_vm is a way faster than listing all virtual machines
@@ -213,12 +209,10 @@ module Deltacloud::Drivers::Vsphere
 
 
     def create_instance(credentials, image_id, opts={})
-      vsphere = new_client(credentials)
       safely do
         if opts[:hwp_cpu]
           raise "Invalid CPU value. Must be in integer format" unless valid_cpu_value?(opts[:hwp_cpu])
         end
-        rootFolder = vsphere.serviceInstance.content.rootFolder
         vm = find_vm(credentials, opts[:image_id])
         raise "ERROR: Could not find the image in given datacenter" unless vm[:instance]
         # New instance need valid resource pool and datastore to be placed.


Mime
View raw message