Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vSphere] Support passing of a distributed switch for each interface. #2185

Merged
merged 1 commit into from Oct 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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