Ejemplo n.º 1
0
    def test_dryrun_config(self):
        ta = terminator_app.TerminatorApp(conf=self.conf)
        self.assertIsInstance(ta.lc, utils.LbaasClient)
        self.assertIsNot(ta.lc, utils.DryRunLbaasClient)

        self.conf['dryrun'] = True
        ta = terminator_app.TerminatorApp(conf=self.conf)
        self.assertIsInstance(ta.lc, utils.DryRunLbaasClient)
        self.assertIsNot(ta.lc, utils.LbaasClient)
Ejemplo n.º 2
0
#!/usr/bin/env python

from terminator.app import utils
from terminator.app import terminator_app
import sys

if __name__ == "__main__":
    conf = utils.load_config(conf=None)
    if "--dryrun" in sys.argv:
        conf['dryrun'] = True
    ta = terminator_app.TerminatorApp(conf=conf)
    if conf.get('dryrun', False):
        ta.run_iteration()  # This is a dry run so do one iteration
    else:
        ta.main_loop()
Ejemplo n.º 3
0
from terminator.app import terminator_app
from terminator.app import utils
from terminator.app.db import crud, tables

ta = terminator_app.TerminatorApp()
lc = utils.LbaasClient()

sess = crud.get_session()

qb = sess.query(tables.Entry).filter(needs_push=1)
qb = qb.order_by(tables.Entry.event_time).all()

ta.create_lbs(354934)

lbs = ta.get_all_lbs(354934)

ta.get_new_terminator_entries()

ta.suspend_aid("some id here", 354934)

ta.unsuspend_aid(354934)

ta.delete_aid(354934)

for i in xrange(0, len(entries)):
    e = entries[i]
    uid = e.entry_id.split(":")[-1]
    e.entry_id = uid
    sess.merge(e)
Ejemplo n.º 4
0
    def test_run_iteration(self, req):
        posts = []
        gets = []
        dels = []
        posts.append(
            mymocks.MockResponse(
                {'access': {
                    'token': {
                        'expires': 'Never',
                        'id': 'Id'
                    }
                }}, 200))

        gets.append(
            mymocks.MockResponse(
                make_fake_feed([SUSPEND, FULL, SUSPEND, TERMINATED]), 200))
        gets.append(mymocks.MockResponse(make_fake_feed([]), 200))

        #populate get_lbs for suspend
        populate_get_lbs(gets, ACTIVE)
        #expect the app to send four posts to delete the 4 lbs
        populate_responseobjects(posts, 202)

        #populate get_lbs for FULL access
        populate_get_lbs(gets, SUSPENDED)

        #expect the app to send four delete suspension calls
        populate_responseobjects(dels, 202)

        #time to suspend the LBs again.
        populate_get_lbs(gets, ACTIVE)

        #re suspending loadbalancers
        populate_responseobjects(posts, 202)

        #finally delete the loadbalancers
        #populate gets for lbs during delete call
        populate_get_lbs(gets, SUSPENDED)

        #expect 4 delete calls to terminate the loadbalancers
        populate_responseobjects(dels, 202)

        req.post.side_effect = posts
        req.get.side_effect = gets
        req.delete.side_effect = dels
        test_conf = utils.load_config(utils.load_json(TEST_CONF_FILE))
        utils.create_tables(test_conf)
        ta = terminator_app.TerminatorApp(test_conf)
        ta.bump_run()
        ta.run_iteration()

        # Time to check the logs and action table to see if everything worked
        sess = crud.get_session(test_conf)

        expected_order_statuses = [(ACTIVE, SUSPENDED), (SUSPENDED, ACTIVE),
                                   (ACTIVE, SUSPENDED), (SUSPENDED, DELETED)]

        lb1234_ord = (sess.query(
            tables.Action).filter(tables.Action.lid == 1234).filter(
                tables.Action.dc == 'ord').order_by(tables.Action.time).all())
        self.assertActionsChangedFromTo(lb1234_ord, expected_order_statuses)

        lb4567_ord = (sess.query(
            tables.Action).filter(tables.Action.lid == 4567).filter(
                tables.Action.dc == 'ord').order_by(tables.Action.time).all())
        self.assertActionsChangedFromTo(lb4567_ord, expected_order_statuses)

        lb1234_dfw = (sess.query(
            tables.Action).filter(tables.Action.lid == 1234).filter(
                tables.Action.dc == 'dfw').order_by(tables.Action.time).all())
        self.assertActionsChangedFromTo(lb1234_dfw, expected_order_statuses)

        lb4567_dfw = (sess.query(
            tables.Action).filter(tables.Action.lid == 4567).filter(
                tables.Action.dc == 'dfw').order_by(tables.Action.time).all())
        self.assertActionsChangedFromTo(lb4567_dfw, expected_order_statuses)
Ejemplo n.º 5
0
 def test_delete_my_account(self):
     ta = terminator_app.TerminatorApp()
     self.assertTrue(ta.delete_aid(354934))
     nop()
Ejemplo n.º 6
0
 def test_unsuspend_my_account(self):
     ta = terminator_app.TerminatorApp()
     self.assertTrue(ta.unsuspend_aid(354934))
     nop()
Ejemplo n.º 7
0
 def test_scan_clb_dbs(self):
     ta = terminator_app.TerminatorApp()
     lbs = ta.get_all_lbs(354934)
     nop()