diff --git a/drydock_provisioner/drivers/node/maasdriver/actions/node.py b/drydock_provisioner/drivers/node/maasdriver/actions/node.py index 9638b480..20f28622 100644 --- a/drydock_provisioner/drivers/node/maasdriver/actions/node.py +++ b/drydock_provisioner/drivers/node/maasdriver/actions/node.py @@ -1281,7 +1281,7 @@ class ApplyNodeNetworking(BaseMaasAction): self.task.save() try: - site_design = self._load_site_design() + site_design = self._load_site_design(resolve_aliases=True) except errors.OrchestratorError: self.task.add_status_msg( msg="Error loading site design.", @@ -1819,7 +1819,7 @@ class ApplyNodeStorage(BaseMaasAction): self.task.save() try: - site_design = self._load_site_design() + site_design = self._load_site_design(resolve_aliases=True) except errors.OrchestratorError: self.task.add_status_msg( msg="Error loading site design.", diff --git a/drydock_provisioner/objects/node.py b/drydock_provisioner/objects/node.py index deb796c6..481765b2 100644 --- a/drydock_provisioner/objects/node.py +++ b/drydock_provisioner/objects/node.py @@ -49,7 +49,7 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile): # Compile the applied version of this model sourcing referenced # data from the passed site design - def compile_applied_model(self, site_design, state_manager): + def compile_applied_model(self, site_design, state_manager, resolve_aliases=False): self.logger.debug("Applying host profile to node %s" % self.name) self.apply_host_profile(site_design) self.logger.debug("Applying hardware profile to node %s" % self.name) @@ -57,8 +57,9 @@ class BaremetalNode(drydock_provisioner.objects.hostprofile.HostProfile): self.source = hd_fields.ModelSource.Compiled self.logger.debug("Resolving kernel parameters on node %s" % self.name) self.resolve_kernel_params(site_design) - self.logger.debug("Resolving device aliases on node %s" % self.name) - self.apply_logicalnames(site_design, state_manager) + if resolve_aliases: + self.logger.debug("Resolving device aliases on node %s" % self.name) + self.apply_logicalnames(site_design, state_manager) return def apply_host_profile(self, site_design): diff --git a/drydock_provisioner/orchestrator/actions/orchestrator.py b/drydock_provisioner/orchestrator/actions/orchestrator.py index 44626967..7064fa87 100644 --- a/drydock_provisioner/orchestrator/actions/orchestrator.py +++ b/drydock_provisioner/orchestrator/actions/orchestrator.py @@ -131,15 +131,18 @@ class BaseAction(object): self.task.align_result() return - def _load_site_design(self): + def _load_site_design(self, resolve_aliases=False): """Load the site design from this action's task. The design_ref in the task can be resolved to a set of design documents that reflect the site design to be operated on. Load this design for use by this action. + + :param resolve_aliases: boolean on whether to resolve device aliases, defaults + to False """ design_status, site_design = self.orchestrator.get_effective_site( - self.task.design_ref) + self.task.design_ref, resolve_aliases=resolve_aliases) if design_status is None or design_status.status == hd_fields.ActionResult.Failure: raise errors.OrchestratorError("Site design failed load.") diff --git a/drydock_provisioner/orchestrator/orchestrator.py b/drydock_provisioner/orchestrator/orchestrator.py index ad74c970..09a45d8e 100644 --- a/drydock_provisioner/orchestrator/orchestrator.py +++ b/drydock_provisioner/orchestrator/orchestrator.py @@ -241,7 +241,7 @@ class Orchestrator(object): return new_task - def compute_model_inheritance(self, site_design): + def compute_model_inheritance(self, site_design, resolve_aliases=False): """Compute inheritance of the design model. Given a fully populated Site model, compute the effective @@ -254,7 +254,9 @@ class Orchestrator(object): for n in nodes or []: try: n.compile_applied_model( - site_design, state_manager=self.state_manager) + site_design, + state_manager=self.state_manager, + resolve_aliases=resolve_aliases) except Exception as ex: node_failed.append(n) self.logger.error( @@ -283,7 +285,7 @@ class Orchestrator(object): return status, site_design - def get_effective_site(self, design_ref): + def get_effective_site(self, design_ref, resolve_aliases=False): """Ingest design data and compile the effective model of the design. Return a tuple of the processing status and the populated instance @@ -297,7 +299,7 @@ class Orchestrator(object): try: status, site_design = self.get_described_site(design_ref) if status.status == hd_fields.ValidationResult.Success: - self.compute_model_inheritance(site_design) + self.compute_model_inheritance(site_design, resolve_aliases=resolve_aliases) self.compute_bootaction_targets(site_design) self.render_route_domains(site_design) status = val.validate_design(site_design, result_status=status) diff --git a/tests/unit/test_node_logicalnames.py b/tests/unit/test_node_logicalnames.py index 217d3f1d..d4932d84 100644 --- a/tests/unit/test_node_logicalnames.py +++ b/tests/unit/test_node_logicalnames.py @@ -140,10 +140,9 @@ class TestClass(object): drydock_state.get_build_data = Mock(side_effect=side_effect) design_status, design_data = deckhand_orchestrator.get_effective_site( - design_ref) + design_ref, resolve_aliases=True) nodes = design_data.baremetal_nodes - nodes[0].apply_logicalnames(design_data, state_manager=drydock_state) expected = { 'primary_boot': 'sda',