Esempio n. 1
0
def teardown():
    sess.close()
    (ms, intrnl) = get_reqs()

    #TODO: move this general approach to test_dns???
    # generalize the entire approach and take a count on the way in and out
    qry = sess.query(ARecord).filter(
        ARecord.name.like(AREC_PREFIX + '%'))
    qry = qry.filter_by(dns_environment=intrnl)
    if qry.count() == 0:
        log.info('successful cascaded deletion of ARecords')
    else:
        log.error('ARecords left intact when they should be delete cascaded')
    for rec in qry.filter_by(dns_domain=ms).all():
        sess.delete(rec)
        commit(sess)
        log.debug('deleted ARecord %s' % rec.fqdn)

    dns_count_after = sess.query(DnsRecord).count()

    if dns_count_after != dns_count_b4:
        log.warning('%s record(s) left after teardown in %s, should be %s' % (
            dns_count_after, func_name(), dns_count_b4))

    del_machines(sess, MCHN_PREFIX)

    mchn_count_after = sess.query(Machine).count()
    if mchn_count_b4 != mchn_count_after:
        log.warning('%s machines left after %s, should be %s'%(
            mchn_count_after, func_name(), mchn_count_b4))
Esempio n. 2
0
def teardown():
    sess.close()
    (ms, intrnl) = get_reqs()

    #TODO: move this general approach to test_dns???
    # generalize the entire approach and take a count on the way in and out
    qry = sess.query(ARecord).filter(ARecord.name.like(AREC_PREFIX + '%'))
    qry = qry.filter_by(dns_environment=intrnl)
    if qry.count() == 0:
        log.info('successful cascaded deletion of ARecords')
    else:
        log.error('ARecords left intact when they should be delete cascaded')
    for rec in qry.filter_by(dns_domain=ms).all():
        sess.delete(rec)
        commit(sess)
        log.debug('deleted ARecord %s' % rec.fqdn)

    dns_count_after = sess.query(DnsRecord).count()

    if dns_count_after != dns_count_b4:
        log.warning('%s record(s) left after teardown in %s, should be %s' %
                    (dns_count_after, func_name(), dns_count_b4))

    del_machines(sess, MCHN_PREFIX)

    mchn_count_after = sess.query(Machine).count()
    if mchn_count_b4 != mchn_count_after:
        log.warning('%s machines left after %s, should be %s' %
                    (mchn_count_after, func_name(), mchn_count_b4))
Esempio n. 3
0
def clean_up():
    del_machines(sess, MACHINE_NAME)
    disk_ids = sess.query(Disk.id).all()
    if disk_ids:
        for id in disk_ids:
            if id in disk_id_cache:
                print 'disk with id %s not deleted'% (id)
                s.query(Disk).filter_by(id=id).delete()
            commit(sess)
    del_service_instance(SHARE_NAME)
    del_service(NAS_SVC)