def compute_provisioning_for_environ(self, infra_instance, exclude_refs=None): """ Computes the provisioning needed for an instance of a namespace model. This method takes an infra model instance and for the current state of the namespace computes the required resources that need to be provisioned to satisfy the requirements of the namespace. It then returns a set containing the infra resources to be provisioned. Users usually have no need for this method; it is there for internal use, but made available for inspecting how a namespace model instance impacts an infra instance. @param infra_instance: An instance of an InfraModel derived class. @keyword exclude_refs: An iterable of references to exclude from the resulting set of provisionable resources. These can be either model or instance references. """ self.infra = infra_instance if exclude_refs is None: exclude_refs = set() exclude_refs = set([infra_instance.get_inst_ref(ref) for ref in exclude_refs]) self.refs_for_components() for v in self._roles.values(): v.fix_arguments() self.infra.compute_provisioning_from_refs(self._get_model_refs(), exclude_refs) return set([p for p in self.infra.components() if AbstractModelReference.find_ref_for_obj(p) not in exclude_refs])
def _fix_arguments(self): #internal host_ref = self._get_arg_value(self._host_ref) if not isinstance(host_ref, AbstractModelReference): #@FIXME: The problem here is that it won't always be possible #to find a ref object of some kind. If the value supplied was #a hard-coded string or variable override, then there will #never be a ref object available for it. In that case we #need to return the object that was already there. This is #probably going to happen more often that we'd like tmp_ref = AbstractModelReference.find_ref_for_obj(self._get_arg_value(host_ref)) if tmp_ref is not None: host_ref = tmp_ref self.host_ref = host_ref