Exemple #1
0
def infoApp(brand, app):
    try :
        app = App.get(App.brand == brand, App.name == app)
        servers = Server.raw(
          '''select * from t_server where id in ({0})'''.format(app.getConfig("SERVERS"))
        )    

        deploy = appmodule.createAppDeploy(app, [s for s in servers])
        if deploy:
            app_status = deploy.getAppStatus()
            if len(app_status.keys()) > 0:
                return app_status
            else:
                return None
        else:
            raise Exception("None Object appdeploy")
    except Exception as e:
        logging.debug(e)
        raise Exception("infoApp: " + str(e))
Exemple #2
0
def deployApp(brand, app, master_rev, config_rev):
    try :
        app_instance = App.get(App.brand == brand, App.name == app)
        app_instance.master_rev = master_rev
        app_instance.config_rev = config_rev
        servers = Server.raw(
          '''select * from t_server where id in ({0})'''.format(app_instance.getConfig("SERVERS"))
        )    
        #     if prd:
        #         profile = DBHelper().getProfile("prd")
        #     else:
        #         profile = DBHelper().getProfile("dev")

        deploy_instance = appmodule.createAppDeploy(app_instance, [s for s in servers])
        if deploy_instance:
            deploy_instance.deploy()
            deploy_instance.saveHistory()
            return None
        else:
            raise Exception("None Object AppDeploy")
    except Exception as e:
        logging.debug(e)
        raise Exception("app deploy fail:" + str(e))
Exemple #3
0
def checkServers(brand, app):
    try :
        app = App.get(App.brand == brand, App.name == app)
        servers = Server.raw(
          '''select * from t_server where id in ({0})'''.format(app.getConfig("SERVERS"))
        ) 
        
        check_list = []
        for server in servers:
            th = utils.CheckThread(server.host, server.port)
            check_list.append(th)
            th.start()
        for th in check_list:
            th.join()
        time.sleep(2)
        flag = True
        for th in check_list:
            flag = flag and th.retcode
        return flag         
    except Exception as e:
        logging.debug(e)
        logging.debug("server not exist, check server fails:" + str(e))
        return False