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
Justin
slapos.toolbox
Commits
3533f9ca
Commit
3533f9ca
authored
Mar 12, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Instance parameters management to webrunner
parent
5ad93361
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
22 deletions
+89
-22
slapos/runner/static/js/jquery/jqueryTabs.js
slapos/runner/static/js/jquery/jqueryTabs.js
+14
-3
slapos/runner/static/js/scripts/common.js
slapos/runner/static/js/scripts/common.js
+3
-0
slapos/runner/static/js/scripts/inspectInstance.js
slapos/runner/static/js/scripts/inspectInstance.js
+17
-1
slapos/runner/templates/instanceInspect.html
slapos/runner/templates/instanceInspect.html
+11
-3
slapos/runner/utils.py
slapos/runner/utils.py
+33
-11
slapos/runner/views.py
slapos/runner/views.py
+11
-4
No files found.
slapos/runner/static/js/jquery/jqueryTabs.js
View file @
3533f9ca
$
(
document
).
ready
(
function
(){
$
(
"
.tabContents
"
).
hide
();
// Hide all tab conten divs by default
$
(
"
.tabContents:first
"
).
show
();
// Show the first div of tab content by default
$
(
"
.tabContents
"
).
hide
();
// Hide all tab content divs by default
var
hashes
=
window
.
location
.
href
.
split
(
'
#
'
);
if
(
hashes
.
length
==
2
){
$
(
"
#tabContaier>ul li
"
).
each
(
function
()
{
var
$tab
=
$
(
this
).
find
(
"
a
"
);
if
(
$tab
.
hasClass
(
"
active
"
))
$tab
.
removeClass
(
"
active
"
);
if
(
$tab
.
attr
(
"
href
"
)
==
"
#
"
+
hashes
[
1
]){
$tab
.
addClass
(
"
active
"
);
$
(
"
#
"
+
hashes
[
1
]).
show
();
}
//alert($(this).attr("href"));
});
}
else
{
$
(
"
.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
;
...
...
slapos/runner/static/js/scripts/common.js
View file @
3533f9ca
...
...
@@ -4,5 +4,8 @@ String.prototype.toHtmlChar = function(){
'
#
'
:
'
#
'
};
return
this
.
replace
(
/
[
<&>'"#
]
/g
,
function
(
s
)
{
return
c
[
s
];
}
);
}
String
.
prototype
.
trim
=
function
()
{
return
this
.
replace
(
/^
\s
*/
,
""
).
replace
(
/
\s
*$/
,
""
);
}
/**************************/
slapos/runner/static/js/scripts/inspectInstance.js
View file @
3533f9ca
...
...
@@ -18,8 +18,24 @@ $(document).ready( function() {
//User have double click on file in to the fileTree
loadFileContent
(
file
);
}
$
(
"
#parameter
"
).
load
(
$SCRIPT_ROOT
+
'
/getParameterXml
'
);
$
(
"
#update
"
).
click
(
function
(){
alert
(
$
(
"
#parameter
"
).
val
());
if
(
$
(
"
#parameter
"
).
val
()
==
""
){
$
(
"
#error
"
).
Popup
(
"
Can not save empty value!
"
,
{
type
:
'
alert
'
,
duration
:
3000
});
}
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/saveParameterXml
'
,
data
:
{
parameter
:
$
(
"
#parameter
"
).
val
().
trim
()},
success
:
function
(
data
){
if
(
data
.
code
==
1
){
$
(
"
#error
"
).
Popup
(
"
Instance parameters updated!
"
,
{
type
:
'
info
'
,
duration
:
3000
});
}
else
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
error
'
,
duration
:
5000
});
}
}
});
});
function
loadFileContent
(
file
){
...
...
slapos/runner/templates/instanceInspect.html
View file @
3533f9ca
...
...
@@ -25,7 +25,7 @@
<div
class=
"tabDetails"
>
<div
id=
"tab1"
class=
"tabContents"
>
<p>
Add your instance parameters here and click on the update button
</p>
<textarea
class=
"parameter"
id=
"parameter"
>
<
?xml version='1.0' encoding='utf-8'?
>
</textarea>
<textarea
class=
"parameter"
id=
"parameter"
></textarea>
<input
type=
"submit"
name=
"update"
id =
"update"
value=
"Update"
class=
"button"
/>
</div>
<!-- end tab1 -->
<div
id=
"tab2"
class=
"tabContents"
>
...
...
@@ -50,10 +50,18 @@
</div>
<!-- end tab2 -->
<div
id=
"tab3"
class=
"tabContents"
>
<p>
Uses parameters below to run your application
</p>
<table
cellpadding=
"0"
cellspacing=
"0"
width=
"100%"
>
{% for item in slap_status %}
<h2>
{{ item[0 ]}}
</h2>
<textarea
rows=
5
readonly
>
{{ item[1] }}
</textarea><br>
<tr>
<th
align=
'left'
colspan=
'2'
>
Computer Partition {{ item[0]}}
</th>
</tr>
{% for k in item[1] %}
<tr>
<td>
{{k}}
</td><td
align=
'left'
>
{{item[1][k]}}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
</div>
<!-- end tab3 -->
<div
id=
"tab4"
class=
"tabContents"
>
<div
id=
"fileTree"
class=
"file_tree_tabs"
></div>
...
...
slapos/runner/utils.py
View file @
3533f9ca
...
...
@@ -25,6 +25,18 @@ class Popen(subprocess.Popen):
self
.
stdin
.
close
()
self
.
stdin
=
None
html_escape_table
=
{
"&"
:
"&"
,
'"'
:
"""
,
"'"
:
"'"
,
">"
:
">"
,
"<"
:
"<"
,
}
def
html_escape
(
text
):
"""Produce entities within text."""
return
""
.
join
(
html_escape_table
.
get
(
c
,
c
)
for
c
in
text
)
def
updateProxy
(
config
):
if
not
os
.
path
.
exists
(
config
[
'instance_root'
]):
...
...
@@ -66,10 +78,17 @@ def updateProxy(config):
'reference'
:
partition_reference
,
'tap'
:
{
'name'
:
partition_reference
},
})
#get instance parameter
param_path
=
os
.
path
.
join
(
config
[
'runner_workdir'
],
".parameter.xml"
)
xml_result
=
readParameters
(
param_path
)
if
type
(
xml_result
)
!=
type
(
''
)
and
xml_result
.
has_key
(
'instance'
):
partition_parameter_kw
=
xml_result
[
'instance'
]
else
:
partition_parameter_kw
=
None
computer
.
updateConfiguration
(
xml_marshaller
.
dumps
(
slap_config
))
slap
.
registerOpenOrder
().
request
(
profile
,
partition_reference
=
partition_reference
,
partition_parameter_kw
=
None
,
software_type
=
None
,
filter_kw
=
None
,
state
=
None
,
shared
=
False
)
partition_parameter_kw
=
partition_parameter_kw
,
software_type
=
None
,
filter_kw
=
None
,
state
=
None
,
shared
=
False
)
return
True
def
readPid
(
file
):
...
...
@@ -199,9 +218,9 @@ def recursifKill(pids):
for
pid
in
pids
:
ppids
=
pidppid
(
pid
)
try
:
os
.
kill
(
pid
,
signal
.
SIGKILL
)
#kill current process
os
.
kill
(
pid
,
signal
.
SIGKILL
)
#kill current process
except
Exception
:
pass
pass
recursifKill
(
ppids
)
#kill all children of this process
def
pidppid
(
pid
):
...
...
@@ -276,8 +295,11 @@ def getSvcStatus(config):
regex
=
"(^unix:.+
\
.socke
t
)|(^error:).*$"
supervisord
=
[]
for
item
in
result
.
split
(
'
\
n
'
):
if
item
!=
""
and
re
.
search
(
regex
,
item
)
==
None
:
supervisord
.
append
(
re
.
split
(
'[
\
s,]+
'
, item))
if
item
.
strip
()
!=
""
:
if
re
.
search
(
regex
,
item
,
re
.
IGNORECASE
)
==
None
:
supervisord
.
append
(
re
.
split
(
'[
\
s,]+
'
, item))
else:
return [] #ignore because it is an error message
return supervisord
def getSvcTailProcess(config, process):
...
...
@@ -558,12 +580,12 @@ def readParameters(path):
xmldoc = minidom.parse(path)
object = {}
for elt in xmldoc.childNodes:
sub_object = {}
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
sub_object[str(subnode.getAttribute('
id
'))] = str(subnode.
sub_object = {}
for subnode in elt.childNodes:
if subnode.nodeType != subnode.TEXT_NODE:
sub_object[str(subnode.getAttribute('
id
'))] = str(subnode.
childNodes[0].data)
object[str(elt.tagName)] = sub_object
object[str(elt.tagName)] = sub_object
return object
except Exception, e:
return str(e)
...
...
slapos/runner/views.py
View file @
3533f9ca
...
...
@@ -359,8 +359,11 @@ def getPath():
else
:
return
jsonify
(
code
=
1
,
result
=
realfile
)
@
app
.
route
(
"/
load
ParameterXml"
,
methods
=
[
'POST'
])
@
app
.
route
(
"/
save
ParameterXml"
,
methods
=
[
'POST'
])
def
redParameterXml
():
project
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".project"
)
if
not
os
.
path
.
exists
(
project
):
return
jsonify
(
code
=
0
,
result
=
"Please first open a Software Release"
)
content
=
request
.
form
[
'parameter'
]
param_path
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".parameter.xml"
)
f
=
open
(
param_path
,
'w'
)
...
...
@@ -370,13 +373,17 @@ def redParameterXml():
if
type
(
result
)
==
type
(
''
):
return
jsonify
(
code
=
0
,
result
=
"XML Error: "
+
result
)
else
:
try
:
updateProxy
(
app
.
config
)
except
Exeption
:
return
jsonify
(
code
=
0
,
result
=
"An error occurred while applying your settings!"
)
return
jsonify
(
code
=
1
,
result
=
""
)
@
app
.
route
(
"/getParameterXml"
,
methods
=
[
'GET'
])
def
getParameterXml
():
param_path
=
os
.
path
.
join
(
app
.
config
[
'runner_workdir'
],
".parameter.xml"
)
if
os
.
path
.
exists
(
param_path
):
content
=
open
(
param_path
,
'
w
'
).
read
()
return
jsonify
(
code
=
1
,
result
=
content
)
content
=
open
(
param_path
,
'
r
'
).
read
()
return
html_escape
(
content
)
else
:
return
jsonify
(
code
=
0
,
result
=
"Error: Can not load default instance parameters"
)
\ No newline at end of file
return
"<?xml version='1.0' encoding='utf-8'?>"
\ No newline at end of file
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