Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/dashboard/views/download_ssh_commands.py b/planetstack/core/dashboard/views/download_ssh_commands.py
new file mode 100644
index 0000000..96d1393
--- /dev/null
+++ b/planetstack/core/dashboard/views/download_ssh_commands.py
@@ -0,0 +1,18 @@
+from view_common import *
+from core.xoslib.objects.sliceplus import SlicePlus
+
+# This was intended to serve as a download feature for the tenant view. Found
+# a better way to do it. This is deprecated.
+
+class DownloadSSHCommandsView(View):
+ url = r'^sshcommands/(?P<sliceid>\d+)/$'
+
+ def get(self, request, sliceid=None, **kwargs):
+ #slice = Slices.objects.get(id=sliceid);
+ #for sliver in slice.slivers.all():
+ # if (sliver.instance_id && sliver.instance_name):
+
+ slice = SlicePlus.objects.get(id=sliceid)
+
+ return HttpResponse(slice.getSliceInfo()["sshCommands"], content_type='text/text')
+
diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js
index 79e093e..4225cac 100644
--- a/planetstack/core/xoslib/static/js/xosTenant.js
+++ b/planetstack/core/xoslib/static/js/xosTenant.js
@@ -297,25 +297,8 @@
$("#tenant-edit-users-dialog").dialog("open");
};
-XOSTenantApp.downloadSSHOld = function(model) {
- sshCommands = "";
- for (index in model.attributes.sliceInfo.sshCommands) {
- sshCommand = model.attributes.sliceInfo.sshCommands[index];
- sshCommands = sshCommands + sshCommand + "\n";
- }
-
- if (sshCommands.length == 0) {
- alert("this slice has no instantiated slivers yet");
- return;
- }
-
- var myWindow = window.open("", "ssh_command_list",""); // "width=640, height=480");
- myWindow.document.write("<html><head><title>SSH Commands</title></head><body><pre>" + sshCommands + "</pre></body></html>");
- myWindow.document.close();
-};
-
XOSTenantApp.downloadSSH = function(model) {
- sshCommands = "";
+ var sshCommands = "";
for (index in model.attributes.sliceInfo.sshCommands) {
sshCommand = model.attributes.sliceInfo.sshCommands[index];
sshCommands = sshCommands + sshCommand + "\n";
@@ -334,7 +317,15 @@
modal: true,
width: 640,
buttons : {
- "Ok" : function() {
+ "Download": function() {
+ var dlLink = document.createElement('a');
+ dlLink.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(sshCommands));
+ dlLink.setAttribute('download', 'sshcommands.txt');
+ dlLink.click();
+
+ //window.open('data:text/text,' + encodeURIComponent(sshCommands));
+ },
+ "Close" : function() {
$(this).dialog("close");
},
}