def polish_blueprint(self, names, polishers): """ Walks a named blueprint for this facility and polish related resources :param names: the name(s) of the blueprint(s) to polish :type names: ``str`` or ``list`` of ``str`` :param polishers: polishers to be applied :type polishers: list of :class:`plumbery.PlumberyPolisher` """ if isinstance(polishers, str): polishers = PlumberyPolisher.filter(self.plumbery.polishers, polishers) self.power_on() infrastructure = PlumberyInfrastructure(self) nodes = PlumberyNodes(self) for name in self.expand_blueprint(names): blueprint = self.get_blueprint(name) container = infrastructure.get_container(blueprint) for polisher in polishers: polisher.shine_container(container) nodes.polish_blueprint(blueprint, polishers, container)
def polish_all_blueprints(self, filter=None): """ Walk all resources and polish them :param filter: the name of a single polisher to apply. If this parameter is missing, all polishers declared in the fittings plan will be applied :type filter: ``str`` This function checks all facilities, one at a time and in the order defined in fittings plan, to apply custom polishers there. Example:: from plumbery.engine import PlumberyEngine PlumberyEngine('fittings.yaml').polish_all_blueprints() """ logging.info("Polishing all blueprints") polishers = PlumberyPolisher.filter(self.polishers, filter) for polisher in polishers: polisher.go(self) for facility in self.facilities: facility.focus() for polisher in polishers: polisher.move_to(facility) facility.polish_all_blueprints(polishers) for polisher in polishers: polisher.reap()
def polish_blueprint(self, names, polishers): """ Walks a named blueprint for this facility and polish related resources :param names: the name(s) of the blueprint(s) to polish :type names: ``str`` or ``list`` of ``str`` :param polishers: polishers to be applied :type polishers: list of :class:`plumbery.PlumberyPolisher` """ if isinstance(polishers, str): polishers = PlumberyPolisher.filter(self.plumbery.polishers, polishers) self.power_on() infrastructure = PlumberyInfrastructure(self) nodes = PlumberyNodes(self) for polisher in polishers: polisher.move_to(self) for name in self.expand_blueprint(names): blueprint = self.get_blueprint(name) container = infrastructure.get_container(blueprint) for polisher in polishers: polisher.shine_container(container) nodes.polish_blueprint(blueprint, polishers, container)
def polish_blueprint(self, names, filter=None, facilities=None): """ Walks resources from the target blueprint and polishes them :param names: the name(s) of the blueprint(s) to polish :type names: ``str`` or ``list`` of ``str`` :param filter: the name of a single polisher to apply. If this parameter is missing, all polishers declared in the fittings plan will be applied :type filter: ``str`` :param facilities: explicit list of target facilities :type facilities: ``str`` or ``list`` of ``str`` This function checks facilities to apply one polisher to one blueprint. The default behaviour is to consider all facilities mentioned in the fittings plan. If a list of facilities is provided, than the action is limited to this subset only. Example:: from plumbery.engine import PlumberyEngine PlumberyEngine('fittings.yaml').polish_blueprint('sql') """ polishers = PlumberyPolisher.filter(self.polishers, filter) if len(polishers) < 1: logging.debug('No polisher has been found') return if isinstance(names, list): label = ' '.join(names) else: label = names logging.info("Polishing blueprint '{}'".format(label)) for polisher in polishers: polisher.go(self) if facilities is not None: facilities = self.list_facility(facilities) else: facilities = self.facilities for facility in facilities: facility.focus() for polisher in polishers: polisher.move_to(facility) facility.polish_blueprint(names, polishers) for polisher in polishers: polisher.reap()
def polish_all_blueprints(self, filter=None, facilities=None): """ Walks all resources and polishes them :param filter: the name of a single polisher to apply. If this parameter is missing, all polishers declared in the fittings plan will be applied :type filter: ``str`` :param facilities: explicit list of target facilities :type facilities: ``str`` or ``list`` of ``str`` This function checks facilities to apply polishers there. The default behaviour is to consider all facilities mentioned in the fittings plan. If a list of facilities is provided, than the action is limited to this subset only. Example:: from plumbery.engine import PlumberyEngine PlumberyEngine('fittings.yaml').polish_all_blueprints() """ polishers = PlumberyPolisher.filter(self.polishers, filter) if len(polishers) < 1: return False logging.info("Polishing all blueprints") for polisher in polishers: polisher.go(self) if facilities is not None: facilities = self.list_facility(facilities) else: facilities = self.facilities for facility in facilities: facility.focus() for polisher in polishers: polisher.move_to(facility) facility.polish_all_blueprints(polishers) for polisher in polishers: polisher.reap()