docl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +15 -0
- data/bin/docl +3 -0
- data/docl.gemspec +23 -0
- data/lib/docl.rb +8 -0
- data/lib/docl/cli.rb +123 -0
- data/lib/docl/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 0d3003e244752ca851975ee0f10932fa45787178
|
4
|
+
data.tar.gz: e906580ea61c15501071f3af2bf915d8727cf80a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b409ceab226c5e1c8a624f67f0cc84d225adc334a786fc62d91653926c813204cd8f10e51d10fac78168da29ffc81d82d7c6432e9a847eb0f96cf42ed6d5a394
|
7
|
+
data.tar.gz: 3680103be741db763b4d4550369e5db2a03d13c1c1d50ba623ca9019bc4422646ad683ce88086214411bb1bbf415a6ec814e6bad5acb1fde6a37810696e31be2
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Nathan Samson <nathan AT nathansamson DOT be>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# DOCL (DigitalOcean Command Line)
|
2
|
+
|
3
|
+
A command line tool for interacting with DigitalOcean.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
gem install docl
|
7
|
+
|
8
|
+
## Status
|
9
|
+
Currently it only supports a very limited subset of oeprations.
|
10
|
+
|
11
|
+
## Documentation
|
12
|
+
Run `docl help` or `docl command help` to get help.
|
13
|
+
|
14
|
+
## Contributing
|
15
|
+
To test the code run `bundle exec docl ...` which will include your code changes.
|
data/bin/docl
ADDED
data/docl.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'docl/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "docl"
|
7
|
+
gem.version = DOCL::VERSION
|
8
|
+
gem.authors = ["Nathan Samson"]
|
9
|
+
gem.email = ["nathan@nathansamson.be"]
|
10
|
+
gem.description = %q{A command line tool for interacting with your DigitalOcean droplets.}
|
11
|
+
gem.summary = %q{A command line tool for interacting with your DigitalOcean droplets.}
|
12
|
+
gem.homepage = "https://github.com/nathansamson/docl"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.required_ruby_version = ">= 1.9.3"
|
19
|
+
|
20
|
+
gem.add_dependency "thor", "~> 0.19.1"
|
21
|
+
gem.add_dependency "barge", "~> 0.10.0"
|
22
|
+
gem.add_dependency "json", "~> 1.8.1"
|
23
|
+
end
|
data/lib/docl.rb
ADDED
data/lib/docl/cli.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
class DOCL::CLI < Thor
|
2
|
+
desc "authorize", "Authrorize docl to read / modify your DO info"
|
3
|
+
def authorize
|
4
|
+
puts "You'll need to enter your DigitalOcean Private Access Token."
|
5
|
+
puts "To be able to create / modify droplets, it needs to be read / write."
|
6
|
+
puts "You can create a token on the DO website vite the Apps & API menu."
|
7
|
+
|
8
|
+
print "Enter your DO Token: "
|
9
|
+
token = $stdin.gets.chomp
|
10
|
+
|
11
|
+
f = File.open(config_path, 'w')
|
12
|
+
f.write(token)
|
13
|
+
f.close
|
14
|
+
File.chmod(0600, config_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "images", "List all images"
|
18
|
+
method_option :public, type: :boolean, default: false, aliases: '-p'
|
19
|
+
def images()
|
20
|
+
images = barge.image.all.images
|
21
|
+
images = images.select { |image| image.public == options.public }
|
22
|
+
images = images.sort { |a, b| a.name <=> b.name }
|
23
|
+
images.each do |image|
|
24
|
+
if !image.slug.nil?
|
25
|
+
puts "#{image.name} (#{image.slug}, id: #{image.id})"
|
26
|
+
else
|
27
|
+
puts "#{image.name} (id: #{image.id})"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "keys", "List all keys"
|
33
|
+
def keys()
|
34
|
+
barge.key.all.ssh_keys.each do |key|
|
35
|
+
puts "#{key.name} (id: #{key.id})"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "regions", "List regions"
|
40
|
+
method_option :metadata, type: :boolean, default: false
|
41
|
+
method_option :private_networking, type: :boolean, default: false
|
42
|
+
method_option :backups, type: :boolean, default: false
|
43
|
+
method_option :ipv6, type: :boolean, default: false
|
44
|
+
def regions()
|
45
|
+
regions = barge.region.all.regions
|
46
|
+
regions = regions.select do |region|
|
47
|
+
if options.ipv6 && !region.features.include?('ipv6')
|
48
|
+
next false
|
49
|
+
end
|
50
|
+
|
51
|
+
if options.metadata && !region.features.include?('metadata')
|
52
|
+
next false
|
53
|
+
end
|
54
|
+
|
55
|
+
if options.private_networking && !region.features.include?('private_networking')
|
56
|
+
next false
|
57
|
+
end
|
58
|
+
|
59
|
+
if options.backups && !region.features.include?('backups')
|
60
|
+
next false
|
61
|
+
end
|
62
|
+
|
63
|
+
next true
|
64
|
+
end
|
65
|
+
regions.sort { |a, b| a.name <=> b.name }.each do |region|
|
66
|
+
puts "#{region.name} (#{region.slug})"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "create [name] [image] [size] [region]", "Create a droplet"
|
71
|
+
method_option :key, type: :string, default: nil
|
72
|
+
method_option :user_data, type: :string, default: nil
|
73
|
+
method_option :private_networking, type: :boolean, default: true
|
74
|
+
method_option :enable_backups, type: :boolean, default: false
|
75
|
+
method_option :ipv6, type: :boolean, default: false
|
76
|
+
method_option :wait, type: :boolean, default: false
|
77
|
+
def create(name, image, size, region)
|
78
|
+
call_options = {
|
79
|
+
name: name,
|
80
|
+
image: image,
|
81
|
+
region: region,
|
82
|
+
size: size,
|
83
|
+
private_networking: options.private_networking,
|
84
|
+
enable_backups: options.enable_backups,
|
85
|
+
ipv6: options.ipv6,
|
86
|
+
}
|
87
|
+
if options[:key]
|
88
|
+
call_options[:ssh_keys] = [options[:key]]
|
89
|
+
end
|
90
|
+
if options.user_data
|
91
|
+
call_options[:user_data] = File.read(options.user_data)
|
92
|
+
end
|
93
|
+
puts call_options
|
94
|
+
|
95
|
+
response = barge.droplet.create(call_options)
|
96
|
+
puts response
|
97
|
+
|
98
|
+
if options.wait
|
99
|
+
print "Waiting for droplet to become available"
|
100
|
+
action_link = response.links.actions.first
|
101
|
+
begin
|
102
|
+
print '.'
|
103
|
+
sleep 1
|
104
|
+
action = barge.action.show(action_link.id).action
|
105
|
+
end until action.status != 'in-progress'
|
106
|
+
puts "Completed"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def config_path
|
112
|
+
File.expand_path('~/.docl-access-token')
|
113
|
+
end
|
114
|
+
|
115
|
+
def barge
|
116
|
+
if !File.exist?(config_path)
|
117
|
+
puts 'Please run docl authorize first.'
|
118
|
+
exit(1)
|
119
|
+
end
|
120
|
+
|
121
|
+
@barge ||= Barge::Client.new(access_token: File.read(config_path))
|
122
|
+
end
|
123
|
+
end
|
data/lib/docl/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Samson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-07 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.19.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.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: barge
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.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.10.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.8.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.8.1
|
55
|
+
description: A command line tool for interacting with your DigitalOcean droplets.
|
56
|
+
email:
|
57
|
+
- nathan@nathansamson.be
|
58
|
+
executables:
|
59
|
+
- docl
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- bin/docl
|
68
|
+
- docl.gemspec
|
69
|
+
- lib/docl.rb
|
70
|
+
- lib/docl/cli.rb
|
71
|
+
- lib/docl/version.rb
|
72
|
+
homepage: https://github.com/nathansamson/docl
|
73
|
+
licenses: []
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.9.3
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.1.11
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: A command line tool for interacting with your DigitalOcean droplets.
|
95
|
+
test_files: []
|
96
|
+
has_rdoc:
|