You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2010/12/07 14:00:06 UTC
[PATCH core] Turned CloudWatch off by default. Added feature for enabling this feature in create instance call.
From: Michal Fojtik <mf...@redhat.com>
---
server/lib/deltacloud/base_driver/features.rb | 7 +++++++
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 6 ++++--
server/lib/deltacloud/models/instance.rb | 1 +
server/views/instances/new.html.haml | 5 +++++
server/views/instances/show.xml.haml | 3 +++
5 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index de055de..feb108e 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -185,5 +185,12 @@ module Deltacloud
end
end
+ declare_feature :instances, :monitoring do
+ description "Enable instance monitoring if backend cloud provider supports it"
+ operation :create do
+ param :monitoring, :string, :optional
+ end
+ end
+
end
end
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index a7a9dbb..10cdae0 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -34,6 +34,7 @@ class EC2Driver < Deltacloud::BaseDriver
feature :instances, :user_data
feature :instances, :authentication_key
feature :instances, :security_group
+ feature :instances, :monitoring
feature :images, :owner_id
feature :buckets, :bucket_location
feature :instances, :register_to_load_balancer
@@ -181,7 +182,7 @@ class EC2Driver < Deltacloud::BaseDriver
:user_data => opts[:user_data],
:key_name => opts[:keyname],
:availability_zone => realm_id,
- :monitoring_enabled => true,
+ :monitoring_enabled => (opts[:monitoring] && opts[:monitoring].eql?('true')),
:instance_type => hwp.name,
:disable_api_termination => false,
:instance_initiated_shutdown_behavior => 'terminate',
@@ -597,7 +598,8 @@ class EC2Driver < Deltacloud::BaseDriver
:instance_profile =>InstanceProfile.new(hwp_name),
:actions=>instance_actions_for( state ),
:keyname => ec2_instance['keyName'],
- :launch_time => ec2_instance['launchTime']
+ :launch_time => ec2_instance['launchTime'],
+ :monitoring => ec2_instance['monitoring']['state'].eql?('enabled')
} )
instance.authn_error = "Key not set for instance" unless ec2_instance['keyName']
return instance
diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
index 1beb034..d9b9e57 100644
--- a/server/lib/deltacloud/models/instance.rb
+++ b/server/lib/deltacloud/models/instance.rb
@@ -30,6 +30,7 @@ class Instance < BaseModel
attr_accessor :instance_profile
attr_accessor :launch_time
attr_accessor :keyname
+ attr_accessor :monitoring
attr_accessor :authn_error
def initialize(init=nil)
diff --git a/server/views/instances/new.html.haml b/server/views/instances/new.html.haml
index 558582d..ce071c3 100644
--- a/server/views/instances/new.html.haml
+++ b/server/views/instances/new.html.haml
@@ -22,6 +22,11 @@
%label
Instance Keyname:
%input{:name => 'keyname', :size => 30 }
+ - if driver_has_feature?(:monitoring)
+ %p
+ %label
+ Enable monitoring ?
+ %input{ :type => :checkbox, :name => :monitoring, :value => "true" }
- if !@hardware_profiles.empty?
%h3 What size machine?
- for hwp in @hardware_profiles
diff --git a/server/views/instances/show.xml.haml b/server/views/instances/show.xml.haml
index c31a215..373b203 100644
--- a/server/views/instances/show.xml.haml
+++ b/server/views/instances/show.xml.haml
@@ -34,6 +34,9 @@
- @instance.private_addresses.each do |address|
%address<
=address
+ - if driver_has_feature?(:monitoring)
+ %monitoring<
+ =@instance.monitoring ? "enabled" : "disabled"
- if driver_has_auth_features?
%authentication{ :type => driver_auth_feature_name }
- if @instance.authn_feature_failed?
--
1.7.3.2