Skip to content

Commit bdec962

Browse files
committed
Move provider_tree RP creation to PciResourceProvider
It is a simple refactor to move the actual RP creation under the scope of PciResourceProvider.update_provider_tree to remove the assumption the RPs are always pre-created by the caller in the provider_tree. blueprint: pci-device-tracking-in-placement Change-Id: I375a1fb013a8e877c159b907484ba16871935879
1 parent 3e68e19 commit bdec962

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nova/compute/pci_placement_translator.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def remove_parent(self, dev: pci_device.PciDevice) -> None:
178178
pass
179179

180180
def update_provider_tree(
181-
self, provider_tree: provider_tree.ProviderTree
181+
self,
182+
provider_tree: provider_tree.ProviderTree,
183+
parent_rp_name: str,
182184
) -> None:
183185

184186
if not self.parent_dev and not self.children_devs:
@@ -191,6 +193,9 @@ def update_provider_tree(
191193

192194
return
193195

196+
if not provider_tree.exists(self.name):
197+
provider_tree.new_child(self.name, parent_rp_name)
198+
194199
provider_tree.update_inventory(
195200
self.name,
196201
# NOTE(gibi): The rest of the inventory fields (reserved,
@@ -341,10 +346,7 @@ def update_provider_tree(
341346
self, provider_tree: provider_tree.ProviderTree
342347
) -> None:
343348
for rp_name, rp in self.rps.items():
344-
if not provider_tree.exists(rp_name):
345-
provider_tree.new_child(rp_name, self.root_rp_name)
346-
347-
rp.update_provider_tree(provider_tree)
349+
rp.update_provider_tree(provider_tree, self.root_rp_name)
348350

349351

350352
def ensure_no_dev_spec_with_devname(dev_specs: ty.List[devspec.PciDeviceSpec]):

0 commit comments

Comments
 (0)