-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from EmilienM/pci
virtual: get real PCI address for each device found
- Loading branch information
Showing
8 changed files
with
218 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"uuid": "7114a452-2e00-4ade-856a-42d4dc7c894f", | ||
"name": "1etsl9fpzrhocpnfv-7bhdj-worker-0-fnz68", | ||
"launch_index": 0, | ||
"availability_zone": "worker", | ||
"project_id": "00552bf9217648d7a5714fbd25f92df2", | ||
"devices": [ | ||
{ | ||
"vlan": 177, | ||
"vf_trusted": true, | ||
"type": "nic", | ||
"mac": "fa:16:3e:00:00:00", | ||
"bus": "pci", | ||
"address": "0000:04:00.0" | ||
}, | ||
{ | ||
"vlan": 178, | ||
"vf_trusted": true, | ||
"type": "nic", | ||
"mac": "fa:16:3e:11:11:11", | ||
"bus": "pci", | ||
"address": "0000:05:00.0" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"links": [ | ||
{ | ||
"id": "tapa046a03c-49", | ||
"vif_id": "a046a03c-4996-4212-8f23-3b8f197b03b3", | ||
"type": "ovs", | ||
"mtu": 1500, | ||
"ethernet_mac_address": "fa:16:3e:9c:9f:89" | ||
}, | ||
{ | ||
"id": "tapdc2a9cd3-f7", | ||
"vif_id": "dc2a9cd3-f7f5-40df-9d52-328f86e6011b", | ||
"type": "hw_veb", | ||
"mtu": 9000, | ||
"ethernet_mac_address": "fa:16:3e:00:00:00" | ||
}, | ||
{ | ||
"id": "tapce5054e4-c6", | ||
"vif_id": "ce5054e4-c65a-4c28-843c-155ab8fed825", | ||
"type": "hw_veb", | ||
"mtu": 9000, | ||
"ethernet_mac_address": "fa:16:3e:11:11:11" | ||
} | ||
], | ||
"networks": [ | ||
{ | ||
"id": "network0", | ||
"type": "ipv4_dhcp", | ||
"link": "tapa046a03c-49", | ||
"network_id": "5765e37b-0a13-49d2-a598-537178ce254f" | ||
}, | ||
{ | ||
"id": "network1", | ||
"type": "ipv4", | ||
"link": "tapdc2a9cd3-f7", | ||
"ip_address": "192.168.177.4", | ||
"netmask": "255.255.255.0", | ||
"routes": [ | ||
{ | ||
"network": "0.0.0.0", | ||
"netmask": "0.0.0.0", | ||
"gateway": "192.168.177.1" | ||
} | ||
], | ||
"network_id": "b3ba899a-e06c-49da-93c5-c992048390b2", | ||
"services": [] | ||
}, | ||
{ | ||
"id": "network2", | ||
"type": "ipv4", | ||
"link": "tapce5054e4-c6", | ||
"ip_address": "192.168.178.107", | ||
"netmask": "255.255.255.0", | ||
"routes": [ | ||
{ | ||
"network": "0.0.0.0", | ||
"netmask": "0.0.0.0", | ||
"gateway": "192.168.178.1" | ||
} | ||
], | ||
"network_id": "a81317cb-aa3d-4675-99cf-aa049f964a3c", | ||
"services": [] | ||
} | ||
], | ||
"services": [ | ||
{ | ||
"type": "dns", | ||
"address": "10.1.2.3" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/jaypipes/ghw" | ||
"github.com/jaypipes/ghw/pkg/net" | ||
"github.com/jaypipes/ghw/pkg/option" | ||
"k8s.io/utils/pointer" | ||
) | ||
|
||
func TestUtils(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Utils") | ||
} | ||
|
||
var _ = Describe("Virtual", func() { | ||
|
||
Context("GetOpenstackData", func() { | ||
It("PCI address replacement based on MAC address", func() { | ||
ospNetworkDataFile = "./testdata/network_data.json" | ||
ospMetaDataFile = "./testdata/meta_data.json" | ||
DeferCleanup(func() { | ||
ospNetworkDataFile = ospMetaDataDir + "/network_data.json" | ||
ospMetaDataFile = ospMetaDataDir + "/meta_data.json" | ||
}) | ||
|
||
ghw.Network = func(opts ...*option.Option) (*net.Info, error) { | ||
return &net.Info{ | ||
NICs: []*net.NIC{{ | ||
MacAddress: "fa:16:3e:00:00:00", | ||
PCIAddress: pointer.String("0000:04:00.0"), | ||
}, { | ||
MacAddress: "fa:16:3e:11:11:11", | ||
PCIAddress: pointer.String("0000:99:99.9"), | ||
}}, | ||
}, nil | ||
} | ||
|
||
DeferCleanup(func() { | ||
ghw.Network = net.New | ||
}) | ||
|
||
metaData, _, err := GetOpenstackData(false) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
Expect(metaData.Devices).To(HaveLen(2)) | ||
Expect(metaData.Devices[0].Mac).To(Equal("fa:16:3e:00:00:00")) | ||
Expect(metaData.Devices[0].Address).To(Equal("0000:04:00.0")) | ||
Expect(metaData.Devices[1].Mac).To(Equal("fa:16:3e:11:11:11")) | ||
Expect(metaData.Devices[1].Address).To(Equal("0000:99:99.9")) | ||
|
||
}) | ||
}) | ||
}) |