rs-api-tools 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rs-create-alerts +105 -0
- data/bin/rs-destroy-deployment +0 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c854b79a460b0c432cd8bbfb7e260fd630ecafa
|
4
|
+
data.tar.gz: db3e2c9037c24a6f96452324690b50c5c27c60a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6004ac7c3848bf1ca5b75f3889588d98a1a3b5a0f1edaf99285f29a38532297a31aa469f3174e6d9a105efffcfbd1f282d7b34187753765fb06c3dd98ef6d9f
|
7
|
+
data.tar.gz: 62fb5384c226a47b2041e40182dca7fb5c06e8db61072d18f8ebd61f08200e97fd1d4a0e174639b7e888f7b99ad1a7ebbb298237417ea8770e9a36e6f619318a
|
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
4
|
+
|
5
|
+
def usage
|
6
|
+
puts "usage: rs-create-alerts [--resource <resource_type>] [--id <resource_id>] [--metadata <metadata_source>] [[--help]]"
|
7
|
+
puts ''
|
8
|
+
puts "Where --resource can be of value ServerTemplate, Server, ServerArray, or Instance; and --id is the ID of that resource type."
|
9
|
+
puts "See rs-create-alerts --help for more information on usage."
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help_info
|
17
|
+
puts("#{$0}")
|
18
|
+
puts ''
|
19
|
+
puts "Creates multiple alerts (alert specifications) on a RightScale resource."
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-create-alerts --resource ServerTemplate --id 323981001 --metadata my_alerts.yaml"
|
22
|
+
puts " rs-create-alerts --resource ServerTemplate --id 324506003 --metadata https://raw.github.com/rightscale-meta/alerts/master/rightscale_default_alerts.yaml"
|
23
|
+
puts " rs-create-alerts --resource ServerArray --id 225572003 --metadata https://raw.github.com/rightscale-meta/alerts/master/rightscale_default_alerts.yaml"
|
24
|
+
puts ''
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'rubygems'
|
28
|
+
require 'getoptlong'
|
29
|
+
|
30
|
+
resource_type = false
|
31
|
+
resource_id = false
|
32
|
+
metadata_source = false
|
33
|
+
verbose = false
|
34
|
+
dry = false
|
35
|
+
debug = false
|
36
|
+
help = false
|
37
|
+
|
38
|
+
opts = GetoptLong.new(
|
39
|
+
[ '--resource', '-r', GetoptLong::REQUIRED_ARGUMENT ],
|
40
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
41
|
+
[ '--metadata', '-m', GetoptLong::REQUIRED_ARGUMENT ],
|
42
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
|
43
|
+
[ '--debug', '-D', GetoptLong::OPTIONAL_ARGUMENT ],
|
44
|
+
[ '--dry', GetoptLong::OPTIONAL_ARGUMENT ],
|
45
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
46
|
+
)
|
47
|
+
|
48
|
+
opts.each do |opt, arg|
|
49
|
+
case opt
|
50
|
+
when '--id'
|
51
|
+
resource_id = arg
|
52
|
+
when '--resource'
|
53
|
+
resource_type = arg
|
54
|
+
when '--metadata'
|
55
|
+
metadata_source = arg
|
56
|
+
when '--help'
|
57
|
+
help = true
|
58
|
+
when '--verbose'
|
59
|
+
verbose = true
|
60
|
+
when '--debug'
|
61
|
+
debug = true
|
62
|
+
when '--dry'
|
63
|
+
dry = true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if help
|
68
|
+
help_info
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
72
|
+
usage_exit if !(metadata_source && resource_type && resource_id)
|
73
|
+
|
74
|
+
alert_spec = Hash.new
|
75
|
+
alert_spec['escalation_name'] = 'warning'
|
76
|
+
alert_spec['subject_href'] = 'ServerTemplate'
|
77
|
+
|
78
|
+
case resource_type
|
79
|
+
when 'ServerTemplate'
|
80
|
+
alert_spec['subject_href'] = "/api/server_templates/#{resource_id}"
|
81
|
+
when 'Server'
|
82
|
+
alert_spec['subject_href'] = "/api/servers/#{resource_id}"
|
83
|
+
when 'ServerArray'
|
84
|
+
alert_spec['subject_href'] = "/api/server_arrays/#{resource_id}"
|
85
|
+
when 'Instance'
|
86
|
+
alert_spec['subject_href'] = "/api/instances/#{resource_id}"
|
87
|
+
end
|
88
|
+
|
89
|
+
puts "metadata source: #{metadata_source}" if debug
|
90
|
+
|
91
|
+
require 'rightscale_metadata'
|
92
|
+
alerts = RightScaleMetadata.new(metadata_source).metadata['alerts']
|
93
|
+
|
94
|
+
require 'yaml'
|
95
|
+
require 'right_api_client'
|
96
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
97
|
+
|
98
|
+
alerts.each { |alert|
|
99
|
+
alert_spec.merge!(alert)
|
100
|
+
alert_spec['variable'] = alert['value']
|
101
|
+
alert_spec['description'] = alert_spec['name'] unless alert_spec['description'] # ui allows blank desc!
|
102
|
+
puts "alert_spec: #{alert_spec}" if (verbose||debug)
|
103
|
+
alert = rightscale.alert_specs.create({ :alert_spec => alert_spec })
|
104
|
+
puts "Created alert, #{alert.href}."
|
105
|
+
}
|
data/bin/rs-destroy-deployment
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rs-api-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Fordham
|
@@ -134,6 +134,7 @@ executables:
|
|
134
134
|
- rs-describe-server
|
135
135
|
- rs-create-alert-spec
|
136
136
|
- rs-clone-rightscript
|
137
|
+
- rs-create-alerts
|
137
138
|
- rs-relaunch-server
|
138
139
|
- rs-update-input
|
139
140
|
- rs-lock-server
|
@@ -213,6 +214,7 @@ files:
|
|
213
214
|
- bin/rs-describe-server
|
214
215
|
- bin/rs-create-alert-spec
|
215
216
|
- bin/rs-clone-rightscript
|
217
|
+
- bin/rs-create-alerts
|
216
218
|
- bin/rs-relaunch-server
|
217
219
|
- bin/rs-update-input
|
218
220
|
- bin/rs-lock-server
|