rs-api-tools 0.0.6 → 0.0.7
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-bind-executable +69 -0
- data/bin/rs-create-alert +115 -0
- data/bin/rs-create-repositories +2 -1
- data/bin/rs-create-servertemplate +123 -4
- data/bin/rs-create-servertemplate-mci +83 -0
- data/bin/rs-describe-alert-specs +47 -0
- data/bin/rs-describe-cookbook +59 -0
- data/bin/rs-describe-cookbooks +77 -0
- data/bin/rs-describe-executables +62 -0
- data/bin/rs-tag-resource +70 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 161db150553634be65ed9f4de24df6d5b07092cd
|
4
|
+
data.tar.gz: 7d192e04dd3b832f5c648dc2316543bd5de39959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80ad41209b5df61065ce169bfa5d4ea3c342fffc3bf362b2b79fdea4f87460005c96014c02bba78cda3b511858c7afec8a4668ab5a77f54878e425ccf3328468
|
7
|
+
data.tar.gz: 59918458030876a61230272eb8a71024bedcd42dbea20690a6e715e8de427012476e221896c5ed4622c5c9d2c8720b51906003d0f1a9b77aa30637d40ea3948d
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-bind-executable
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("usage: rs-bind-executable [--id <server_template_id>] --recipe <recipe_name>]")
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help
|
17
|
+
usage
|
18
|
+
puts ''
|
19
|
+
puts "Binds an executable (Chef recipe or RightScript) to a ServerTemplate."
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-bind-executable --id 324481001 --recipe 'postfix'"
|
22
|
+
puts ''
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts = GetoptLong.new(
|
27
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
+
[ '--recipe', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
|
29
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
30
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
|
31
|
+
[ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
|
32
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
|
33
|
+
)
|
34
|
+
|
35
|
+
server_template_id = false
|
36
|
+
|
37
|
+
runnable_binding = Hash.new
|
38
|
+
#runnable_binding[position] =
|
39
|
+
runnable_binding['recipe'] = false
|
40
|
+
#runnable_binding[right_script_href]
|
41
|
+
runnable_binding['sequence'] = 'boot'
|
42
|
+
|
43
|
+
show_help = false
|
44
|
+
verbose = false
|
45
|
+
|
46
|
+
opts.each do |opt, arg|
|
47
|
+
case opt
|
48
|
+
when '--id'
|
49
|
+
server_template_id = arg
|
50
|
+
when '--recipe'
|
51
|
+
runnable_binding['recipe'] = arg
|
52
|
+
when '--help'
|
53
|
+
show_help = true
|
54
|
+
when '--verbose'
|
55
|
+
verbose = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
help if show_help
|
60
|
+
|
61
|
+
require 'json'
|
62
|
+
require 'yaml'
|
63
|
+
require 'right_api_client'
|
64
|
+
|
65
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
66
|
+
|
67
|
+
runnable_binding = rightscale.server_templates(:id => server_template_id).show.runnable_bindings.create({ 'runnable_binding' => runnable_binding })
|
68
|
+
|
69
|
+
puts "Executable binded, #{runnable_binding.href}."
|
data/bin/rs-create-alert
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
def usage
|
4
|
+
puts "usage: rs-create-alert [--resource <resource_type>] [--id <resource_id>] [--name <alert_name>] [--description <alert_description>] [--file <alert_file>] [--value <alert_value] [--condition <alert_condition] [[--help]]"
|
5
|
+
puts ''
|
6
|
+
puts "Where --resource can be of value ServerTemplate, Server, ServerArray, or Instance; and --id is the ID of that resource type."
|
7
|
+
puts "See rs-create-alert --help for more information on usage."
|
8
|
+
end
|
9
|
+
|
10
|
+
def usage_exit
|
11
|
+
usage; exit
|
12
|
+
end
|
13
|
+
|
14
|
+
def help_info
|
15
|
+
puts("#{$0}")
|
16
|
+
puts ''
|
17
|
+
puts "Creates an alert (specification) on a RightScale resource."
|
18
|
+
puts ''
|
19
|
+
puts "examples: rs-create-alert --resource ServerTemplate --id 323981001 --name 'cpu busy' --file 'cpu-0/cpu-idle' --value 'value' --condition '<' --threshold '15' --duration 3 --escalation 'warning' --verbose"
|
20
|
+
puts ''
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rubygems'
|
24
|
+
require 'getoptlong'
|
25
|
+
|
26
|
+
resource_type = false
|
27
|
+
resource_id = false
|
28
|
+
|
29
|
+
alert_spec = Hash.new
|
30
|
+
alert_spec['description'] = false
|
31
|
+
alert_spec['escalation_name'] = 'warning'
|
32
|
+
alert_spec['subject_href'] = 'ServerTemplate'
|
33
|
+
#alert_spec['vote_tag'] = false
|
34
|
+
#alert_spec['vote_type'] = false
|
35
|
+
|
36
|
+
verbose = false
|
37
|
+
dry = false
|
38
|
+
debug = false
|
39
|
+
help = false
|
40
|
+
|
41
|
+
opts = GetoptLong.new(
|
42
|
+
[ '--resource', '-r', GetoptLong::REQUIRED_ARGUMENT ],
|
43
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
44
|
+
[ '--name', '-n', GetoptLong::REQUIRED_ARGUMENT ],
|
45
|
+
[ '--description', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
|
46
|
+
[ '--file', '-f', GetoptLong::REQUIRED_ARGUMENT ],
|
47
|
+
[ '--value', GetoptLong::REQUIRED_ARGUMENT],
|
48
|
+
[ '--condition', GetoptLong::REQUIRED_ARGUMENT],
|
49
|
+
[ '--threshold', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
50
|
+
[ '--duration', GetoptLong::REQUIRED_ARGUMENT],
|
51
|
+
[ '--escalation', '-e', GetoptLong::OPTIONAL_ARGUMENT],
|
52
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
|
53
|
+
[ '--debug', '-D', GetoptLong::OPTIONAL_ARGUMENT ],
|
54
|
+
[ '--dry', GetoptLong::OPTIONAL_ARGUMENT ],
|
55
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
56
|
+
)
|
57
|
+
|
58
|
+
opts.each do |opt, arg|
|
59
|
+
case opt
|
60
|
+
when '--id'
|
61
|
+
resource_id = arg
|
62
|
+
when '--resource'
|
63
|
+
resource_type = arg
|
64
|
+
when '--name'
|
65
|
+
alert_spec['name'] = arg
|
66
|
+
when '--description'
|
67
|
+
alert_spec['description'] = arg
|
68
|
+
when '--file'
|
69
|
+
alert_spec['file'] = arg
|
70
|
+
when '--value'
|
71
|
+
alert_spec['variable'] = arg
|
72
|
+
when '--condition'
|
73
|
+
alert_spec['condition'] = arg
|
74
|
+
when '--threshold'
|
75
|
+
alert_spec['threshold'] = arg
|
76
|
+
when '--duration'
|
77
|
+
alert_spec['duration'] = arg
|
78
|
+
when '--escalation'
|
79
|
+
alert_spec['escalation_name'] = arg
|
80
|
+
when '--help'
|
81
|
+
help = true
|
82
|
+
when '--verbose'
|
83
|
+
verbose = true
|
84
|
+
when '--debug'
|
85
|
+
debug = true
|
86
|
+
when '--dry'
|
87
|
+
dry = true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if help
|
92
|
+
help_info
|
93
|
+
exit
|
94
|
+
end
|
95
|
+
|
96
|
+
case resource_type
|
97
|
+
when 'ServerTemplate'
|
98
|
+
alert_spec['subject_href'] = "/api/server_templates/#{resource_id}"
|
99
|
+
when 'Server'
|
100
|
+
alert_spec['subject_href'] = "/api/servers/#{resource_id}"
|
101
|
+
when 'ServerArray'
|
102
|
+
alert_spec['subject_href'] = "/api/server_arrays/#{resource_id}"
|
103
|
+
when 'Instance'
|
104
|
+
alert_spec['subject_href'] = "/api/instances/#{resource_id}"
|
105
|
+
end
|
106
|
+
|
107
|
+
require 'yaml'
|
108
|
+
require 'right_api_client'
|
109
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
110
|
+
|
111
|
+
puts "alert_spec: #{alert_spec}" if (verbose||debug)
|
112
|
+
|
113
|
+
alert = rightscale.alert_specs.create({ :alert_spec => alert_spec })
|
114
|
+
|
115
|
+
puts "Created alert, #{alert.href}."
|
data/bin/rs-create-repositories
CHANGED
@@ -114,7 +114,8 @@ library.cookbooks.each { |cookbook|
|
|
114
114
|
|
115
115
|
if existing_repos.count > 0
|
116
116
|
puts "Found #{existing_repos.count} repositories." if verbose
|
117
|
-
existing_repos.each { |repo|
|
117
|
+
existing_repos.each { |repo|
|
118
|
+
puts "#{repository['name']} exists."
|
118
119
|
puts repo.raw if verbose
|
119
120
|
puts "==> Delete repository [#{repo.id}] ? (y/n)"
|
120
121
|
delete_repo = yesno
|
@@ -16,6 +16,7 @@ def help_info
|
|
16
16
|
puts "Creates a RightScale ServerTemplate."
|
17
17
|
puts ''
|
18
18
|
puts "examples: rs-create-servertemplate --name 'Skynet Terminator Terminator' --description 'Ends all Skynet terminators.'"
|
19
|
+
puts " rs-create-servertemplate --metadata rightscale.yaml"
|
19
20
|
puts ''
|
20
21
|
end
|
21
22
|
|
@@ -26,13 +27,19 @@ server_template = Hash.new
|
|
26
27
|
server_template['name'] = false
|
27
28
|
server_template['description'] = ''
|
28
29
|
|
30
|
+
metadata = false
|
29
31
|
verbose = false
|
32
|
+
dry = false
|
33
|
+
debug = false
|
30
34
|
help = false
|
31
35
|
|
32
36
|
opts = GetoptLong.new(
|
33
|
-
[ '--name', '-
|
34
|
-
[ '--description', '-
|
37
|
+
[ '--name', '-n', GetoptLong::REQUIRED_ARGUMENT ],
|
38
|
+
[ '--description', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
|
39
|
+
[ '--metadata', '-m', GetoptLong::OPTIONAL_ARGUMENT],
|
35
40
|
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
|
41
|
+
[ '--debug', '-D', GetoptLong::OPTIONAL_ARGUMENT ],
|
42
|
+
[ '--dry', GetoptLong::OPTIONAL_ARGUMENT ],
|
36
43
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
37
44
|
)
|
38
45
|
|
@@ -42,10 +49,16 @@ opts.each do |opt, arg|
|
|
42
49
|
server_template['name'] = arg
|
43
50
|
when '--description'
|
44
51
|
server_template['description'] = arg
|
52
|
+
when '--metadata'
|
53
|
+
metadata = arg
|
45
54
|
when '--help'
|
46
55
|
help = true
|
47
56
|
when '--verbose'
|
48
57
|
verbose = true
|
58
|
+
when '--debug'
|
59
|
+
debug = true
|
60
|
+
when '--dry'
|
61
|
+
dry = true
|
49
62
|
end
|
50
63
|
end
|
51
64
|
|
@@ -54,11 +67,117 @@ if help
|
|
54
67
|
exit
|
55
68
|
end
|
56
69
|
|
57
|
-
usage_exit if !(server_template['name'])
|
70
|
+
usage_exit if !(server_template['name'] || metadata)
|
71
|
+
|
72
|
+
def yesno
|
73
|
+
begin
|
74
|
+
system("stty raw -echo")
|
75
|
+
str = STDIN.getc
|
76
|
+
ensure
|
77
|
+
system("stty -raw echo")
|
78
|
+
end
|
79
|
+
if str.downcase == "y"
|
80
|
+
return true
|
81
|
+
elsif str.downcase == "n"
|
82
|
+
return false
|
83
|
+
else
|
84
|
+
raise "Invalid response. Please enter y/n."
|
85
|
+
end
|
86
|
+
end
|
58
87
|
|
59
88
|
require 'yaml'
|
60
89
|
require 'right_api_client'
|
61
90
|
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
62
91
|
|
92
|
+
# creation via supply of metadata file
|
93
|
+
if metadata
|
94
|
+
require 'net/http'
|
95
|
+
require 'uri'
|
96
|
+
require 'yaml'
|
97
|
+
|
98
|
+
uri = URI.parse(metadata)
|
99
|
+
if %w( http https ).include?(uri.scheme)
|
100
|
+
metadata = YAML.parse(Net::HTTP.get(uri))
|
101
|
+
else
|
102
|
+
metadata = YAML.load_file(metadata)
|
103
|
+
end
|
104
|
+
|
105
|
+
server_template = metadata['server_template']
|
106
|
+
end
|
107
|
+
|
63
108
|
puts "Creating ServerTemplate, '#{server_template['name']}'."
|
64
|
-
|
109
|
+
puts server_template if verbose
|
110
|
+
if dry
|
111
|
+
puts 'Dry run, skipping creation of ServerTemplate'
|
112
|
+
else
|
113
|
+
st = rightscale.server_templates.create({ :server_template => server_template })
|
114
|
+
puts "Success, resource href: #{st.href}."
|
115
|
+
end
|
116
|
+
|
117
|
+
if metadata
|
118
|
+
# add tags to server_template
|
119
|
+
server_template['tags'].each { |tag|
|
120
|
+
system("rs-tag-resource --href #{st.href} --tag '#{tag}'")
|
121
|
+
}
|
122
|
+
|
123
|
+
# import multi-cloud images (if needed), and
|
124
|
+
# add multi-cloud images to server_template
|
125
|
+
server_template['multi_cloud_images'].each { |mci|
|
126
|
+
make_default = ''
|
127
|
+
puts "Import published MCI, #{mci['publication_id']} ? (y/n)"
|
128
|
+
import_mci = yesno
|
129
|
+
system("rs-import-publication --id #{mci['publication_id']}") if mci['publication_id'] if import_mci
|
130
|
+
if mci['id']
|
131
|
+
if mci['default']
|
132
|
+
make_default = ' --default'
|
133
|
+
end
|
134
|
+
system("rs-create-servertemplate-mci --servertemplate #{st.href.split('/')[-1]} --mci #{mci['id']}#{make_default}")
|
135
|
+
end
|
136
|
+
}
|
137
|
+
|
138
|
+
# create cookbook repositories/import cookbooks
|
139
|
+
puts 'Do you need to create the Chef repositories ? (y/n)'
|
140
|
+
create_repos = yesno
|
141
|
+
if create_repos
|
142
|
+
if server_template['cookbooks'] == 'Cheffile'
|
143
|
+
puts 'Setting up repositories from Cheffile.'
|
144
|
+
system("rs-create-repositories --cheffile #{Dir.pwd}/Cheffile")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'librarian_chef_dsl_parser'))
|
149
|
+
library = LibrarianChefDSLParser.new("#{Dir.pwd}/Cheffile")
|
150
|
+
|
151
|
+
cookbook_hrefs = Array.new
|
152
|
+
library.cookbooks.each { |cookbook|
|
153
|
+
filter = Array.new
|
154
|
+
filter.push("name==#{cookbook['name']}")
|
155
|
+
filter.push("namespace==primary")
|
156
|
+
cookbooks = rightscale.cookbooks.index(:filter => filter).select{ |c|
|
157
|
+
c.raw['source_info_summary'] == "#{cookbook['name']} #{cookbook['options'][:ref]}"
|
158
|
+
}
|
159
|
+
puts cookbooks.first if debug
|
160
|
+
cookbook_hrefs.push(cookbooks.first.href)
|
161
|
+
}
|
162
|
+
puts "cookbook hrefs: #{cookbook_hrefs}"
|
163
|
+
# TODO: multi_attach
|
164
|
+
cookbook_hrefs.each { |href|
|
165
|
+
rightscale.server_templates(:id => st.href.split('/')[-1]).show.cookbook_attachments.create({ 'cookbook_attachment' => { 'cookbook_href' => "#{href}" }})
|
166
|
+
}
|
167
|
+
|
168
|
+
# bind executables
|
169
|
+
if server_template['boot_scripts'] == 'node.json'
|
170
|
+
require 'json'
|
171
|
+
recipes = JSON.parse(IO.read("#{Dir.pwd}/node.json"))['run_list'].map {|s| s.gsub('recipe[', '').gsub(']', '')}
|
172
|
+
recipes.each { |recipe|
|
173
|
+
"Adding recipe, '#{recipe}' to boot scripts."
|
174
|
+
system("rs-bind-executable --id #{st.href.split('/')[-1]} --recipe #{recipe}")
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
# add alerts
|
179
|
+
server_template['alerts'].each { |alert|
|
180
|
+
system("rs-create-alert --resource ServerTemplate --id #{st.href.split('/')[-1]} --name '#{alert['name']}' --file '#{alert['file']}' --value '#{alert['value']}' --condition '#{alert['condition']}' --threshold '#{alert['threshold']}' --duration #{alert['duration']} --escalation '#{alert['escalation_name']}' --verbose")
|
181
|
+
}
|
182
|
+
|
183
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
def usage
|
4
|
+
puts "usage: rs-create-servertemplate-mci [--servertemplate <server_template_id>] [--mci <multi_cloud_image_id>] [[--default]] [[--help]]"
|
5
|
+
puts ''
|
6
|
+
puts "See rs-create-servertemplate-mci --help for more information on usage."
|
7
|
+
end
|
8
|
+
|
9
|
+
def usage_exit
|
10
|
+
usage; exit
|
11
|
+
end
|
12
|
+
|
13
|
+
def help_info
|
14
|
+
puts("#{$0}")
|
15
|
+
puts ''
|
16
|
+
puts "Adds a MultiCloud image to a RightScale ServerTemplate."
|
17
|
+
puts ''
|
18
|
+
puts "examples: rs-create-servertemplate-mci --servertemplate 32392500 --mci 322234001 --default"
|
19
|
+
puts ''
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'getoptlong'
|
24
|
+
|
25
|
+
server_template_multi_cloud_image_params = { "multi_cloud_image_href" => false, "server_template_href" => false }
|
26
|
+
|
27
|
+
default = false
|
28
|
+
verbose = false
|
29
|
+
dry = false
|
30
|
+
debug = false
|
31
|
+
help = false
|
32
|
+
|
33
|
+
opts = GetoptLong.new(
|
34
|
+
[ '--servertemplate', '-t', GetoptLong::REQUIRED_ARGUMENT ],
|
35
|
+
[ '--mci', '-m', GetoptLong::REQUIRED_ARGUMENT ],
|
36
|
+
[ '--default', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
|
37
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
|
38
|
+
[ '--debug', '-D', GetoptLong::OPTIONAL_ARGUMENT ],
|
39
|
+
[ '--dry', GetoptLong::OPTIONAL_ARGUMENT ],
|
40
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
41
|
+
)
|
42
|
+
|
43
|
+
opts.each do |opt, arg|
|
44
|
+
case opt
|
45
|
+
when '--servertemplate'
|
46
|
+
server_template_multi_cloud_image_params['server_template_href'] = "/api/server_templates/#{arg}"
|
47
|
+
when '--mci'
|
48
|
+
server_template_multi_cloud_image_params['multi_cloud_image_href'] = "/api/multi_cloud_images/#{arg}"
|
49
|
+
when '--default'
|
50
|
+
default = true
|
51
|
+
when '--help'
|
52
|
+
help = true
|
53
|
+
when '--verbose'
|
54
|
+
verbose = true
|
55
|
+
when '--debug'
|
56
|
+
debug = true
|
57
|
+
when '--dry'
|
58
|
+
dry = true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if help
|
63
|
+
help_info
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
|
67
|
+
usage_exit if !(server_template_multi_cloud_image_params['server_template_href'] && server_template_multi_cloud_image_params['multi_cloud_image_href'])
|
68
|
+
|
69
|
+
require 'yaml'
|
70
|
+
require 'right_api_client'
|
71
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
72
|
+
|
73
|
+
puts "Adding MCI to ServerTemplate."
|
74
|
+
puts "server_template_multi_cloud_image: #{server_template_multi_cloud_image_params}"
|
75
|
+
|
76
|
+
server_template_multi_cloud_image = rightscale.server_template_multi_cloud_images.create({ :server_template_multi_cloud_image => server_template_multi_cloud_image_params })
|
77
|
+
|
78
|
+
puts "Created #{server_template_multi_cloud_image.href}."
|
79
|
+
|
80
|
+
if default
|
81
|
+
puts "Making #{server_template_multi_cloud_image.href} the default MCI."
|
82
|
+
server_template_multi_cloud_image.make_default
|
83
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-alert-specs
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("#{$0} [--xml] [--json]")
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
opts = GetoptLong.new(
|
14
|
+
[ '--servertemplate', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
|
15
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
16
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
17
|
+
)
|
18
|
+
|
19
|
+
servertemplate = false
|
20
|
+
json = false
|
21
|
+
xml = false
|
22
|
+
|
23
|
+
opts.each do |opt, arg|
|
24
|
+
case opt
|
25
|
+
when '--servertemplate'
|
26
|
+
servertemplate = arg
|
27
|
+
when '--json'
|
28
|
+
json = true
|
29
|
+
when '--xml'
|
30
|
+
xml = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'yaml'
|
35
|
+
require 'right_api_client'
|
36
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
37
|
+
|
38
|
+
if servertemplate
|
39
|
+
puts "Fetching alerts for ServerTemplate, #{servertemplate}."
|
40
|
+
alert_specs = rightscale.server_templates(:id => servertemplate).show.alert_specs.index
|
41
|
+
else
|
42
|
+
alert_specs = rightscale.alert_specs.index
|
43
|
+
end
|
44
|
+
|
45
|
+
alert_specs.each { |spec|
|
46
|
+
puts spec.raw.to_yaml
|
47
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-cookbook [--id <cookbook_id>]
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("usage: rs-describe-cookbook [--id <cookbook_id]")
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help
|
17
|
+
usage
|
18
|
+
puts ''
|
19
|
+
puts "Describes a Chef Cookbook available to a RightScale account."
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-describe-cookbook --id 13950001"
|
22
|
+
puts ''
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts = GetoptLong.new(
|
27
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
29
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
|
30
|
+
[ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
|
31
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
|
32
|
+
)
|
33
|
+
|
34
|
+
cookbook_id = false
|
35
|
+
show_help = false
|
36
|
+
verbose = false
|
37
|
+
|
38
|
+
opts.each do |opt, arg|
|
39
|
+
case opt
|
40
|
+
when '--id'
|
41
|
+
cookbook_id = arg
|
42
|
+
when '--help'
|
43
|
+
show_help = true
|
44
|
+
when '--verbose'
|
45
|
+
verbose = true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
help if show_help
|
50
|
+
|
51
|
+
require 'json'
|
52
|
+
require 'yaml'
|
53
|
+
require 'right_api_client'
|
54
|
+
|
55
|
+
client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
56
|
+
|
57
|
+
cookbook = client.cookbooks(:id => cookbook_id).show.raw
|
58
|
+
|
59
|
+
puts cookbook.to_yaml
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-cookbooks
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("usage: rs-describe-cookbooks")
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help
|
17
|
+
usage
|
18
|
+
puts ''
|
19
|
+
puts "Describes the Chef Cookbooks available to a RightScale account."
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-describe-cookbooks"
|
22
|
+
puts ''
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts = GetoptLong.new(
|
27
|
+
[ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
|
28
|
+
[ '--namespace', '-N', GetoptLong::OPTIONAL_ARGUMENT ],
|
29
|
+
[ '--state', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
|
30
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
31
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
|
32
|
+
[ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
|
33
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
|
34
|
+
)
|
35
|
+
|
36
|
+
name = false
|
37
|
+
namespace = false
|
38
|
+
state = false
|
39
|
+
filter = Array.new
|
40
|
+
show_help = false
|
41
|
+
verbose = false
|
42
|
+
|
43
|
+
opts.each do |opt, arg|
|
44
|
+
case opt
|
45
|
+
when '--name'
|
46
|
+
name = arg
|
47
|
+
filter.push("name==#{name}")
|
48
|
+
when '--namespace'
|
49
|
+
namespace = arg
|
50
|
+
filter.push("namespace==#{namespace}")
|
51
|
+
when '--state'
|
52
|
+
state = arg
|
53
|
+
filter.push("state==#{state}")
|
54
|
+
when '--help'
|
55
|
+
show_help = true
|
56
|
+
when '--verbose'
|
57
|
+
verbose = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
help if show_help
|
62
|
+
|
63
|
+
require 'json'
|
64
|
+
require 'yaml'
|
65
|
+
require 'right_api_client'
|
66
|
+
|
67
|
+
client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
68
|
+
|
69
|
+
puts "filter: #{filter}" if verbose
|
70
|
+
|
71
|
+
cookbooks = client.cookbooks.index(:filter => filter)
|
72
|
+
|
73
|
+
puts "Found #{cookbooks.count} cookbook(s)."
|
74
|
+
|
75
|
+
cookbooks.each { |cookbook|
|
76
|
+
puts cookbook.raw.to_yaml
|
77
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-executables
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("usage: rs-describe-executables [--id <server_template_id>]")
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help
|
17
|
+
usage
|
18
|
+
puts ''
|
19
|
+
puts "Describes the executables bindings of a ServerTemplate."
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-describe-executables --id 40890992002"
|
22
|
+
puts ''
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts = GetoptLong.new(
|
27
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
28
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
29
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
|
30
|
+
[ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
|
31
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
|
32
|
+
)
|
33
|
+
|
34
|
+
server_template_id = false
|
35
|
+
show_help = false
|
36
|
+
verbose = false
|
37
|
+
|
38
|
+
opts.each do |opt, arg|
|
39
|
+
case opt
|
40
|
+
when '--id'
|
41
|
+
server_template_id = arg
|
42
|
+
when '--help'
|
43
|
+
show_help = true
|
44
|
+
when '--verbose'
|
45
|
+
verbose = true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
help if show_help
|
50
|
+
|
51
|
+
require 'json'
|
52
|
+
require 'yaml'
|
53
|
+
require 'right_api_client'
|
54
|
+
|
55
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
56
|
+
|
57
|
+
executables = rightscale.server_templates(:id => server_template_id).show.runnable_bindings.index
|
58
|
+
|
59
|
+
executables.each { |executable|
|
60
|
+
puts executable.raw.to_yaml
|
61
|
+
}
|
62
|
+
|
data/bin/rs-tag-resource
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
def usage
|
4
|
+
puts "usage: rs-tag-resource [--href <resource_href>] [[--help]]"
|
5
|
+
puts ''
|
6
|
+
puts "See rs-tag-resource --help for more information on usage."
|
7
|
+
end
|
8
|
+
|
9
|
+
def usage_exit
|
10
|
+
usage; exit
|
11
|
+
end
|
12
|
+
|
13
|
+
def help_info
|
14
|
+
puts("#{$0}")
|
15
|
+
puts ''
|
16
|
+
puts "Tags a RightScale resource (href)."
|
17
|
+
puts ''
|
18
|
+
puts "examples: rs-tag-resource --href '/api/server_templates/323918001' --tag 'human:name=chris'"
|
19
|
+
puts ''
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'getoptlong'
|
24
|
+
|
25
|
+
href = false
|
26
|
+
tag = false
|
27
|
+
verbose = false
|
28
|
+
dry = false
|
29
|
+
debug = false
|
30
|
+
help = false
|
31
|
+
|
32
|
+
opts = GetoptLong.new(
|
33
|
+
[ '--href', '-h', GetoptLong::REQUIRED_ARGUMENT ],
|
34
|
+
[ '--tag', '-t', GetoptLong::REQUIRED_ARGUMENT ],
|
35
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
|
36
|
+
[ '--debug', '-D', GetoptLong::OPTIONAL_ARGUMENT ],
|
37
|
+
[ '--dry', GetoptLong::OPTIONAL_ARGUMENT ],
|
38
|
+
[ '--help', GetoptLong::NO_ARGUMENT ]
|
39
|
+
)
|
40
|
+
|
41
|
+
opts.each do |opt, arg|
|
42
|
+
case opt
|
43
|
+
when '--href'
|
44
|
+
href = arg
|
45
|
+
when '--tag'
|
46
|
+
tag = arg
|
47
|
+
when '--help'
|
48
|
+
help = true
|
49
|
+
when '--verbose'
|
50
|
+
verbose = true
|
51
|
+
when '--debug'
|
52
|
+
debug = true
|
53
|
+
when '--dry'
|
54
|
+
dry = true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if help
|
59
|
+
help_info
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
usage_exit if !(href || tag)
|
64
|
+
|
65
|
+
require 'yaml'
|
66
|
+
require 'right_api_client'
|
67
|
+
rightscale = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
|
68
|
+
|
69
|
+
puts "Adding tag, '#{tag}' to resource #{href}."
|
70
|
+
rightscale.tags.multi_add(:resource_hrefs => [href], :tags => [tag])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Fordham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -69,10 +69,13 @@ dependencies:
|
|
69
69
|
description: RightScale API Command Line Tools.
|
70
70
|
email: chris@fordham-nagy.id.au
|
71
71
|
executables:
|
72
|
+
- rs-create-alert
|
72
73
|
- rs-describe-rightscripts
|
74
|
+
- rs-tag-resource
|
73
75
|
- rs-clone-server
|
74
76
|
- rs-describe-instance
|
75
77
|
- rs-clone-deployment
|
78
|
+
- rs-describe-cookbooks
|
76
79
|
- rs-update-inputs
|
77
80
|
- rs-start-server
|
78
81
|
- rs-unlock-server
|
@@ -81,6 +84,7 @@ executables:
|
|
81
84
|
- rs-describe-publication
|
82
85
|
- rs-terminate-self
|
83
86
|
- rs-describe-attached-vols
|
87
|
+
- rs-describe-executables
|
84
88
|
- rs-terminate-all
|
85
89
|
- rs-describe-servers
|
86
90
|
- rs-update-server-array
|
@@ -96,6 +100,7 @@ executables:
|
|
96
100
|
- rs-describe-ec2-ebs-snapshots
|
97
101
|
- rs-describe-repositories
|
98
102
|
- rs-describe-ec2-ebs-volumes
|
103
|
+
- rs-bind-executable
|
99
104
|
- rs-terminate-server
|
100
105
|
- rs-run-recipe
|
101
106
|
- rs-describe-servertemplates
|
@@ -103,11 +108,13 @@ executables:
|
|
103
108
|
- rs-describe-keys
|
104
109
|
- rs-describe-ec2-security-groups
|
105
110
|
- rs-terminate-deployment
|
111
|
+
- rs-create-servertemplate-mci
|
106
112
|
- rs-describe-rightscript
|
107
113
|
- rs-reboot-server
|
108
114
|
- rs-get-array-instances
|
109
115
|
- rs-describe-server-arrays
|
110
116
|
- rs-query-cloud
|
117
|
+
- rs-describe-alert-specs
|
111
118
|
- rs-launch-deployment
|
112
119
|
- rs-describe-server-self
|
113
120
|
- rs-describe-server
|
@@ -123,6 +130,7 @@ executables:
|
|
123
130
|
- rs-describe-multi-cloud-images
|
124
131
|
- rs-create-repositories
|
125
132
|
- rs-launch-server
|
133
|
+
- rs-describe-cookbook
|
126
134
|
- rs-get-server-monitoring
|
127
135
|
- rs-run-rightscript
|
128
136
|
- rs-describe-server-array
|
@@ -136,10 +144,13 @@ executables:
|
|
136
144
|
extensions: []
|
137
145
|
extra_rdoc_files: []
|
138
146
|
files:
|
147
|
+
- bin/rs-create-alert
|
139
148
|
- bin/rs-describe-rightscripts
|
149
|
+
- bin/rs-tag-resource
|
140
150
|
- bin/rs-clone-server
|
141
151
|
- bin/rs-describe-instance
|
142
152
|
- bin/rs-clone-deployment
|
153
|
+
- bin/rs-describe-cookbooks
|
143
154
|
- bin/rs-update-inputs
|
144
155
|
- bin/rs-start-server
|
145
156
|
- bin/rs-unlock-server
|
@@ -148,6 +159,7 @@ files:
|
|
148
159
|
- bin/rs-describe-publication
|
149
160
|
- bin/rs-terminate-self
|
150
161
|
- bin/rs-describe-attached-vols
|
162
|
+
- bin/rs-describe-executables
|
151
163
|
- bin/rs-terminate-all
|
152
164
|
- bin/rs-describe-servers
|
153
165
|
- bin/rs-update-server-array
|
@@ -163,6 +175,7 @@ files:
|
|
163
175
|
- bin/rs-describe-ec2-ebs-snapshots
|
164
176
|
- bin/rs-describe-repositories
|
165
177
|
- bin/rs-describe-ec2-ebs-volumes
|
178
|
+
- bin/rs-bind-executable
|
166
179
|
- bin/rs-terminate-server
|
167
180
|
- bin/rs-run-recipe
|
168
181
|
- bin/rs-describe-servertemplates
|
@@ -170,11 +183,13 @@ files:
|
|
170
183
|
- bin/rs-describe-keys
|
171
184
|
- bin/rs-describe-ec2-security-groups
|
172
185
|
- bin/rs-terminate-deployment
|
186
|
+
- bin/rs-create-servertemplate-mci
|
173
187
|
- bin/rs-describe-rightscript
|
174
188
|
- bin/rs-reboot-server
|
175
189
|
- bin/rs-get-array-instances
|
176
190
|
- bin/rs-describe-server-arrays
|
177
191
|
- bin/rs-query-cloud
|
192
|
+
- bin/rs-describe-alert-specs
|
178
193
|
- bin/rs-launch-deployment
|
179
194
|
- bin/rs-describe-server-self
|
180
195
|
- bin/rs-describe-server
|
@@ -190,6 +205,7 @@ files:
|
|
190
205
|
- bin/rs-describe-multi-cloud-images
|
191
206
|
- bin/rs-create-repositories
|
192
207
|
- bin/rs-launch-server
|
208
|
+
- bin/rs-describe-cookbook
|
193
209
|
- bin/rs-get-server-monitoring
|
194
210
|
- bin/rs-run-rightscript
|
195
211
|
- bin/rs-describe-server-array
|