5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/mccloud/provider/aws/provider/old_status.rb', line 5
def status(selection=nil,options=nil)
unless options.verbose?
filter=@environment.config.mccloud.filter
puts "Using Filter: #{filter}"
else
filter=""
end
regions=["us-east-1","eu-west-1"]
puts
puts "Stack(s)"
regions.each do |region|
cf = Fog::AWS::CloudFormation.new(:region => region)
cf.describe_stacks.body["Stacks"].each do |stack|
name="#{stack['StackName']}"
stackfilter=filter.gsub(/-/,'')
if name.start_with?(stackfilter)
short_name=stack['StackName'].dup
short_name[stackfilter]=""
puts "[#{short_name}] - #{stack['StackStatus']}"
printf " %-25s %-30s %-30s %-20s %-15s\n", "Timestamp", "Resource Type", "LogicalResourceId", "ResourceStatus","ResourceStatusReaon"
120.times { |i| printf "=" } ; puts
events = cf.describe_stack_events("#{stack['StackName']}").body['StackEvents']
sorted_events=events.reverse
sorted_events.each do |event|
printf " %-25s %-30s %-30s %-20s %-15s\n", event['Timestamp'],event['ResourceType'],event['LogicalResourceId'], event['ResourceStatus'],event['ResourceStatusReason']
end
puts
puts " Outputs:"
stack['Outputs'].each do |output|
puts " - #{output['OutputKey']}: #{output['OutputValue']}"
end
puts
end
end
end
puts
puts "Server(s)"
printf "%-10s %-12s %-20s %-15s %-8s\n", "Name", "Instance Id", "IP", "Type","Status"
80.times { |i| printf "=" } ; puts
@raw_provider.servers.each do |vm|
name="<no name set>"
if !vm.tags["Name"].nil?
name=vm.tags["Name"].strip
end
if name.start_with?(filter)
unless filter==""
name[filter]=""
printf "%-10s %-12s %-20s %-20s %-15s %-8s\n",name,vm.id, vm.public_ip_address, vm.private_ip_address,vm.flavor.name,vm.state
else
puts "Name: #{name}"
puts "Instance Id: #{vm.id}"
puts "Public Ip: #{vm.public_ip_address}"
puts "Flavor: #{vm.flavor.name}"
puts "State: #{vm.state}"
80.times { |i| printf "=" } ; puts
end
end
end
puts
puts "Images:"
80.times { |i| printf "=" } ; puts
images_list=@raw_provider.images.all({"Owner" => "self"})
images_list.each do |image|
printf "%-10s %-10s %-10s %-20s\n",image.id,image.name.gsub(/"#{filter}"/,''),image.state, image.description[0..20]
end
puts
puts "Loadbalancers:"
80.times { |i| printf "=" } ; puts
@environment.config.lbs.each do |name,lb|
puts "[#{name}] #{lb.instance.dns_name}"
puts "[#{name}] - In service: #{lb.instance.instances_in_service}"
puts "[#{name}] - Out service: #{lb.instance.instances_out_of_service}"
end
puts
puts "Ips:"
80.times { |i| printf "=" } ; puts
@environment.config.ips.each do |name,ip|
puts "This needs some work! "
end
end
|