rs-api-tools 0.0.1
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.
- data/bin/.DS_Store +0 -0
- data/bin/rs-clone-deployment +58 -0
- data/bin/rs-clone-rightscript +79 -0
- data/bin/rs-clone-server +2 -0
- data/bin/rs-describe-alerts +42 -0
- data/bin/rs-describe-attached-vols +83 -0
- data/bin/rs-describe-deployment +85 -0
- data/bin/rs-describe-deployments +42 -0
- data/bin/rs-describe-ec2-ebs-snapshots +41 -0
- data/bin/rs-describe-ec2-ebs-volumes +42 -0
- data/bin/rs-describe-ec2-security-groups +42 -0
- data/bin/rs-describe-keys +42 -0
- data/bin/rs-describe-multi-cloud-images +42 -0
- data/bin/rs-describe-rightscript +81 -0
- data/bin/rs-describe-rightscripts +42 -0
- data/bin/rs-describe-server +97 -0
- data/bin/rs-describe-server-array +80 -0
- data/bin/rs-describe-server-arrays +42 -0
- data/bin/rs-describe-server-self +67 -0
- data/bin/rs-describe-server-templates +42 -0
- data/bin/rs-describe-servers +42 -0
- data/bin/rs-fetch-rightscripts +126 -0
- data/bin/rs-get-array-instances +64 -0
- data/bin/rs-get-server-input +2 -0
- data/bin/rs-get-server-monitoring +64 -0
- data/bin/rs-get-server-sketchy-data +42 -0
- data/bin/rs-launch-deployment +2 -0
- data/bin/rs-launch-server +2 -0
- data/bin/rs-ping-active-servers +44 -0
- data/bin/rs-reboot-deployment +2 -0
- data/bin/rs-reboot-server +75 -0
- data/bin/rs-relaunch-deployment +2 -0
- data/bin/rs-relaunch-server +74 -0
- data/bin/rs-run-all-boot-executables +94 -0
- data/bin/rs-run-rightscript +98 -0
- data/bin/rs-search-tags +69 -0
- data/bin/rs-start-deployment +2 -0
- data/bin/rs-start-server +75 -0
- data/bin/rs-stop-deployment +2 -0
- data/bin/rs-stop-server +2 -0
- data/bin/rs-terminate-all +2 -0
- data/bin/rs-terminate-deployment +2 -0
- data/bin/rs-terminate-self +70 -0
- data/bin/rs-terminate-server +90 -0
- data/bin/rs-update-input +71 -0
- data/bin/rs-update-inputs +71 -0
- data/bin/rs-update-server-array +63 -0
- metadata +194 -0
data/bin/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-clone-rightscript
|
4
|
+
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'getoptlong'
|
8
|
+
require 'json'
|
9
|
+
require 'rest_connection'
|
10
|
+
require 'active_support' #for to_xml()
|
11
|
+
require 'xmlsimple'
|
12
|
+
|
13
|
+
def usage
|
14
|
+
puts("#{$0} --name <right_script_name> [--source] [--xml] [--json]")
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
opts = GetoptLong.new(
|
19
|
+
[ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
|
20
|
+
[ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
|
21
|
+
[ '--source', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
|
22
|
+
[ '--edit', '-e', GetoptLong::OPTIONAL_ARGUMENT ],
|
23
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
24
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
25
|
+
)
|
26
|
+
|
27
|
+
json = false
|
28
|
+
xml = false
|
29
|
+
name = false
|
30
|
+
script_id = false
|
31
|
+
source = false
|
32
|
+
edit = false
|
33
|
+
|
34
|
+
opts.each do |opt, arg|
|
35
|
+
case opt
|
36
|
+
when '--name'
|
37
|
+
name = arg
|
38
|
+
when '--id'
|
39
|
+
script_id = arg
|
40
|
+
when '--source'
|
41
|
+
source = true
|
42
|
+
when '--edit'
|
43
|
+
edit = true
|
44
|
+
when '--json'
|
45
|
+
json = true
|
46
|
+
when '--xml'
|
47
|
+
xml = true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
usage if !(name || script_id)
|
52
|
+
|
53
|
+
if name
|
54
|
+
right_script = RightScript.find(:first) {|script| script.name =~ /#{name}/ }
|
55
|
+
elsif script_id
|
56
|
+
right_script = RightScript.find(script_id.to_i)
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'getoptlong'
|
5
|
+
|
6
|
+
def usage
|
7
|
+
puts("usage: rs-clone-rightscript [--name <right_script_name> | --id <right_script_id>]")
|
8
|
+
puts(" [[--verbose]]")
|
9
|
+
end
|
10
|
+
|
11
|
+
def usage_exit
|
12
|
+
usage; exit
|
13
|
+
end
|
14
|
+
|
15
|
+
def help
|
16
|
+
usage
|
17
|
+
puts ''
|
18
|
+
puts 'Clones a RightScale RightsScript.'
|
19
|
+
puts ''
|
20
|
+
puts "examples: rs-clone-rightscript --name 'Hello World'"
|
21
|
+
puts ''
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
|
25
|
+
opts = GetoptLong.new(
|
26
|
+
[ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
|
27
|
+
[ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
|
28
|
+
[ '--source', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
|
29
|
+
[ '--edit', '-e', GetoptLong::OPTIONAL_ARGUMENT ],
|
30
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
31
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
32
|
+
)
|
33
|
+
|
34
|
+
json = false
|
35
|
+
xml = false
|
36
|
+
script_name = false
|
37
|
+
script_id = false
|
38
|
+
source = false
|
39
|
+
edit = false
|
40
|
+
verbose = false
|
41
|
+
help = false
|
42
|
+
|
43
|
+
opts.each do |opt, arg|
|
44
|
+
case opt
|
45
|
+
when '--name'
|
46
|
+
script_name = arg
|
47
|
+
when '--id'
|
48
|
+
script_id = arg
|
49
|
+
when '--source'
|
50
|
+
source = true
|
51
|
+
when '--edit'
|
52
|
+
edit = true
|
53
|
+
when '--json'
|
54
|
+
json = true
|
55
|
+
when '--xml'
|
56
|
+
xml = true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
usage if !(script_name || script_id)
|
61
|
+
|
62
|
+
require 'json'
|
63
|
+
require 'rest_connection'
|
64
|
+
require 'active_support' #for to_xml()
|
65
|
+
|
66
|
+
# get script
|
67
|
+
if script_name
|
68
|
+
puts "Finding script: '%#{script_name}%'"
|
69
|
+
right_script = RightScriptInternal.find(:first) { |s| s.name =~ /#{script_name}/ }
|
70
|
+
puts "Found script, '#{right_script.name}'."
|
71
|
+
puts right_script.to_yaml if verbose
|
72
|
+
elsif script_id
|
73
|
+
right_script = RightScriptInternal.find(script_id.to_i)
|
74
|
+
else
|
75
|
+
usage_exit
|
76
|
+
end
|
77
|
+
|
78
|
+
new_script = right_script.clone
|
79
|
+
puts new_script.to_yaml
|
data/bin/rs-clone-server
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-alerts
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'json'
|
8
|
+
require 'rest_connection'
|
9
|
+
require 'active_support' #for to_xml()
|
10
|
+
require 'xmlsimple'
|
11
|
+
|
12
|
+
def usage
|
13
|
+
puts("#{$0} [--xml] [--json]")
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
19
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
20
|
+
)
|
21
|
+
|
22
|
+
json = false
|
23
|
+
xml = false
|
24
|
+
|
25
|
+
opts.each do |opt, arg|
|
26
|
+
case opt
|
27
|
+
when '--json'
|
28
|
+
json = true
|
29
|
+
when '--xml'
|
30
|
+
xml = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
alerts = AlertSpec.find_all()
|
35
|
+
|
36
|
+
if json
|
37
|
+
puts alerts.to_json
|
38
|
+
elsif xml
|
39
|
+
puts JSON.parse(alerts.to_json).to_xml(:root => 'deployments', :skip_instruct => true)
|
40
|
+
else
|
41
|
+
puts alerts.to_yaml
|
42
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-attached-vols
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
|
8
|
+
def usage
|
9
|
+
puts("usage: rs-describe-attached-vols <server_nickname> [[--verbose]]")
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage_exit
|
13
|
+
usage; exit
|
14
|
+
end
|
15
|
+
|
16
|
+
def help
|
17
|
+
usage
|
18
|
+
puts ''
|
19
|
+
puts 'Describes the attached volumes of a RightScale Server.'
|
20
|
+
puts ''
|
21
|
+
puts "examples: rs-describe-attached-vols 'Sandbox'"
|
22
|
+
puts ''
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts = GetoptLong.new(
|
27
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
28
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
29
|
+
)
|
30
|
+
|
31
|
+
json = false
|
32
|
+
xml = false
|
33
|
+
verbose = false
|
34
|
+
|
35
|
+
opts.each do |opt, arg|
|
36
|
+
case opt
|
37
|
+
when '--json'
|
38
|
+
json = true
|
39
|
+
when '--xml'
|
40
|
+
xml = true
|
41
|
+
when '--verbose'
|
42
|
+
verbose = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
usage_exit if ! ARGV[0]
|
47
|
+
|
48
|
+
server_name = ARGV[0]
|
49
|
+
region = 'us-west-1'
|
50
|
+
|
51
|
+
require 'json'
|
52
|
+
require 'rest_connection'
|
53
|
+
require 'active_support' #for to_xml()
|
54
|
+
#require 'xmlsimple'
|
55
|
+
|
56
|
+
# get server
|
57
|
+
if server_name
|
58
|
+
puts "Finding server: '%#{server_name}%'"
|
59
|
+
server = Server.find(:first) { |s| s.nickname =~ /#{server_name}/ }
|
60
|
+
puts "Found server, '#{server.nickname}'."
|
61
|
+
elsif server_id
|
62
|
+
server = Server.find(server_id.to_i)
|
63
|
+
else
|
64
|
+
usage_exit
|
65
|
+
end
|
66
|
+
|
67
|
+
puts "Getting server settings for '#{server.nickname}'."
|
68
|
+
server_settings = server.settings
|
69
|
+
instance_id = server_settings['aws-id']
|
70
|
+
puts "Found instance-id, #{instance_id}."
|
71
|
+
volumes = Array.new
|
72
|
+
puts "Getting volumes for #{instance_id}."
|
73
|
+
volumes_out = `ec2-describe-volumes --region '#{region}' --filter attachment.instance-id=#{instance_id} --filter attachment.status=attached `
|
74
|
+
volumes_out.split("\n").each do |line|
|
75
|
+
volume = Array.new
|
76
|
+
line.split("\t").each do |value|
|
77
|
+
volume.push(value)
|
78
|
+
end
|
79
|
+
volumes.push(volume)
|
80
|
+
end
|
81
|
+
|
82
|
+
#puts volumes.inspect
|
83
|
+
puts volumes.to_yaml
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-deployment
|
4
|
+
|
5
|
+
require 'getoptlong'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'json'
|
8
|
+
require 'rest_connection'
|
9
|
+
require 'active_support' #for to_xml()
|
10
|
+
require 'xmlsimple'
|
11
|
+
|
12
|
+
def usage
|
13
|
+
puts("#{$0} --id <deployment_id> [--show-servers] [--xml] [--json] [--param]")
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
[ '--id', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
19
|
+
[ '--servers', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
|
20
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
21
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
|
22
|
+
[ '--param', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
|
23
|
+
[ '--params', '-P', GetoptLong::OPTIONAL_ARGUMENT ]
|
24
|
+
)
|
25
|
+
|
26
|
+
json = false
|
27
|
+
xml = false
|
28
|
+
show_servers = false
|
29
|
+
deployment_id = nil
|
30
|
+
param = false
|
31
|
+
params = false
|
32
|
+
|
33
|
+
opts.each do |opt, arg|
|
34
|
+
case opt
|
35
|
+
when '--id'
|
36
|
+
deployment_id = arg.to_i
|
37
|
+
when '--servers'
|
38
|
+
show_servers = true
|
39
|
+
when '--json'
|
40
|
+
json = true
|
41
|
+
when '--xml'
|
42
|
+
xml = true
|
43
|
+
when '--param'
|
44
|
+
param = arg
|
45
|
+
when '--params'
|
46
|
+
params = true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
usage if !deployment_id
|
51
|
+
deployment = Deployment.find(deployment_id)
|
52
|
+
|
53
|
+
if param
|
54
|
+
data = XmlSimple.xml_in(JSON.parse(deployment.params.to_json).to_xml(:root => 'deployment', :skip_instruct => true))
|
55
|
+
data.sort.each do |k, v|
|
56
|
+
if k == param
|
57
|
+
puts v
|
58
|
+
end
|
59
|
+
end
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
if show_servers
|
64
|
+
servers = deployment.servers
|
65
|
+
servers.each { |server|
|
66
|
+
if json
|
67
|
+
puts server.params.to_json
|
68
|
+
elsif xml
|
69
|
+
puts JSON.parse(server.params.to_json).to_xml(:root => 'server', :skip_instruct => true)
|
70
|
+
else
|
71
|
+
puts server.params.to_yaml
|
72
|
+
end
|
73
|
+
}
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
|
77
|
+
if json
|
78
|
+
puts deployment.to_json
|
79
|
+
elsif xml
|
80
|
+
puts JSON.parse(deployment.params.to_json).to_xml(:root => 'deployment', :skip_instruct => true)
|
81
|
+
else
|
82
|
+
puts deployment.to_yaml
|
83
|
+
end
|
84
|
+
|
85
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-deployments
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'json'
|
8
|
+
require 'rest_connection'
|
9
|
+
require 'active_support' #for to_xml()
|
10
|
+
require 'xmlsimple'
|
11
|
+
|
12
|
+
def usage
|
13
|
+
puts("#{$0} [--xml] [--json]")
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
19
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
20
|
+
)
|
21
|
+
|
22
|
+
json = false
|
23
|
+
xml = false
|
24
|
+
|
25
|
+
opts.each do |opt, arg|
|
26
|
+
case opt
|
27
|
+
when '--json'
|
28
|
+
json = true
|
29
|
+
when '--xml'
|
30
|
+
xml = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
deployments = Deployment.find_all()
|
35
|
+
|
36
|
+
if json
|
37
|
+
puts deployments.to_json
|
38
|
+
elsif xml
|
39
|
+
puts JSON.parse(deployments.to_json).to_xml(:root => 'deployments', :skip_instruct => true)
|
40
|
+
else
|
41
|
+
puts deployments.to_yaml
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-ec2-ebs-snapshots
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'json'
|
8
|
+
require 'rest_connection'
|
9
|
+
require 'active_support' #for to_xml()
|
10
|
+
|
11
|
+
def usage
|
12
|
+
puts("#{$0} [--xml] [--json]")
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
opts = GetoptLong.new(
|
17
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
18
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
19
|
+
)
|
20
|
+
|
21
|
+
json = false
|
22
|
+
xml = false
|
23
|
+
|
24
|
+
opts.each do |opt, arg|
|
25
|
+
case opt
|
26
|
+
when '--json'
|
27
|
+
json = true
|
28
|
+
when '--xml'
|
29
|
+
xml = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
ebs_snapshots = Ec2EbsSnapshot.find_all()
|
34
|
+
|
35
|
+
if json
|
36
|
+
puts ebs_snapshots.to_json
|
37
|
+
elsif xml
|
38
|
+
puts JSON.parse(ebs_snapshots.to_json).to_xml(:root => 'ec2-ebs-snapshots', :skip_instruct => true)
|
39
|
+
else
|
40
|
+
puts ebs_snapshots.to_yaml
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# rs-describe-ec2-ebs-volumes
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'getoptlong'
|
7
|
+
require 'json'
|
8
|
+
require 'rest_connection'
|
9
|
+
require 'active_support' #for to_xml()
|
10
|
+
require 'xmlsimple'
|
11
|
+
|
12
|
+
def usage
|
13
|
+
puts("#{$0} [--xml] [--json]")
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
opts = GetoptLong.new(
|
18
|
+
[ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
|
19
|
+
[ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
|
20
|
+
)
|
21
|
+
|
22
|
+
json = false
|
23
|
+
xml = false
|
24
|
+
|
25
|
+
opts.each do |opt, arg|
|
26
|
+
case opt
|
27
|
+
when '--json'
|
28
|
+
json = true
|
29
|
+
when '--xml'
|
30
|
+
xml = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ebs_volumes = Ec2EbsVolume.find_all()
|
35
|
+
|
36
|
+
if json
|
37
|
+
puts ebs_volumes.to_json
|
38
|
+
elsif xml
|
39
|
+
puts JSON.parse(ebs_volumes.to_json).to_xml(:root => 'ec2-ebs-volumes', :skip_instruct => true)
|
40
|
+
else
|
41
|
+
puts ebs_volumes.to_yaml
|
42
|
+
end
|