def index(req): initial = {} initial['odb_type'] = sqlalchemy_django_engine[DATABASE_ENGINE.replace('django.db.backends.', '')] initial['odb_host'] = DATABASE_HOST initial['odb_port'] = DATABASE_PORT initial['odb_user'] = DATABASE_USER initial['odb_db_name'] = DATABASE_NAME delete_form = DeleteClusterForm(prefix='delete') items = req.zato.odb.query(Cluster).order_by('name').all() for item in items: client = get_lb_client(item) try: lb_config = client.get_config() item.lb_config = lb_config # Assign the flags indicating whether servers are DOWN or in the MAINT mode. set_servers_state(item, client) except Exception, e: msg = 'Could not invoke agent, client:[{client!r}], e:[{e}]'.format(client=client, e=format_exc(e)) logger.error(msg) item.lb_config = None
def get_servers_state(req, cluster_id): cluster = req.zato.odb.query(Cluster).filter_by(id=cluster_id).one() client = get_lb_client(cluster) # Assign the flags indicating whether servers are DOWN or in the MAINT mode. try: set_servers_state(cluster, client) except Exception, e: msg = "Failed to invoke the load-balancer's agent and set the state of servers, e:[{e}]".format(e=format_exc(e)) logger.error(msg) return HttpResponseServerError(msg)