Class: Breeze::Describe

Inherits:
Veur
  • Object
show all
Defined in:
lib/breeze/tasks/describe.rb

Instance Method Summary collapse

Methods inherited from Veur

inherited

Instance Method Details

#addressesObject



38
39
40
41
42
# File 'lib/breeze/tasks/describe.rb', line 38

def addresses
  report "ALLOCATED IP ADDRESSES",
    ['Address', 'Server'],
    fog.addresses.map{ |a| [a.public_ip, a.server_id] }
end

#cache_clustersObject



78
79
80
81
82
83
# File 'lib/breeze/tasks/describe.rb', line 78

def cache_clusters
  report 'CACHE CLUSTERS',
    ['Name', 'Type', 'Engine', 'Nodes', 'Status'],
    elasticache.clusters.map{ |c| [c.id, c.node_type, c.engine, c.num_nodes, c.status] }
    # c.nodes[0]['Address']
end

#cloud_resourcesObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/breeze/tasks/describe.rb', line 8

def cloud_resources
  images
  servers
  addresses
  volumes
  db_servers
  dns_zones
  cache_clusters
  load_balancers
end

#db_serversObject



54
55
56
57
58
# File 'lib/breeze/tasks/describe.rb', line 54

def db_servers
  report "DATABASE SERVERS",
    ['Name', 'Type', 'Storage', 'State', 'Endpoint'],
    rds.servers.map{ |s| [s.id, s.flavor_id, s.allocated_storage, s.state, s.endpoint] }
end

#dns_records(zone_id) ⇒ Object



70
71
72
73
74
75
# File 'lib/breeze/tasks/describe.rb', line 70

def dns_records(zone_id)
  zone = dns.zones.get(zone_id)
  report "DNS RECORDS FOR #{zone.domain}",
    ['Name', 'Type', 'TTL', 'Value'],
    zone.records.map{ |r| [r.name, r.type, r.ttl, r.ip.join(', ')] }
end

#dns_zonesObject



61
62
63
64
65
66
67
# File 'lib/breeze/tasks/describe.rb', line 61

def dns_zones
  zones = dns.zones
  zones.each(&:reload) # necessary in order to get nameservers
  report "DNS ZONES",
    ['Domain', 'Zone ID', 'Name servers'],
    zones.map{ |z| [z.domain, z.id, z.nameservers.join(', ')] }
end

#imagesObject



20
21
22
23
24
25
26
# File 'lib/breeze/tasks/describe.rb', line 20

def images
  report 'MACHINE IMAGES',
    ['Name or Location', 'Image ID', 'Owner', 'Image Type', 'Public'],
    fog.images.all('Owner' => Breeze::CONFIGURATION[:image_owner]).map{ |i|
      [i.display_name, i.id, i.owner_id, i.full_type, i.is_public]
    }
end

#load_balancersObject



86
87
88
89
90
# File 'lib/breeze/tasks/describe.rb', line 86

def load_balancers
  report 'ELASTIC LOAD BALANCERS',
    ['Name', 'DNS name', 'Availability zones', 'Instances'],
    elb.load_balancers.map{ |lb| [lb.id, lb.dns_name, lb.availability_zones.join(', '), lb.instances.join(', ')] }
end

#serversObject



29
30
31
32
33
34
35
# File 'lib/breeze/tasks/describe.rb', line 29

def servers
  report "SERVER INSTANCES",
    ['Name', 'Instance ID', 'IP Address', 'Image ID', 'Type', 'Zone', 'State', 'Info'],
    fog.servers.map { |i|
      [i.name, i.id, i.public_ip_address, i.image_id, i.flavor_id, i.availability_zone, i.state, i.breeze_state]
    }
end

#volumesObject



45
46
47
48
49
50
51
# File 'lib/breeze/tasks/describe.rb', line 45

def volumes
  report "VOLUMES",
    ['Volume ID', 'Size', 'Status', 'Zone', 'Snapshot ID', 'Used by'],
    fog.volumes.map { |v|
      [v.id, v.size, v.state, v.availability_zone, v.snapshot_id, v.server_id]
    }
end