コード例 #1
0
    def watchdogs(self, status='active', lc=None):
        """ Return all active/expired tasks for this lab controller
            The lab controllers login with host/fqdn
        """
        # TODO work on logic that determines whether or not originator
        # was qpid or kobo ?
        if lc is None:
            try:
                labcontroller = identity.current.user.lab_controller
            except AttributeError:
                raise BX(
                    _('No lab controller passed in and not currently logged in'
                      ))

            if not labcontroller:
                raise BX(
                    _(u'Invalid login: %s, must log in as a lab controller' %
                      identity.current.user))
        else:
            try:
                labcontroller = LabController.by_name(lc)
            except InvalidRequestError:
                raise BX(_(u'Invalid lab controller: %s' % lc))

        return [
            dict(recipe_id=w.recipe.id,
                 system=w.recipe.resource.fqdn,
                 is_virt_recipe=(w.recipe.resource.type == ResourceType.virt))
            for w in Watchdog.by_status(labcontroller, status)
        ]
コード例 #2
0
ファイル: labcontroller.py プロジェクト: sibiaoluo/beaker
    def remove(self, id, *args, **kw):
        try:
            labcontroller = LabController.by_id(id)
            labcontroller.removed = datetime.utcnow()
            systems = System.query.filter_by(lab_controller_id=id).values(System.id)
            for system_id in systems:
                sys_activity = SystemActivity(identity.current.user, 'WEBUI', \
                    'Changed', 'lab_controller', labcontroller.fqdn,
                    None, system_id=system_id[0])
            system_table.update().where(system_table.c.lab_controller_id == id).\
                values(lab_controller_id=None).execute()
            watchdogs = Watchdog.by_status(labcontroller=labcontroller, 
                status='active')
            for w in watchdogs:
                w.recipe.recipeset.job.cancel(msg='LabController %s has been deleted' % labcontroller.fqdn)
            for lca in labcontroller._distro_trees:
                lca.distro_tree.activity.append(DistroTreeActivity(
                        user=identity.current.user, service=u'WEBUI',
                        action=u'Removed', field_name=u'lab_controller_assocs',
                        old_value=u'%s %s' % (lca.lab_controller, lca.url),
                        new_value=None))
                session.delete(lca)
            labcontroller.disabled = True
            LabControllerActivity(identity.current.user, 'WEBUI', 
                'Changed', 'Disabled', unicode(False), unicode(True), 
                lab_controller_id=id)
            LabControllerActivity(identity.current.user, 'WEBUI', 
                'Changed', 'Removed', unicode(False), unicode(True), 
                lab_controller_id=id)
            session.commit()
        finally:
            session.close()

        flash( _(u"%s removed") % labcontroller.fqdn )
        raise redirect(".")
コード例 #3
0
ファイル: labcontroller.py プロジェクト: ShaolongHu/beaker
    def remove(self, id, *args, **kw):
        labcontroller = LabController.by_id(id)
        labcontroller.removed = datetime.utcnow()
        # de-associate systems
        systems = System.query.filter(System.lab_controller == labcontroller)
        System.record_bulk_activity(systems, user=identity.current.user,
                service=u'WEBUI', action=u'Changed', field=u'lab_controller',
                old=labcontroller.fqdn, new=None)
        systems.update({'lab_controller_id': None}, synchronize_session=False)
        # cancel running recipes
        watchdogs = Watchdog.by_status(labcontroller=labcontroller, 
            status='active')
        for w in watchdogs:
            w.recipe.recipeset.job.cancel(msg='LabController %s has been deleted' % labcontroller.fqdn)
        # remove distro trees
        distro_tree_assocs = LabControllerDistroTree.query\
            .filter(LabControllerDistroTree.lab_controller == labcontroller)\
            .join(LabControllerDistroTree.distro_tree)
        DistroTree.record_bulk_activity(distro_tree_assocs, user=identity.current.user,
                service=u'WEBUI', action=u'Removed', field=u'lab_controller_assocs',
                old=labcontroller.fqdn, new=None)
        distro_tree_assocs.delete(synchronize_session=False)
        labcontroller.disabled = True
        labcontroller.record_activity(user=identity.current.user, service=u'WEBUI',
                field=u'Disabled', action=u'Changed', old=unicode(False), new=unicode(True))
        labcontroller.record_activity(user=identity.current.user, service=u'WEBUI',
                field=u'Removed', action=u'Changed', old=unicode(False), new=unicode(True))

        flash( _(u"%s removed") % labcontroller.fqdn )
        raise redirect(".")
コード例 #4
0
ファイル: labcontroller.py プロジェクト: sibiaoluo/beaker
 def has_active_recipes(self, id):
     labcontroller = LabController.by_id(id)
     count = Watchdog.by_status(labcontroller=labcontroller, status='active').count()
     if count:
         return {'has_active_recipes' : True}
     else:
         return {'has_active_recipes' : False}
コード例 #5
0
ファイル: watchdog.py プロジェクト: pombredanne/beaker-1
    def index(self, *args, **kw):
        query = Watchdog.by_status(status=u'active')\
                .join(Watchdog.recipe).join(Recipe.recipeset).join(RecipeSet.job)\
                .order_by(Job.id)\
                .options(
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.job),
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.lab_controller),
                    joinedload_all(Watchdog.recipetask, RecipeTask.task))

        col = myPaginateDataGrid.Column
        fields = [
            col(name='job_id',
                getter=lambda x: x.recipe.recipeset.job.link,
                title="Job ID"),
            col(name='system_name',
                getter=lambda x: x.recipe.resource.link,
                title="System"),
            col(name='lab_controller',
                getter=lambda x: x.recipe.recipeset.lab_controller,
                title="Lab Controller"),
            col(name='task_name',
                getter=lambda x: x.recipetask.name_markup
                if x.recipetask is not None else None,
                title="Task Name"),
            col(name='kill_time',
                getter=lambda x: x.kill_time,
                title="Kill Time",
                options=dict(datetime=True))
        ]

        watchdog_grid = myPaginateDataGrid(fields=fields)
        return dict(title="Watchdogs",
                    grid=watchdog_grid,
                    search_bar=None,
                    list=query)
コード例 #6
0
 def has_active_recipes(self, id):
     labcontroller = LabController.by_id(id)
     count = Watchdog.by_status(labcontroller=labcontroller,
                                status='active').count()
     if count:
         return {'has_active_recipes': True}
     else:
         return {'has_active_recipes': False}
コード例 #7
0
def remove_labcontroller(labcontroller):
    """
    Disables and marks a lab controller as removed.
    """
    labcontroller.removed = datetime.utcnow()
    systems = System.query.filter(System.lab_controller == labcontroller)

    # Record systems set to status=broken. Trigger any event listener listening
    # for status changes.
    for sys in systems:
        sys.mark_broken('Lab controller de-associated')
        sys.abort_queued_commands("System disassociated from lab controller")
    # de-associate systems
    System.record_bulk_activity(systems,
                                user=identity.current.user,
                                service=u'HTTP',
                                action=u'Changed',
                                field=u'Lab Controller',
                                old=labcontroller.fqdn,
                                new=None)
    systems.update({'lab_controller_id': None}, synchronize_session=False)

    # cancel running recipes
    watchdogs = Watchdog.by_status(labcontroller=labcontroller,
                                   status='active')
    for w in watchdogs:
        w.recipe.recipeset.job.cancel(
            msg='Lab controller %s has been deleted' % labcontroller.fqdn)

    # remove distro trees
    distro_tree_assocs = LabControllerDistroTree.query\
        .filter(LabControllerDistroTree.lab_controller == labcontroller)
    DistroTree.record_bulk_activity(distro_tree_assocs.join(
        LabControllerDistroTree.distro_tree),
                                    user=identity.current.user,
                                    service=u'HTTP',
                                    action=u'Removed',
                                    field=u'lab_controller_assocs',
                                    old=labcontroller.fqdn,
                                    new=None)
    distro_tree_assocs.delete(synchronize_session=False)
    labcontroller.disabled = True
    labcontroller.record_activity(user=identity.current.user,
                                  service=u'HTTP',
                                  field=u'Disabled',
                                  action=u'Changed',
                                  old=unicode(False),
                                  new=unicode(True))
    labcontroller.record_activity(user=identity.current.user,
                                  service=u'HTTP',
                                  field=u'Removed',
                                  action=u'Changed',
                                  old=unicode(False),
                                  new=unicode(True))
コード例 #8
0
ファイル: watchdog.py プロジェクト: sibiaoluo/beaker
    def extend(self, time):
        '''Allow admins to push watchdog times out after an outage'''

        watchdogs = []
        for w in Watchdog.by_status(status=u'active'):
            n_kill_time = w.kill_time + timedelta(seconds=time)
            watchdogs.append("R:%s watchdog moved from %s to %s" % (
                              w.recipe_id, w.kill_time, n_kill_time))
            w.kill_time = n_kill_time

        if watchdogs:
            return "\n".join(watchdogs)
        else:
            return 'No active watchdogs found'
コード例 #9
0
ファイル: watchdog.py プロジェクト: pombredanne/beaker-1
    def extend(self, time):
        '''Allow admins to push watchdog times out after an outage'''

        watchdogs = []
        for w in Watchdog.by_status(status=u'active'):
            n_kill_time = w.kill_time + timedelta(seconds=time)
            watchdogs.append("R:%s watchdog moved from %s to %s" %
                             (w.recipe_id, w.kill_time, n_kill_time))
            w.kill_time = n_kill_time

        if watchdogs:
            return "\n".join(watchdogs)
        else:
            return 'No active watchdogs found'
コード例 #10
0
ファイル: labcontroller.py プロジェクト: qhsong/beaker
def remove_labcontroller(labcontroller):
    """
    Disables and marks a lab controller as removed.
    """
    labcontroller.removed = datetime.utcnow()

    # de-associate systems
    systems = System.query.filter(System.lab_controller == labcontroller)
    System.record_bulk_activity(systems,
                                user=identity.current.user,
                                service=u'HTTP',
                                action=u'Changed',
                                field=u'lab_controller',
                                old=labcontroller.fqdn,
                                new=None)
    systems.update({'lab_controller_id': None}, synchronize_session=False)

    # cancel running recipes
    watchdogs = Watchdog.by_status(labcontroller=labcontroller,
                                   status='active')
    for w in watchdogs:
        w.recipe.recipeset.job.cancel(msg='LabController %s has been deleted' %
                                      labcontroller.fqdn)

    # remove distro trees
    distro_tree_assocs = LabControllerDistroTree.query\
        .filter(LabControllerDistroTree.lab_controller == labcontroller)\
        .join(LabControllerDistroTree.distro_tree)
    DistroTree.record_bulk_activity(distro_tree_assocs,
                                    user=identity.current.user,
                                    service=u'HTTP',
                                    action=u'Removed',
                                    field=u'lab_controller_assocs',
                                    old=labcontroller.fqdn,
                                    new=None)
    distro_tree_assocs.delete(synchronize_session=False)
    labcontroller.disabled = True
    labcontroller.record_activity(user=identity.current.user,
                                  service=u'HTTP',
                                  field=u'Disabled',
                                  action=u'Changed',
                                  old=unicode(False),
                                  new=unicode(True))
    labcontroller.record_activity(user=identity.current.user,
                                  service=u'HTTP',
                                  field=u'Removed',
                                  action=u'Changed',
                                  old=unicode(False),
                                  new=unicode(True))
コード例 #11
0
def remove_labcontroller(labcontroller):
    """
    Disables and marks a lab controller as removed.
    """
    labcontroller.removed = datetime.utcnow()
    systems = System.query.filter(System.lab_controller == labcontroller)

    # Record systems set to status=broken. Trigger any event listener listening
    # for status changes.
    for sys in systems:
        sys.mark_broken('Lab controller de-associated')

    # de-associate systems
    System.record_bulk_activity(systems, user=identity.current.user,
                                service=u'HTTP', action=u'Changed', field=u'Lab Controller',
                                old=labcontroller.fqdn, new=None)
    systems.update({'lab_controller_id': None},
                   synchronize_session=False)

    # cancel running recipes
    watchdogs = Watchdog.by_status(labcontroller=labcontroller,
                                   status='active')
    for w in watchdogs:
        w.recipe.recipeset.job.cancel(msg='Lab controller %s has been deleted' % labcontroller.fqdn)

    # remove distro trees
    distro_tree_assocs = LabControllerDistroTree.query\
        .filter(LabControllerDistroTree.lab_controller == labcontroller)\
        .join(LabControllerDistroTree.distro_tree)
    DistroTree.record_bulk_activity(
        distro_tree_assocs, user=identity.current.user,
        service=u'HTTP', action=u'Removed', field=u'lab_controller_assocs',
        old=labcontroller.fqdn, new=None)
    distro_tree_assocs.delete(synchronize_session=False)
    labcontroller.disabled = True
    labcontroller.record_activity(
        user=identity.current.user, service=u'HTTP',
        field=u'Disabled', action=u'Changed', old=unicode(False), new=unicode(True))
    labcontroller.record_activity(
        user=identity.current.user, service=u'HTTP',
        field=u'Removed', action=u'Changed', old=unicode(False), new=unicode(True))
コード例 #12
0
ファイル: recipetasks.py プロジェクト: ustbgaofan/beaker
    def watchdogs(self, status='active',lc=None):
        """ Return all active/expired tasks for this lab controller
            The lab controllers login with host/fqdn
        """
        # TODO work on logic that determines whether or not originator
        # was qpid or kobo ?
        if lc is None:
            try:
                labcontroller = identity.current.user.lab_controller
            except AttributeError:
                raise BX(_('No lab controller passed in and not currently logged in'))

            if not labcontroller:
                raise BX(_(u'Invalid login: %s, must log in as a lab controller' % identity.current.user))
        else:
            try:
                labcontroller = LabController.by_name(lc)
            except InvalidRequestError:
                raise BX(_(u'Invalid lab controller: %s' % lc))

        return [dict(recipe_id = w.recipe.id,
                        system = w.recipe.resource.fqdn) for w in Watchdog.by_status(labcontroller, status)]
コード例 #13
0
ファイル: watchdog.py プロジェクト: ustbgaofan/beaker
    def index(self, *args, **kw):
        query = Watchdog.by_status(status=u'active')\
                .join(Watchdog.recipe, Recipe.recipeset, RecipeSet.job)\
                .order_by(Job.id)\
                .options(
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.job),
                    joinedload_all(Watchdog.recipe, Recipe.recipeset, RecipeSet.lab_controller),
                    joinedload_all(Watchdog.recipetask, RecipeTask.task))

        col = myPaginateDataGrid.Column
        fields = [col(name='job_id', getter=lambda x: x.recipe.recipeset.job.link, title="Job ID"),
                  col(name='system_name', getter=lambda x: x.recipe.resource.link, title="System"),
                  col(name='lab_controller', getter=lambda x: x.recipe.recipeset.lab_controller, title="Lab Controller"),
                  col(name='task_name', getter=lambda x: x.recipetask.name_markup
                        if x.recipetask is not None else None, title="Task Name"),
                  col(name='kill_time', getter=lambda x: x.kill_time,
                      title="Kill Time", options=dict(datetime=True))]

        watchdog_grid = myPaginateDataGrid(fields=fields)
        return dict(title="Watchdogs",
                grid=watchdog_grid,
                search_bar=None,
                list=query)