ocean_commander 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGZiZGE5YTM1MDMwYmE0ZTAzNmFiMjQ1NGE4MmE4YmE5YmVjNGUzMA==
5
+ data.tar.gz: !binary |-
6
+ NDQzOGZmOTY4YjBkMjRiZTRmYzZmMTBlYmFlMThhOTViZjc5NTllMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTY0ZTBmMWNhNmM3NTMyYmQyNmYzMzJiMzczM2I2YWQ4ZDBjMTFmOGU5NDU3
10
+ NGFjZjE5OGIwMzY2ZTA4NWQ4ZmY1MmI3MDZhNzM5YzM5ZWNhMDNkYjFhYTlh
11
+ ZWYxODlhM2M0MGE2MGE5ZjI0M2QyMDE3YmFmNDQ2YjYzMzRjMmY=
12
+ data.tar.gz: !binary |-
13
+ ZTUwNzE1OWIzMDIyZmY5MzFjNTk3OTBmNWM3YTkyYTMxYmVjMWQyOTdlMDA2
14
+ NDAwNGYzZDdhNjg1ZWMzNzg3N2VmMmRmZDNmYjAzY2I5ZjcyM2ZiNDQzNTNi
15
+ YjQzYjY4ZTZjNTQzNDkxMWI5ZWYzMGEyNDY1NjgwZGFhMjFlMWU=
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
19
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ocean_commander.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ming Liu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # OceanCommander
2
+
3
+ Command line tool to manage your Digital Ocean's resources
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ocean_commander'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ocean_commander
18
+
19
+ ## Usage
20
+
21
+ First you need to get your Digital Ocean's client id and API key from https://www.digitalocean.com/api_access
22
+
23
+ Then you can set these environment variables
24
+
25
+ $ export DIGITAL_OCEAN_CLIENT_ID=[CLIENT_ID]
26
+ $ export DIGITAL_OCEAN_API_KEY=[API_KEY]
27
+
28
+ Now you can manage your Digital Ocean's resources
29
+
30
+ $ ocean droplets list
31
+
32
+ You can get help info like this
33
+
34
+ $ ocean help
35
+ $ ocean droplets help
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/ocean_commander"
4
+
5
+ OceanCommander::Ocean.start(ARGV)
@@ -0,0 +1,34 @@
1
+ require 'thor'
2
+ require 'digital_ocean'
3
+ require 'table_print'
4
+
5
+ require_relative "ocean_commander/version"
6
+ require_relative "ocean_commander/general"
7
+ require_relative "ocean_commander/droplets"
8
+ require_relative "ocean_commander/regions"
9
+ require_relative "ocean_commander/images"
10
+ require_relative "ocean_commander/ssh_keys"
11
+ require_relative "ocean_commander/sizes"
12
+ require_relative "ocean_commander/domains"
13
+
14
+ module OceanCommander
15
+ class Ocean < General
16
+ desc "droplets", "manage droplets"
17
+ subcommand :droplets, Droplets
18
+
19
+ desc "ssh_keys", "manage ssh keys"
20
+ subcommand :ssh_keys, SshKeys
21
+
22
+ desc "images", "manage images"
23
+ subcommand :images, Images
24
+
25
+ desc "regions", "list regions"
26
+ subcommand :regions, Regions
27
+
28
+ desc "sizes", "manage sizes"
29
+ subcommand :sizes, Sizes
30
+
31
+ desc "domains", "manage domains"
32
+ subcommand :domains, Domains
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ module OceanCommander
2
+ class Domains < General
3
+ desc "list", "list domains"
4
+ def list
5
+ tp api.domains.list.domains
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,52 @@
1
+ module OceanCommander
2
+ class Droplets < General
3
+ desc "list", "list droplets"
4
+ def list
5
+ tp api.droplets.list.droplets
6
+ end
7
+ desc "create NAME SIZE_ID IMAGE_ID REGION_ID", "create a droplet"
8
+ def create(name, size, image, region, ssh_keys='')
9
+ tp api.droplets.create(name: name, size_id: size, image_id: image, region_id: region, ssh_key_ids: ssh_keys).droplet
10
+ end
11
+
12
+ desc "delete ID", "delete a droplet"
13
+ def delete(id)
14
+ tp api.droplets.delete(id)
15
+ end
16
+
17
+ desc "show", "show a droplet"
18
+ def show(id)
19
+ tp api.droplets.show(id).droplet
20
+ end
21
+
22
+ desc "reboot", "reboot a droplet"
23
+ def reboot(id)
24
+ tp api.droplets.reboot(id).droplet
25
+ end
26
+
27
+ desc "shutdown", "shutdown a droplet"
28
+ def shutdown(id)
29
+ tp api.droplets.shutdown(id)
30
+ end
31
+
32
+ desc "poweron", "turn on a droplet"
33
+ def poweron(id)
34
+ tp api.droplets.power_on(id)
35
+ end
36
+
37
+ desc "poweroff", "turn off a droplet"
38
+ def poweroff(id)
39
+ tp api.droplets.power_off(id)
40
+ end
41
+
42
+ desc "rebuild", "rebuild a droplet"
43
+ def rebuild(id, image_id)
44
+ tp api.droplets.rebuild(id, image_id: image_id)
45
+ end
46
+
47
+ desc "password_reset", "reset password for a droplet"
48
+ def password_reset(id, image_id)
49
+ tp api.droplets.password_reset(id)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,17 @@
1
+ module OceanCommander
2
+ class General < Thor
3
+ class_option :debug, :type => :boolean
4
+ class_option :client_id, :type => :string
5
+ class_option :api_key, :type => :string
6
+
7
+ private
8
+
9
+ def api
10
+ DigitalOcean::API.new(
11
+ client_id: options[:client_id] || ENV['DIGITAL_OCEAN_CLIENT_ID'],
12
+ api_key: options[:api_key] || ENV['DIGITAL_OCEAN_API_KEY'],
13
+ debug: options[:debug] || false
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ module OceanCommander
2
+ class Images < General
3
+ desc "list", "list images"
4
+ def list
5
+ tp api.images.list.images
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module OceanCommander
2
+ class Regions < General
3
+ desc "list", "list regions"
4
+ def list
5
+ tp api.regions.list.regions
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module OceanCommander
2
+ class Sizes < General
3
+ desc "list", "list sizes"
4
+ def list
5
+ tp api.sizes.list.sizes
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ module OceanCommander
2
+ class SshKeys < General
3
+ desc "list", "list ssh keys"
4
+ def list
5
+ tp api.ssh_keys.list.ssh_keys
6
+ end
7
+
8
+ desc "show SSH_KEY_ID", "show an ssh key"
9
+ def show(id=nil)
10
+ tp api.ssh_keys.show(id).ssh_key
11
+ end
12
+
13
+ desc "add NAME SSH_PUB_KEY", "add a ssh public key"
14
+ def add(name,ssh_pub_key=nil)
15
+ tp api.ssh_keys.add(name: name, ssh_pub_key: ssh_pub_key).ssh_key
16
+ end
17
+
18
+ desc "edit SSH_KEY_ID SSH_PUB_KEY", "edit an ssh key"
19
+ def edit(id, ssh_pub_key=nil)
20
+ tp api.ssh_keys.edit(id, ssh_pub_key: ssh_pub_key).ssh_key
21
+ end
22
+
23
+ desc "destroy", "delete an ssh public key"
24
+ def destroy(id)
25
+ tp api.ssh_keys.delete(id).ssh_key
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module OceanCommander
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ocean_commander/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ocean_commander"
8
+ spec.version = OceanCommander::VERSION
9
+ spec.authors = ["Ming Liu"]
10
+ spec.email = ["liuming@lmws.net"]
11
+ spec.description = %q{Command line tool to manage your Digital Ocean's resources}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/liuming/ocean_commander"
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_dependency "thor", ">= 0.18.1"
22
+ spec.add_dependency "digital_ocean", ">= 1.2.0"
23
+ spec.add_dependency "table_print", ">= 1.4.0"
24
+ spec.add_development_dependency "bundler", "~> 1.3.5"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec", ">=2.14.1"
27
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ocean_commander
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ming Liu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-15 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: digital_ocean
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: table_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.14.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.14.1
97
+ description: Command line tool to manage your Digital Ocean's resources
98
+ email:
99
+ - liuming@lmws.net
100
+ executables:
101
+ - ocean
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/ocean
111
+ - lib/ocean_commander.rb
112
+ - lib/ocean_commander/domains.rb
113
+ - lib/ocean_commander/droplets.rb
114
+ - lib/ocean_commander/general.rb
115
+ - lib/ocean_commander/images.rb
116
+ - lib/ocean_commander/regions.rb
117
+ - lib/ocean_commander/sizes.rb
118
+ - lib/ocean_commander/ssh_keys.rb
119
+ - lib/ocean_commander/version.rb
120
+ - ocean_commander.gemspec
121
+ homepage: https://github.com/liuming/ocean_commander
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.1.9
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Command line tool to manage your Digital Ocean's resources
145
+ test_files: []