acquia_toolbelt 1.0.0
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 +15 -0
- data/.gitignore +3 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/Rakefile +1 -0
- data/acquia_toolbelt-0.0.1.gem +0 -0
- data/acquia_toolbelt.gemspec +29 -0
- data/bin/acquia +444 -0
- data/lib/acquia_toolbelt.rb +4 -0
- data/lib/acquia_toolbelt/version.rb +3 -0
- data/readme.md +53 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzQwNDA2Y2I3N2ZkMTY3NDUyZDRhZmEzYTBiZWY4NmNhYWM0MDdiMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmNlMTgyMTIyMTgyNWVkODQ4MGQ5NGY1OTQyNTRhNDhhNTliZWYzZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZThiNWRmYWExYzE4NDE2NDQwMzYzNmUwNWQzYzM0YzNhZThhNjM4MjdlOGFk
|
10
|
+
YzVkNjlhNTY4Y2U5MzFjYjNlMzYyZDZlOThhZTU4MzRhM2I3ZjY3YjFlNWJl
|
11
|
+
MzgxMmNmNjUzMDVmNjM2ZmMzZmRhMTA2N2U3NzdjODE4MTRjZTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWQwNjMzZjVmYTViN2JhYzc1ZDMzYTUwYWZjZmI5YzJmMzU2MzBjMGNhZWIy
|
14
|
+
YWUwOWYyNzE5ZDM3YWZiODVjZWMyNDExNzY2ODczNGJjNWU4MjNiN2FiOTZm
|
15
|
+
ZTJlNzhmMTNjYmI2NzJjOWQ1MTI4ZjY0MTBlNmVlOTRhNTY5MjU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Jacob Bednarz.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'acquia_toolbelt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "acquia_toolbelt"
|
8
|
+
spec.version = AcquiaToolbelt::VERSION
|
9
|
+
spec.authors = ["Jacob Bednarz"]
|
10
|
+
spec.email = ["jacob.bednarz@gmail.com"]
|
11
|
+
spec.description = %q{A CLI tool for interacting with Acquia's hosting services.}
|
12
|
+
spec.summary = ""
|
13
|
+
spec.homepage = "https://github.com/jacobbednarz/acquia-toolbelt"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "thor", "0.18.1"
|
22
|
+
spec.add_runtime_dependency "netrc", "0.7.7"
|
23
|
+
spec.add_runtime_dependency "highline", "1.6.19"
|
24
|
+
spec.add_runtime_dependency "faraday", "0.8.8"
|
25
|
+
spec.add_runtime_dependency "json", "1.8.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
end
|
data/bin/acquia
ADDED
@@ -0,0 +1,444 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "netrc"
|
5
|
+
require "highline/import"
|
6
|
+
require "faraday"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
class Acquia < Thor
|
10
|
+
# A no_commands block is designed to show the methods that cannot be invoked
|
11
|
+
# and as such, do not have a description.
|
12
|
+
no_commands {
|
13
|
+
# Internal: Used for outputting a pretty success message.
|
14
|
+
#
|
15
|
+
# Returns the coloured and formatted string.
|
16
|
+
def success(text)
|
17
|
+
puts "\e[#32m#{text}\e[0m"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Internal: Used for outputting a pretty error message.
|
21
|
+
#
|
22
|
+
# Returns the coloured and formatted string.
|
23
|
+
def fail(text)
|
24
|
+
puts "\e[#31m#{text}\e[0m"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Internal: Used for outputting a pretty info message.
|
28
|
+
#
|
29
|
+
# Returns the coloured and formatted string.
|
30
|
+
def info(text)
|
31
|
+
puts "\e[#36m#{text}\e[0m"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Internal: Create a request to the Acquia API.
|
35
|
+
#
|
36
|
+
# The request generated contains all the correct user authentication and
|
37
|
+
# headers.
|
38
|
+
#
|
39
|
+
# Returns a JSON string of the body.
|
40
|
+
def acquia_api_call(resource, method = "GET", data = {})
|
41
|
+
n = Netrc.read
|
42
|
+
@acquia_user, @acquia_password = n["cloudapi.acquia.com"]
|
43
|
+
|
44
|
+
#conn = Faraday.new(:proxy => "http://csydl217.au.fcl.internal:3128")
|
45
|
+
conn = Faraday.new
|
46
|
+
conn.basic_auth(@acquia_user, @acquia_password)
|
47
|
+
|
48
|
+
case method
|
49
|
+
when "GET"
|
50
|
+
response = conn.get "https://cloudapi.acquia.com/v1/#{resource}.json"
|
51
|
+
JSON.parse response.body
|
52
|
+
when "POST"
|
53
|
+
response = conn.post "https://cloudapi.acquia.com/v1/#{resource}.json", data.to_json
|
54
|
+
JSON.parse response.body
|
55
|
+
when "DELETE"
|
56
|
+
response = conn.delete "https://cloudapi.acquia.com/v1/#{resource}.json"
|
57
|
+
JSON.parse response.body
|
58
|
+
else
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Internal: Get defined subscription environments.
|
63
|
+
#
|
64
|
+
# This is a helper method that fetches all the available environments for a
|
65
|
+
# subscription and returns them for use in other methods.
|
66
|
+
#
|
67
|
+
# Returns an array of environments.
|
68
|
+
def get_acquia_environments(subscription)
|
69
|
+
env_data = acquia_api_call "sites/#{subscription}/envs"
|
70
|
+
|
71
|
+
envs = []
|
72
|
+
env_data.each do |env|
|
73
|
+
envs << env["name"]
|
74
|
+
end
|
75
|
+
|
76
|
+
envs
|
77
|
+
end
|
78
|
+
|
79
|
+
# Internal: Truncate a SSH key to a secure and recognisable size.
|
80
|
+
#
|
81
|
+
# Displaying whole SSH keys is probably a bad idea so instead we are getting
|
82
|
+
# the first 30 characters and the last 100 characters of the key and
|
83
|
+
# separating them with an ellipis. This allows you to recognise the
|
84
|
+
# important parts of the key instead of the whole thing.
|
85
|
+
#
|
86
|
+
# Returns string.
|
87
|
+
def truncate_ssh_key(ssh_key)
|
88
|
+
front_part = ssh_key[0...30]
|
89
|
+
back_part = ssh_key[-50, 50]
|
90
|
+
new_ssh_key = "#{front_part}...#{back_part}"
|
91
|
+
end
|
92
|
+
|
93
|
+
# Internal: Send a request to purge a domain's cache.
|
94
|
+
#
|
95
|
+
# Purge the web cache via an API call.
|
96
|
+
#
|
97
|
+
# Returns a status message.
|
98
|
+
def purge_acquia_domain(subscription, environment, domain)
|
99
|
+
# Ensure all the required fields are available.
|
100
|
+
if subscription.nil? || environment.nil? || domain.nil?
|
101
|
+
fail "Purge request is missing a required parameter."
|
102
|
+
return
|
103
|
+
end
|
104
|
+
|
105
|
+
purge_request = acquia_api_call "sites/#{subscription}/envs/#{environment}/domains/#{domain}/cache", "DELETE"
|
106
|
+
success "#{domain} has been successfully purged." if purge_request["id"]
|
107
|
+
end
|
108
|
+
}
|
109
|
+
|
110
|
+
# Public: Log into the Acquia Cloud API.
|
111
|
+
#
|
112
|
+
# This sets up the user account within the netrc file so that subsequent
|
113
|
+
# calls can reuse the authentication without the user being prompted for it.
|
114
|
+
#
|
115
|
+
# Returns the status of your login attempt.
|
116
|
+
desc "login", "Login to your Acquia account."
|
117
|
+
def login
|
118
|
+
user = ask "Enter your username:"
|
119
|
+
password = ask "Enter your password:"
|
120
|
+
|
121
|
+
# Update (or create if needed) the netrc file that will contain the user
|
122
|
+
# authentication details.
|
123
|
+
n = Netrc.read
|
124
|
+
n.new_item_prefix = "# This entry was added for connecting to the Acquia Cloud API\n"
|
125
|
+
n["cloudapi.acquia.com"] = user, password
|
126
|
+
n.save
|
127
|
+
|
128
|
+
success "Your user credentials have been successfully set."
|
129
|
+
end
|
130
|
+
|
131
|
+
# Public: Display an overview of the subscriptions.
|
132
|
+
#
|
133
|
+
# Returns all subscriptions with their respective data.
|
134
|
+
desc "list-subscriptions", "Find all subscriptions that you have access to."
|
135
|
+
def list_subscriptions
|
136
|
+
subscriptions = acquia_api_call "sites"
|
137
|
+
|
138
|
+
subscriptions.each do |subscription|
|
139
|
+
say
|
140
|
+
# Get the individual subscription information.
|
141
|
+
subscription_info = acquia_api_call "sites/#{subscription}"
|
142
|
+
say "#{subscription_info["title"]}"
|
143
|
+
say "> Username: #{subscription_info["unix_username"]}"
|
144
|
+
say "> Subscription: #{subscription_info["name"]}"
|
145
|
+
|
146
|
+
# If the VCS type is SVN, we want it in all uppercase, otherwise just
|
147
|
+
# capitilise it.
|
148
|
+
if subscription_info["vcs_type"] == 'svn'
|
149
|
+
say "> #{subscription_info["vcs_type"].upcase} URL: #{subscription_info["vcs_url"]}"
|
150
|
+
else
|
151
|
+
say "> #{subscription_info["vcs_type"].capitalize} URL: #{subscription_info["vcs_url"]}"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Public: Provide an overview of the environments in your subscription.
|
157
|
+
#
|
158
|
+
# Returns the environment data in a pretty format.
|
159
|
+
desc "list-environments <subscription>", "Provide an overview of the environments in your subscription."
|
160
|
+
option :environment, :aliases => "-e"
|
161
|
+
def list_environments(subscription)
|
162
|
+
# If the environment option is set, just fetch a single environment.
|
163
|
+
if options[:environment]
|
164
|
+
subscription_envs = [options[:environment]]
|
165
|
+
else
|
166
|
+
subscription_envs = get_acquia_environments(subscription)
|
167
|
+
end
|
168
|
+
|
169
|
+
subscription_envs.each do |environment|
|
170
|
+
env_info = acquia_api_call "sites/#{subscription}/envs/#{environment}"
|
171
|
+
say
|
172
|
+
say "> Host: #{env_info["ssh_host"]}"
|
173
|
+
say "> Environment: #{env_info["name"]}"
|
174
|
+
say "> Current release: #{env_info["vcs_path"]}"
|
175
|
+
say "> DB clusters: #{env_info["db_clusters"].to_s unless env_info["db_clusters"].nil?}"
|
176
|
+
say "> Default domain: #{env_info["default_domain"]}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# Public: Get server specs and information from an environment.
|
181
|
+
#
|
182
|
+
# This allows the ability to get all the server data from all server types
|
183
|
+
# that are available within the subscription's environments.
|
184
|
+
#
|
185
|
+
# Returns server information on a per environment basis.
|
186
|
+
desc "list-servers <subscription>", "Get a list of servers specifications for an environment."
|
187
|
+
option :environment, :aliases => "-e"
|
188
|
+
def list_servers(subscription)
|
189
|
+
# Determine if we want just a single environment, or all of them at once.
|
190
|
+
if options[:environment]
|
191
|
+
subscription_envs = [options[:environment]]
|
192
|
+
else
|
193
|
+
subscription_envs = get_acquia_environments(subscription)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Loop over each environment and get all the associated server data.
|
197
|
+
subscription_envs.each do |environment|
|
198
|
+
if options[:environment].nil?
|
199
|
+
say
|
200
|
+
say "Environment: #{environment}"
|
201
|
+
end
|
202
|
+
|
203
|
+
server_env = acquia_api_call "sites/#{subscription}/envs/#{environment}/servers"
|
204
|
+
server_env.each do |server|
|
205
|
+
say
|
206
|
+
say "> Host: #{server["fqdn"]}"
|
207
|
+
say "> EC2 region: #{server["ec2_region"]}"
|
208
|
+
say "> Availability zone: #{server["ec2_availability_zone"]}"
|
209
|
+
say "> EC2 instance type: #{server["ami_type"]}"
|
210
|
+
|
211
|
+
# Show how many PHP processes this node can have. Note, this is only
|
212
|
+
# available on the web servers.
|
213
|
+
if server["services"] && server["services"]["php_max_procs"]
|
214
|
+
say "> PHP max processes: #{server["services"]["php_max_procs"]}"
|
215
|
+
end
|
216
|
+
|
217
|
+
if server["services"] && server["services"]["status"]
|
218
|
+
say "> Status: #{server["services"]["status"]}"
|
219
|
+
end
|
220
|
+
|
221
|
+
if server["services"] && server["services"]["web"]
|
222
|
+
say "> Web status: #{server["services"]["web"]["status"]}"
|
223
|
+
end
|
224
|
+
|
225
|
+
# The state of varnish.
|
226
|
+
if server["services"] && server["services"]["varnish"]
|
227
|
+
say "> Varnish status: #{server["services"]["varnish"]["status"]}"
|
228
|
+
end
|
229
|
+
|
230
|
+
# Only load balancers will have the "external IP" property.
|
231
|
+
if server["services"] && server["services"]["external_ip"]
|
232
|
+
say "> External IP: #{server["services"]["external_ip"]}"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# Public: Get information regarding the database instances.
|
239
|
+
#
|
240
|
+
# Within this method we have a few different options to get the information we
|
241
|
+
# require. If just an environment is passed, only the names are returned. Pass
|
242
|
+
# the environment param and the username, pasword, host, db cluster and
|
243
|
+
# instance name are returned for each database available. Passing a database
|
244
|
+
# name and the environment will only return that particular database.
|
245
|
+
#
|
246
|
+
# Returns database information.
|
247
|
+
desc "list-databases <subscription>", "See information about the databases within a subscription."
|
248
|
+
option :environment, :aliases => "-e"
|
249
|
+
option :database, :aliases => "-d"
|
250
|
+
def list_databases(subscription)
|
251
|
+
# If we have both the database name and environment, only fetch a single
|
252
|
+
# result.
|
253
|
+
if options[:database] && options[:environment]
|
254
|
+
database = acquia_api_call "sites/#{subscription}/envs/#{options[:environment]}/dbs/#{options[:database]}"
|
255
|
+
say
|
256
|
+
say "> Username: #{database["username"]}"
|
257
|
+
say "> Password: #{database["password"]}"
|
258
|
+
say "> Host: #{database["host"]}"
|
259
|
+
say "> DB cluster: #{database["db_cluster"]}"
|
260
|
+
say "> Instance name: #{database["instance_name"]}"
|
261
|
+
return
|
262
|
+
end
|
263
|
+
|
264
|
+
# Fetch all the databases in a specific environment.
|
265
|
+
if options[:environment]
|
266
|
+
databases = acquia_api_call "sites/#{subscription}/envs/#{options[:environment]}/dbs"
|
267
|
+
databases.each do |db|
|
268
|
+
say
|
269
|
+
say "#{db["name"]}"
|
270
|
+
say "> Username: #{db["username"]}"
|
271
|
+
say "> Password: #{db["password"]}"
|
272
|
+
say "> Host: #{db["host"]}"
|
273
|
+
say "> DB cluster: #{db["db_cluster"]}"
|
274
|
+
say "> Instance name: #{db["instance_name"]}"
|
275
|
+
end
|
276
|
+
else
|
277
|
+
subscription_envs = [options[:environment]]
|
278
|
+
databases = acquia_api_call "sites/#{subscription}/dbs"
|
279
|
+
|
280
|
+
say
|
281
|
+
databases.each do |db|
|
282
|
+
say "> #{db["name"]}"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# Public: List all backups for a database instance.
|
288
|
+
#
|
289
|
+
# Fetching all database backups for an instance is a pretty heavy call as the
|
290
|
+
# data isn't restricted in any way by time, id's, etc.
|
291
|
+
#
|
292
|
+
# Returns a database backup listing.
|
293
|
+
desc "list-database-backups <subscription> <environment> <database>", "Get all backups for a database instance."
|
294
|
+
def list_database_backups(subscription, environment, database)
|
295
|
+
backups = acquia_api_call "sites/#{subscription}/envs/#{environment}/dbs/#{database}/backups"
|
296
|
+
backups.each do |backup|
|
297
|
+
say
|
298
|
+
say "> ID: #{backup["id"]}"
|
299
|
+
say "> MD5: #{backup["checksum"]}"
|
300
|
+
say "> Type: #{backup["type"]}"
|
301
|
+
say "> Path: #{backup["path"]}"
|
302
|
+
say "> Link: #{backup["link"]}"
|
303
|
+
say "> Started: #{Time.at(backup["started"].to_i)}"
|
304
|
+
say "> Completed: #{Time.at(backup["completed"].to_i)}"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
# Public: Create a new database instance.
|
309
|
+
#
|
310
|
+
# Returns a success message upon creation.
|
311
|
+
desc "add-database <subscription> <database>", "Create a new database instance."
|
312
|
+
def add_database(subscription, database)
|
313
|
+
add_database = acquia_api_call "sites/#{subscription}/dbs", "POST", :db => "#{database}"
|
314
|
+
success "A new database has been created." if add_database["id"]
|
315
|
+
end
|
316
|
+
|
317
|
+
# Public: Delete a database instance.
|
318
|
+
#
|
319
|
+
# Returns a status message based on the task completion.
|
320
|
+
desc "delete-database <subscription> <database>", "Remove all instances of a database."
|
321
|
+
def delete_database(subscription, database)
|
322
|
+
delete_db = acquia_api_call "sites/#{subscription}/dbs/#{database}?backup=0", "DELETE"
|
323
|
+
success "Database has been successfully deleted." if delete_db["id"]
|
324
|
+
end
|
325
|
+
|
326
|
+
# Public: Copy a database from one environment to another.
|
327
|
+
#
|
328
|
+
# Returns the status message.
|
329
|
+
desc "copy-database <subscription> <database> <source> <destination>", "Copy a database one from environment to another."
|
330
|
+
def copy_database(subscription, database, source, destination)
|
331
|
+
copy_database = acquia_api_call "sites/#{subscription}/dbs/#{database}/db-copy/#{source}/#{destination}", "POST"
|
332
|
+
success "Database #{database} has been copied from #{source} to #{destination}." if copy_database["id"]
|
333
|
+
end
|
334
|
+
|
335
|
+
# Public: Show all the available domains for a subscription.
|
336
|
+
#
|
337
|
+
# Returns a list of the domains available.
|
338
|
+
desc "list-domains <subscription>", "Show all available domains for a subscription."
|
339
|
+
option :environment, :aliases => "-e"
|
340
|
+
def list_domains(subscription)
|
341
|
+
if options[:environment]
|
342
|
+
subscription_envs = [options[:environment]]
|
343
|
+
else
|
344
|
+
subscription_envs = get_acquia_environments(subscription)
|
345
|
+
end
|
346
|
+
|
347
|
+
subscription_envs.each do |environment|
|
348
|
+
domains = acquia_api_call "sites/#{subscription}/envs/#{environment}/domains"
|
349
|
+
# Got top padding?
|
350
|
+
if options[:environment]
|
351
|
+
say
|
352
|
+
else
|
353
|
+
say
|
354
|
+
say "Environment: #{environment}"
|
355
|
+
end
|
356
|
+
domains.each do |domain|
|
357
|
+
say "> #{domain["name"]}"
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# Public: Clear a web cache on a domain.
|
363
|
+
#
|
364
|
+
# Send off a DELETE request to clear the web cache for a particular domain or
|
365
|
+
# environment.
|
366
|
+
#
|
367
|
+
# Note: Clearing a whole environment is pretty perfomance heavy - use with
|
368
|
+
# caution!
|
369
|
+
#
|
370
|
+
# Returns a status message form the purge request.
|
371
|
+
desc "purge-domain <subscription> <environment>", "Clear the web cache of an environment or domain."
|
372
|
+
option :environment, :aliases => "-e"
|
373
|
+
option :domain, :aliases => "-d"
|
374
|
+
def purge_domain(subscription, environment)
|
375
|
+
domain = options[:domain]
|
376
|
+
|
377
|
+
# If the domain is not defined, we are going to clear a whole environmnt.
|
378
|
+
# This can have severe performance impacts on your environments. We need to
|
379
|
+
# be sure this is defintely what you want to do.
|
380
|
+
if domain
|
381
|
+
purge_acquia_domain(subscription, environment, domain)
|
382
|
+
else
|
383
|
+
all_env_clear = ask "You are about to clear all domains in the #{environment} environment. Are you sure? (y/n)"
|
384
|
+
# Last chance to bail out.
|
385
|
+
if all_env_clear == "y"
|
386
|
+
domains = acquia_api_call "sites/#{subscription}/envs/#{environment}/domains"
|
387
|
+
domains.each do |domain|
|
388
|
+
purge_acquia_domain("#{subscription}", "#{environment}", "#{domain["name"]}")
|
389
|
+
end
|
390
|
+
else
|
391
|
+
info "Ok, no action has been taken."
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
# Public: Get all the SVN users.
|
397
|
+
#
|
398
|
+
# Returns a list of the SVN users.
|
399
|
+
desc "list-svn-users <subscription>", "See all the SVN users on a subscription."
|
400
|
+
def list_svn_users(subscription)
|
401
|
+
svn_users = acquia_api_call "sites/#{subscription}/svnusers"
|
402
|
+
|
403
|
+
svn_users.each do |user|
|
404
|
+
say
|
405
|
+
say "> ID: #{user["id"]}"
|
406
|
+
say "> Name: #{user["username"]}"
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
desc "delete-svn-user <subscription> <userid>", "Delete a SVN user."
|
411
|
+
def delete_svn_user(subscription, userid)
|
412
|
+
svn_user_removal = acquia_api_call "sites/#{subscription}/svnusers/#{userid}", "DELETE"
|
413
|
+
success "#{userid} has been removed from the SVN users." if svn_user_removal["id"]
|
414
|
+
end
|
415
|
+
|
416
|
+
# Public: Get users on the subscription.
|
417
|
+
#
|
418
|
+
# Display a user listing with a truncated SSH key for security and ease of
|
419
|
+
# use.
|
420
|
+
#
|
421
|
+
# Returns a list of users and truncated SSH keys.
|
422
|
+
desc "list-ssh-users <subscription>", "Find out who has access and SSH keys."
|
423
|
+
def list_ssh_users(subscription)
|
424
|
+
users = acquia_api_call "sites/#{subscription}/sshkeys"
|
425
|
+
|
426
|
+
users.each do |user|
|
427
|
+
say
|
428
|
+
say "> ID: #{user["id"]}"
|
429
|
+
say "> Name: #{user["nickname"]}"
|
430
|
+
say "> Key: #{truncate_ssh_key user["ssh_pub_key"]}"
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
# Public: Copy files from one environment to another.
|
435
|
+
#
|
436
|
+
# Returns a status message.
|
437
|
+
desc "copy-files <subscription> <source> <destination>", "Copy files from one environment to another."
|
438
|
+
def copy_files(subscription, source, destination)
|
439
|
+
file_copy = acquia_api_call "/sites/#{subscription}/files-copy/#{source}/#{target}", "POST"
|
440
|
+
success "File copy from #{source} to #{destination} has started." if file_copy["id"]
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
Acquia.start
|
data/readme.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Acquia Toolbelt
|
2
|
+
|
3
|
+
The Acquia Toolbelt is a CLI tool for using the Acquia Cloud API. Some of the
|
4
|
+
features include getting information around your servers, subscription,
|
5
|
+
databases, tasks and domains.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Installation is available (and recommended) via Ruby Gems.
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install acquia_toolbelt
|
13
|
+
```
|
14
|
+
|
15
|
+
Once installed, the toolbelt is accessible via invoking `acquia` within the command line.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
You can see all available commands by running `acquia` without any commands or parameters. Additonally, more information on each command is available via `acquia help [COMMAND]`.
|
20
|
+
|
21
|
+
```
|
22
|
+
$ acquia
|
23
|
+
|
24
|
+
Commands:
|
25
|
+
acquia add-database <subscription> <database> # Create a new database instance.
|
26
|
+
acquia copy-database <subscription> <database> <source> <destination> # Copy a database one from environment to another.
|
27
|
+
acquia copy-files <subscription> <source> <destination> # Copy files from one environment to another.
|
28
|
+
acquia delete-database <subscription> <database> # Remove all instances of a database.
|
29
|
+
acquia delete-svn-user <subscription> <userid> # Delete a SVN user.
|
30
|
+
acquia help [COMMAND] # Describe available commands or one specific command
|
31
|
+
acquia list-database-backups <subscription> <environment> <database> # Get all backups for a database instance.
|
32
|
+
acquia list-databases <subscription> # See information about the databases within a subscription.
|
33
|
+
acquia list-domains <subscription> # Show all available domains for a subscription.
|
34
|
+
acquia list-environments <subscription> # Provide an overview of the environments in your subscription.
|
35
|
+
acquia list-servers <subscription> # Get a list of servers specifications for an environment.
|
36
|
+
acquia list-ssh-users <subscription> # Find out who has access and SSH keys.
|
37
|
+
acquia list-subscriptions # Find all subscriptions that you have access to.
|
38
|
+
acquia list-svn-users <subscription> # See all the SVN users on a subscription.
|
39
|
+
acquia login # Login to your Acquia account.
|
40
|
+
acquia purge-domain <subscription> # Clear the web cache of an environment or domain.
|
41
|
+
```
|
42
|
+
|
43
|
+
## Getting started
|
44
|
+
|
45
|
+
Before you can start using any commands, you need to first run `acquia login`. This will write your login details to a local netrc file so that you won't be prompted for login details every time a request is made. After that, the sky is the limit!
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acquia_toolbelt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Bednarz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: netrc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.7
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: highline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.19
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.19
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.8
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.8.8
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A CLI tool for interacting with Acquia's hosting services.
|
112
|
+
email:
|
113
|
+
- jacob.bednarz@gmail.com
|
114
|
+
executables:
|
115
|
+
- acquia
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .gitignore
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE
|
122
|
+
- Rakefile
|
123
|
+
- acquia_toolbelt-0.0.1.gem
|
124
|
+
- acquia_toolbelt.gemspec
|
125
|
+
- bin/acquia
|
126
|
+
- lib/acquia_toolbelt.rb
|
127
|
+
- lib/acquia_toolbelt/version.rb
|
128
|
+
- readme.md
|
129
|
+
homepage: https://github.com/jacobbednarz/acquia-toolbelt
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.0.3
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: ''
|
153
|
+
test_files: []
|