Merge remote-tracking branch 'upstream/master' into stopbug
This commit is contained in:
commit
6a438d1444
|
@ -72,9 +72,6 @@ src/
|
|||
...
|
||||
web/
|
||||
web.py
|
||||
dep/
|
||||
etcd-multi-nodes.sh
|
||||
etcd-one-node.sh
|
||||
doc/
|
||||
tools/
|
||||
update-basefs.sh
|
||||
|
@ -131,9 +128,10 @@ file system.
|
|||
|
||||
### etcd ###
|
||||
|
||||
For single host environment, start **dep/etcd-one-node.sh** . Some recent
|
||||
For single host environment, start **tools/etcd-one-node.sh** . Some recent
|
||||
Ubuntu releases have included **etcd** in the repository, just `apt-get
|
||||
install etcd`, and it need not to start etcd manually.
|
||||
install etcd`, and it need not to start etcd manually. For others, you
|
||||
should install etcd manually.
|
||||
|
||||
For multi hosts distributed environment, start
|
||||
**dep/etcd-multi-nodes.sh** in each etcd server hosts. This scripts
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
# Docklet Development Guide on GitHub
|
||||
This document is intended for GitHubers to contribute for Docklet System.
|
||||
|
||||
## Introduction of Docklet Development Workflow
|
||||
We use fork and pull request workflow to push forward Docklet Project.
|
||||
|
||||
![Docklet Workflow](images/workflow.png)
|
||||
|
||||
## Step by Step
|
||||
### Prepare
|
||||
Before work, we need to prepare our working repository. These actions should be executed just once.
|
||||
##### Step 1 : fork
|
||||
Open https://github.com/unias/docklet in your browser and click **Fork** button on the top-right corner.
|
||||
##### Step 2 : clone & config
|
||||
* clone docklet from your github repository
|
||||
```
|
||||
git clone https://github.com/YourName/docklet.git
|
||||
```
|
||||
* config your local repository
|
||||
```
|
||||
# add unias/docklet as your upstream
|
||||
git remote add upstream https://github.com/unias/docklet.git
|
||||
# set push to upstream not work
|
||||
git remote set-url --push upstream no_push
|
||||
```
|
||||
|
||||
### Work
|
||||
This part is about the steps of making contributions to Docklet by pull request.
|
||||
#### Work : Begin
|
||||
##### Step 3 : fetch
|
||||
Fetch the latest code from **upstream(unias/docklet)**
|
||||
```
|
||||
git fetch upstream
|
||||
```
|
||||
##### Step 4 : branch
|
||||
Create new branch for your work
|
||||
```
|
||||
git checkout -b BranchName upstream/master
|
||||
```
|
||||
This is not the step you must do and you can work on local master branch. But we recommend you follow these steps. Using branch to develop new features fits git.
|
||||
#### Work : Work
|
||||
Now you can focus on your work by **commit** and **push**.
|
||||
##### Step 5 : commit & commit
|
||||
Commit is commit. Nothing to say.
|
||||
##### Step 6 : push & push
|
||||
Push your work to **your own Github repository** by **BranchName**
|
||||
```
|
||||
git push origin BranchName
|
||||
```
|
||||
#### Work : End
|
||||
After you complete work of this feature, you maybe want to create a pull request to unias/docklet. Please follow steps below.
|
||||
##### Step 7 : fetch
|
||||
Fetch the latest code from **unias/docklet**
|
||||
```
|
||||
git fetch upstream
|
||||
```
|
||||
##### Step 8 : merge
|
||||
Merge upstream's latest code to your working branch
|
||||
```
|
||||
git merge upstream/master
|
||||
```
|
||||
Please ensure that you are on your working branch.
|
||||
|
||||
If conflict happens, resolve it and commit.
|
||||
##### Step 9 : push
|
||||
Push to your github repository by BranchName.
|
||||
```
|
||||
git push origin BranchName
|
||||
```
|
||||
##### Step 10 : pull request
|
||||
Open https://github.com/YourName/docklet, click **New pull request** and select your working **BranchName** to create the pull request.
|
||||
|
||||
## Tips
|
||||
##### local master
|
||||
After you fetch upstream code, you can move forward your local master branch to upstream/master. And push your github repository master branch to update.
|
||||
```
|
||||
git fetch upstream
|
||||
git checkout master
|
||||
git merge upstream/master
|
||||
git push origin master
|
||||
```
|
||||
##### pretty git log or git log with GUI
|
||||
You can config your git log command with pretty format.
|
||||
```
|
||||
git config --global alias.lg "log --graph --color --pretty=format:' %Cred%h %Creset/ %<(10,trunc)%Cblue%an%Creset | %<(60,trunc)%s | %cr %Cred%d' --remotes --branches"
|
||||
```
|
||||
Now, type **git lg** to see what happens.
|
||||
|
||||
Of course, you can use GUI with git. **gitg** is a good choice. It shows log of git very friendly.
|
||||
##### understand git log
|
||||
git log has much information. You should understand the log info of git. This can help you know how to move forward your work. Especially the reference of branches : upstream/master, HEAD, master, origin/master, other branches.
|
||||
##### graphs/network of github
|
||||
The Graphs/Network of Github is very useful. With this, you can know whether you can create a pull request without conflict. Open https://github.com/unias/docklet/network in your browser and see the network graph of docklet.
|
Binary file not shown.
After Width: | Height: | Size: 168 KiB |
|
@ -37,12 +37,12 @@ apt-get install -y etcd
|
|||
|
||||
# check and install configurable-http-proxy
|
||||
which configurable-http-proxy &>/dev/null || npm install -g configurable-http-proxy
|
||||
which configurable-http-proxy &>/dev/null || { echo "Error : install configurable-http-proxy failed, you should try again" && exit 1; }
|
||||
which configurable-http-proxy &>/dev/null || { echo "Error: install configurable-http-proxy failed, you should try again" && exit 1; }
|
||||
|
||||
[[ -f conf/docklet.conf ]] || { echo "Generating docklet.conf from template" && cp conf/docklet.conf.template conf/docklet.conf; }
|
||||
|
||||
echo ""
|
||||
echo "All preparation installation is done."
|
||||
echo "All preparation installations are done."
|
||||
echo "****************************************"
|
||||
echo "* Please Read Lines Below Before Start *"
|
||||
echo "****************************************"
|
||||
|
@ -51,8 +51,8 @@ echo ""
|
|||
echo "Before staring : you need a basefs image. "
|
||||
echo "basefs images are provided at: "
|
||||
echo " http://docklet.unias.org/download"
|
||||
echo "Please download it to FS_PREFIX/local and then extract it. (defalut FS_PRERIX is /opt/docklet)"
|
||||
echo "Probably you will get a dicectory structure like"
|
||||
echo "please download it to FS_PREFIX/local and then extract it. (defalut FS_PRERIX is /opt/docklet)"
|
||||
echo "you will get a dicectory structure like"
|
||||
echo " /opt/docklet/local/basefs/etc "
|
||||
echo " /opt/docklet/local/basefs/bin "
|
||||
echo " /opt/docklet/local/basefs/..."
|
||||
|
|
|
@ -342,7 +342,8 @@ class DockletHttpHandler(http.server.BaseHTTPRequestHandler):
|
|||
res['mem_use'] = fetcher.get_mem_use(cmds[2])
|
||||
elif cmds[3] == 'basic_info':
|
||||
res['basic_info'] = fetcher.get_basic_info(cmds[2])
|
||||
self.response(200, {'success':'true', 'monitor':res})
|
||||
user_info = G_usermgr.selfQuery(cur_user = cur_user)
|
||||
self.response(200, {'success':'true', 'monitor':res, 'groupinfo':user_info['data']['groupinfo']})
|
||||
elif cmds[1] == 'user':
|
||||
if not user == 'root':
|
||||
self.response(400, {'success':'false', 'message':'Root Required'})
|
||||
|
|
|
@ -7,9 +7,9 @@ function processMemData(data)
|
|||
mem_usedp = data.monitor.mem_use.usedp;
|
||||
var usedp = data.monitor.mem_use.usedp;
|
||||
var unit = data.monitor.mem_use.unit;
|
||||
var quota = data.monitor.mem_use.quota;
|
||||
var quota = data.groupinfo.memory;
|
||||
var val = data.monitor.mem_use.val;
|
||||
var out = "("+val+unit+"/"+quota+unit+")";
|
||||
var out = "("+val+unit+"/"+quota+"MB)";
|
||||
$("#con_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
|
||||
}
|
||||
function getMemY()
|
||||
|
@ -21,7 +21,10 @@ function processCpuData(data)
|
|||
cpu_usedp = data.monitor.cpu_use.usedp;
|
||||
var val = data.monitor.cpu_use.val;
|
||||
var unit = data.monitor.cpu_use.unit;
|
||||
var quota = data.groupinfo.cpu;
|
||||
quota = quota/1000.0;
|
||||
$("#con_cpu").html(val +" "+ unit);
|
||||
$("#con_cpuquota").html(quota.toFixed(2)+"% Cores");
|
||||
}
|
||||
function getCpuY()
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<!-- Menu Body -->
|
||||
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<li class="user-footer" style="background-color:#e6e6e6">
|
||||
<div class="pull-left">
|
||||
<a href="/user/info/" class="btn btn-default btn-flat">Profile</a>
|
||||
</div>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
Facebook</a>
|
||||
<a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign in using
|
||||
Google+</a-->
|
||||
{{ link }}
|
||||
<a href="{{ url }}">{{ link }}</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -34,13 +34,14 @@
|
|||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Node ID</th>
|
||||
<th>Node Name</th>
|
||||
<th>Node ID</th>
|
||||
<th>Node Name</th>
|
||||
<th>IP Address</th>
|
||||
<th>Status</th>
|
||||
<th>Cpu used</th>
|
||||
<th>Mem used</th>
|
||||
<th>Summary</th>
|
||||
<th>Cpu used</th>
|
||||
<th>Cpu quota</th>
|
||||
<th>Mem used</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -56,6 +57,7 @@
|
|||
<td><div id='{{cluster}}_{{ loop.index }}_state' class="label label-primary">Running</div></td>
|
||||
{% endif %}
|
||||
<td id='{{cluster}}_{{ loop.index }}_cpu'>--</td>
|
||||
<td id='{{cluster}}_{{ loop.index }}_cpuquota'>--</td>
|
||||
<td id='{{cluster}}_{{ loop.index }}_mem'>--</td>
|
||||
|
||||
<td><a class="btn btn-info btn-xs" href='/vclusters/{{ cluster }}/{{ container['containername'] }}/'>Realtime</a></td>
|
||||
|
@ -97,21 +99,25 @@
|
|||
$("#"+index+"_pid").html('--');
|
||||
$("#"+index+"_ip").html('--');
|
||||
$("#"+index+"_cpu").html('--');
|
||||
$("#"+index+"_cpuquota").html('--');
|
||||
$("#"+index+"_mem").html('--');
|
||||
return;
|
||||
}
|
||||
|
||||
$.post(url+"/cpu_use",{},function(data){
|
||||
var usedp = data.monitor.cpu_use.usedp;
|
||||
var quota = data.groupinfo.cpu;
|
||||
quota = quota/100000.0;
|
||||
$("#"+index+"_cpu").html((usedp/0.01).toFixed(2)+"%");
|
||||
$("#"+index+"_cpuquota").html((quota*100).toFixed(2)+"% Cores");
|
||||
},"json");
|
||||
|
||||
$.post(url+"/mem_use",{},function(data){
|
||||
var usedp = data.monitor.mem_use.usedp;
|
||||
var unit = data.monitor.mem_use.unit;
|
||||
var quota = data.monitor.mem_use.quota;
|
||||
var quota = data.groupinfo.memory;
|
||||
var val = data.monitor.mem_use.val;
|
||||
var out = "("+val+unit+"/"+quota+unit+")";
|
||||
var out = "("+val+unit+"/"+quota+"MB)";
|
||||
$("#"+index+"_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
|
||||
},"json");
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<th>State</th>
|
||||
<th>IP Address</th>
|
||||
<th>CPU Use</th>
|
||||
<th>CPU Quota</th>
|
||||
<th>Mem Use</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -57,6 +58,7 @@
|
|||
<td id='con_ip'>{{ container['IP'] }}</td>
|
||||
{% endif %}
|
||||
<td id='con_cpu'>--</td>
|
||||
<td id='con_cpuquota'>--</td>
|
||||
<td id='con_mem'>--</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from webViews.view import normalView
|
||||
from webViews.authenticate.auth import is_authenticated
|
||||
from webViews.dockletrequest import dockletRequest
|
||||
from flask import redirect, request, render_template, session, make_response
|
||||
from flask import redirect, request, render_template, session, make_response, abort
|
||||
from webViews import cookie_tool
|
||||
|
||||
import hashlib
|
||||
|
@ -20,16 +20,18 @@ if (env.getenv('EXTERNAL_LOGIN') == 'True'):
|
|||
import external_generate
|
||||
|
||||
def refreshInfo():
|
||||
'''not used now'''
|
||||
result = dockletRequest.post('/login/', data)
|
||||
data = {}
|
||||
result = dockletRequest.post('/user/selfQuery/', data)
|
||||
ok = result and result.get('success', None)
|
||||
session['username'] = request.form['username']
|
||||
session['nickname'] = result['data']['nickname']
|
||||
session['description'] = result['data']['description'][0:10]
|
||||
session['avatar'] = '/static/avatar/'+ result['data']['avatar']
|
||||
session['usergroup'] = result['data']['group']
|
||||
session['status'] = result['data']['status']
|
||||
session['token'] = result['data']['token']
|
||||
if (ok and ok == "true"):
|
||||
session['username'] = result['data']['username']
|
||||
session['nickname'] = result['data']['nickname']
|
||||
session['description'] = result['data']['description']
|
||||
session['avatar'] = '/static/avatar/'+ result['data']['avatar']
|
||||
session['usergroup'] = result['data']['group']
|
||||
session['status'] = result['data']['status']
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
class loginView(normalView):
|
||||
template_path = "login.html"
|
||||
|
@ -37,13 +39,15 @@ class loginView(normalView):
|
|||
@classmethod
|
||||
def get(self):
|
||||
if is_authenticated():
|
||||
#refreshInfo()
|
||||
refreshInfo()
|
||||
return redirect(request.args.get('next',None) or '/dashboard/')
|
||||
if (env.getenv('EXTERNAL_LOGIN') == 'True'):
|
||||
url = external_generate.external_login_url
|
||||
link = external_generate.external_login_link
|
||||
else:
|
||||
link = ''
|
||||
return render_template(self.template_path, link = link)
|
||||
url = ''
|
||||
return render_template(self.template_path, link = link, url = url)
|
||||
|
||||
@classmethod
|
||||
def post(self):
|
||||
|
|
|
@ -26,7 +26,8 @@ class dockletRequest():
|
|||
@classmethod
|
||||
def unauthorizedpost(self, url = '/', data = None):
|
||||
data = dict(data)
|
||||
logger.info("Docklet Unauthorized Request: data = %s, url = %s" % (data, url))
|
||||
data_log = {'user': data['user']}
|
||||
logger.info("Docklet Unauthorized Request: data = %s, url = %s" % (data_log, url))
|
||||
result = requests.post(endpoint + url, data = data).json()
|
||||
logger.info("Docklet Unauthorized Response: result = %s, url = %s"%(result, url))
|
||||
return result
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from flask import redirect, request
|
||||
from webViews.dockletrequest import dockletRequest
|
||||
from webViews.authenticate import login
|
||||
from webViews.view import normalView
|
||||
import json
|
||||
|
||||
|
@ -15,4 +16,5 @@ class userinfoView(normalView):
|
|||
@classmethod
|
||||
def post(self):
|
||||
result = json.dumps(dockletRequest.post('/user/selfModify/', request.form))
|
||||
login.refreshInfo()
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue