Esempio n. 1
0
 def _run(self, persona, component_order, instances):
     self._run_phase(
         PhaseFunctors(
             start=None,
             run=lambda i: i.pre_start(),
             end=None,
         ),
         component_order,
         instances,
         "pre-start",
     )
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Starting %s.', i.name),
             run=lambda i: i.start(),
             end=lambda i, result: LOG.info("Start %s applications",
                                            colorizer.quote(result)),
         ), component_order, instances, "start", 'stopped')
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Post-starting %s.',
                                      colorizer.quote(i.name)),
             run=lambda i: i.post_start(),
             end=None,
         ), component_order, instances, "post-start", 'stopped')
 def _run(self, persona, component_order, instances):
     removals = ['configure']
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Unconfiguring %s.',
                                      colorizer.quote(i.name)),
             run=lambda i: i.unconfigure(),
             end=None,
         ), component_order, instances, 'unconfigure', *removals)
     removals += ['post-install']
     self._run_phase(
         PhaseFunctors(
             start=None,
             run=lambda i: i.pre_uninstall(),
             end=None,
         ), component_order, instances, 'pre-uninstall', *removals)
     removals += ['install']
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Uninstalling %s.',
                                      colorizer.quote(i.name)),
             run=lambda i: i.uninstall(),
             end=None,
         ), component_order, instances, 'uninstall', *removals)
     removals += [
         'download', 'configure', "download-patch", 'pre-install',
         'post-install'
     ]
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Post-uninstalling %s.',
                                      colorizer.quote(i.name)),
             run=lambda i: i.post_uninstall(),
             end=None,
         ), component_order, instances, 'post-uninstall', *removals)
Esempio n. 3
0
 def _run(self, persona, component_order, instances):
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Stopping %s.', colorizer.quote(i.name
                                                                      )),
             run=lambda i: i.stop(),
             end=lambda i, result: LOG.info("Stopped %s items.",
                                            colorizer.quote(result)),
         ), component_order, instances, "stopped", 'pre-start', 'start',
         'post-start')
Esempio n. 4
0
 def _run(self, persona, component_order, instances):
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Creating a package for component %s.', colorizer.quote(i.name)),
             run=lambda i: i.package(),
             end=self._finish_package,
         ),
         component_order,
         instances,
         None,
         )
Esempio n. 5
0
 def _run(self, persona, component_order, instances):
     self._run_phase(
         PhaseFunctors(
             start=None,
             run=self._fetch_status,
             end=self._print_status,
         ),
         component_order,
         instances,
         None,
     )
Esempio n. 6
0
 def _run(self, persona, component_order, instances):
     self._run_phase(
         PhaseFunctors(
             start=lambda i: LOG.info('Running tests of component %s.',
                                      colorizer.quote(i.name)),
             run=lambda i: i.run_tests(),
             end=None,
         ),
         component_order,
         instances,
         None,
     )
Esempio n. 7
0
    def _run(self, persona, component_order, instances):
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Downloading %s.', colorizer.quote(i.name)),
                run=lambda i: i.download(),
                end=lambda i, result: LOG.info("Performed %s downloads.", len(result))
            ),
            component_order,
            instances,
            "download"
            )
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Configuring %s.', colorizer.quote(i.name)),
                run=lambda i: i.configure(),
                end=None,
            ),
            component_order,
            instances,
            "configure",
            'unconfigure'
            )

        if self.only_configure:
            # TODO(harlowja) this could really be a new action that
            # does the download and configure and let the install
            # routine actually do the install steps...
            LOG.info("Exiting early, only asked to download and configure!")
            return

        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Preinstalling %s.', colorizer.quote(i.name)),
                run=lambda i: i.pre_install(),
                end=None,
            ),
            component_order,
            instances,
            "pre-install"
            )

        def install_start(instance):
            subsystems = set(list(instance.subsystems))
            if subsystems:
                utils.log_iterable(sorted(subsystems), logger=LOG,
                    header='Installing %s using subsystems' % colorizer.quote(instance.name))
            else:
                LOG.info("Installing %s.", colorizer.quote(instance.name))

        def install_finish(instance, result):
            if not result:
                LOG.info("Finished install of %s.", colorizer.quote(instance.name))
            else:
                LOG.info("Finished install of %s with result %s.",
                         colorizer.quote(instance.name), result)

        self._run_phase(
            PhaseFunctors(
                start=install_start,
                run=lambda i: i.install(),
                end=install_finish,
            ),
            component_order,
            instances,
            "install",
            'uninstall'
            )
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Post-installing %s.', colorizer.quote(i.name)),
                run=lambda i: i.post_install(),
                end=None
            ),
            component_order,
            instances,
            "post-install",
            'uninstall', 'unconfigure', 'pre-uninstall', 'post-uninstall'
            )
Esempio n. 8
0
    def _run(self, persona, component_order, instances):
        removals = []
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Downloading %s.', colorizer.quote(i.name)),
                run=lambda i: i.download(),
                end=lambda i, result: LOG.info("Performed %s downloads.", len(result))
            ),
            component_order,
            instances,
            "download",
            *removals
            )
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Post-download patching %s.', colorizer.quote(i.name)),
                run=lambda i: i.patch("download"),
                end=None,
            ),
            component_order,
            instances,
            "download-patch",
            *removals
            )

        removals += ['uninstall', 'unconfigure']
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Configuring %s.', colorizer.quote(i.name)),
                run=lambda i: i.configure(),
                end=None,
            ),
            component_order,
            instances,
            "configure",
            *removals
            )

        if self.only_configure:
            # TODO(harlowja) this could really be a new action that
            # does the download and configure and let the install
            # routine actually do the install steps...
            LOG.info("Exiting early, only asked to download and configure!")
            return

        def preinstall_run(instance):
            instance.pre_install()

        removals += ['pre-uninstall', 'post-uninstall']
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Preinstalling %s.', colorizer.quote(i.name)),
                run=preinstall_run,
                end=None,
            ),
            component_order,
            instances,
            "pre-install",
            *removals
            )

        all_instance_dependencies = {}

        def capture_run(instance):
            instance_dependencies = {}
            if isinstance(instance, (components.PkgInstallComponent)):
                instance_dependencies['packages'] = instance.packages
            if isinstance(instance, (components.PythonInstallComponent)):
                instance_dependencies['pips'] = instance.pip_requires
            all_instance_dependencies[instance.name] = instance_dependencies

        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Capturing dependencies of %s.', colorizer.quote(i.name)),
                run=capture_run,
                end=None,
            ),
            component_order,
            instances,
            None,
            *removals
            )

        # Do validation on the installed dependency set.
        self._analyze_dependencies(all_instance_dependencies)

        def install_start(instance):
            subsystems = set(list(instance.subsystems))
            if subsystems:
                utils.log_iterable(sorted(subsystems), logger=LOG,
                                   header='Installing %s using subsystems' % colorizer.quote(instance.name))
            else:
                LOG.info("Installing %s.", colorizer.quote(instance.name))

        def install_finish(instance, result):
            if not result:
                LOG.info("Finished install of %s.", colorizer.quote(instance.name))
            else:
                LOG.info("Finished install of %s with result %s.",
                         colorizer.quote(instance.name), result)

        self._run_phase(
            PhaseFunctors(
                start=install_start,
                run=lambda i: i.install(),
                end=install_finish,
            ),
            component_order,
            instances,
            "install",
            *removals
            )
        self._run_phase(
            PhaseFunctors(
                start=lambda i: LOG.info('Post-installing %s.', colorizer.quote(i.name)),
                run=lambda i: i.post_install(),
                end=None
            ),
            component_order,
            instances,
            "post-install",
            *removals
            )