Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
ea66f341
Commit
ea66f341
authored
May 25, 2016
by
Leigh B Stoller
Browse files
New page to convert rspec to geni-lib script, not linked in anyplace yet.
parent
2b990329
Changes
4
Hide whitespace changes
Inline
Side-by-side
www/aptui/js/rspec2genilib.js
0 → 100644
View file @
ea66f341
require
(
window
.
APT_OPTIONS
.
configObject
,
[
'
underscore
'
,
'
js/quickvm_sup
'
,
'
js/lib/text!template/rspec2genilib.html
'
,
'
js/lib/text!template/waitwait-modal.html
'
,
'
js/lib/text!template/oops-modal.html
'
,
"
filestyle
"
],
function
(
_
,
sup
,
mainString
,
waitString
,
oopsString
)
{
'
use strict
'
;
var
mainTemplate
=
_
.
template
(
mainString
);
function
initialize
()
{
window
.
APT_OPTIONS
.
initialize
(
sup
);
$
(
'
#main-body
'
).
html
(
mainString
);
$
(
'
#waitwait_div
'
).
html
(
waitString
);
$
(
'
#oops_div
'
).
html
(
oopsString
);
//
// Fix for filestyle problem; not a real class I guess, it
// runs at page load, and so the filestyle'd button in the
// form is not as it should be.
//
$
(
'
#rspec-upload-button
'
).
each
(
function
()
{
$
(
this
).
filestyle
({
input
:
false
,
buttonText
:
$
(
this
).
attr
(
'
data-buttonText
'
),
classButton
:
$
(
this
).
attr
(
'
data-classButton
'
)});
});
//
// File upload handler.
//
$
(
'
#rspec-upload-button
'
).
change
(
function
()
{
var
reader
=
new
FileReader
();
var
button
=
$
(
this
);
reader
.
onload
=
function
(
event
)
{
var
newrspec
=
event
.
target
.
result
;
/*
* Clear the file so that the change handler will
* run if the same file is selected again (say, after
* fixing a script error).
*/
$
(
"
#rspec-upload-button
"
).
filestyle
(
'
clear
'
);
$
(
"
#rspec-textarea
"
).
val
(
newrspec
);
$
(
'
#convert-button
'
).
removeAttr
(
"
disabled
"
);
};
reader
.
readAsText
(
this
.
files
[
0
]);
});
// Enable button when the textarea changes.
$
(
'
#rspec-textarea
'
).
change
(
function
()
{
$
(
'
#convert-button
'
).
removeAttr
(
"
disabled
"
);
});
// Send off rspec to server for conversion.
$
(
'
#convert-button
'
).
click
(
function
(
event
)
{
event
.
preventDefault
();
ConvertRspec
();
});
}
function
ConvertRspec
()
{
var
rspec
=
$
.
trim
(
$
(
'
#rspec-textarea
'
).
val
());
if
(
!
rspec
.
length
)
{
return
;
}
console
.
info
(
rspec
);
var
callback
=
function
(
json
)
{
console
.
info
(
json
);
sup
.
HideWaitWait
();
if
(
json
.
code
)
{
sup
.
SpitOops
(
"
oops
"
,
json
.
value
);
return
;
}
$
(
'
#genilib-textarea
'
).
text
(
json
.
value
);
};
sup
.
ShowWaitWait
(
"
We are converting your rspec to geni-lib
"
);
var
xmlthing
=
sup
.
CallServerMethod
(
null
,
"
rspec2genilib
"
,
"
Convert
"
,
{
"
rspec
"
:
rspec
});
xmlthing
.
done
(
callback
);
}
$
(
document
).
ready
(
initialize
);
});
www/aptui/rspec2genilib.ajax
0 → 100644
View file @
ea66f341
<?php
#
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir
(
".."
);
include_once
(
"geni_defs.php"
);
chdir
(
"apt"
);
#
# Convert rspec to geni-lib
#
function
Do_Convert
()
{
global
$this_user
;
global
$ajax_args
,
$suexec_output
;
$this_idx
=
$this_user
->
uid_idx
();
$this_uid
=
$this_user
->
uid
();
if
(
!
isset
(
$ajax_args
[
"rspec"
]))
{
SPITAJAX_ERROR
(
1
,
"Missing rspec"
);
return
;
}
$command
=
"webrspec2genilib"
;
$infname
=
tempnam
(
"/tmp"
,
"rspec2genilibin"
);
$outfname
=
tempnam
(
"/tmp"
,
"rspec2genilibout"
);
$fp
=
fopen
(
$infname
,
"w"
);
fwrite
(
$fp
,
$ajax_args
[
"rspec"
]);
fclose
(
$fp
);
chmod
(
$infname
,
0666
);
chmod
(
$outfname
,
0666
);
#
# Invoke the backend.
#
$retval
=
SUEXEC
(
nobody
,
"nobody"
,
"
$command
-o
$outfname
$infname
"
,
SUEXEC_ACTION_IGNORE
);
if
(
$retval
!=
0
)
{
SPITAJAX_ERROR
(
1
,
$suexec_output
);
}
else
{
$script
=
file_get_contents
(
$outfname
);
SPITAJAX_RESPONSE
(
$script
);
}
unlink
(
$infname
);
unlink
(
$outfname
);
}
# Local Variables:
# mode:php
# End:
?>
www/aptui/rspec2genilib.php
0 → 100644
View file @
ea66f341
<?php
#
# Copyright (c) 2000-2016 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
chdir
(
".."
);
include
(
"defs.php3"
);
chdir
(
"apt"
);
include
(
"quickvm_sup.php"
);
# Must be after quickvm_sup.php since it changes the auth domain.
$page_title
=
"Convert RSpec to GeniLib"
;
RedirectSecure
();
$this_user
=
CheckLoginOrRedirect
();
SPITHEADER
(
1
);
# Place to hang the toplevel template.
echo
"<div id='main-body'></div>
\n
"
;
SPITREQUIRE
(
"rspec2genilib"
);
SPITFOOTER
();
?>
www/aptui/template/rspec2genilib.html
0 → 100644
View file @
ea66f341
<div
class=
"row"
>
<div
class=
'col-sm-10 col-sm-offset-1
col-xs-12 col-xs-offset-0'
>
<div
class=
'panel panel-default'
>
<div
class=
"panel-heading"
>
<h5>
Please paste in your rspec
</h5>
</div>
<div
class=
'panel-body'
>
<div
class=
"form-group"
>
<textarea
class=
"form-control col-xs-12"
id=
'rspec-textarea'
rows=
15
type=
'textarea'
></textarea>
</div>
</div>
<div
class=
'panel-footer'
>
<center>
<input
class=
'filestyle'
type=
'file'
id=
"rspec-upload-button"
data-classButton=
'btn btn-primary btn-xs'
data-input=
'false'
style=
'margin-right: 15px'
data-buttonText=
'Upload'
>
<button
class=
'btn btn-primary btn-xs'
type=
'button'
id=
'convert-button'
>
Convert
</button>
</center>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
'col-sm-10 col-sm-offset-1
col-xs-12 col-xs-offset-0'
>
<div
class=
'panel panel-default'
>
<div
class=
"panel-heading"
>
<h5>
Here is your geni-lib script
</h5>
</div>
<div
class=
'panel-body'
>
<div
class=
"form-group"
>
<textarea
class=
"form-control col-xs-12"
id=
'genilib-textarea'
rows=
15
type=
'textarea'
></textarea>
</div>
</div>
</div>
</div>
</div>
<div
id=
'waitwait_div'
></div>
<div
id=
'oops_div'
></div>
Write
Preview
Supports
Markdown
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