コード例 #1
0
ファイル: ticket.py プロジェクト: annttu/Renki
def create_ticket(user_data_table):
    logger.info("Creating ticket for renkiSrv instances")
    service_group_id = user_data_table.get_service_group_id()

    ticket_group = TicketGroupDatabase()
    ticket_group.save()
    dbconn.session.flush()

    user_data_table.ticket_group_id = ticket_group.id
    user_data_table.real_save()
    dbconn.session.flush()
    
    new_data = str(user_data_table.as_dict())

    History = user_data_table.__history_mapper__.class_

    try:
        History.query().filter(History.id == user_data_table.id).one()
        old_data = "old"
    except:
        old_data = "new"

    # Find all the servers that the ticket needs to be sent to
    sg = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.id == service_group_id).one()
    services = ServiceDatabase.query().filter(ServiceDatabase.service_group_id == sg.id).all()
    for s in services:
        ticket = TicketDatabase()
        ticket.old_data = old_data
        ticket.new_data = new_data
        ticket.ticket_group_id = ticket_group.id
        ticket.save()
コード例 #2
0
ファイル: ticket.py プロジェクト: annttu/Renki
def create_delete_ticket(user_data_table):
    service_group_id = user_data_table.get_service_group_id()

    ticket_group = TicketGroupDatabase()
    ticket_group.save()
    dbconn.session.flush()

    # Find all the servers that the ticket needs to be sent to
    sg = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.id == service_group_id).one()
    services = ServiceDatabase.query().filter(ServiceDatabase.service_group_id == sg.id).all()
    for s in services:
        ticket = TicketDatabase()
        ticket.old_data = str(user_data_table.as_dict())
        ticket.new_data = "deleted"
        ticket.ticket_group_id = ticket_group.id
        ticket.save()
コード例 #3
0
ファイル: ticket.py プロジェクト: pombredanne/Renki
def create_ticket(user_data_table):
    logger.info("Creating ticket for renkiSrv instances")
    service_group_id = user_data_table.get_service_group_id()

    ticket_group = TicketGroupDatabase()
    ticket_group.save()
    dbconn.session.flush()

    user_data_table.ticket_group_id = ticket_group.id
    user_data_table.real_save()
    dbconn.session.flush()
    
    new_data = str(user_data_table.as_dict())

    History = user_data_table.__history_mapper__.class_

    try:
        History.query().filter(History.id == user_data_table.id).one()
        old_data = "old"
    except:
        old_data = "new"

    # Find all the servers that the ticket needs to be sent to
    sg = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.id == service_group_id).one()
    services = ServiceDatabase.query().filter(ServiceDatabase.service_group_id == sg.id).all()
    for s in services:
        ticket = TicketDatabase()
        ticket.old_data = old_data
        ticket.new_data = new_data
        ticket.ticket_group_id = ticket_group.id
        ticket.save()

        if s.server.name in sock.sock.connections:
            logger.info("Sending ticket to server %s" % s.server.name)
            packet = {'type': MsgTypes.TICKET, 'ticket': ticket.as_dict()}
            sock.sock.connections[s.server.name].send(packet)
        else:
            logger.warning("Not sending ticket to server %s because it's not connected!")
コード例 #4
0
ファイル: ticket.py プロジェクト: pombredanne/Renki
def create_delete_ticket(user_data_table):
    service_group_id = user_data_table.get_service_group_id()

    ticket_group = TicketGroupDatabase()
    ticket_group.save()
    dbconn.session.flush()

    # Find all the servers that the ticket needs to be sent to
    sg = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.id == service_group_id).one()
    services = ServiceDatabase.query().filter(ServiceDatabase.service_group_id == sg.id).all()
    for s in services:
        ticket = TicketDatabase()
        ticket.old_data = str(user_data_table.as_dict())
        ticket.new_data = "deleted"
        ticket.ticket_group_id = ticket_group.id
        ticket.save()

        if s.server.name in sock.sock.connections:
            logger.info("Sending ticket to server %s" % s.server.name)
            packet = {'type': MsgTypes.TICKET, 'ticket': ticket.as_dict()}
            sock.sock.connections[s.server.name].send(packet)
        else:
            logger.warning("Not sending ticket to server %s because it's not connected!")
コード例 #5
0
ファイル: admin.py プロジェクト: annttu/Renki
def setup_development_servers():
    """
    Add lakka and hilla servers and create couple services and service groups
    """
    if not ServerDatabase.query().filter(ServerDatabase.name == 'Hilla').all():
        hilla = ServerDatabase()
        hilla.name = 'Hilla'
        hilla.save()
    else:
        hilla = ServerDatabase.query().filter(ServerDatabase.name == 'Hilla').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'Lakka').all():
        lakka = ServerDatabase()
        lakka.name = 'Lakka'
        lakka.save()
    else:
        lakka = ServerDatabase.query().filter(ServerDatabase.name == 'Lakka').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'db1').all():
        db1 = ServerDatabase()
        db1.name = 'db1'
        db1.save()
    else:
        db1 = ServerDatabase.query().filter(ServerDatabase.name == 'db1').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'db2').all():
        db2 = ServerDatabase()
        db2.name = 'db2'
        db2.save()
    else:
        db2 = ServerDatabase.query().filter(ServerDatabase.name == 'db2').one()

    if not ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Hilla_ports').all():
        hilla_ports = ServiceGroupDatabase()
        hilla_ports.name = 'Hilla_ports'
        hilla_ports.type = 'port'
        hilla_ports.save()
    else:
        hilla_ports = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Hilla_ports').one()

    if not ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Lakka_ports').all():
        lakka_ports = ServiceGroupDatabase()
        lakka_ports.name = 'Lakka_ports'
        lakka_ports.type = 'port'
        lakka_ports.save()
    else:
        lakka_ports = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Lakka_ports').one()

    if not ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Mysql_databases').all():
        mysql_databases = ServiceGroupDatabase()
        mysql_databases.name = 'Mysql_databases'
        mysql_databases.type = 'mysql_database'
        mysql_databases.save()
    else:
        mysql_databases = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Mysql_databases').one()

    if not ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Psql_databases').all():
        psql_databases = ServiceGroupDatabase()
        psql_databases.name = 'Psql_databases'
        psql_databases.type = 'Psql_database'
        psql_databases.save()
    else:
        psql_databases = ServiceGroupDatabase.query().filter(ServiceGroupDatabase.name == 'Psql_databases').one()

    dbsession.flush()

    if not ServiceDatabase.query().filter(ServiceDatabase.name == 'Mysql_database').all():
        mysql_database = ServiceDatabase()
        mysql_database.name = 'Mysql_Database'
        mysql_database.service_group = mysql_databases
        mysql_database.server = hilla
        mysql_database.save()
    else:
        mysql_database = ServiceDatabase.query().filter(ServiceDatabase.name == 'Mysql_database').one()

    if not ServiceDatabase.query().filter(ServiceDatabase.name == 'Psql_database').all():
        psql_database = ServiceDatabase()
        psql_database.name = 'Psql_database'
        psql_database.service_group = psql_databases
        psql_database.server = hilla
        psql_database.save()
    else:
        psql_database = ServiceDatabase.query().filter(ServiceDatabase.name == 'Psql_database').one()

    if not ServiceDatabase.query().filter(ServiceDatabase.name == 'Hilla_port').all():
        hilla_port = ServiceDatabase()
        hilla_port.name = 'Hilla_port'
        hilla_port.service_group = hilla_ports
        hilla_port.server = hilla
        hilla_port.save()
    else:
        hilla_port = ServiceDatabase.query().filter(ServiceDatabase.name == 'Hilla_port').one()

    if not ServiceDatabase.query().filter(ServiceDatabase.name == 'Lakka_port').all():
        lakka_port = ServiceDatabase()
        lakka_port.name = 'Lakka_port'
        lakka_port.service_group = lakka_ports
        lakka_port.server = hilla
        lakka_port.save()
    else:
        lakka_port = ServiceDatabase.query().filter(ServiceDatabase.name == 'Lakka_port').one()
    dbsession.commit()
コード例 #6
0
def setup_development_servers():
    """
    Add lakka and hilla servers and create couple services and service groups
    """
    if not ServerDatabase.query().filter(ServerDatabase.name == 'Hilla').all():
        hilla = ServerDatabase()
        hilla.name = 'Hilla'
        hilla.save()
    else:
        hilla = ServerDatabase.query().filter(
            ServerDatabase.name == 'Hilla').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'Lakka').all():
        lakka = ServerDatabase()
        lakka.name = 'Lakka'
        lakka.save()
    else:
        lakka = ServerDatabase.query().filter(
            ServerDatabase.name == 'Lakka').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'db1').all():
        db1 = ServerDatabase()
        db1.name = 'db1'
        db1.save()
    else:
        db1 = ServerDatabase.query().filter(ServerDatabase.name == 'db1').one()

    if not ServerDatabase.query().filter(ServerDatabase.name == 'db2').all():
        db2 = ServerDatabase()
        db2.name = 'db2'
        db2.save()
    else:
        db2 = ServerDatabase.query().filter(ServerDatabase.name == 'db2').one()

    if not ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Hilla_ports').all():
        hilla_ports = ServiceGroupDatabase()
        hilla_ports.name = 'Hilla_ports'
        hilla_ports.type = 'port'
        hilla_ports.save()
    else:
        hilla_ports = ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Hilla_ports').one()

    if not ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Lakka_ports').all():
        lakka_ports = ServiceGroupDatabase()
        lakka_ports.name = 'Lakka_ports'
        lakka_ports.type = 'port'
        lakka_ports.save()
    else:
        lakka_ports = ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Lakka_ports').one()

    if not ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Mysql_databases').all():
        mysql_databases = ServiceGroupDatabase()
        mysql_databases.name = 'Mysql_databases'
        mysql_databases.type = 'mysql_database'
        mysql_databases.save()
    else:
        mysql_databases = ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Mysql_databases').one()

    if not ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Psql_databases').all():
        psql_databases = ServiceGroupDatabase()
        psql_databases.name = 'Psql_databases'
        psql_databases.type = 'Psql_database'
        psql_databases.save()
    else:
        psql_databases = ServiceGroupDatabase.query().filter(
            ServiceGroupDatabase.name == 'Psql_databases').one()

    dbsession.flush()

    if not ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Mysql_database').all():
        mysql_database = ServiceDatabase()
        mysql_database.name = 'Mysql_Database'
        mysql_database.service_group = mysql_databases
        mysql_database.server = hilla
        mysql_database.save()
    else:
        mysql_database = ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Mysql_database').one()

    if not ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Psql_database').all():
        psql_database = ServiceDatabase()
        psql_database.name = 'Psql_database'
        psql_database.service_group = psql_databases
        psql_database.server = hilla
        psql_database.save()
    else:
        psql_database = ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Psql_database').one()

    if not ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Hilla_port').all():
        hilla_port = ServiceDatabase()
        hilla_port.name = 'Hilla_port'
        hilla_port.service_group = hilla_ports
        hilla_port.server = hilla
        hilla_port.save()
    else:
        hilla_port = ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Hilla_port').one()

    if not ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Lakka_port').all():
        lakka_port = ServiceDatabase()
        lakka_port.name = 'Lakka_port'
        lakka_port.service_group = lakka_ports
        lakka_port.server = hilla
        lakka_port.save()
    else:
        lakka_port = ServiceDatabase.query().filter(
            ServiceDatabase.name == 'Lakka_port').one()
    dbsession.commit()