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
Xiaowu Zhang
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
Hide 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,8 +30,10 @@ def cloneRepo(data):
...
@@ -30,8 +30,10 @@ 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"
)
config_writer
.
set_value
(
"user"
,
"name"
,
data
[
"user"
])
if
data
[
"user"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
config_writer
.
set_value
(
"user"
,
"name"
,
data
[
"user"
])
if
data
[
"email"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
,
e
:
json
=
str
(
e
)
json
=
str
(
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 @@
...
@@ -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>
<tr>
<li><a
href=
"#tab2"
>
SLAP response
</a></li>
<th>
Partition and Process name
</th><th>
Status
</th><th>
Process PID
</th><th>
UpTime
</th><th></th>
<li><a
href=
"#tab3"
>
Partitions Content
</a></li>
</tr>
</ul>
<!-- //Tab buttons -->
{% for item in supervisor %}
<div
class=
"tabDetails"
>
<tr>
<div
id=
"tab1"
class=
"tabContents"
>
<td><b><a
href=
"{{ url_for('tailProcess', process=item[0]) }}"
>
{{ item[0]}}
</a></b></td>
<p>
This tab show all process generated by slapgrid for your application. You can click on the process name to display logs.
</p>
<td
align=
"center"
><a
href=
"{{ url_for('startStopProccess', process=item[0], action=item[1]) }}"
>
{{ item[1]}}
</a></td>
{% if supervisor != []%}
<td
align=
"center"
>
{{ item[3]}}
</td><td>
{{ item[5]}}
</td>
<table
cellpadding=
"0"
cellspacing=
"0"
width=
"100%"
>
<td
align=
"center"
><a
href=
"{{ url_for('startStopProccess', process=item[0], action='RESTART') }}"
>
Restart
</a></td>
<tr>
</tr>
<th>
Partition and Process name
</th><th>
Status
</th><th>
Process PID
</th><th>
UpTime
</th><th></th>
{% endfor %}
</tr>
</table>
{% for item in supervisor %}
{% else %}
<tr>
<h3>
Please run the software instance before displaying process
</h3>
<td><b><a
href=
"{{ url_for('tailProcess', process=item[0]) }}"
>
{{ item[0]}}
</a></b></td>
{%endif%}
<td
align=
"center"
><a
href=
"{{ url_for('startStopProccess', process=item[0], action=item[1]) }}"
>
{{ item[1]}}
</a></td>
<br/>
<td
align=
"center"
>
{{ item[3]}}
</td><td>
{{ item[5]}}
</td>
<h2>
SLAP:
</h2>
<td
align=
"center"
><a
href=
"{{ url_for('startStopProccess', process=item[0], action='RESTART') }}"
>
Restart
</a></td>
{% for item in slap_status %}
</tr>
<b>
{{ item[0 ]}}
</b><br>
{% endfor %}
<textarea
cols=
103
rows=
5
readonly
>
{{ item[1] }}
</textarea><br>
</table>
{% endfor %}
{% else %}
<h2>
File content:
</h2>
<h2>
Please run the software instance before displaying process
</h2>
<div
id=
"fileTree"
class=
"file_tree"
></div>
{%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 %}
{% endblock %}
slapos/runner/utils.py
View file @
ed69c295
...
@@ -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):
...
...
slapos/runner/views.py
View file @
ed69c295
...
@@ -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
():
...
...
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