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.
Files changed (48) hide show
  1. data/bin/.DS_Store +0 -0
  2. data/bin/rs-clone-deployment +58 -0
  3. data/bin/rs-clone-rightscript +79 -0
  4. data/bin/rs-clone-server +2 -0
  5. data/bin/rs-describe-alerts +42 -0
  6. data/bin/rs-describe-attached-vols +83 -0
  7. data/bin/rs-describe-deployment +85 -0
  8. data/bin/rs-describe-deployments +42 -0
  9. data/bin/rs-describe-ec2-ebs-snapshots +41 -0
  10. data/bin/rs-describe-ec2-ebs-volumes +42 -0
  11. data/bin/rs-describe-ec2-security-groups +42 -0
  12. data/bin/rs-describe-keys +42 -0
  13. data/bin/rs-describe-multi-cloud-images +42 -0
  14. data/bin/rs-describe-rightscript +81 -0
  15. data/bin/rs-describe-rightscripts +42 -0
  16. data/bin/rs-describe-server +97 -0
  17. data/bin/rs-describe-server-array +80 -0
  18. data/bin/rs-describe-server-arrays +42 -0
  19. data/bin/rs-describe-server-self +67 -0
  20. data/bin/rs-describe-server-templates +42 -0
  21. data/bin/rs-describe-servers +42 -0
  22. data/bin/rs-fetch-rightscripts +126 -0
  23. data/bin/rs-get-array-instances +64 -0
  24. data/bin/rs-get-server-input +2 -0
  25. data/bin/rs-get-server-monitoring +64 -0
  26. data/bin/rs-get-server-sketchy-data +42 -0
  27. data/bin/rs-launch-deployment +2 -0
  28. data/bin/rs-launch-server +2 -0
  29. data/bin/rs-ping-active-servers +44 -0
  30. data/bin/rs-reboot-deployment +2 -0
  31. data/bin/rs-reboot-server +75 -0
  32. data/bin/rs-relaunch-deployment +2 -0
  33. data/bin/rs-relaunch-server +74 -0
  34. data/bin/rs-run-all-boot-executables +94 -0
  35. data/bin/rs-run-rightscript +98 -0
  36. data/bin/rs-search-tags +69 -0
  37. data/bin/rs-start-deployment +2 -0
  38. data/bin/rs-start-server +75 -0
  39. data/bin/rs-stop-deployment +2 -0
  40. data/bin/rs-stop-server +2 -0
  41. data/bin/rs-terminate-all +2 -0
  42. data/bin/rs-terminate-deployment +2 -0
  43. data/bin/rs-terminate-self +70 -0
  44. data/bin/rs-terminate-server +90 -0
  45. data/bin/rs-update-input +71 -0
  46. data/bin/rs-update-inputs +71 -0
  47. data/bin/rs-update-server-array +63 -0
  48. metadata +194 -0
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-ec2-security-groups
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
+ security_groups = Ec2SecurityGroup.find_all()
35
+
36
+ if json
37
+ puts security_groups.to_json
38
+ elsif xml
39
+ puts JSON.parse(security_groups.to_json).to_xml(:root => 'ec2-security-groups', :skip_instruct => true)
40
+ else
41
+ puts security_groups.to_yaml
42
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-keys
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
+ keys = Ec2SshKey.find_all()
35
+
36
+ if json
37
+ puts keys.to_json
38
+ elsif xml
39
+ puts JSON.parse(keys.to_json).to_xml(:root => 'keys', :skip_instruct => true)
40
+ else
41
+ puts keys.to_yaml
42
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-multi-cloud-images
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
+ multi_cloud_images = MultiCloudImage.find_all()
35
+
36
+ if json
37
+ puts multi_cloud_images.to_json
38
+ elsif xml
39
+ puts JSON.parse(multi_cloud_images.to_json).to_xml(:root => 'multi_cloud_images', :skip_instruct => true)
40
+ else
41
+ puts multi_cloud_images.to_yaml
42
+ end
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-rightscript
4
+
5
+ # rs-describe-rightscript --source --name 'Format Debian EBS volume partitions' > /tmp/script.tmp.bash && sed -e '1d' /tmp/script.tmp.bash > /tmp/script.bash && `echo "$EDITOR" /tmp/script.bash`
6
+
7
+ require 'rubygems'
8
+ require 'getoptlong'
9
+ require 'json'
10
+ require 'rest_connection'
11
+ require 'active_support' #for to_xml()
12
+ require 'xmlsimple'
13
+
14
+ def usage
15
+ puts("#{$0} --name <right_script_name> [--source] [--xml] [--json]")
16
+ exit
17
+ end
18
+
19
+ opts = GetoptLong.new(
20
+ [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
21
+ [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
22
+ [ '--source', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
23
+ [ '--edit', '-e', GetoptLong::OPTIONAL_ARGUMENT ],
24
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
25
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
26
+ )
27
+
28
+ json = false
29
+ xml = false
30
+ name = false
31
+ script_id = false
32
+ source = false
33
+ edit = false
34
+
35
+ opts.each do |opt, arg|
36
+ case opt
37
+ when '--name'
38
+ name = arg
39
+ when '--id'
40
+ script_id = arg
41
+ when '--source'
42
+ source = true
43
+ when '--edit'
44
+ edit = true
45
+ when '--json'
46
+ json = true
47
+ when '--xml'
48
+ xml = true
49
+ end
50
+ end
51
+
52
+ usage if !(name || script_id)
53
+
54
+ if name
55
+ right_script = RightScript.find(:first) {|script| script.name =~ /#{name}/ }
56
+ elsif script_id
57
+ right_script = RightScript.find(script_id.to_i)
58
+ end
59
+
60
+ if source
61
+ if edit
62
+ name = right_script.name.gsub!(' ','_')+'.bash'
63
+ open("/tmp/#{name}", 'w') { |f|
64
+ f.puts right_script.script
65
+ }
66
+ editor = ENV['EDITOR']
67
+ system("#{editor} /tmp/#{name}")
68
+ exit
69
+ else
70
+ puts right_script.script
71
+ end
72
+ exit
73
+ end
74
+
75
+ if json
76
+ puts right_script.to_json
77
+ elsif xml
78
+ puts JSON.parse(right_script.to_json).to_xml(:root => 'right_script', :skip_instruct => true)
79
+ else
80
+ puts right_script.to_yaml
81
+ end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-rightscripts
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
+ right_scripts = RightScript.find_all()
35
+
36
+ if json
37
+ puts right_scripts.to_json
38
+ elsif xml
39
+ puts JSON.parse(right_scripts.to_json).to_xml(:root => 'right_scripts', :skip_instruct => true)
40
+ else
41
+ puts right_scripts.to_yaml
42
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-server
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("usage: rs-describe-server --settings [current] [--nickname <server_nickname> | --id <server_id>]")
14
+ puts(" [[--verbose]]")
15
+ end
16
+
17
+ def usage_exit
18
+ usage; exit
19
+ end
20
+
21
+ def help
22
+ usage
23
+ puts ''
24
+ puts 'Reboots a RightScale server.'
25
+ puts ''
26
+ puts "examples: rs-reboot-server --name 'Sandbox'"
27
+ puts ''
28
+ exit
29
+ end
30
+
31
+ opts = GetoptLong.new(
32
+ [ '--nickname', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
33
+ [ '--settings', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
34
+ [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
35
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
36
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
37
+ )
38
+
39
+ server_name = false
40
+ server_id = false
41
+ settings = false
42
+ json = false
43
+ xml = false
44
+ verbose = false
45
+
46
+ opts.each do |opt, arg|
47
+ case opt
48
+ when '--nickname'
49
+ server_name = arg
50
+ when '--settings'
51
+ settings = arg
52
+ usage_exit if !(settings = 'current' || settings = 'next')
53
+ when '--id'
54
+ server_id = arg
55
+ when '--json'
56
+ json = true
57
+ when '--xml'
58
+ xml = true
59
+ when '--verbose'
60
+ verbose = true
61
+ end
62
+ end
63
+
64
+ usage_exit if !(server_name || server_id)
65
+
66
+ # get server
67
+ if server_name
68
+ puts "Finding server: '%#{server_name}%'"
69
+ server = Server.find(:first) { |s| s.nickname =~ /#{server_name}/ }
70
+ #puts "Found server, '#{server.nickname}'."
71
+ elsif server_id
72
+ server = Server.find(server_id.to_i)
73
+ else
74
+ usage_exit
75
+ end
76
+
77
+ if settings
78
+ if settings == 'next'
79
+ server_settings = server.settings
80
+ elsif settings == 'current'
81
+ server.reload_current
82
+ server_settings = server.settings
83
+ end
84
+ output = server_settings
85
+ else
86
+ output = server
87
+ end
88
+
89
+ if json
90
+ puts output.to_json
91
+ elsif xml
92
+ puts JSON.parse(output.to_json).to_xml(:root => 'servers', :skip_instruct => true)
93
+ else
94
+ puts output.to_yaml
95
+ end
96
+
97
+
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-server-array
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("usage: rs-describe-server-array [--name <server_nickname> | --id <server_id>]")
14
+ puts(" [[--verbose]]")
15
+ end
16
+
17
+ def usage_exit
18
+ usage; exit
19
+ end
20
+
21
+ def help
22
+ usage
23
+ puts ''
24
+ puts 'Describes a server array.'
25
+ puts ''
26
+ puts "examples: rs-describe-server-array --name 'PHP App Server Array'"
27
+ puts ''
28
+ exit
29
+ end
30
+
31
+ opts = GetoptLong.new(
32
+ [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
33
+ [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
34
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
35
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
36
+ )
37
+
38
+ array_name = false
39
+ array_id = false
40
+ json = false
41
+ xml = false
42
+ verbose = false
43
+
44
+ opts.each do |opt, arg|
45
+ case opt
46
+ when '--name'
47
+ array_name = arg
48
+ when '--id'
49
+ array_id = arg
50
+ when '--json'
51
+ json = true
52
+ when '--xml'
53
+ xml = true
54
+ when '--verbose'
55
+ verbose = true
56
+ end
57
+ end
58
+
59
+ usage_exit if !(array_name || array_id)
60
+
61
+ # get server
62
+ if array_name
63
+ puts "Finding server array: '%#{array_name}%'"
64
+ server_array = Ec2ServerArray.find(:first) { |s| s.nickname =~ /#{array_name}/ }
65
+ elsif array_id
66
+ server_array = Ec2ServerArray.find(array_id.to_i)
67
+ else
68
+ usage_exit
69
+ end
70
+ puts "Found server array, '#{server_array.nickname}'."
71
+
72
+ if json
73
+ puts server_array.to_json
74
+ elsif xml
75
+ puts JSON.parse(output.to_json).to_xml(:root => 'server-array', :skip_instruct => true)
76
+ else
77
+ puts server_array.to_yaml
78
+ end
79
+
80
+
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-server-arrays
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
+ servers = Ec2ServerArray.find_all()
35
+
36
+ if json
37
+ puts servers.to_json
38
+ elsif xml
39
+ puts JSON.parse(servers.to_json).to_xml(:root => 'servers', :skip_instruct => true)
40
+ else
41
+ puts servers.to_yaml
42
+ end