lib/esx.rb in esx-0.2.3 vs lib/esx.rb in esx-0.2.4
- old
+ new
@@ -4,11 +4,11 @@
require 'net/scp'
require 'net/ssh'
module ESX
- VERSION = '0.2.3'
+ VERSION = '0.2.4'
class Host
attr_reader :address, :user, :password
@@ -90,10 +90,13 @@
# :datastore => datastore1 #(string, optional)
# :disk_file => path to vmdk inside datastore (optional)
# :disk_type => flat, sparse (default flat)
# }
#
+ # supported guest_id list:
+ # http://pubs.vmware.com/vsphere-50/index.jsp?topic=/com.vmware.wssdk.apiref.doc_50/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html
+ #
# Default values above.
def create_vm(specification)
spec = specification
spec[:cpus] = (specification[:cpus] || 1).to_i
spec[:guest_id] = specification[:guest_id] || 'otherGuest'
@@ -353,27 +356,43 @@
#
def ip_address
guest_info.ip_address
end
+ def nics
+ list = []
+ vm_object.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).each do |n|
+ list << NetworkInterface.wrap(n)
+ end
+ list
+ end
+
end
class NetworkInterface
attr_accessor :_wrapped_object
+ # Accepts VirtualEthernetCard and GuestNicInfo objects
def self.wrap(obj)
ni = NetworkInterface.new
ni._wrapped_object = obj
ni
end
+ # returns nil if the NetworkInterface is of type VirtualEthernetCard
+ # returns the IP address if VMWare tools installed in guest and _wrapped_object is of
+ # type GuestNicInfo
def ip_address
- _wrapped_object.ipAddress.first
+ if _wrapped_object.is_a? RbVmomi::VIM::VirtualEthernetCard
+ nil
+ else
+ _wrapped_object.ipAddress.first
+ end
end
def mac
- _wrapped_object.ipAddress.last
+ _wrapped_object.macAddress
end
end
class GuestInfo