diff --git a/rbmd/__init__.py b/rbmd/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/rbmd/conf.json b/rbmd/conf.json new file mode 100644 index 0000000..09026a0 --- /dev/null +++ b/rbmd/conf.json @@ -0,0 +1,7 @@ +{ + +"mount":"http://127.0.0.1:9076/mount", +"api": "http://127.0.0.1:9076/v1/", +"ws": "ws://php.difrex.ru/ws" + +} diff --git a/rbmd/settings.py b/rbmd/settings.py new file mode 100644 index 0000000..45f797b --- /dev/null +++ b/rbmd/settings.py @@ -0,0 +1,125 @@ +""" +Django settings for rbmd project. + +Generated by 'django-admin startproject' using Django 1.9.7. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.9/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'mpcqsg+e*wiw%^-x%1kv%pq-fi3@9hrp)n@+iz&q8&=)m3v_$z' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'rbmd.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'rbmd.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + +STATIC_URL = '/static/' +#PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) +#STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "rbmd/static"), ] diff --git a/rbmd/static/images-logo.png b/rbmd/static/images-logo.png new file mode 100644 index 0000000..9ab8646 Binary files /dev/null and b/rbmd/static/images-logo.png differ diff --git a/rbmd/static/script.js b/rbmd/static/script.js new file mode 100644 index 0000000..bc9e08c --- /dev/null +++ b/rbmd/static/script.js @@ -0,0 +1,147 @@ +$(function() { + $('#mountFormTrigger').click(function(event){ + $.ajax({ + url:"get_status.php", + success:function(data){ + var status = JSON.parse(data); + var htmlSelect = ''; +for (n in status["quorum"]) { htmlSelect += "";} + + $('#selectNode').html(htmlSelect); + console.log(htmlSelect);} + }) + }) + +}); + + + $('#mountFormTrigger').click(function(event){ + $.ajax({ + url:"get_status.php", + success:function(data){ + var status = JSON.parse(data); + var htmlSelect = ''; + for (n in status["quorum"]) { htmlSelect += "";} + $('#selectNode').html(htmlSelect); + console.log(htmlSelect);} + }) + }) + + +$(function() { + console.log( "ready!" ); +}); + + function resolve() { + $.ajax({ + url:"resolve.php", + data:{"node":deadNode}, + success:function(data){$('#details').css("display", "none");} + }) + } + + function unmount(a, b, c) { + var u = confirm(a + ": confirm unmount of " + b); + if (u == true) { + $.ajax({ + url:"unmount.php", + data:{"node":a, "mountpoint":b, "block":c}, + success:function(data){ + var res = JSON.parse(data); + message = "
"+ res["message"] +"
"; + $("#rspContainer").css("display", "block"); + $("#rsp").html(message) + if (res["state"] == 'OK'){$("#rspContainer").css("background-color", "#4CAF50" );} + else {$("#rspContainer").css("background-color", "#f44336" )} + } + }) + } + } + + function displayData(a){ + $("#status").html(""+a.health+"
"); + if (a.health == 'deadly.') { + $('#showDeadlyDetails').css("display","block"); + $('#resolve').css("display","block"); + $("#mountFormTrigger").addClass("w3-disabled") + } else { + $('#showDeadlyDetails').css("display","none"); + $('#resolve').css("display","none"); + $("#mountFormTrigger").removeClass("w3-disabled") + $('#details').css("border", "0"); + } + $("#leader").text(a.leader); + $( "#statusContainer:contains('alive')" ).css("background-color", "#4CAF50" ); + $( "#statusContainer:contains('resizing')" ).css("background-color", "#ff9800" ); + $( "#statusContainer:contains('deadly')" ).css("background-color", "#f44336" );; + var node2 = {"quorum":[]}; + for (var node in a.quorum){ + node2.quorum.push(node) + }; + w3DisplayData("id01", node2); + $('.tablink').css('display', 'block'); + if (n != undefined && n != 'dead'){ + var t = new Date(a.quorum[n]["updated"] * 1000) + var up_formatted = t.getFullYear() + "/" + + (t.getMonth() + 1) + "/" + + t.getDate() + " " + + t.getHours() + ":" + + t.getMinutes() + ":" + + t.getSeconds(); + $("#name").html(n); + $("#ipv4").html(a.quorum[n]["ip"]["v4"].join("