vagrant-abiquo 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/CHANGELOG.md +6 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +106 -0
- data/LICENSE.txt +22 -0
- data/README.md +106 -0
- data/Rakefile +22 -0
- data/Vagrantfile +21 -0
- data/box/abiquo.box +0 -0
- data/box/metadata.json +3 -0
- data/lib/vagrant-abiquo.rb +14 -0
- data/lib/vagrant-abiquo/actions.rb +86 -0
- data/lib/vagrant-abiquo/actions/check_state.rb +19 -0
- data/lib/vagrant-abiquo/actions/create.rb +113 -0
- data/lib/vagrant-abiquo/actions/destroy.rb +35 -0
- data/lib/vagrant-abiquo/actions/modify_provision_path.rb +38 -0
- data/lib/vagrant-abiquo/actions/power_off.rb +33 -0
- data/lib/vagrant-abiquo/actions/power_on.rb +34 -0
- data/lib/vagrant-abiquo/actions/reload.rb +31 -0
- data/lib/vagrant-abiquo/config.rb +49 -0
- data/lib/vagrant-abiquo/errors.rb +33 -0
- data/lib/vagrant-abiquo/helpers/client.rb +149 -0
- data/lib/vagrant-abiquo/helpers/result.rb +40 -0
- data/lib/vagrant-abiquo/plugin.rb +22 -0
- data/lib/vagrant-abiquo/provider.rb +121 -0
- data/lib/vagrant-abiquo/version.rb +5 -0
- data/locales/en.yml +103 -0
- data/test/Vagrantfile +22 -0
- data/test/scripts/provision.sh +3 -0
- data/test/test.sh +11 -0
- data/vagrant-abiquo.gemspec +21 -0
- metadata +118 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Abiquo
|
3
|
+
class Plugin < Vagrant.plugin('2')
|
4
|
+
name 'Abiquo'
|
5
|
+
description <<-DESC
|
6
|
+
This plugin installs a provider that allows Vagrant to manage
|
7
|
+
machines using Abiquo's API.
|
8
|
+
DESC
|
9
|
+
|
10
|
+
config(:abiquo, :provider) do
|
11
|
+
require_relative 'config'
|
12
|
+
Config
|
13
|
+
end
|
14
|
+
|
15
|
+
provider(:abiquo) do
|
16
|
+
require_relative 'provider'
|
17
|
+
Provider
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'vagrant-abiquo/actions'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Abiquo
|
5
|
+
class Provider < Vagrant.plugin('2', :provider)
|
6
|
+
|
7
|
+
# This class method caches status for all droplets within
|
8
|
+
# the Digital Ocean account. A specific droplet's status
|
9
|
+
# may be refreshed by passing :refresh => true as an option.
|
10
|
+
def self.virtualmachine(machine)
|
11
|
+
@client = Helpers::ApiClient.new(machine)
|
12
|
+
if !@virtualmachines
|
13
|
+
vms_accept = {:accept => "application/vnd.abiquo.virtualmachines+json" }
|
14
|
+
@virtualmachines = JSON.parse(@client.http_request(machine.provider_config.abiquo_api_uri+"/cloud/virtualmachines?limit=0","GET", vms_accept))
|
15
|
+
end
|
16
|
+
|
17
|
+
@virtualmachines['collection'].each do |vm|
|
18
|
+
|
19
|
+
puts "VM id --> "+machine.id if not machine.id.nil?
|
20
|
+
puts "Lista de VMs -->"+vm['id'].to_s
|
21
|
+
if vm['id'].to_s == machine.id
|
22
|
+
virtualmachine ||= {'status' => 'active'}
|
23
|
+
@found = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
if not @found
|
27
|
+
virtualmachine ||= {'status' => 'not_created'}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.droplet(machine, opts = {})
|
32
|
+
client = Helpers::ApiClient.new(machine)
|
33
|
+
|
34
|
+
# load status of droplets if it has not been done before
|
35
|
+
if !@droplets
|
36
|
+
result = client.request('/droplets')
|
37
|
+
@droplets = result['droplets']
|
38
|
+
end
|
39
|
+
|
40
|
+
if opts[:refresh] && machine.id
|
41
|
+
# refresh the droplet status for the given machine
|
42
|
+
@droplets.delete_if { |d| d['id'].to_s == machine.id }
|
43
|
+
result = client.request("/droplets/#{machine.id}")
|
44
|
+
@droplets << droplet = result['droplet']
|
45
|
+
else
|
46
|
+
# lookup droplet status for the given machine
|
47
|
+
droplet = @droplets.find { |d| d['id'].to_s == machine.id }
|
48
|
+
end
|
49
|
+
|
50
|
+
# if lookup by id failed, check for a droplet with a matching name
|
51
|
+
# and set the id to ensure vagrant stores locally
|
52
|
+
# TODO allow the user to configure this behavior
|
53
|
+
if !droplet
|
54
|
+
name = machine.config.vm.hostname || machine.name
|
55
|
+
droplet = @droplets.find { |d| d['name'] == name.to_s }
|
56
|
+
machine.id = droplet['id'].to_s if droplet
|
57
|
+
end
|
58
|
+
|
59
|
+
droplet ||= {'status' => 'not_created'}
|
60
|
+
end
|
61
|
+
|
62
|
+
def initialize(machine)
|
63
|
+
@machine = machine
|
64
|
+
end
|
65
|
+
|
66
|
+
def action(name)
|
67
|
+
return Actions.send(name) if Actions.respond_to?(name)
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
|
71
|
+
# This method is called if the underying machine ID changes. Providers
|
72
|
+
# can use this method to load in new data for the actual backing
|
73
|
+
# machine or to realize that the machine is now gone (the ID can
|
74
|
+
# become `nil`). No parameters are given, since the underlying machine
|
75
|
+
# is simply the machine instance given to this object. And no
|
76
|
+
# return value is necessary.
|
77
|
+
def machine_id_changed
|
78
|
+
end
|
79
|
+
|
80
|
+
# This should return a hash of information that explains how to
|
81
|
+
# SSH into the machine. If the machine is not at a point where
|
82
|
+
# SSH is even possible, then `nil` should be returned.
|
83
|
+
#
|
84
|
+
# The general structure of this returned hash should be the
|
85
|
+
# following:
|
86
|
+
#
|
87
|
+
# {
|
88
|
+
# :host => "1.2.3.4",
|
89
|
+
# :port => "22",
|
90
|
+
# :username => "mitchellh",
|
91
|
+
# :private_key_path => "/path/to/my/key"
|
92
|
+
# }
|
93
|
+
#
|
94
|
+
# **Note:** Vagrant only supports private key based authenticatonion,
|
95
|
+
# mainly for the reason that there is no easy way to exec into an
|
96
|
+
# `ssh` prompt with a password, whereas we can pass a private key
|
97
|
+
# via commandline.
|
98
|
+
def ssh_info
|
99
|
+
droplet = Provider.droplet(@machine)
|
100
|
+
|
101
|
+
return nil if droplet['status'].to_sym != :active
|
102
|
+
|
103
|
+
return {
|
104
|
+
:host => droplet['ip_address'],
|
105
|
+
:port => '22',
|
106
|
+
:username => 'root',
|
107
|
+
:private_key_path => nil
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
# This should return the state of the machine within this provider.
|
112
|
+
# The state must be an instance of {MachineState}. Please read the
|
113
|
+
# documentation of that class for more information.
|
114
|
+
def state
|
115
|
+
state = Provider.virtualmachine(@machine)['status'].to_sym
|
116
|
+
long = short = state.to_s
|
117
|
+
Vagrant::MachineState.new(state, short, long)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_abiquo:
|
3
|
+
info:
|
4
|
+
off: "VM is off"
|
5
|
+
not_created: "VM has not been created"
|
6
|
+
already_active: "VM is already active"
|
7
|
+
already_off: "VM is already off"
|
8
|
+
creating: "Creating VM..."
|
9
|
+
deploying: "Deploying VM..."
|
10
|
+
deploycompleted: "VM deploy completed successfully"
|
11
|
+
deployfailed: "VM deploy failed. Look to Abiquo events."
|
12
|
+
vm_ip: "Assigned IP address: %{ip}"
|
13
|
+
vm_private_ip: "Private IP address: %{ip}"
|
14
|
+
destroying: "Destroying the VM..."
|
15
|
+
powering_off: "Powering off the VM..."
|
16
|
+
powering_on: "Powering on the VM..."
|
17
|
+
rebuilding: "Rebuilding the VM..."
|
18
|
+
reloading: "Rebooting the VM..."
|
19
|
+
creating_user: "Creating user account: %{user}..."
|
20
|
+
modifying_sudo: "Modifying sudoers file to remove tty requirement..."
|
21
|
+
using_key: "Using existing SSH key: %{name}"
|
22
|
+
creating_key: "Creating new SSH key: %{name}..."
|
23
|
+
trying_rsync_install: "Rsync not found, attempting to install with yum..."
|
24
|
+
rsyncing: "Rsyncing folder: %{hostpath} => %{guestpath}..."
|
25
|
+
rsync_missing: "The rsync executable was not found in the current path."
|
26
|
+
config:
|
27
|
+
client_id: "Client ID is required"
|
28
|
+
api_key: "API key is required"
|
29
|
+
private_key: "SSH private key path is required"
|
30
|
+
public_key: "SSH public key not found: %{key}"
|
31
|
+
errors:
|
32
|
+
public_key: |-
|
33
|
+
There was an issue reading the public key at:
|
34
|
+
|
35
|
+
Path: %{path}
|
36
|
+
|
37
|
+
Please check the file's permissions.
|
38
|
+
api_status: |-
|
39
|
+
There was an issue with the request made to Abiquo API
|
40
|
+
API at:
|
41
|
+
|
42
|
+
Path: %{path}
|
43
|
+
Headers: %{headers}
|
44
|
+
Data: %{data}
|
45
|
+
|
46
|
+
The response status from the API was:
|
47
|
+
|
48
|
+
Status: %{status}
|
49
|
+
Response: %{response}
|
50
|
+
apifind_error: |-
|
51
|
+
There was an issue when looking for:
|
52
|
+
Entity: %{entity}
|
53
|
+
Name: %{name}
|
54
|
+
|
55
|
+
Probably doesn't exist. Please check through Abiquo UI
|
56
|
+
restclient_error: |-
|
57
|
+
There was an issue with the request made to Abiquo API at:
|
58
|
+
Path: %{path}
|
59
|
+
Headers: %{headers}
|
60
|
+
Data: %{data}
|
61
|
+
|
62
|
+
The response status from the API was:
|
63
|
+
Response: %{response}
|
64
|
+
rsync: |-
|
65
|
+
There was an error when attemping to rsync a share folder.
|
66
|
+
Please inspect the error message below for more info.
|
67
|
+
|
68
|
+
Host path: %{hostpath}
|
69
|
+
Guest path: %{guestpath}
|
70
|
+
Error: %{stderr}
|
71
|
+
json: |-
|
72
|
+
There was an issue with the JSON response from the Digital Ocean
|
73
|
+
API at:
|
74
|
+
|
75
|
+
Path: %{path}
|
76
|
+
URI Params: %{params}
|
77
|
+
|
78
|
+
The response JSON from the API was:
|
79
|
+
|
80
|
+
Response: %{response}
|
81
|
+
result_match: |-
|
82
|
+
The result collection for %{collection_name}:
|
83
|
+
|
84
|
+
%{sub_obj}
|
85
|
+
|
86
|
+
Contained no object with the value "%{value}" for the the
|
87
|
+
key "%{key}".
|
88
|
+
|
89
|
+
Please ensure that the configured value exists in the collection.
|
90
|
+
certificate: |-
|
91
|
+
The secure connection to the Digital Ocean API has failed. Please
|
92
|
+
ensure that your local certificates directory is defined in the
|
93
|
+
provider config.
|
94
|
+
|
95
|
+
config.vm.provider :digital_ocean do |vm|
|
96
|
+
vm.ca_path = "/path/to/ssl/ca/cert.crt"
|
97
|
+
end
|
98
|
+
|
99
|
+
This is generally caused by the OpenSSL configuration associated
|
100
|
+
with the Ruby install being unaware of the system specific ca
|
101
|
+
certs.
|
102
|
+
local_ip: |-
|
103
|
+
The Digital Ocean provider was unable to determine the host's IP.
|
data/test/Vagrantfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Vagrant.require_plugin('vagrant-abiquo')
|
2
|
+
|
3
|
+
Vagrant.configure('2') do |config|
|
4
|
+
config.vm.provider :abiquo do |provider, override|
|
5
|
+
override.vm.box = 'abiquo'
|
6
|
+
override.vm.box_url = "https://github.com/danfaizer/vagrant-abiquo/raw/master/box/abiquo.box"
|
7
|
+
provider.api_user = ENV['ABIQUO_API_USER']
|
8
|
+
provider.api_password = ENV['ABIQUO_API_PASSWORD']
|
9
|
+
provider.api_uri = 'https://preproduction.bcn.abiquo.com/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
config.vm.provision :shell, :path => 'scripts/provision.sh'
|
13
|
+
|
14
|
+
config.vm.define :virtualmachine do |virtualmachine|
|
15
|
+
virtualmachine.vm.provider :abiquo do |provider|
|
16
|
+
provider.datacenter = 'DC1'
|
17
|
+
provider.virtualdatacenter = 'vdc1'
|
18
|
+
provider.virtualappliance = 'vapp1'
|
19
|
+
provider.template = 'Core'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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-abiquo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vagrant-abiquo"
|
8
|
+
gem.version = VagrantPlugins::Abiquo::VERSION
|
9
|
+
gem.authors = ["Daniel Beneyto"]
|
10
|
+
gem.email = ["daniel.beneyto@abiquo.com"]
|
11
|
+
gem.description = %q{Enables Vagrant to manage Abiquo instances}
|
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 "rest-client", ">= 1.6.7"
|
19
|
+
gem.add_dependency "json"
|
20
|
+
gem.add_dependency "log4r"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-abiquo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Beneyto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.7
|
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 Abiquo instances
|
56
|
+
email:
|
57
|
+
- daniel.beneyto@abiquo.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.md
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- Vagrantfile
|
69
|
+
- box/abiquo.box
|
70
|
+
- box/metadata.json
|
71
|
+
- lib/vagrant-abiquo.rb
|
72
|
+
- lib/vagrant-abiquo/actions.rb
|
73
|
+
- lib/vagrant-abiquo/actions/check_state.rb
|
74
|
+
- lib/vagrant-abiquo/actions/create.rb
|
75
|
+
- lib/vagrant-abiquo/actions/destroy.rb
|
76
|
+
- lib/vagrant-abiquo/actions/modify_provision_path.rb
|
77
|
+
- lib/vagrant-abiquo/actions/power_off.rb
|
78
|
+
- lib/vagrant-abiquo/actions/power_on.rb
|
79
|
+
- lib/vagrant-abiquo/actions/reload.rb
|
80
|
+
- lib/vagrant-abiquo/config.rb
|
81
|
+
- lib/vagrant-abiquo/errors.rb
|
82
|
+
- lib/vagrant-abiquo/helpers/client.rb
|
83
|
+
- lib/vagrant-abiquo/helpers/result.rb
|
84
|
+
- lib/vagrant-abiquo/plugin.rb
|
85
|
+
- lib/vagrant-abiquo/provider.rb
|
86
|
+
- lib/vagrant-abiquo/version.rb
|
87
|
+
- locales/en.yml
|
88
|
+
- test/Vagrantfile
|
89
|
+
- test/scripts/provision.sh
|
90
|
+
- test/test.sh
|
91
|
+
- vagrant-abiquo.gemspec
|
92
|
+
homepage:
|
93
|
+
licenses: []
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.0.15
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Enables Vagrant to manage Abiquo instances
|
115
|
+
test_files:
|
116
|
+
- test/Vagrantfile
|
117
|
+
- test/scripts/provision.sh
|
118
|
+
- test/test.sh
|