Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tristan Cavelier
slapos.toolbox
Commits
ed69c295
Commit
ed69c295
authored
Jan 26, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Running Instance should use only the current Software Release
parent
2b16e458
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
46 deletions
+156
-46
slapos/runner/gittools.py
slapos/runner/gittools.py
+4
-2
slapos/runner/static/css/jqueryTabs.css
slapos/runner/static/css/jqueryTabs.css
+59
-0
slapos/runner/static/jquery/jqueryTabs.js
slapos/runner/static/jquery/jqueryTabs.js
+15
-0
slapos/runner/templates/instanceInspect.html
slapos/runner/templates/instanceInspect.html
+42
-27
slapos/runner/utils.py
slapos/runner/utils.py
+24
-1
slapos/runner/views.py
slapos/runner/views.py
+12
-16
No files found.
slapos/runner/gittools.py
View file @
ed69c295
...
...
@@ -30,7 +30,9 @@ def cloneRepo(data):
repo
=
Repo
.
clone_from
(
data
[
"repo"
],
workDir
)
config_writer
=
repo
.
config_writer
()
config_writer
.
add_section
(
"user"
)
if
data
[
"user"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"name"
,
data
[
"user"
])
if
data
[
"email"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
code
=
1
except
Exception
,
e
:
...
...
slapos/runner/static/css/jqueryTabs.css
0 → 100644
View file @
ed69c295
#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
;
}
slapos/runner/static/jquery/jqueryTabs.js
0 → 100644
View file @
ed69c295
$
(
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
slapos/runner/templates/instanceInspect.html
View file @
ed69c295
...
...
@@ -4,11 +4,13 @@
{{ super() }}
<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>
<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 != "" %}
<script
type=
"text/javascript"
charset=
"utf-8"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#fileTree
'
).
fileTree
({
root
:
"
{{file_path}}
"
,
script
:
$SCRIPT_ROOT
+
"
/readFolder
"
,
folderEvent
:
'
click
'
,
expandSpeed
:
750
,
collapseSpeed
:
750
,
multiFolder
:
false
,
selectFolder
:
false
},
function
(
file
)
{
alert
(
file
);
});
});
</script>
...
...
@@ -16,30 +18,43 @@
{% endblock %}
{% block body %}
<h2>
Instance inspection
</h2><br/>
<h2>
Supervisor:
</h2>
{% if supervisor != [] %}
<table
cellpadding=
"0"
cellspacing=
"0"
width=
"100%"
>
<div
id=
"tabContaier"
>
<ul>
<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>
<th>
Partition and Process name
</th><th>
Status
</th><th>
Process PID
</th><th>
UpTime
</th><th></th>
</tr>
{% for item in supervisor %}
{% for item in supervisor %}
<tr>
<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"
>
{{ item[3]}}
</td><td>
{{ item[5]}}
</td>
<td
align=
"center"
><a
href=
"{{ url_for('startStopProccess', process=item[0], action='RESTART') }}"
>
Restart
</a></td>
</tr>
{% endfor %}
</table>
{% else %}
<h3>
Please run the software instance before displaying process
</h3>
{%endif%}
<br/>
<h2>
SLAP:
</h2>
{% for item in slap_status %}
<b>
{{ item[0 ]}}
</b><br>
<textarea
cols=
103
rows=
5
readonly
>
{{ item[1] }}
</textarea><br>
{% endfor %}
<h2>
File content:
</h2>
<div
id=
"fileTree"
class=
"file_tree"
></div>
{% endfor %}
</table>
{% else %}
<h2>
Please run the software instance before displaying process
</h2>
{%endif%}
</div>
<!-- end tab1 -->
<div
id=
"tab2"
class=
"tabContents"
>
<p>
Uses parameters below to run your application
</p>
{% for item in slap_status %}
<h2>
{{ item[0 ]}}
</h2>
<textarea
rows=
5
readonly
>
{{ item[1] }}
</textarea><br>
{% endfor %}
</div>
<!-- end tab2 -->
<div
id=
"tab3"
class=
"tabContents"
>
<div
id=
"fileTree"
class=
"file_tree_tabs"
></div>
</div>
<!-- end tab3 -->
</div>
</div>
{% endblock %}
slapos/runner/utils.py
View file @
ed69c295
...
...
@@ -134,6 +134,7 @@ def runSoftwareWithLock(config):
writePid
(
slapgrid_pid
,
slapgrid
.
pid
)
slapgrid
.
wait
()
#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'
])
md5
=
""
for
path
in
os
.
listdir
(
config
[
'software_root'
]):
...
...
@@ -221,6 +222,17 @@ def svcStopAll(config):
return
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
'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
):
result
=
Popen
([
config
[
'supervisor'
],
config
[
'configuration_file_path'
],
'status'
]).
communicate
()[
0
]
...
...
@@ -283,6 +295,17 @@ def getProjectList(folder):
project.append(elt)
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):
json = ""
code = 0
...
...
@@ -329,7 +352,7 @@ def getProjectTitle(config):
project = open(conf, "r").read().replace(config['
workspace
'] + "/", "").split("/")
software = 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"
def loadSoftwareData(runner_dir):
...
...
slapos/runner/views.py
View file @
ed69c295
...
...
@@ -8,13 +8,15 @@ from gittools import cloneRepo, gitStatus, switchBranch, createBranch, getDiff,
app
=
Flask
(
__name__
)
@
app
.
before_request
def
before_request
():
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
# general views
@
app
.
route
(
'/'
)
def
home
():
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'
))
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
return
render_template
(
'index.html'
)
@
app
.
route
(
'/configRepo'
)
...
...
@@ -100,6 +102,8 @@ def inspectInstance():
if
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
file_content
=
app
.
config
[
'instance_root'
]
result
=
getSvcStatus
(
app
.
config
)
if
len
(
result
)
==
0
:
result
=
[]
return
render_template
(
'instanceInspect.html'
,
file_path
=
file_content
,
supervisor
=
result
,
slap_status
=
getSlapStatus
(
app
.
config
),
supervisore
=
result
)
...
...
@@ -108,15 +112,8 @@ def inspectInstance():
def
removeInstance
():
if
isInstanceRunning
(
app
.
config
):
flash
(
'Instantiation in progress, cannot remove'
)
elif
os
.
path
.
exists
(
app
.
config
[
'instance_root'
]):
svcStopAll
(
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'
])
else
:
removeInstanceRoot
(
app
.
config
)
flash
(
'Instance removed'
)
return
redirect
(
url_for
(
'inspectInstance'
))
...
...
@@ -210,12 +207,11 @@ def checkFolder():
@
app
.
route
(
"/setCurentProject"
,
methods
=
[
'POST'
])
def
setCurentProject
():
folder
=
request
.
form
[
'path'
]
if
os
.
path
.
exists
(
folder
):
open
(
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
),
'w'
).
write
(
folder
)
if
configNewSR
(
app
.
config
,
folder
):
session
[
'title'
]
=
getProjectTitle
(
app
.
config
)
return
jsonify
(
code
=
1
,
result
=
""
)
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'
])
def
manageProject
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment