Skip to content

Commit

Permalink
[vSphere] Support passing of a distributed switch for each interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcGrimme committed Sep 27, 2013
1 parent a40a371 commit 3f60613
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/fog/vsphere/models/compute/interface.rb
Expand Up @@ -13,6 +13,7 @@ class Interface < Fog::Model
attribute :summary
attribute :type
attribute :key
attribute :virtualswitch

def initialize(attributes={} )
super defaults.merge(attributes)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/vsphere/requests/compute/create_vm.rb
Expand Up @@ -50,7 +50,7 @@ def device_change attributes
end

def create_nic_backing nic, attributes
raw_network = get_raw_network(nic.network, attributes[:datacenter])
raw_network = get_raw_network(nic.network, attributes[:datacenter], if nic.virtualswitch then nic.virtualswitch end)

if raw_network.kind_of? RbVmomi::VIM::DistributedVirtualPortgroup
RbVmomi::VIM.VirtualEthernetCardDistributedVirtualPortBackingInfo(
Expand Down Expand Up @@ -126,4 +126,4 @@ def create_vm attributes = { }
end
end
end
end
end
4 changes: 2 additions & 2 deletions lib/fog/vsphere/requests/compute/get_network.rb
Expand Up @@ -10,14 +10,14 @@ def get_network(name, datacenter_name)

protected

def get_raw_network(name, datacenter_name)
def get_raw_network(name, datacenter_name, distributedswitch_name=nil)
dc = find_raw_datacenter(datacenter_name)

@connection.serviceContent.viewManager.CreateContainerView({
:container => dc.networkFolder,
:type => ["Network"],
:recursive => true
}).view.select{|n| n.name == name}.first
}).view.select { |n| n.name == name and (not distributedswitch_name or n.config.distributedVirtualSwitch.name == distributedswitch_name)}.first
end
end

Expand Down

0 comments on commit 3f60613

Please sign in to comment.