This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
from functools import wraps | |
except ImportError: | |
from django.utls.functional import wraps | |
from django.conf import settings | |
from django.contrib.auth import REDIRECT_FIELD_NAME | |
from django.http import HttpResponseForbidden, HttpResponseRedirect | |
from django.template import loader, RequestContext, TemplateDoesNotExist | |
from django.utils.decorators import available_attrs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/users/<username>', methods = ['GET', 'POST', 'PATCH', 'DELETE']) | |
@requires_auth | |
def api_user(username): | |
current_user = User.get(request.authorization.username) | |
app.logger.debug("req.auth.username = %s", request.authorization.username) | |
# Only "SELF" can access/modify user info | |
if current_user.username != username: | |
return unauthorized() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callback: function(opts, event) { | |
if (opts.primary) { | |
function getAddHostTag(cb) { | |
console.log(cb); | |
cb('before ajax'); | |
return $.ajax({ | |
url: "/api/addhosttag/", | |
dataType: 'json', | |
data: {hostid: m.id, tagname: tagname}, | |
type: "POST", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_config_reload_or_del(del_func): | |
def wrap(add_func): | |
def wrapped_f(*args, **kwargs): | |
# check config before add config file | |
if check_nagios_config(): | |
if add_func(*args, **kwargs): | |
# check config after add config file | |
if check_nagios_config(): | |
if reload_nagios(): | |
return (True, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from dbase import db_session | |
from gametype import GameType | |
from game import Game | |
from app import App | |
from apphostmap import AppHostMap | |
from host import Host | |
from user import User | |
from currency import Currency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- # | |
import SoftLayer.API | |
from models.host import Host | |
from models.dbase import db_session as session | |
api_username = 'XXXXX_NAME' | |
api_key = 'XXXXXXX_KEY' | |
client = SoftLayer.API.Client('SoftLayer_Account', None, api_username, api_key) | |
hs = client.getHardware() | |
server_ids = [h['id'] for h in hs] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplejson as json | |
from flask_application.models.nagcmd import NagCMD | |
from flask_application.models.dbase import db_session | |
from flask_application.models.host import Host | |
from flask_application.models.app import App | |
from flask_application.models.hostmonitem import HostMonItem | |
with open('nagiosconfig_orig', 'r') as f: | |
fc = json.load(f) | |
ef = open('host_err.txt', 'w') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask_application.elexlib.nagconf import NagConf | |
from flask_application.models.dbase import db_session | |
from flask_application.models.hostmonitem import HostMonItem | |
import time | |
nc = NagConf() | |
hms = db_session.query(HostMonItem).all() | |
for hm in hms: | |
time.sleep(0.2) | |
print 'sleeping' | |
added, msg = nc.add_service( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplejson as json | |
import MySQLdb | |
from MySQLdb.cursors import DictCursor | |
import sqlalchemy.pool as pool | |
qServiceItem = ['id', 'config_name', 'service_description', 'check_command', 'max_check_attempts', 'check_interval', 'retry_interval'] | |
def get_conn(): | |
c = MySQLdb.connect("localhost", "nagiosql", | |
"db@xingcloud", "XXXXXX", |
OlderNewer