From 65a00df6c4cbba32faa74c17e995ec6e31246282 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Tue, 20 Jan 2015 01:02:08 -0800 Subject: [PATCH] SSH commands dialog --- .../core/xoslib/dashboards/xosTenant.html | 5 ++ planetstack/core/xoslib/objects/sliceplus.py | 8 ++- .../core/xoslib/static/js/xosTenant.js | 51 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/planetstack/core/xoslib/dashboards/xosTenant.html b/planetstack/core/xoslib/dashboards/xosTenant.html index 6735da3..141e3ee 100644 --- a/planetstack/core/xoslib/dashboards/xosTenant.html +++ b/planetstack/core/xoslib/dashboards/xosTenant.html @@ -22,6 +22,7 @@ + @@ -63,6 +64,10 @@
+ +
+
+
diff --git a/planetstack/core/xoslib/objects/sliceplus.py b/planetstack/core/xoslib/objects/sliceplus.py index 7e9836c..9187bff 100644 --- a/planetstack/core/xoslib/objects/sliceplus.py +++ b/planetstack/core/xoslib/objects/sliceplus.py @@ -19,6 +19,7 @@ class SlicePlus(Slice, PlusObjectMixin): used_sites = {} used_deployments = {} sliverCount = 0 + sshCommands = [] for sliver in self.slivers.all(): site = sliver.node.site_deployment.site deployment = sliver.node.site_deployment.deployment @@ -26,6 +27,10 @@ class SlicePlus(Slice, PlusObjectMixin): used_deployments[deployment.name] = used_deployments.get(deployment.name, 0) + 1 sliverCount = sliverCount + 1 + if (sliver.instance_id and sliver.instance_name): + sshCommand = 'ssh -o "ProxyCommand ssh -q %s@%s" ubuntu@%s' % (sliver.instance_id, sliver.node.name, sliver.instance_name) + sshCommands.append(sshCommand); + users = {} for priv in SlicePrivilege.objects.filter(slice=self): if not (priv.user.id in users.keys()): @@ -37,7 +42,8 @@ class SlicePlus(Slice, PlusObjectMixin): "sliverCount": sliverCount, "siteCount": len(used_sites.keys()), "users": users, - "roles": []} + "roles": [], + "sshCommands": sshCommands} if user: auser = self._sliceInfo["users"].get(user.id, None) diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index 286537d..07762ed 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -72,6 +72,7 @@ XOSTenantButtonView = Marionette.ItemView.extend({ "click button.btn-tenant-delete": "deleteClicked", "click button.btn-tenant-add-user": "addUserClicked", "click button.btn-tenant-save": "saveClicked", + "click button.btn-tenant-download-ssh": "downloadClicked", }, createClicked: function(e) { @@ -86,6 +87,10 @@ XOSTenantButtonView = Marionette.ItemView.extend({ XOSTenantApp.editUsers(this.options.linkedView.model); }, + downloadClicked: function(e) { + XOSTenantApp.downloadSSH(this.options.linkedView.model); + }, + saveClicked: function(e) { model = this.options.linkedView.model; model.tenantSiteCollection.putToSlice(model); @@ -113,6 +118,7 @@ XOSTenantApp.addRegions({ tenantButtons: "#tenantButtons", tenantAddSliceInterior: "#tenant-addslice-interior", tenantEditUsersInterior: "#tenant-edit-users-interior", + tenantSSHCommandsInterior: "#tenant-ssh-commands-interior", }); XOSTenantApp.setDirty = function(dirty) { @@ -269,6 +275,51 @@ XOSTenantApp.editUsers = function(model) { $("#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("SSH Commands
" + sshCommands + "
"); + myWindow.document.close(); +}; + +XOSTenantApp.downloadSSH = 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 htmlView = new HTMLView({html: "
" + sshCommands + "
"}); + XOSTenantApp.tenantSSHCommandsInterior.show(htmlView); + + $("#tenant-ssh-commands-dialog").dialog({ + autoOpen: false, + modal: true, + width: 640, + buttons : { + "Ok" : function() { + $(this).dialog("close"); + }, + } + }); + $("#tenant-ssh-commands-dialog").dialog("open"); +}; + XOSTenantApp.deleteSlice = function(model) { var app=this; app.deleteDialog(model, function() { console.log("afterDelete"); app.viewSlice(undefined); }); -- 2.43.0