Skip to content

Commit

Permalink
Accommodate non-NSX-T Distributed Virtual Switches
Browse files Browse the repository at this point in the history
Previously the vSphere CPI NSX-T Policy API assumed _all_ Distributed
Virtual Switches (DVSes) were NSX-T Segments, but that assummption was
false; DVSes may be managed by vSphere and not NSX-T.

We now check whether the network interface controller (NIC) is
NSX-T-managed before attempting to tag the NIC's port with NSX-T
metadata.

fixes:
```
unable to create bosh vm:CPI 'set_vm_metadata' method responded with error: CmdError{"type":"Unknown","message":"Invalid Query","ok_to_retry":false}
```

[fixes #302]
[#179334136](https://www.pivotaltracker.com/story/show/179334136)

Signed-off-by: Brian Cunnie <bcunnie@vmware.com>
  • Loading branch information
julian-hj authored and Brian Cunnie committed Aug 26, 2021
1 parent 38514b7 commit 66a1e3a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/vsphere_cpi/spec/integration/nsxt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,41 @@ def initialize(name: "BOSH-CPI-test-#{SecureRandom.uuid}", id: SecureRandom.uuid
expect(server_pool_2.members).to be_nil
end
end

context 'with non-nsxt distributed virtual switches' do
let(:nsxt_spec) { {} }
let(:dvpg_name) { ENV.fetch('BOSH_VSPHERE_CPI_FOLDER_PORTGROUP_ONE') }
let(:policy_network_spec) do
{
'static-bridged' => {
'ip' => "169.254.#{rand(1..254)}.#{rand(4..254)}",
'netmask' => '255.255.254.0',
'cloud_properties' => { 'name' => segment_1.name },
'default' => ['dns', 'gateway'],
'dns' => ['169.254.1.2'],
'gateway' => '169.254.1.3'
},
'static' => {
'ip' => "169.254.#{rand(1..254)}.#{rand(4..254)}",
'netmask' => '255.255.254.0',
'cloud_properties' => { 'name' => dvpg_name },
'default' => ['dns', 'gateway'],
'dns' => ['169.254.1.2'],
'gateway' => '169.254.1.3'
}
}
end
it 'creates a VM without errors' do
simple_vm_lifecycle(cpi, '', vm_type, policy_network_spec) do |vm_id|
cpi.set_vm_metadata(vm_id, {'id' => 'foo'})

vm = @cpi.vm_provider.find(vm_id)
segment_names = vm.get_nsxt_segment_vif_list.map { |x| x[0] }
expect(segment_names.length).to eq(1)
expect(segment_names).to include(segment_1.name)
end
end
end
end
end

Expand Down

0 comments on commit 66a1e3a

Please sign in to comment.