Skip to content

Commit

Permalink
Merge pull request #327 from baifendian/dev
Browse files Browse the repository at this point in the history
合并dev分支代码到master
  • Loading branch information
qqzxingchen authored Nov 11, 2016
2 parents 88ff01f + 7696bb8 commit da61067
Show file tree
Hide file tree
Showing 113 changed files with 5,907 additions and 4,211 deletions.
35 changes: 17 additions & 18 deletions Aries/Aries/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import yaml

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.join(BASE_DIR,"middleware"))
LOG_BASE_DIR=os.path.join(BASE_DIR.rstrip("Aries"), "log")
FTP_LOCAL_DIR=os.path.join(BASE_DIR.rstrip("Aries"), "download/")

FILE_PATH=os.path.join(BASE_DIR.rstrip("Aries"), "sbin")
file_name='{0}/Aries.yaml'.format(FILE_PATH).replace('\\','/')
yaml_file = open(file_name)
OPENSTACK_KEY_PATH = os.path.join(BASE_DIR,"openstack/middleware/common/key.yaml")
SETTINGS = yaml.load(yaml_file)
print SETTINGS

Expand All @@ -42,9 +44,9 @@
SECRET_KEY = '4q+z5arz(+!__dtzxpn*n7g@3w0s7x)xtr+v!ts9m!-vzp=^)4'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ['*']
APPEND_SLASH=False
# Application definition
INSTALLED_APPS = (
Expand Down Expand Up @@ -73,6 +75,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'middleware.UserSessionMiddleware',
)

ROOT_URLCONF = 'Aries.urls'
Expand Down Expand Up @@ -281,30 +284,21 @@
WEBHDFS_TIMEOUT = WEBHDFS_SETTINGS["TIMEOUT"]
WEBHDFS_MAX_TRIES = WEBHDFS_SETTINGS["MAX_TRIES"]
WEBHDFS_RETRY_DELAY = WEBHDFS_SETTINGS["RETRY_DELAY"]
# HADOOP_RUN_SCRIPT = os.path.join(BASE_DIR, os.path.pardir, 'sbin/hadoop-run.sh')

CLIENTHDFS_SETTINGS = SETTINGS["CLIENTHDFS"]
HADOOP_HOME = CLIENTHDFS_SETTINGS["HADOOP_HOME"]
NAMENODE_PATH = CLIENTHDFS_SETTINGS["NAMENODE_PATH"]

HADOOP_RUN_SCRIPT = "hadoop-run.sh"
SESSION_COOKIE_AGE=60*30
#kubectl_file
KUBECTL_OSX = os.path.join(BASE_DIR, '../package', 'kubectl_osx_1_2_4')
KUBECTL_LINUX = os.path.join(BASE_DIR, '../package', 'kubectl_linux_1_2_4')

#codis设置
CODIS_LOCAL_DIR = os.path.join(BASE_DIR, "codis/redisconf/")
CODIS_COMMOND_DIR = os.path.join(BASE_DIR, "codis/commandlog/")
CODIS_DATADIR = os.path.join(BASE_DIR, "codis/serverconf/data/")
CODIS_LOGFILE_DIR = os.path.join(BASE_DIR, "codis/serverconf/log/")
CODIS_PIDFILE_DIR = os.path.join(BASE_DIR, "codis/serverconf/pid/")
CODIS_SHOME = os.path.join(BASE_DIR, "codis/")

CODIS_SETTINGS = SETTINGS["CODIS"]
CODIS_INDEX_LINE = CODIS_SETTINGS["INDEX_LINE"]
CODIS_ZK_ADDR = CODIS_SETTINGS["ZK_ADDR"]
#CODIS_HOST_INFO = [0,'172.24.3.64','root','',0,'a',0]
CODIS_HOST_INFO = CODIS_SETTINGS["HOST_INFO"]
CODIS_MEMORY_MAX = CODIS_SETTINGS["MEMORY_MAX"]
OPENTSDB_URL = CODIS_SETTINGS["PENTSDB_URL"]
SSH_PKEY = CODIS_SETTINGS["SSH_PKEY"]
SSH_KNOWN_HOSTS = CODIS_SETTINGS['SSH_KNOWN_HOSTS']
CODIS_REST_URL = CODIS_SETTINGS['CODIS_REST_URL']
OPENTSDB_URL = CODIS_SETTINGS['OPENTSDB_URL']

#openstack设置:
OPENSTACK_SETTINGS = SETTINGS["OPENSTACK"]
Expand All @@ -314,8 +308,13 @@
PORT_NOVA = OPENSTACK_SETTINGS["PORT_NOVA"]
IP_CINDER = OPENSTACK_SETTINGS["IP_CINDER"]
PORT_CINDER = OPENSTACK_SETTINGS["PORT_CINDER"]
MONITOR_URL = OPENSTACK_SETTINGS['MONITOR_URL']

#启动一个线程开始定时统计配额. default: 10m
POLL_TIME = 600
import sumSpace
sumSpace.run(POLL_TIME)

#admin页面白名单IP
WHITELIST_SETTINGS = SETTINGS['WHITELIST']
WHITELIST_IP = WHITELIST_SETTINGS['WHITELIST_IP']
3 changes: 2 additions & 1 deletion Aries/Aries/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
admin.autodiscover()
import views
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
#url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', views.permission_check),
url(r'^v1/user_auth/', include('user_auth.urls')),
url(r'^v1/hdfs/', include('hdfs.urls')),
url(r'^v1/codis/', include('codis.urls')),
Expand Down
23 changes: 23 additions & 0 deletions Aries/Aries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from user_auth.models import *
from ldap_client import ldap_get_vaild
from django.views.decorators.csrf import ensure_csrf_cookie
from django.conf import settings

def is_admin(account,cur_space_in):
is_supper = 0
Expand Down Expand Up @@ -170,3 +171,25 @@ def index(request):
user = ""
user = json.dumps(user)
return render_to_response('index/index.html',locals())

def permission_check(request):
from django.contrib import admin
from django.conf.urls import patterns,url,include
import urls
admin.autodiscover()
if request.META.has_key('HTTP_X_FORWARDED_FOR'):
ip = request.META['HTTP_X_FORWARDED_FOR']
else:
ip = request.META['REMOTE_ADDR']
whitelist = settings.WHITELIST_IP
temp = False
for i in whitelist:
#ac_logger.error('\n\n\n ip is :\n %s \n\n\n'%ip)
#ac_logger.error('\n\n\n whitelist ip is :\n %s \n\n\n'%i)
if ip.startswith(i):
temp = True
break
if temp:
urls.urlpatterns[0] = url(r'^admin/', include(admin.site.urls))
else:
return HttpResponse('<h2>Permission Forbidden!</h2>')
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit da61067

Please sign in to comment.