rs-api-tools 0.0.2 → 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9315e341912486ed63bb7b7bf1a97c78cdf5b9ba
4
+ data.tar.gz: 1b51fdd242ab6e5e9fe6d025f403a46a7f978b1f
5
+ SHA512:
6
+ metadata.gz: a965b7a761677f38ea8b773399c430feab8d14164c6127b61d34370f146a80a1a9717d4c9e545a7ee74dd02430c4dc9082f301a76aa61fe91255f677002dceda
7
+ data.tar.gz: fb39d8f15634d86b0f9ba7e96ea39d73b4a9b4dadc58c241a2c38f05d18c3b795194104628bb39ff908f8b20505c6210482ffeb5bb686510a2eec96e7abbc340
File without changes
data/bin/rs-clone-server CHANGED
File without changes
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-create-org-repositories --org [<github_organization>]
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts "#{$0} [--org <github_org>]"
10
+ puts ''
11
+ puts "See rs-create-org-repositories --help for information on usage."
12
+ end
13
+
14
+ def usage_exit
15
+ usage; exit
16
+ end
17
+
18
+ def help_info
19
+ puts("#{$0}")
20
+ puts ''
21
+ puts "Creates RightScale Repositories from each git repository of an organization's account on GitHub."
22
+ puts ''
23
+ puts "examples: rs-create-org-repositories --org opscode-cookbooks"
24
+ puts " rs-create-org-repositories --org opscode-cookbooks --user charliemurphy --password rickjames"
25
+ puts ''
26
+ puts 'The --user and --password params are the github account used (mostly due to rate limiting with their API if you need to action many API requests).'
27
+ end
28
+
29
+ org = false
30
+ master = false
31
+ user = false
32
+ password = false
33
+ dry = false
34
+ interactive = true
35
+ json = false
36
+ xml = false
37
+ verbose = false
38
+ help = false
39
+
40
+ opts = GetoptLong.new(
41
+ [ '--org', '-o', GetoptLong::REQUIRED_ARGUMENT ],
42
+ [ '--dry', '-d', GetoptLong::OPTIONAL_ARGUMENT ],
43
+ [ '--user', '-u', GetoptLong::OPTIONAL_ARGUMENT ],
44
+ [ '--password', '-p', GetoptLong::OPTIONAL_ARGUMENT ],
45
+ [ '--master', '-m', GetoptLong::OPTIONAL_ARGUMENT ],
46
+ [ '--noninteractive', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
47
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
48
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
49
+ [ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ],
50
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ]
51
+ )
52
+
53
+ opts.each do |opt, arg|
54
+ case opt
55
+ when '--org'
56
+ org = arg
57
+ when '--dry'
58
+ dry = arg
59
+ when '--master'
60
+ master = arg
61
+ when '--user'
62
+ user = arg
63
+ when '--password'
64
+ password = arg
65
+ when '--noninteractive'
66
+ interactive = false
67
+ puts 'Warning: non-interactive mode.'
68
+ when '--help'
69
+ help = true
70
+ when '--json'
71
+ json = true
72
+ when '--verbose'
73
+ verbose = true
74
+ when '--xml'
75
+ xml = true
76
+ end
77
+ end
78
+
79
+ if help
80
+ help_info
81
+ exit
82
+ end
83
+
84
+ usage_exit if !(org)
85
+
86
+ def yesno
87
+ begin
88
+ system("stty raw -echo")
89
+ str = STDIN.getc
90
+ ensure
91
+ system("stty -raw echo")
92
+ end
93
+ if str.downcase == "y"
94
+ return true
95
+ elsif str.downcase == "n"
96
+ return false
97
+ else
98
+ raise "Invalid response. Please enter y/n."
99
+ end
100
+ end
101
+
102
+ require 'octokit'
103
+ require 'json'
104
+ require 'yaml'
105
+
106
+ if user
107
+ if password
108
+ puts 'Authenticating with the GitHub API.' if verbose
109
+ github_client = Octokit::Client.new :login => user, :password => password
110
+ user = github_client.user
111
+ user.login
112
+ puts "Logged in as user, '#{user.login}'." if verbose
113
+ puts "Finding repositories of GitHub organization, '#{org}'..."
114
+ repositories = github_client.repos org, :per_page => 500
115
+ else
116
+ usage_exit
117
+ end
118
+ else
119
+ repositories = Octokit.repos org, :per_page => 500
120
+ end
121
+
122
+ puts "Found #{repositories.count} cookbook repositories."
123
+
124
+ # log into RightScale first, no point continuing if this is not possible
125
+ require 'right_api_client'
126
+ rs_client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
127
+
128
+ repositories.each { |repo|
129
+ # get the tags of the repository
130
+ puts "Tags for '#{repo['name']}':" if verbose
131
+ repo_tags = repo.rels['tags'].get.data
132
+ repo_tags.each { |tag|
133
+ puts " #{tag['name']}" if verbose
134
+ }
135
+ puts " (no tags found)" if (!repo_tags.first and verbose)
136
+
137
+ # only continue if there is at least one tag
138
+ if repo_tags.first
139
+ puts "Latest tag is #{repo_tags.first['name']}" if verbose
140
+
141
+ # create profile of the repository to add
142
+ # http://reference.rightscale.com/api1.5/resources/ResourceRepositories.html#create
143
+ repository = Hash.new
144
+ repository['source_type'] = 'git'
145
+ repository['auto_import'] = true
146
+ repository['source'] = repo.rels['clone'].href
147
+
148
+ # not yet supported
149
+ repository['credentials'] = Hash.new
150
+ repository['credentials']['ssh_key'] = 'text:'
151
+
152
+ if master
153
+ repository['name'] = "#{repo['name']} master"
154
+ repository['commit_reference'] = 'master'
155
+ repository['description'] = "#{repo.description} master branch)."
156
+ else
157
+ repository['name'] = "#{repo['name']} #{repo_tags.first['name']}"
158
+ repository['commit_reference'] = repo_tags.first['name']
159
+ repository['description'] = "#{repo.description} (#{repo_tags.first['name']} tag)."
160
+ end
161
+ puts repository if verbose
162
+
163
+ if dry
164
+ puts 'Dry run only, exiting.'
165
+ exit
166
+ end
167
+
168
+ if interactive
169
+ puts "==> Create repository, #{repository['name']} ? (y/n)"
170
+ response = yesno
171
+ if response
172
+ puts "Creating RightScale repository, '#{repository['name']}'."
173
+ rs_client.repositories.create({ :repository => repository })
174
+ else
175
+ puts "skipping creation of '#{repository['name']}'."
176
+ end
177
+ else
178
+ # non-interactive
179
+ puts "Creating RightScale repository, '#{repository['name']}'."
180
+ rs_client.repositories.create({ :repository => repository })
181
+ end
182
+ end
183
+ }
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-instance
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-describe-instance [--cloud <cloud_id>] [--id <instance_id> || --name <instance_name>]")
10
+ end
11
+
12
+ def usage_exit
13
+ usage; exit
14
+ end
15
+
16
+ def help
17
+ usage
18
+ puts ''
19
+ puts 'Describes a cloud instance.'
20
+ puts ''
21
+ puts "examples: rs-describe-instance --cloud 9 --id 1NP2LKNQBCQLR"
22
+ puts ' rs-describe-instance --cloud 8 --name "AWS VPC NAT ServerTemplate (13.2)"'
23
+ puts ''
24
+ exit
25
+ end
26
+
27
+ opts = GetoptLong.new(
28
+ [ '--cloud', '-c', GetoptLong::OPTIONAL_ARGUMENT ],
29
+ [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
30
+ [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
31
+ [ '--view', '-V', GetoptLong::OPTIONAL_ARGUMENT ],
32
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
33
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
34
+ [ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
35
+ [ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
36
+ )
37
+
38
+ cloud_id = false
39
+ instance_id = false
40
+ instance_name = false
41
+ view = 'default'
42
+ show_help = false
43
+ verbose = false
44
+
45
+ opts.each do |opt, arg|
46
+ case opt
47
+ when '--cloud'
48
+ cloud_id = arg
49
+ when '--id'
50
+ instance_id = arg
51
+ when '--name'
52
+ instance_name = arg
53
+ when '--view'
54
+ view = arg
55
+ when '--help'
56
+ show_help = true
57
+ when '--verbose'
58
+ verbose = true
59
+ end
60
+ end
61
+
62
+ help if show_help
63
+ usage_exit if !(cloud_id)
64
+ usage_exit if !(instance_id || instance_name)
65
+
66
+ require 'json'
67
+ require 'yaml'
68
+ require 'right_api_client'
69
+
70
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
71
+
72
+ if instance_name
73
+ puts "Finding instances named, '#{instance_name}'..."
74
+ instances = client.clouds(:id => cloud_id).show.instances(filter: ["name==#{instance_name}"])
75
+ puts "Found #{instances.index.count} instances."
76
+ instances.index.each {|instance|
77
+ puts instance.raw.to_yaml
78
+ }
79
+ else
80
+ puts "Retrieving instance, #{instance_id}."
81
+ instance = client.clouds(:id => cloud_id).show.instances(:id => instance_id).show(:view => view)
82
+ puts instance.show.raw.to_yaml
83
+ end
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-instances
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-describe-instances [--cloud <cloud_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 cloud's instances."
20
+ puts ''
21
+ puts "examples: rs-describe-instances --cloud 9"
22
+ puts ''
23
+ exit
24
+ end
25
+
26
+ opts = GetoptLong.new(
27
+ [ '--cloud', '-c', GetoptLong::OPTIONAL_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
+ cloud_id = false
35
+ show_help = false
36
+ verbose = false
37
+
38
+ opts.each do |opt, arg|
39
+ case opt
40
+ when '--cloud'
41
+ cloud_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
+ usage_exit if !(cloud_id)
51
+
52
+ require 'json'
53
+ require 'yaml'
54
+ require 'right_api_client'
55
+
56
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
57
+
58
+ puts "Retrieving instances for cloud #{cloud_id}..."
59
+ instances = client.clouds(:id => '8').show.instances.index
60
+
61
+ puts instances.to_yaml
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-publication
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-describe-publication [--name <publication_name>] || --id <publication_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 publication in the RightScale Marketplace.'
20
+ puts ''
21
+ puts "examples: rs-describe-publication --name 'Load Balancer with HAProxy 1.5dev (v13.5)'"
22
+ puts ''
23
+ exit
24
+ end
25
+
26
+ opts = GetoptLong.new(
27
+ [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
28
+ [ '--id', '-s', 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
+ publication_name = false
36
+ publication_id = false
37
+ show_help = false
38
+ verbose = false
39
+
40
+ opts.each do |opt, arg|
41
+ case opt
42
+ when '--name'
43
+ publication_name = arg
44
+ when '--id'
45
+ publication_id = arg
46
+ when '--help'
47
+ show_help = true
48
+ when '--verbose'
49
+ verbose = true
50
+ end
51
+ end
52
+
53
+ help if show_help
54
+ usage_exit if !(publication_name || publication_id)
55
+
56
+ require 'json'
57
+ require 'yaml'
58
+ require 'right_api_client'
59
+
60
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
61
+
62
+ # get publication
63
+ if publication_name
64
+ puts "Finding publication: '%#{publication_name}%'"
65
+ publication = client.publications.index(:filter => ["name==#{publication_name}"]).last
66
+ puts "Found publication, '#{publication.href}'."
67
+ elsif publication_id
68
+ puts "Retrieving publication, #{publication_id}."
69
+ publication = client.publications(:id => "#{publication_id}")
70
+ else
71
+ usage_exit
72
+ end
73
+
74
+ puts publication.show.raw.to_yaml
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-publication
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-describe-publications")
10
+ end
11
+
12
+ def usage_exit
13
+ usage; exit
14
+ end
15
+
16
+ def help
17
+ usage
18
+ puts ''
19
+ puts 'Lists all publications shared to the account in the RightScale Marketplace.'
20
+ puts ''
21
+ puts "examples: rs-describe-publications"
22
+ puts ''
23
+ exit
24
+ end
25
+
26
+ opts = GetoptLong.new(
27
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
28
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
29
+ [ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
30
+ [ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
31
+ )
32
+
33
+ show_help = false
34
+ verbose = false
35
+
36
+ opts.each do |opt, arg|
37
+ case opt
38
+ when '--help'
39
+ show_help = true
40
+ when '--verbose'
41
+ verbose = true
42
+ end
43
+ end
44
+
45
+ help if show_help
46
+
47
+ require 'json'
48
+ require 'yaml'
49
+ require 'right_api_client'
50
+
51
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
52
+
53
+ publications = client.publications.index
54
+
55
+ puts publications.show.raw.to_yaml
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-describe-repositories
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-describe-repositories")
10
+ end
11
+
12
+ def usage_exit
13
+ usage; exit
14
+ end
15
+
16
+ def help
17
+ usage
18
+ puts ''
19
+ puts "Describes the RightScale (Chef) Repositories within a RightScale account."
20
+ puts ''
21
+ puts "examples: rs-describe-repositories"
22
+ puts ''
23
+ exit
24
+ end
25
+
26
+ opts = GetoptLong.new(
27
+ [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
28
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
29
+ [ '--help', '-h', GetoptLong::OPTIONAL_ARGUMENT ],
30
+ [ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
31
+ )
32
+
33
+ show_help = false
34
+ verbose = false
35
+
36
+ opts.each do |opt, arg|
37
+ case opt
38
+ when '--help'
39
+ show_help = true
40
+ when '--verbose'
41
+ verbose = true
42
+ end
43
+ end
44
+
45
+ help if show_help
46
+
47
+ require 'json'
48
+ require 'yaml'
49
+ require 'right_api_client'
50
+
51
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
52
+
53
+ repositories = client.repositories.index
54
+
55
+ puts repositories.to_yaml
@@ -7,7 +7,7 @@ require 'getoptlong'
7
7
 
8
8
  def usage
9
9
  puts("usage: rs-describe-server --settings [current] [--name <server_nickname> | --id <server_id>]")
10
- puts(" [[--verbose]]")
10
+ puts(" [[--verbose]] [[--api]]")
11
11
  end
12
12
 
13
13
  def usage_exit
@@ -19,7 +19,7 @@ def help
19
19
  puts ''
20
20
  puts 'Describes a RightScale server.'
21
21
  puts ''
22
- puts "examples: rs-describe-server --id 836587 --settings current"
22
+ puts "examples: rs-describe-server --id 836587 --settings current --api 1.5"
23
23
  puts ''
24
24
  exit
25
25
  end
@@ -29,7 +29,8 @@ opts = GetoptLong.new(
29
29
  [ '--settings', '-s', GetoptLong::OPTIONAL_ARGUMENT ],
30
30
  [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
31
31
  [ '--xml', '-x', GetoptLong::OPTIONAL_ARGUMENT ],
32
- [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ]
32
+ [ '--json', '-j', GetoptLong::OPTIONAL_ARGUMENT ],
33
+ [ '--api', '-a', GetoptLong::OPTIONAL_ARGUMENT ]
33
34
  )
34
35
 
35
36
  server_name = false
@@ -39,6 +40,7 @@ json = false
39
40
  xml = false
40
41
  verbose = false
41
42
  server = false
43
+ api_version = '1.0'
42
44
 
43
45
  opts.each do |opt, arg|
44
46
  case opt
@@ -55,7 +57,9 @@ opts.each do |opt, arg|
55
57
  xml = true
56
58
  when '--verbose'
57
59
  verbose = true
58
- end
60
+ when '--api'
61
+ api_version = arg
62
+ end
59
63
  end
60
64
 
61
65
  usage_exit if !(server_name || server_id)
@@ -66,9 +70,17 @@ require 'rest_connection'
66
70
  # get server
67
71
  if server_name
68
72
  puts "Finding server: '%#{server_name}%'"
69
- server = Server.find(:first) { |s| s.nickname =~ /#{server_name}/ }
73
+ if api_version == '1.5'
74
+ server = Server.find(:first) { |s| s.nickname =~ /#{server_name}/ }
75
+ else
76
+ server = McServer.find(:first) { |s| s.nickname =~ /#{server_name}/ }
77
+ end
70
78
  elsif server_id
71
- server = Server.find(server_id.to_i)
79
+ if api_version == '1.5'
80
+ server = McServer.find(server_id.to_i)
81
+ else
82
+ server = Server.find(server_id.to_i)
83
+ end
72
84
  else
73
85
  usage_exit
74
86
  end
File without changes
File without changes
@@ -6,14 +6,16 @@ require 'rubygems'
6
6
  require 'getoptlong'
7
7
  require 'json'
8
8
  require 'rest_connection'
9
- require 'active_support' #for to_xml()
10
- require 'xmlsimple'
11
9
 
12
10
  def usage
13
- puts("#{$0} [--xml] [--json]")
11
+ puts("#{$0} [--xml] [--json] [[--name <server_name>] || --id <server_id>]]")
14
12
  exit
15
13
  end
16
14
 
15
+ def usage_exit
16
+ usage; exit
17
+ end
18
+
17
19
  opts = GetoptLong.new(
18
20
  [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
19
21
  [ '--id', '-i', GetoptLong::OPTIONAL_ARGUMENT ],
@@ -34,11 +36,11 @@ opts.each do |opt, arg|
34
36
  server_name = arg
35
37
  when '--id'
36
38
  server_id = arg
37
- when '--json'
38
- json = true
39
- when '--xml'
40
- xml = true
41
- end
39
+ when '--json'
40
+ json = true
41
+ when '--xml'
42
+ xml = true
43
+ end
42
44
  end
43
45
 
44
46
  # get server
File without changes
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # rs-import-publication
4
+
5
+ require 'rubygems'
6
+ require 'getoptlong'
7
+
8
+ def usage
9
+ puts("usage: rs-import-publication [--name <publication_name>] || --id <publication_id")
10
+ end
11
+
12
+ def usage_exit
13
+ usage; exit
14
+ end
15
+
16
+ def help
17
+ usage
18
+ puts ''
19
+ puts 'Imports a publication from the RightScale Marketplace.'
20
+ puts ''
21
+ puts "examples: rs-import-publication --name 'Load Balancer with HAProxy 1.5dev (v13.5)'"
22
+ puts ''
23
+ exit
24
+ end
25
+
26
+ opts = GetoptLong.new(
27
+ [ '--name', '-n', GetoptLong::OPTIONAL_ARGUMENT ],
28
+ [ '--id', '-s', 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
+ publication_name = false
36
+ publication_id = false
37
+ show_help = false
38
+ verbose = false
39
+
40
+ opts.each do |opt, arg|
41
+ case opt
42
+ when '--name'
43
+ publication_name = arg
44
+ when '--id'
45
+ publication_id = arg
46
+ when '--help'
47
+ show_help = true
48
+ when '--verbose'
49
+ verbose = true
50
+ end
51
+ end
52
+
53
+ help if show_help
54
+ usage_exit if !(publication_name || publication_id)
55
+
56
+ require 'json'
57
+ require 'yaml'
58
+ require 'right_api_client'
59
+
60
+ client = RightApi::Client.new(YAML.load_file(File.join(ENV['HOME'], '.rightscale', 'right_api_client.yml')))
61
+
62
+ # get publication
63
+ if publication_name
64
+ puts "Finding publication: '%#{publication_name}%'"
65
+ publication = client.publications.index(:filter => ["name==#{publication_name}"]).last
66
+ puts "Found publication, '#{publication.href}'."
67
+ elsif publication_id
68
+ publication = client.publications(:id => "#{publication_id}")
69
+ else
70
+ usage_exit
71
+ end
72
+
73
+ import = publication.import
74
+ puts "Imported '#{import.show.name}' [rev #{import.show.revision}] (#{import.show.href})"
File without changes
data/bin/rs-launch-server CHANGED
File without changes
data/bin/rs-query-cloud CHANGED
File without changes
File without changes
File without changes
File without changes
data/bin/rs-start-server CHANGED
File without changes
File without changes
data/bin/rs-stop-server CHANGED
File without changes
data/bin/rs-terminate-all CHANGED
File without changes
File without changes
File without changes
data/bin/rs-unlock-server CHANGED
File without changes
data/bin/rs-update-inputs CHANGED
File without changes
metadata CHANGED
@@ -1,147 +1,221 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rs-api-tools
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 2
9
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Chris Fordham
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-06-12 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 4
30
- - 4
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
31
19
  version: 1.4.4
32
- - - <=
33
- - !ruby/object:Gem::Version
34
- segments:
35
- - 1
36
- - 6
37
- - 1
38
- version: 1.6.1
39
20
  type: :runtime
40
- version_requirements: *id001
41
- - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.4
27
+ - !ruby/object:Gem::Dependency
42
28
  name: rest_connection
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: right_api_client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
43
49
  prerelease: false
44
- requirement: &id002 !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- segments:
49
- - 0
50
- version: "0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: octokit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
51
62
  type: :runtime
52
- version_requirements: *id002
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
53
69
  description: RightScale API Command Line Tools.
54
- email: chris@xhost.com.au
55
- executables:
56
- - rs-clone-deployment
57
- - rs-clone-rightscript
70
+ email: chris@fordham-nagy.id.au
71
+ executables:
72
+ - rs-describe-server-templates
73
+ - rs-describe-rightscripts
58
74
  - rs-clone-server
59
- - rs-create-alert-spec
60
- - rs-describe-alerts
75
+ - rs-describe-instance
76
+ - rs-clone-deployment
77
+ - rs-update-inputs
78
+ - rs-start-server
79
+ - rs-unlock-server
80
+ - rs-describe-publications
81
+ - rs-fetch-rightscripts
82
+ - rs-describe-publication
83
+ - rs-terminate-self
61
84
  - rs-describe-attached-vols
62
- - rs-describe-deployment
85
+ - rs-terminate-all
86
+ - rs-describe-servers
87
+ - rs-update-server-array
88
+ - rs-fetch-executables
89
+ - rs-relaunch-deployment
90
+ - rs-run-all-boot-executables
91
+ - rs-get-server-input
92
+ - rs-create-org-repositories
63
93
  - rs-describe-deployments
94
+ - rs-ping-active-servers
95
+ - rs-describe-key
64
96
  - rs-describe-ec2-ebs-snapshots
97
+ - rs-describe-repositories
65
98
  - rs-describe-ec2-ebs-volumes
66
- - rs-describe-ec2-security-groups
67
- - rs-describe-key
99
+ - rs-terminate-server
100
+ - rs-run-recipe
101
+ - rs-search-tags
68
102
  - rs-describe-keys
69
- - rs-describe-multi-cloud-images
103
+ - rs-describe-ec2-security-groups
104
+ - rs-terminate-deployment
70
105
  - rs-describe-rightscript
71
- - rs-describe-rightscripts
72
- - rs-describe-server
73
- - rs-describe-server-array
74
- - rs-describe-server-arrays
75
- - rs-describe-server-self
76
- - rs-describe-server-templates
77
- - rs-describe-servers
78
- - rs-fetch-executables
79
- - rs-fetch-rightscripts
106
+ - rs-reboot-server
80
107
  - rs-get-array-instances
81
- - rs-get-server-input
82
- - rs-get-server-monitoring
83
- - rs-get-server-sketchy-data
84
- - rs-launch-deployment
85
- - rs-launch-server
86
- - rs-lock-server
87
- - rs-ping-active-servers
108
+ - rs-describe-server-arrays
88
109
  - rs-query-cloud
89
- - rs-reboot-deployment
90
- - rs-reboot-server
91
- - rs-relaunch-deployment
110
+ - rs-launch-deployment
111
+ - rs-describe-server-self
112
+ - rs-describe-server
113
+ - rs-create-alert-spec
114
+ - rs-clone-rightscript
92
115
  - rs-relaunch-server
93
- - rs-run-all-boot-executables
94
- - rs-run-recipe
95
- - rs-run-rightscript
96
- - rs-search-tags
116
+ - rs-update-input
117
+ - rs-lock-server
118
+ - rs-describe-instances
97
119
  - rs-start-deployment
98
- - rs-start-server
99
- - rs-stop-deployment
100
120
  - rs-stop-server
121
+ - rs-reboot-deployment
122
+ - rs-describe-multi-cloud-images
123
+ - rs-launch-server
124
+ - rs-get-server-monitoring
125
+ - rs-run-rightscript
126
+ - rs-describe-server-array
101
127
  - rs-tag-array
102
- - rs-terminate-all
103
- - rs-terminate-deployment
104
- - rs-terminate-self
105
- - rs-terminate-server
106
- - rs-unlock-server
107
- - rs-update-input
108
- - rs-update-inputs
109
- - rs-update-server-array
128
+ - rs-get-server-sketchy-data
129
+ - rs-import-publication
130
+ - rs-describe-deployment
131
+ - rs-describe-alerts
132
+ - rs-stop-deployment
110
133
  extensions: []
111
-
112
134
  extra_rdoc_files: []
113
-
114
- files: []
115
-
116
- has_rdoc: true
135
+ files:
136
+ - bin/rs-describe-server-templates
137
+ - bin/rs-describe-rightscripts
138
+ - bin/rs-clone-server
139
+ - bin/rs-describe-instance
140
+ - bin/rs-clone-deployment
141
+ - bin/rs-update-inputs
142
+ - bin/rs-start-server
143
+ - bin/rs-unlock-server
144
+ - bin/rs-describe-publications
145
+ - bin/rs-fetch-rightscripts
146
+ - bin/rs-describe-publication
147
+ - bin/rs-terminate-self
148
+ - bin/rs-describe-attached-vols
149
+ - bin/rs-terminate-all
150
+ - bin/rs-describe-servers
151
+ - bin/rs-update-server-array
152
+ - bin/rs-fetch-executables
153
+ - bin/rs-relaunch-deployment
154
+ - bin/rs-run-all-boot-executables
155
+ - bin/rs-get-server-input
156
+ - bin/rs-create-org-repositories
157
+ - bin/rs-describe-deployments
158
+ - bin/rs-ping-active-servers
159
+ - bin/rs-describe-key
160
+ - bin/rs-describe-ec2-ebs-snapshots
161
+ - bin/rs-describe-repositories
162
+ - bin/rs-describe-ec2-ebs-volumes
163
+ - bin/rs-terminate-server
164
+ - bin/rs-run-recipe
165
+ - bin/rs-search-tags
166
+ - bin/rs-describe-keys
167
+ - bin/rs-describe-ec2-security-groups
168
+ - bin/rs-terminate-deployment
169
+ - bin/rs-describe-rightscript
170
+ - bin/rs-reboot-server
171
+ - bin/rs-get-array-instances
172
+ - bin/rs-describe-server-arrays
173
+ - bin/rs-query-cloud
174
+ - bin/rs-launch-deployment
175
+ - bin/rs-describe-server-self
176
+ - bin/rs-describe-server
177
+ - bin/rs-create-alert-spec
178
+ - bin/rs-clone-rightscript
179
+ - bin/rs-relaunch-server
180
+ - bin/rs-update-input
181
+ - bin/rs-lock-server
182
+ - bin/rs-describe-instances
183
+ - bin/rs-start-deployment
184
+ - bin/rs-stop-server
185
+ - bin/rs-reboot-deployment
186
+ - bin/rs-describe-multi-cloud-images
187
+ - bin/rs-launch-server
188
+ - bin/rs-get-server-monitoring
189
+ - bin/rs-run-rightscript
190
+ - bin/rs-describe-server-array
191
+ - bin/rs-tag-array
192
+ - bin/rs-get-server-sketchy-data
193
+ - bin/rs-import-publication
194
+ - bin/rs-describe-deployment
195
+ - bin/rs-describe-alerts
196
+ - bin/rs-stop-deployment
117
197
  homepage: https://github.com/flaccid/rs-api-tools
118
- licenses: []
119
-
198
+ licenses:
199
+ - Apache 2
200
+ metadata: {}
120
201
  post_install_message:
121
202
  rdoc_options: []
122
-
123
- require_paths:
203
+ require_paths:
124
204
  - lib
125
- required_ruby_version: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- segments:
130
- - 0
131
- version: "0"
132
- required_rubygems_version: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- segments:
137
- - 0
138
- version: "0"
205
+ required_ruby_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
139
215
  requirements: []
140
-
141
216
  rubyforge_project:
142
- rubygems_version: 1.3.6
217
+ rubygems_version: 2.0.3
143
218
  signing_key:
144
- specification_version: 3
219
+ specification_version: 4
145
220
  summary: rs-api-tools
146
221
  test_files: []
147
-