Class: Rudy::AWS::EC2::Zones
- Inherits:
-
Object
- Object
- Rudy::AWS::EC2::Zones
show all
- Includes:
- Base, ObjectBase
- Defined in:
- lib/rudy/aws/ec2/zone.rb
Instance Attribute Summary
Attributes included from Base
#ec2
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#initialize
Methods included from Huxtable
change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Class Method Details
.from_hash(h) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/rudy/aws/ec2/zone.rb', line 44
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
|
Instance Method Details
#any? ⇒ Boolean
52
53
54
55
|
# File 'lib/rudy/aws/ec2/zone.rb', line 52
def any?
zones = list || []
!zones.empty?
end
|
#get(name) ⇒ Object
57
58
59
60
61
|
# File 'lib/rudy/aws/ec2/zone.rb', line 57
def get(name)
zones = list(name) || []
return if zones.empty?
zones.first
end
|
#list(*names) ⇒ Object
26
27
28
29
30
|
# File 'lib/rudy/aws/ec2/zone.rb', line 26
def list(*names)
zones = list_as_hash(names)
zones &&= zones.values
zones
end
|
#list_as_hash(*names) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rudy/aws/ec2/zone.rb', line 32
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
end
|
#zone?(name) ⇒ Boolean
63
64
65
66
67
68
69
70
|
# File 'lib/rudy/aws/ec2/zone.rb', line 63
def zone?(name)
begin
kp = get(name)
kp.is_a?(Rudy::AWS::EC2::Zone)
rescue => ex
false
end
end
|