Sha256: d9c14fb09a47bd4a5648ba20615a98caa9e31947e18449ec81230d4683106fec
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
module Rudy::AWS module EC2 class Zone < Storable field :name field :region field :state def liner_note "%-10s %9s %s" % [self.name, self.region, self.state] end def to_s(titles=false) str = titles ? "%-20s %s#{$/}" % ['name', 'region', 'state'] : "" str << liner_note end end module Zones include Rudy::AWS::EC2 # important! include, extend self # then extend def list(*names) zones = list_as_hash(names) zones &&= zones.values zones end def list_as_hash(*names) names = names.flatten zlist = @@ec2.describe_availability_zones(:zone_name => names) return unless zlist['availabilityZoneInfo'].is_a?(Hash) zones = {} zlist['availabilityZoneInfo']['item'].each do |zhash| zon = Zones.from_hash(zhash) zones[zon.name] = zon end zones = nil if zones.empty? zones end def self.from_hash(h) zone = Rudy::AWS::EC2::Zone.new zone.name = h['zoneName'] zone.region = h['regionName'] zone.state = h['zoneState'] zone end def any? zones = list || [] !zones.empty? end def get(name) zones = list(name) || [] return if zones.empty? zones.first end def zone?(name) begin kp = get(name) kp.is_a?(Rudy::AWS::EC2::Zone) rescue => ex false end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
solutious-rudy-0.9.0 | lib/rudy/aws/ec2/zone.rb |
solutious-rudy-0.9.1 | lib/rudy/aws/ec2/zone.rb |
rudy-0.9.0 | lib/rudy/aws/ec2/zone.rb |
rudy-0.9.1 | lib/rudy/aws/ec2/zone.rb |