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

Conversation

MarcGrimme
Copy link
Contributor

Background:

Remark: This is only related to the vSphere implementation of fog.

It is not yet possible with fog to create a nic (nic backing) on a vmware guest on different distributed switches that host the same network but are located in different datacenters.
Until now there is no option to add a nic with a specific distributed switch aside the nic configuration.

This leads to guests not being created.
Error message:

RbVmomi::Fault: failed to create vm: InvalidArgument: A specified parameter was not correct.
spec.deviceChange.device.port.switchUuid
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/lib/fog/vsphere/requests/compute/create_vm.rb:27:in `rescue in create_vm'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/lib/fog/vsphere/requests/compute/create_vm.rb:8:in `create_vm'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/lib/fog/vsphere/models/compute/server.rb:211:in `save'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/lib/fog/core/collection.rb:52:in `create'
        from (irb):15:in `<main>'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/bin/fog:54:in `block in <main>'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/bin/fog:54:in `catch'
        from /usr/share/foreman/.gem/ruby/1.9.1/gems/fog-1.11.1/bin/fog:54:in `<main>'

The message A specified parameter was not correct. spec.deviceChange.device.port.switchUuid is the relevant error message from vmware.

The error is located at the place where the raw network is selected from vsphere as follows (lib/fog/vsphere/requests/compute/get_network.rb):

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

This will select the first distributed switch to be found matching the required network name. Nevertheless if the same network is used in different dcs always the same distributed switch is selected.
This will fail in one of the two dcs as a special distributed switch is required.

Solution:

It would be an option to pass the required distributed switch along with the interface to be created (optional).
If there is no distributed switch passed as option the code is executed as before but otherwise the network for this given distributed switch is selected.

The solution might look as follows:

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

This pull request solves this critical problem with this aproach.

Any better ideas?

Let me know what you think.
Marc.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 3f60613 on grimme-atix-de:interface_dswitch into a40a371 on fog:master.

@geemus
Copy link
Member

geemus commented Sep 27, 2013

Thanks!

@jeffmccune - could you review? Thanks!

MarcGrimme added a commit that referenced this pull request Oct 7, 2013
[vSphere] Support passing of a distributed switch for each interface.
@MarcGrimme MarcGrimme merged commit ddf44fa into fog:master Oct 7, 2013
@MarcGrimme MarcGrimme deleted the interface_dswitch branch October 7, 2013 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants