Пример #1
0
    def run(self, cmdline, db):
        try:
            tasks = self._get_tasks(cmdline, db)
        except FafError as ex:
            self.log_error("Unable to process command line arguments: {0}"
                           .format(str(ex)))
            return 1

        new_components = {}

        i = 0
        for osplugin, db_release in tasks:
            i += 1

            self.log_info("[{0} / {1}] Processing '{2} {3}'"
                          .format(i, len(tasks), osplugin.nice_name,
                                  db_release.version))

            db_components = [c.component.name for c in db_release.components]
            remote_components = osplugin.get_components(db_release.version)

            for remote_component in remote_components:
                if remote_component in db_components:
                    continue

                db_component = get_component_by_name(db, remote_component,
                                                     db_release.opsys.name)

                if db_component is None:
                    key = (db_release.opsys, remote_component)
                    if key in new_components:
                        db_component = new_components[key]
                    else:
                        self.log_info("Creating new component '{0}' in "
                                      "operating system '{1}'"
                                      .format(remote_component,
                                              osplugin.nice_name))

                        db_component = OpSysComponent()
                        db_component.name = remote_component
                        db_component.opsys = db_release.opsys
                        db.session.add(db_component)

                        new_components[key] = db_component

                self.log_info("Creating new component '{0}' in {1} {2}"
                              .format(remote_component, osplugin.nice_name,
                                      db_release.version))
                db_release_component = OpSysReleaseComponent()
                db_release_component.release = db_release
                db_release_component.component = db_component
                db.session.add(db_release_component)

        db.session.flush()
        return 0
Пример #2
0
    def run(self, cmdline, db):
        try:
            tasks = self._get_tasks(cmdline, db)
        except FafError as ex:
            self.log_error("Unable to process command line arguments: {0}"
                           .format(str(ex)))
            return 1

        new_components = {}

        i = 0
        for osplugin, db_release in tasks:
            i += 1

            self.log_info("[{0} / {1}] Processing '{2} {3}'"
                          .format(i, len(tasks), osplugin.nice_name,
                                  db_release.version))

            db_components = [c.component.name for c in db_release.components]
            remote_components = osplugin.get_components(db_release.version)

            for remote_component in remote_components:
                if remote_component in db_components:
                    continue

                db_component = get_component_by_name(db, remote_component,
                                                     db_release.opsys.name)

                if db_component is None:
                    key = (db_release.opsys, remote_component)
                    if key in new_components:
                        db_component = new_components[key]
                    else:
                        self.log_info("Creating new component '{0}' in "
                                      "operating system '{1}'"
                                      .format(remote_component,
                                              osplugin.nice_name))

                        db_component = OpSysComponent()
                        db_component.name = remote_component
                        db_component.opsys = db_release.opsys
                        db.session.add(db_component)

                        new_components[key] = db_component

                self.log_info("Creating new component '{0}' in {1} {2}"
                              .format(remote_component, osplugin.nice_name,
                                      db_release.version))
                db_release_component = OpSysReleaseComponent()
                db_release_component.release = db_release
                db_release_component.component = db_component
                db.session.add(db_release_component)

        db.session.flush()
        return 0
Пример #3
0
    def run(self, cmdline, db):
        if cmdline.opsys is None:
            self.log_error("You must specify an operating system")
            return 1

        if not cmdline.opsys in systems:
            self.log_error("Operating system '{0}' does not exist".format(
                cmdline.opsys))
            return 1

        opsys = systems[cmdline.opsys]
        db_opsys = get_opsys_by_name(db, opsys.nice_name)
        if db_opsys is None:
            self.log_error("Operating system '{0}' is not installed".format(
                opsys.nice_name))
            return 1

        db_component = get_component_by_name(db, cmdline.COMPONENT,
                                             opsys.nice_name)
        if db_component is None:
            self.log_info(
                "Adding component '{0}' to operating system '{1}'".format(
                    cmdline.COMPONENT, opsys.nice_name))

            db_component = OpSysComponent()
            db_component.opsys = db_opsys
            db_component.name = cmdline.COMPONENT
            db.session.add(db_component)

        for release in cmdline.opsys_release:
            db_release = get_osrelease(db, opsys.nice_name, release)
            if db_release is None:
                self.log_warn("Release '{0} {1}' is not defined".format(
                    opsys.nice_name, release))
                continue

            db_relcomponent = get_component_by_name_release(
                db, db_release, cmdline.COMPONENT)
            if db_relcomponent is None:
                self.log_info("Adding component '{0}' to '{1} {2}'".format(
                    cmdline.COMPONENT, opsys.nice_name, release))

                db_relcomponent = OpSysReleaseComponent()
                db_relcomponent.component = db_component
                db_relcomponent.release = db_release
                db.session.add(db_relcomponent)

        db.session.flush()
        return 0
Пример #4
0
    def run(self, cmdline, db):
        if cmdline.opsys is None:
            self.log_error("You must specify an operating system")
            return 1

        if not cmdline.opsys in systems:
            self.log_error("Operating system '{0}' does not exist"
                           .format(cmdline.opsys))
            return 1

        opsys = systems[cmdline.opsys]
        db_opsys = get_opsys_by_name(db, opsys.nice_name)
        if db_opsys is None:
            self.log_error("Operating system '{0}' is not installed"
                           .format(opsys.nice_name))
            return 1

        db_component = get_component_by_name(db, cmdline.COMPONENT,
                                             opsys.nice_name)
        if db_component is None:
            self.log_info("Adding component '{0}' to operating system '{1}'"
                          .format(cmdline.COMPONENT, opsys.nice_name))

            db_component = OpSysComponent()
            db_component.opsys = db_opsys
            db_component.name = cmdline.COMPONENT
            db.session.add(db_component)

        for release in cmdline.opsys_release:
            db_release = get_osrelease(db, opsys.nice_name, release)
            if db_release is None:
                self.log_warn("Release '{0} {1}' is not defined"
                              .format(opsys.nice_name, release))
                continue

            db_relcomponent = get_component_by_name_release(db, db_release,
                                                            cmdline.COMPONENT)
            if db_relcomponent is None:
                self.log_info("Adding component '{0}' to '{1} {2}'"
                              .format(cmdline.COMPONENT,
                                      opsys.nice_name, release))

                db_relcomponent = OpSysReleaseComponent()
                db_relcomponent.component = db_component
                db_relcomponent.release = db_release
                db.session.add(db_relcomponent)

        db.session.flush()
        return 0