def _run_phase(self, functors, component_order, instances, phase_name, *inv_phase_names): """ Run a given 'functor' across all of the components, in order. """ component_results = OrderedDict() if not phase_name: phase_recorder = phase.NullPhaseRecorder() else: phase_recorder = phase.PhaseRecorder(self._get_phase_filename(phase_name)) neg_phase_recs = [] if inv_phase_names: for n in inv_phase_names: if not n: neg_phase_recs.append(phase.NullPhaseRecorder()) else: neg_phase_recs.append(phase.PhaseRecorder(self._get_phase_filename(n))) def change_activate(instance, on_off): # Activate/deactivate them and there siblings (if any) instance.activated = on_off for (_name, sibling_instance) in instance.siblings.items(): sibling_instance.activated = on_off def run_inverse_recorders(c_name): for n in neg_phase_recs: n.unmark(c_name) # Reset all activations for c in component_order: change_activate(instances[c], False) # Run all components which have not been ran previously (due to phase tracking) for c in component_order: result = None instance = instances[c] if c in phase_recorder: LOG.debug("Skipping phase named %r for component %r since it already happened.", phase_name, c) else: try: with phase_recorder.mark(c): if functors.start: functors.start(instance) if functors.run: result = functors.run(instance) if functors.end: functors.end(instance, result) except excp.NoTraceException: pass change_activate(instance, True) component_results[c] = result run_inverse_recorders(c) return component_results
def env_exports(self): to_set = OrderedDict() params = ghelper.get_shared_params(**self.options) for (endpoint, details) in params['endpoints'].items(): to_set[("GLANCE_%s_URI" % (endpoint.upper()))] = details['uri'] return to_set
def env_exports(self): params = khelper.get_shared_params(**utils.merge_dicts(self.options, khelper.get_shared_passwords(self))) to_set = OrderedDict() to_set['OS_PASSWORD'] = params['admin_password'] to_set['OS_TENANT_NAME'] = params['admin_tenant'] to_set['OS_USERNAME'] = params['admin_user'] to_set['OS_AUTH_URL'] = params['endpoints']['public']['uri'] for (endpoint, details) in params['endpoints'].items(): if endpoint.find('templated') != -1: continue to_set[("KEYSTONE_%s_URI" % (endpoint.upper()))] = details['uri'] return to_set
def _run_phase(self, functors, component_order, instances, phase_name, *inv_phase_names): """ Run a given 'functor' across all of the components, in order. """ # All the results for each component end up in here # in the order in which they ran... component_results = OrderedDict() # This phase recorder will be used to check if a given component # and action has ran in the past, if so that components action # will not be ran again. It will also be used to mark that a given # component has completed a phase (if that phase runs). if not phase_name: phase_recorder = phase.NullPhaseRecorder() else: phase_recorder = phase.PhaseRecorder(self._get_phase_filename(phase_name)) # These phase recorders will be used to undo other actions activities # ie, when an install completes you want the uninstall phase to be # removed from that actions phase file (and so on). This list will be # used to accomplish that. neg_phase_recs = [] if inv_phase_names: for n in inv_phase_names: if not n: neg_phase_recs.append(phase.NullPhaseRecorder()) else: neg_phase_recs.append(phase.PhaseRecorder(self._get_phase_filename(n))) def change_activate(instance, on_off): # Activate/deactivate a component instance and there siblings (if any) # # This is used when you say are looking at components # that have been activated before your component has been. # # Typically this is useful for checking if a previous component # has a shared dependency with your component and if so then there # is no need to reinstall said dependency... instance.activated = on_off for (_name, sibling_instance) in instance.siblings.items(): sibling_instance.activated = on_off def run_inverse_recorders(c_name): for n in neg_phase_recs: n.unmark(c_name) # Reset all activations for c in component_order: change_activate(instances[c], False) # Run all components which have not been ran previously (due to phase tracking) for c in component_order: result = None instance = instances[c] if c in phase_recorder: LOG.debug("Skipping phase named %r for component %r since it already happened.", phase_name, c) else: try: with phase_recorder.mark(c): if functors.start: functors.start(instance) if functors.run: result = functors.run(instance) if functors.end: functors.end(instance, result) except excp.NoTraceException: pass change_activate(instance, True) component_results[c] = result run_inverse_recorders(c) return component_results