示例#1
0
def initialize_app(app, home_endpoint=None):
    models.connect()

    @app.before_request
    def _db_connect():
        models.database.connect()

    @app.teardown_request
    def _db_close(exc):
        if not models.database.is_closed():
            models.database.commit()
            models.database.close()

    admin = Admin(app, name='Raw Table Admin', template_mode='bootstrap3')

    if home_endpoint:
        admin.add_link(
            MenuLink("Devtest Main", url="/", endpoint=home_endpoint))

    admin.add_views(TestBedView(), EquipmentModelView(), EquipmentView(),
                    NetworksView(), InterfacesView(), ConnectionView(),
                    AccountIdsView(), TestequipmentView())
    admin.add_views(SoftwareView(), SoftwareVariantView(), FunctionView())
    admin.add_views(ScenarioView(), TestSuiteView(), TestCaseView(),
                    TestResultsView())
    admin.add_view(RadarComponentView())
示例#2
0
def pick_testbed():
    from devtest.ui import simpleui
    from devtest.db import models
    models.connect()
    tblist = models.TestBed.get_list()
    return simpleui.choose(tblist,
                           defidx=tblist.index("default"),
                           prompt="Choose testbed")
示例#3
0
def list_testbeds(verbose):
    from devtest.db import models
    models.connect()
    print("Available testbeds:")
    if verbose:
        for tb in models.TestBed.select():
            print(" ", colors.green(tb.name))
            for te in tb.testequipment:
                print("   ", te.equipment.name, "role:", te.function.name)
    else:
        for tb in models.TestBed.get_list():
            print(" ", colors.green(tb))
示例#4
0
def get_testbed(name, storageurl=None, debug=False):
    """Entry point for Testbed, container of the device tree.

    Returns:
        TestBedRuntime initialized from the testbed in the database.
    """
    models.connect(storageurl)
    try:
        testbed = models.TestBed.select().where(
            models.TestBed.name == name).get()
    except models.DoesNotExist as err:
        raise ConfigError("Bad TestBed name {!r}: {}".format(name,
                                                             err)) from None
    return TestBedRuntime(testbed, debug=debug)
示例#5
0
 def initialize(self, config=None):
     super().initialize(config=config)
     self._tci = testcases_importer.TestcasesImporter()
     models.connect()
     self._resultstack = []