Esempio n. 1
0
    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(".")
Esempio n. 2
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))
Esempio n. 3
0
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))
Esempio n. 4
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))