display ssh command in sliver detail view
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 577719c..8ec00a9 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -1107,9 +1107,9 @@
class SliverAdmin(PlanetStackBaseAdmin):
form = SliverForm
fieldsets = [
- ('Sliver Details', {'fields': ['backend_status_text', 'slice', 'deployment', 'node', 'ip', 'instance_id', 'instance_name', 'flavor', 'image', ], 'classes': ['suit-tab suit-tab-general'], })
+ ('Sliver Details', {'fields': ['backend_status_text', 'slice', 'deployment', 'node', 'ip', 'instance_id', 'instance_name', 'flavor', 'image', 'ssh_command'], 'classes': ['suit-tab suit-tab-general'], })
]
- readonly_fields = ('backend_status_text', )
+ readonly_fields = ('backend_status_text', 'ssh_command', )
list_display = ['backend_status_icon', 'ip', 'instance_id', 'instance_name', 'slice', 'flavor', 'image', 'node', 'deployment']
list_display_links = ('backend_status_icon', 'ip',)
@@ -1119,6 +1119,13 @@
user_readonly_fields = ['slice', 'deployment', 'node', 'ip', 'instance_name', 'flavor', 'image']
+ def ssh_command(self, obj):
+ ssh_command = obj.get_ssh_command()
+ if ssh_command:
+ return ssh_command
+ else:
+ return "(not available)"
+
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'slice':
kwargs['queryset'] = Slice.select_by_user(request.user)
@@ -1134,11 +1141,9 @@
def get_formsets(self, request, obj=None):
# make some fields read only if we are updating an existing record
if obj == None:
- #self.readonly_fields = ('ip', 'instance_name')
- self.readonly_fields = ('backend_status_text',)
+ self.readonly_fields = ('backend_status_text', 'ssh_command', )
else:
- self.readonly_fields = ('backend_status_text',)
- #self.readonly_fields = ('ip', 'instance_name', 'slice', 'image', 'key')
+ self.readonly_fields = ('backend_status_text', 'ssh_command',)
for inline in self.get_inline_instances(request, obj):
# hide MyInline in the add view
diff --git a/planetstack/core/models/sliver.py b/planetstack/core/models/sliver.py
index d2f794f..61924cf 100644
--- a/planetstack/core/models/sliver.py
+++ b/planetstack/core/models/sliver.py
@@ -155,3 +155,9 @@
def get_node_stats(self):
# Note sure what should go back here
return 1
+
+ def get_ssh_command(self):
+ if (not self.instance_id) or (not self.node) or (not self.instance_name):
+ return None
+ else:
+ return 'ssh -o "ProxyCommand ssh -q %s@%s" ubuntu@%s' % (self.instance_id, self.node.name, self.instance_name)
diff --git a/planetstack/core/xoslib/objects/sliceplus.py b/planetstack/core/xoslib/objects/sliceplus.py
index 0c66258..6bbbfa2 100644
--- a/planetstack/core/xoslib/objects/sliceplus.py
+++ b/planetstack/core/xoslib/objects/sliceplus.py
@@ -31,9 +31,9 @@
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);
+ sshCommand = sliver.get_ssh_command()
+ if sshCommand:
+ sshCommands.append(sshCommand)
ready_sites[site.name] = ready_sites.get(site.name, 0) + 1