Commit ed69c295 authored by Alain Takoudjou's avatar Alain Takoudjou

Running Instance should use only the current Software Release

parent 2b16e458
...@@ -30,7 +30,9 @@ def cloneRepo(data): ...@@ -30,7 +30,9 @@ def cloneRepo(data):
repo = Repo.clone_from(data["repo"], workDir) repo = Repo.clone_from(data["repo"], workDir)
config_writer = repo.config_writer() config_writer = repo.config_writer()
config_writer.add_section("user") config_writer.add_section("user")
if data["user"] != "":
config_writer.set_value("user", "name", data["user"]) config_writer.set_value("user", "name", data["user"])
if data["email"] != "":
config_writer.set_value("user", "email", data["email"]) config_writer.set_value("user", "email", data["email"])
code = 1 code = 1
except Exception, e: except Exception, e:
......
#tabContaier{
background: #e4e4e4;
padding:3px;
position:relative;
width:757px;
font-size: 14px;
}
#tabContaier textarea {
width:702px;
}
#tabContaier > ul{
overflow:hidden;
border-right:1px solid #fff;
height:34px;
position:absolute;
z-index:100;
}
#tabContaier > ul > li{
float:left;
list-style:none;
}
#tabContaier > ul > li a{
background:#ddd;
border:1px solid #fcfcfc;
border-right:0;
border-bottom: 0;
color:#666;
cursor:pointer;
display:block;
height:34px;
line-height:34px;
padding:0 30px;
text-decoration:none;
color: #737373;
text-shadow: 0px 1px #FFF;
font-size: 17px;
}
#tabContaier > ul > li a:hover{
background:#eee;
}
#tabContaier > ul > li a.active{
background:#fbfbfb;
border:1px solid #fff;
border-right:0;
color:#333;
}
.tabDetails{
background:#fbfbfb;
border:1px solid #fff;
border-top: none;
margin:34px 0 0;
}
.tabContents{
padding:20px
}
.tabContents p{
padding:0 0 10px;
}
$(document).ready(function(){
$(".tabContents").hide(); // Hide all tab conten divs by default
$(".tabContents:first").show(); // Show the first div of tab content by default
$("#tabContaier ul li a").click(function(){ //Fire the click event
if($(this).hasClass('active')){
return;
}
var activeTab = $(this).attr("href"); // Catch the click link
$("#tabContaier ul li a").removeClass("active"); // Remove pre-highlighted link
$(this).addClass("active"); // set clicked link to highlight state
$(".tabContents").hide(); // hide currently visible tab content div
$(activeTab).fadeIn(); // show the target tab content div by matching clicked link.
});
});
\ No newline at end of file
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
{{ super() }} {{ super() }}
<link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" /> <link href="{{ url_for('static', filename='css/jqueryFileTree.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script> <script src="{{ url_for('static', filename='jquery/jqueryFileTree.js') }}" type="text/javascript" charset="utf-8"></script>
<link href="{{ url_for('static', filename='css/jqueryTabs.css', _external=False) }}" rel="stylesheet" type="text/css" media="screen" />
<script src="{{ url_for('static', filename='jquery/jqueryTabs.js') }}" type="text/javascript" charset="utf-8"></script>
{%if file_path != "" %} {%if file_path != "" %}
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready( function() { $(document).ready( function() {
$('#fileTree').fileTree({ root: "{{file_path}}", script: $SCRIPT_ROOT + "/readFolder", folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: false }, function(file) { $('#fileTree').fileTree({ root: "{{file_path}}", script: $SCRIPT_ROOT + "/readFolder", folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: false }, function(file) {
alert(file);
}); });
}); });
</script> </script>
...@@ -16,30 +18,43 @@ ...@@ -16,30 +18,43 @@
{% endblock %} {% endblock %}
{% block body %} {% block body %}
<h2>Instance inspection</h2><br/> <h2>Instance inspection</h2><br/>
<h2>Supervisor:</h2> <div id="tabContaier">
{% if supervisor != [] %} <ul>
<table cellpadding="0" cellspacing="0" width="100%"> <li><a class="active" href="#tab1">Slapgrid Supervisor</a></li>
<li><a href="#tab2">SLAP response</a></li>
<li><a href="#tab3">Partitions Content</a></li>
</ul><!-- //Tab buttons -->
<div class="tabDetails">
<div id="tab1" class="tabContents">
<p>This tab show all process generated by slapgrid for your application. You can click on the process name to display logs.</p>
{% if supervisor != []%}
<table cellpadding="0" cellspacing="0" width="100%">
<tr> <tr>
<th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th> <th>Partition and Process name</th><th>Status</th><th>Process PID </th><th> UpTime</th><th></th>
</tr> </tr>
{% for item in supervisor %} {% for item in supervisor %}
<tr> <tr>
<td><b><a href="{{ url_for('tailProcess', process=item[0]) }}">{{ item[0]}}</a></b></td> <td><b><a href="{{ url_for('tailProcess', process=item[0]) }}">{{ item[0]}}</a></b></td>
<td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action=item[1]) }}">{{ item[1]}}</a></td> <td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action=item[1]) }}">{{ item[1]}}</a></td>
<td align="center">{{ item[3]}}</td><td>{{ item[5]}}</td> <td align="center">{{ item[3]}}</td><td>{{ item[5]}}</td>
<td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action='RESTART') }}">Restart</a></td> <td align="center"><a href="{{ url_for('startStopProccess', process=item[0], action='RESTART') }}">Restart</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% else %} {% else %}
<h3>Please run the software instance before displaying process</h3> <h2>Please run the software instance before displaying process</h2>
{%endif%} {%endif%}
<br/> </div><!-- end tab1 -->
<h2>SLAP:</h2> <div id="tab2" class="tabContents">
{% for item in slap_status %} <p>Uses parameters below to run your application</p>
<b>{{ item[0 ]}}</b><br> {% for item in slap_status %}
<textarea cols=103 rows=5 readonly>{{ item[1] }}</textarea><br> <h2>{{ item[0 ]}}</h2>
{% endfor %} <textarea rows=5 readonly>{{ item[1] }}</textarea><br>
<h2>File content:</h2> {% endfor %}
<div id="fileTree" class="file_tree"></div> </div><!-- end tab2 -->
<div id="tab3" class="tabContents">
<div id="fileTree" class="file_tree_tabs"></div>
</div><!-- end tab3 -->
</div>
</div>
{% endblock %} {% endblock %}
...@@ -134,6 +134,7 @@ def runSoftwareWithLock(config): ...@@ -134,6 +134,7 @@ def runSoftwareWithLock(config):
writePid(slapgrid_pid, slapgrid.pid) writePid(slapgrid_pid, slapgrid.pid)
slapgrid.wait() slapgrid.wait()
#Saves the current compile software for re-use #Saves the current compile software for re-use
#This uses the new software create by slapgrid (if not exits yet)
data = loadSoftwareData(config['runner_workdir']) data = loadSoftwareData(config['runner_workdir'])
md5 = "" md5 = ""
for path in os.listdir(config['software_root']): for path in os.listdir(config['software_root']):
...@@ -221,6 +222,17 @@ def svcStopAll(config): ...@@ -221,6 +222,17 @@ def svcStopAll(config):
return Popen([config['supervisor'], config['configuration_file_path'], return Popen([config['supervisor'], config['configuration_file_path'],
'shutdown']).communicate()[0] 'shutdown']).communicate()[0]
def removeInstanceRoot(config):
if os.path.exists(config['instance_root']):
svcStopAll(config)
for root, dirs, files in os.walk(config['instance_root']):
for fname in dirs:
fullPath = os.path.join(root, fname)
if not os.access(fullPath, os.W_OK) :
# Some directories may be read-only, preventing to remove files in it
os.chmod(fullPath, 0744)
shutil.rmtree(config['instance_root'])
def getSvcStatus(config): def getSvcStatus(config):
result = Popen([config['supervisor'], config['configuration_file_path'], result = Popen([config['supervisor'], config['configuration_file_path'],
'status']).communicate()[0] 'status']).communicate()[0]
...@@ -283,6 +295,17 @@ def getProjectList(folder): ...@@ -283,6 +295,17 @@ def getProjectList(folder):
project.append(elt) project.append(elt)
return project return project
def configNewSR(config, project):
if os.path.exists(project):
stopProxy(config)
removeProxyDb(config)
startProxy(config)
removeInstanceRoot(config)
open(os.path.join(config['runner_workdir'], ".project"), 'w').write(project)
return True
else:
return False
def newSoftware(folder, config, session): def newSoftware(folder, config, session):
json = "" json = ""
code = 0 code = 0
...@@ -329,7 +352,7 @@ def getProjectTitle(config): ...@@ -329,7 +352,7 @@ def getProjectTitle(config):
project = open(conf, "r").read().replace(config['workspace'] + "/", "").split("/") project = open(conf, "r").read().replace(config['workspace'] + "/", "").split("/")
software = project[len(project) - 1] software = project[len(project) - 1]
del project[len(project) - 1] del project[len(project) - 1]
return software + "(in " + string.join(project, '/') + ")" return software + "(SR in /" + string.join(project, '/') + ")"
return "No Profile" return "No Profile"
def loadSoftwareData(runner_dir): def loadSoftwareData(runner_dir):
......
...@@ -8,13 +8,15 @@ from gittools import cloneRepo, gitStatus, switchBranch, createBranch, getDiff, ...@@ -8,13 +8,15 @@ from gittools import cloneRepo, gitStatus, switchBranch, createBranch, getDiff,
app = Flask(__name__) app = Flask(__name__)
@app.before_request
def before_request():
session['title'] = getProjectTitle(app.config)
# general views # general views
@app.route('/') @app.route('/')
def home(): def home():
if not os.path.exists(app.config['workspace']) or len(os.listdir(app.config['workspace'])) == 0: if not os.path.exists(app.config['workspace']) or len(os.listdir(app.config['workspace'])) == 0:
session['title'] = "No project"
return redirect(url_for('configRepo')) return redirect(url_for('configRepo'))
session['title'] = getProjectTitle(app.config)
return render_template('index.html') return render_template('index.html')
@app.route('/configRepo') @app.route('/configRepo')
...@@ -100,6 +102,8 @@ def inspectInstance(): ...@@ -100,6 +102,8 @@ def inspectInstance():
if os.path.exists(app.config['instance_root']): if os.path.exists(app.config['instance_root']):
file_content = app.config['instance_root'] file_content = app.config['instance_root']
result = getSvcStatus(app.config) result = getSvcStatus(app.config)
if len(result) == 0:
result = []
return render_template('instanceInspect.html', return render_template('instanceInspect.html',
file_path=file_content, supervisor=result, slap_status=getSlapStatus(app.config), file_path=file_content, supervisor=result, slap_status=getSlapStatus(app.config),
supervisore=result) supervisore=result)
...@@ -108,15 +112,8 @@ def inspectInstance(): ...@@ -108,15 +112,8 @@ def inspectInstance():
def removeInstance(): def removeInstance():
if isInstanceRunning(app.config): if isInstanceRunning(app.config):
flash('Instantiation in progress, cannot remove') flash('Instantiation in progress, cannot remove')
elif os.path.exists(app.config['instance_root']): else:
svcStopAll(app.config) removeInstanceRoot(app.config)
for root, dirs, files in os.walk(app.config['instance_root']):
for fname in dirs:
fullPath = os.path.join(root, fname)
if not os.access(fullPath, os.W_OK) :
# Some directories may be read-only, preventing to remove files in it
os.chmod(fullPath, 0744)
shutil.rmtree(app.config['instance_root'])
flash('Instance removed') flash('Instance removed')
return redirect(url_for('inspectInstance')) return redirect(url_for('inspectInstance'))
...@@ -210,12 +207,11 @@ def checkFolder(): ...@@ -210,12 +207,11 @@ def checkFolder():
@app.route("/setCurentProject", methods=['POST']) @app.route("/setCurentProject", methods=['POST'])
def setCurentProject(): def setCurentProject():
folder = request.form['path'] folder = request.form['path']
if os.path.exists(folder): if configNewSR(app.config, folder):
open(os.path.join(app.config['runner_workdir'], ".project"), 'w').write(folder)
session['title'] = getProjectTitle(app.config) session['title'] = getProjectTitle(app.config)
return jsonify(code=1, result="") return jsonify(code=1, result="")
else: else:
return jsonify(code=0, result=("Can not open '" + folder + "'")) return jsonify(code=0, result=("Can not setup this Software Release"))
@app.route("/manageProject", methods=['GET']) @app.route("/manageProject", methods=['GET'])
def manageProject(): def manageProject():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment