vagrant-1cloud 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +10 -0
- data/LICENSE +373 -0
- data/Rakefile +22 -0
- data/lib/vagrant-1cloud.rb +14 -0
- data/lib/vagrant-1cloud/actions.rb +138 -0
- data/lib/vagrant-1cloud/actions/check_state.rb +19 -0
- data/lib/vagrant-1cloud/actions/create.rb +70 -0
- data/lib/vagrant-1cloud/actions/destroy.rb +30 -0
- data/lib/vagrant-1cloud/actions/power_off.rb +35 -0
- data/lib/vagrant-1cloud/actions/power_on.rb +36 -0
- data/lib/vagrant-1cloud/actions/reload.rb +33 -0
- data/lib/vagrant-1cloud/actions/shut_down.rb +35 -0
- data/lib/vagrant-1cloud/config.rb +46 -0
- data/lib/vagrant-1cloud/errors.rb +33 -0
- data/lib/vagrant-1cloud/helpers/client.rb +83 -0
- data/lib/vagrant-1cloud/helpers/result.rb +40 -0
- data/lib/vagrant-1cloud/plugin.rb +21 -0
- data/lib/vagrant-1cloud/provider.rb +67 -0
- data/lib/vagrant-1cloud/version.rb +5 -0
- data/locales/en.yml +67 -0
- data/test/Vagrantfile +16 -0
- data/test/scripts/provision.sh +3 -0
- data/test/test.sh +9 -0
- data/vagrant-1cloud.gemspec +21 -0
- metadata +113 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module OneCloud
|
3
|
+
class Plugin < Vagrant.plugin('2')
|
4
|
+
name 'OneCloud'
|
5
|
+
description <<-DESC
|
6
|
+
This plugin installs a provider that allows Vagrant to manage
|
7
|
+
machines using 1cloud's API.
|
8
|
+
DESC
|
9
|
+
|
10
|
+
config(:1cloud, :provider) do
|
11
|
+
require_relative 'config'
|
12
|
+
Config
|
13
|
+
end
|
14
|
+
|
15
|
+
provider(:1cloud, parallel: false, defaultable: false) do
|
16
|
+
require_relative 'provider'
|
17
|
+
Provider
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'vagrant-1cloud/actions'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module OneCloud
|
5
|
+
class Provider < Vagrant.plugin('2', :provider)
|
6
|
+
|
7
|
+
# This class method caches status for all droplets within
|
8
|
+
# the 1cloud account. A specific droplet's status
|
9
|
+
# may be refreshed by passing :refresh => true as an option.
|
10
|
+
def self.droplet(machine, opts = {})
|
11
|
+
client = Helpers::ApiClient.new(machine)
|
12
|
+
|
13
|
+
# load status of droplets if it has not been done before
|
14
|
+
if !@droplets
|
15
|
+
@droplets = client.request('/server')
|
16
|
+
end
|
17
|
+
|
18
|
+
if opts[:refresh] && machine.id
|
19
|
+
# refresh the droplet status for the given machine
|
20
|
+
@droplets.delete_if { |d| d['id'].to_s == machine.id }
|
21
|
+
@droplets << droplet = client.request("/server/#{machine.id}")
|
22
|
+
else
|
23
|
+
# lookup droplet status for the given machine
|
24
|
+
droplet = @droplets.find { |d| d['id'].to_s == machine.id }
|
25
|
+
end
|
26
|
+
|
27
|
+
# if lookup by id failed, check for a droplet with a matching name
|
28
|
+
# and set the id to ensure vagrant stores locally
|
29
|
+
# TODO allow the user to configure this behavior
|
30
|
+
if !droplet
|
31
|
+
name = machine.config.vm.hostname || machine.name
|
32
|
+
droplet = @droplets.find { |d| d['name'] == name.to_s }
|
33
|
+
machine.id = droplet['id'].to_s if droplet
|
34
|
+
end
|
35
|
+
|
36
|
+
droplet ||= {'state' => 'not_created'}
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(machine)
|
40
|
+
@machine = machine
|
41
|
+
end
|
42
|
+
|
43
|
+
def action(name)
|
44
|
+
return Actions.send(name) if Actions.respond_to?(name)
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
# This method is called if the underlying machine ID changes. Providers
|
49
|
+
# can use this method to load in new data for the actual backing
|
50
|
+
# machine or to realize that the machine is now gone (the ID can
|
51
|
+
# become `nil`). No parameters are given, since the underlying machine
|
52
|
+
# is simply the machine instance given to this object. And no
|
53
|
+
# return value is necessary.
|
54
|
+
def machine_id_changed
|
55
|
+
end
|
56
|
+
|
57
|
+
# This should return the state of the machine within this provider.
|
58
|
+
# The state must be an instance of {MachineState}. Please read the
|
59
|
+
# documentation of that class for more information.
|
60
|
+
def state
|
61
|
+
state = Provider.droplet(@machine)['state'].to_sym
|
62
|
+
long = short = state.to_s
|
63
|
+
Vagrant::MachineState.new(state, short, long)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_1cloud:
|
3
|
+
info:
|
4
|
+
off: "Droplet is off"
|
5
|
+
not_created: "Droplet has not been created"
|
6
|
+
already_active: "Droplet is already active"
|
7
|
+
already_off: "Droplet is already off"
|
8
|
+
creating: "Creating a new droplet..."
|
9
|
+
destroying: "Destroying the droplet..."
|
10
|
+
shutting_down: "Shutting down the droplet..."
|
11
|
+
powering_off: "Powering off the droplet..."
|
12
|
+
powering_on: "Powering on the droplet..."
|
13
|
+
reloading: "Rebooting the droplet..."
|
14
|
+
config:
|
15
|
+
token: "Token is required"
|
16
|
+
errors:
|
17
|
+
api_status: |-
|
18
|
+
There was an issue with the request made to the 1cloud
|
19
|
+
API at:
|
20
|
+
|
21
|
+
Path: %{path}
|
22
|
+
URI Params: %{params}
|
23
|
+
|
24
|
+
The response status from the API was:
|
25
|
+
|
26
|
+
Status: %{status}
|
27
|
+
Response: %{response}
|
28
|
+
rsync: |-
|
29
|
+
There was an error when attemping to rsync a share folder.
|
30
|
+
Please inspect the error message below for more info.
|
31
|
+
|
32
|
+
Host path: %{hostpath}
|
33
|
+
Guest path: %{guestpath}
|
34
|
+
Error: %{stderr}
|
35
|
+
json: |-
|
36
|
+
There was an issue with the JSON response from the 1cloud
|
37
|
+
API at:
|
38
|
+
|
39
|
+
Path: %{path}
|
40
|
+
URI Params: %{params}
|
41
|
+
|
42
|
+
The response JSON from the API was:
|
43
|
+
|
44
|
+
Response: %{response}
|
45
|
+
result_match: |-
|
46
|
+
The result collection for %{collection_name}:
|
47
|
+
|
48
|
+
%{sub_obj}
|
49
|
+
|
50
|
+
Contained no object with the value "%{value}" for the the
|
51
|
+
key "%{key}".
|
52
|
+
|
53
|
+
Please ensure that the configured value exists in the collection.
|
54
|
+
certificate: |-
|
55
|
+
The secure connection to the 1cloud API has failed. Please
|
56
|
+
ensure that your local certificates directory is defined in the
|
57
|
+
provider config.
|
58
|
+
|
59
|
+
config.vm.provider :1cloud do |vm|
|
60
|
+
vm.ca_path = "/path/to/ssl/ca/cert.crt"
|
61
|
+
end
|
62
|
+
|
63
|
+
This is generally caused by the OpenSSL configuration associated
|
64
|
+
with the Ruby install being unaware of the system specific ca
|
65
|
+
certs.
|
66
|
+
local_ip: |-
|
67
|
+
The 1cloud provider was unable to determine the host's IP.
|
data/test/Vagrantfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Vagrant.require_plugin('vagrant-1cloud')
|
2
|
+
|
3
|
+
Vagrant.configure('2') do |config|
|
4
|
+
|
5
|
+
config.vm.provider :1cloud do |provider|
|
6
|
+
provider.token = ENV['DO_TOKEN']
|
7
|
+
end
|
8
|
+
|
9
|
+
config.vm.define "test" do |t|
|
10
|
+
t.ssh.insert_key = false
|
11
|
+
t.ssh.private_key_path = '~/.ssh/id_rsa'
|
12
|
+
t.vm.box = '1cloud'
|
13
|
+
t.vm.hostname = 'test'
|
14
|
+
t.vm.provision :shell, :path => 'scripts/provision.sh'
|
15
|
+
end
|
16
|
+
end
|
data/test/test.sh
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-1cloud/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-1cloud"
|
8
|
+
gem.version = VagrantPlugins::OneCloud::VERSION
|
9
|
+
gem.authors = ["Bulat Yusupov"]
|
10
|
+
gem.email = ["usbulat@gmail.com"]
|
11
|
+
gem.description = %q{Enables Vagrant to manage 1cloud droplets. Based on https://github.com/devopsgroup-io/vagrant-digitalocean.}
|
12
|
+
gem.summary = gem.description
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_dependency "faraday", ">= 0.8.6"
|
19
|
+
gem.add_dependency "json"
|
20
|
+
gem.add_dependency "log4r"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-1cloud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bulat Yusupov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
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: log4r
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Enables Vagrant to manage 1cloud droplets. Based on https://github.com/devopsgroup-io/vagrant-digitalocean.
|
56
|
+
email:
|
57
|
+
- usbulat@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- Rakefile
|
66
|
+
- lib/vagrant-1cloud.rb
|
67
|
+
- lib/vagrant-1cloud/actions.rb
|
68
|
+
- lib/vagrant-1cloud/actions/check_state.rb
|
69
|
+
- lib/vagrant-1cloud/actions/create.rb
|
70
|
+
- lib/vagrant-1cloud/actions/destroy.rb
|
71
|
+
- lib/vagrant-1cloud/actions/power_off.rb
|
72
|
+
- lib/vagrant-1cloud/actions/power_on.rb
|
73
|
+
- lib/vagrant-1cloud/actions/reload.rb
|
74
|
+
- lib/vagrant-1cloud/actions/shut_down.rb
|
75
|
+
- lib/vagrant-1cloud/config.rb
|
76
|
+
- lib/vagrant-1cloud/errors.rb
|
77
|
+
- lib/vagrant-1cloud/helpers/client.rb
|
78
|
+
- lib/vagrant-1cloud/helpers/result.rb
|
79
|
+
- lib/vagrant-1cloud/plugin.rb
|
80
|
+
- lib/vagrant-1cloud/provider.rb
|
81
|
+
- lib/vagrant-1cloud/version.rb
|
82
|
+
- locales/en.yml
|
83
|
+
- test/Vagrantfile
|
84
|
+
- test/scripts/provision.sh
|
85
|
+
- test/test.sh
|
86
|
+
- vagrant-1cloud.gemspec
|
87
|
+
homepage:
|
88
|
+
licenses: []
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.6.8
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Enables Vagrant to manage 1cloud droplets. Based on https://github.com/devopsgroup-io/vagrant-digitalocean.
|
110
|
+
test_files:
|
111
|
+
- test/Vagrantfile
|
112
|
+
- test/scripts/provision.sh
|
113
|
+
- test/test.sh
|