From: Jan Provaznik <[email protected]>
---
.../controllers/resources/instances_controller.rb | 32 +++++++++-
src/app/views/resources/instances/show.haml | 60 ++++++++++++++++++++
src/config/routes.rb | 2 +-
3 files changed, 89 insertions(+), 5 deletions(-)
create mode 100644 src/app/views/resources/instances/show.haml
diff --git a/src/app/controllers/resources/instances_controller.rb
b/src/app/controllers/resources/instances_controller.rb
index 1976561..4bef66a 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -60,10 +60,21 @@ class Resources::InstancesController < ApplicationController
def edit
end
- def start
- end
-
- def stop
+ def show
+ @instance = Instance.find((params[:id] || []).first)
+ require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+ @url_params = params.clone
+ @tab_captions = ['Properties', 'History', 'Permissions']
+ @details_tab = params[:details_tab].blank? ? 'properties' :
params[:details_tab]
+ respond_to do |format|
+ format.js do
+ if @url_params.delete :details_pane
+ render :partial => 'layouts/details_pane' and return
+ end
+ render :partial => @details_tab and return
+ end
+ format.html { render :action => 'show'}
+ end
end
def index
@@ -84,6 +95,19 @@ class Resources::InstancesController < ApplicationController
)
end
+ def key
+ @instance = Instance.find((params[:id] || []).first)
+ require_privilege(Privilege::INSTANCE_CONTROL,@instance.pool)
+ unless @instance.instance_key.nil?
+ send_data @instance.instance_key.pem,
+ :filename => "#[email protected]_key.name}.pem",
+ :type => "text/plain"
+ return
+ end
+ flash[:warning] = "SSH Key not found for this Instance."
+ redirect_to resources_instance_path(@instance)
+ end
+
private
def init_new_instance_attrs
diff --git a/src/app/views/resources/instances/show.haml
b/src/app/views/resources/instances/show.haml
new file mode 100644
index 0000000..deb1a49
--- /dev/null
+++ b/src/app/views/resources/instances/show.haml
@@ -0,0 +1,60 @@
+%h2 Instance Details
+%ul
+ %li
+ = label_tag :name, 'Name'
+ %span= @instance.name
+ %li
+ = label_tag :status, 'Status'
+ %span= @instance.state
+ %li
+ = label_tag :public_addresses, 'Public Addresses'
+ %span= @instance.public_addresses
+ %li
+ = label_tag :private_addresses, 'Private Addresses'
+ %span= @instance.private_addresses
+ %li
+ = label_tag :operating_system, 'Operating system'
+ %span= "#[email protected]}
#[email protected]_version}"
+ %li
+ = label_tag :provider, 'Provider'
+ %span= @instance.cloud_account.provider.name if @instance.cloud_account
+ %li
+ = label_tag :base_template, 'Base Template'
+ %span= @instance.template.name
+ %li
+ = label_tag :architecture, 'Architecture'
+ %span= @instance.hardware_profile.architecture.value
+ %li
+ = label_tag :memory, 'Memory'
+ %span= @instance.hardware_profile.memory.value
+ %li
+ = label_tag :storage, 'Storage'
+ %span= @instance.hardware_profile.storage.value
+ %li
+ = label_tag :instantiation_time, 'Instantiation Time'
+ %span= @instance.created_at.strftime("%d-%b-%Y %H:%M:%S")
+ %li
+ = label_tag :uptime, 'Uptime'
+ %span= @instance.total_state_time(@instance.state)
+ %li
+ = label_tag :current_alerts, 'Current Alerts'
+ %span= 0
+ %li
+ = label_tag :console_connection, 'Console Connection'
+ %span= 'via SSH'
+ - unless @instance.instance_key_id.nil?
+ %li
+ = label_tag :instance_key, 'SSH key'
+ %span= link_to("Download", key_resources_instance_path(@instance))
+ %li
+ = label_tag :owner, 'Owner'
+ %span= "#[email protected]_name} #[email protected]_name}"
+ %li
+ = label_tag :shared_to, 'Shared to'
+ %span= "N/A"
+ - if @instance.state == Instance::STATE_ERROR
+ %li
+ = label_tag :error, 'Error'
+ %span= @instance.last_error
+
+= link_to 'Back', resources_instances_path, :class => 'button'
diff --git a/src/config/routes.rb b/src/config/routes.rb
index cb1536a..bfd6cac 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -34,7 +34,7 @@ ActionController::Routing::Routes.draw do |map|
map.namespace 'resources' do |r|
r.resources :pools, :deployments
- r.resources :instances, :collection => {:start => :get, :stop => :get,
:select_template => :get}
+ r.resources :instances, :collection => {:start => :get, :stop => :get,
:select_template => :get}, :member => {:key => :get}
end
map.namespace 'image_factory' do |r|
--
1.7.2.3
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel