lib/ec2/host/host_data.rb in ec2-host-0.5.3 vs lib/ec2/host/host_data.rb in ec2-host-0.5.4

- old
+ new

@@ -73,20 +73,24 @@ def monitoring instance.monitoring.state end + def placement + instance.placement + end + def availability_zone instance.placement.availability_zone end - def spot? - instance.instance_lifecycle == 'spot' + def tenancy + instance.placement.tenancy end - def dedicated? - instance.placement.tenancy == 'dedicated' + def instance_lifecycle + instance.instance_lifecycle end # compatibility with dino-host def ip private_ip_address @@ -112,11 +116,11 @@ def stopping? state == "stopping" end - def stopped + def stopped? state == "stopped" end def running? state == "running" @@ -124,10 +128,20 @@ def pending? state == "pending" end + def spot? + instance_lifecycle == 'spot' + end + alias :spot :spot? + + def dedicated? + tenancy == 'dedicated' + end + alias :dedicated :dedicated? + # match with condition or not # # @param [Hash] condition search parameters def match?(condition) return false if !condition[:state] and (terminated? or shutting_down?) @@ -157,11 +171,11 @@ "private_ip_address" => private_ip_address, "public_ip_address" => public_ip_address, "launch_time" => launch_time, "state" => state, "monitoring" => monitoring, - "spot" => spot?, + "spot" => spot, ) end def info if self.class.display_short_info? @@ -198,9 +212,10 @@ else parts = 1.upto(Config.role_max_depth).map do |i| (condition["role#{i}".to_sym] || condition["usage#{i}".to_sym] || []).first end end + return true if parts.compact.empty? # no role conditions roles.find {|role| role.match?(*parts) } end def instance_match?(condition) excepts = [:role, :usage]