vagrant_abiquo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +149 -0
- data/LICENSE.txt +22 -0
- data/README.md +100 -0
- data/Rakefile +22 -0
- data/Vagrantfile +39 -0
- data/box/abiquo.box +0 -0
- data/box/metadata.json +3 -0
- data/lib/vagrant_abiquo.rb +18 -0
- data/lib/vagrant_abiquo/actions.rb +133 -0
- data/lib/vagrant_abiquo/actions/check_state.rb +24 -0
- data/lib/vagrant_abiquo/actions/create.rb +120 -0
- data/lib/vagrant_abiquo/actions/create_vapp.rb +38 -0
- data/lib/vagrant_abiquo/actions/destroy.rb +46 -0
- data/lib/vagrant_abiquo/actions/power_off.rb +30 -0
- data/lib/vagrant_abiquo/actions/power_on.rb +30 -0
- data/lib/vagrant_abiquo/actions/reset.rb +37 -0
- data/lib/vagrant_abiquo/config.rb +55 -0
- data/lib/vagrant_abiquo/errors.rb +45 -0
- data/lib/vagrant_abiquo/helpers/abiquo.rb +173 -0
- data/lib/vagrant_abiquo/helpers/client.rb +15 -0
- data/lib/vagrant_abiquo/helpers/result.rb +40 -0
- data/lib/vagrant_abiquo/plugin.rb +26 -0
- data/lib/vagrant_abiquo/provider.rb +67 -0
- data/lib/vagrant_abiquo/version.rb +5 -0
- data/locales/en.yml +111 -0
- data/test/Vagrantfile +25 -0
- data/test/scripts/provision.sh +3 -0
- data/test/test.sh +9 -0
- data/vagrant_abiquo.gemspec +20 -0
- metadata +110 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'abiquo-api'
|
2
|
+
require 'log4r'
|
3
|
+
include Log4r
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Abiquo
|
7
|
+
module Helpers
|
8
|
+
module Client
|
9
|
+
def client
|
10
|
+
@client ||= AbiquoAPI.new(@machine.provider_config.abiquo_connection_data)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Abiquo
|
3
|
+
module Helpers
|
4
|
+
class Result
|
5
|
+
def initialize(body)
|
6
|
+
@result = body
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
@result[key.to_s]
|
11
|
+
end
|
12
|
+
|
13
|
+
def find_id(sub_obj, search)
|
14
|
+
find(sub_obj, search)["id"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(sub_obj, search)
|
18
|
+
key = search.keys.first
|
19
|
+
value = search[key].to_s
|
20
|
+
key = key.to_s
|
21
|
+
|
22
|
+
result = @result[sub_obj.to_s].inject(nil) do |result, obj|
|
23
|
+
obj[key] == value ? obj : result
|
24
|
+
end
|
25
|
+
|
26
|
+
result || error(sub_obj, key, value)
|
27
|
+
end
|
28
|
+
|
29
|
+
def error(sub_obj, key, value)
|
30
|
+
raise(Errors::ResultMatchError, {
|
31
|
+
:key => key,
|
32
|
+
:value => value,
|
33
|
+
:collection_name => sub_obj.to_s,
|
34
|
+
:sub_obj => @result[sub_obj.to_s]
|
35
|
+
})
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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, parallel: true) do
|
16
|
+
require_relative 'provider'
|
17
|
+
Provider
|
18
|
+
end
|
19
|
+
|
20
|
+
action_hook(:create_vapp, :environment_load) do |hook|
|
21
|
+
require_relative 'actions/create_vapp.rb'
|
22
|
+
hook.prepend(Actions::CreatevApp)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'vagrant_abiquo/helpers/client'
|
2
|
+
require 'abiquo-api'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Abiquo
|
6
|
+
class Provider < Vagrant.plugin('2', :provider)
|
7
|
+
|
8
|
+
def self.virtualmachine(machine, opts = {})
|
9
|
+
@client ||= AbiquoAPI.new(machine.provider_config.abiquo_connection_data)
|
10
|
+
|
11
|
+
vapp_name = machine.provider_config.virtualappliance.nil? ? File.basename(machine.env.cwd) : machine.provider_config.virtualappliance
|
12
|
+
# If machine ID is nil try to lookup by name
|
13
|
+
if machine.id.nil?
|
14
|
+
vms_lnk = AbiquoAPI::Link.new :href => 'cloud/virtualmachines',
|
15
|
+
:type => 'application/vnd.abiquo.virtualmachines+json',
|
16
|
+
:client => @client
|
17
|
+
@vm = vms_lnk.get.select {|v| v.label == machine.name.to_s and
|
18
|
+
v.link(:virtualappliance).title == vapp_name }.first
|
19
|
+
machine.id = @vm.url unless @vm.nil?
|
20
|
+
@vm
|
21
|
+
else
|
22
|
+
# ID is the URL of the VM
|
23
|
+
begin
|
24
|
+
vm_lnk = AbiquoAPI::Link.new :href => machine.id,
|
25
|
+
:type => 'application/vnd.abiquo.virtualmachine+json',
|
26
|
+
:client => @client
|
27
|
+
@vm = vm_lnk.get
|
28
|
+
rescue AbiquoAPIClient::NotFound
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize(machine)
|
35
|
+
@machine = machine
|
36
|
+
end
|
37
|
+
|
38
|
+
def action(name)
|
39
|
+
return Actions.send(name) if Actions.respond_to?(name)
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def ssh_info
|
44
|
+
return nil if state.id != :ON
|
45
|
+
|
46
|
+
@vm ||= Provider.virtualmachine(@machine)
|
47
|
+
@ip ||= @vm.link(:nics).get.first.ip
|
48
|
+
|
49
|
+
template = @vm.link(:virtualmachinetemplate).get unless @username
|
50
|
+
@username = template.loginUser if template.respond_to? :loginUser
|
51
|
+
|
52
|
+
{
|
53
|
+
:host => @ip,
|
54
|
+
:port => 22,
|
55
|
+
:username => @username
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
def state
|
60
|
+
@vm ||= Provider.virtualmachine(@machine)
|
61
|
+
state = @vm.nil? ? :not_created : @vm.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,111 @@
|
|
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
|
+
create: Creating VM...
|
9
|
+
deploy: Deploying VM...
|
10
|
+
deploycompleted: VM deploy completed successfully
|
11
|
+
deployfailed: VM deploy failed. Look to Abiquo events.
|
12
|
+
vm_ip: Virtual machine IP is %{ip}
|
13
|
+
vm_private_ip: Private IP address %{ip}
|
14
|
+
destroying: Destroying VM '%{vm}'...
|
15
|
+
deleted: VM '%{vm}' has been deleted.
|
16
|
+
deleted_vapp: vApp '%{vapp}' has been deleted since it was empty.
|
17
|
+
powering_off: Powering off the VM...
|
18
|
+
powering_on: Powering on the VM...
|
19
|
+
rebuilding: Rebuilding the VM...
|
20
|
+
reloading: Rebooting the VM...
|
21
|
+
creating_user: Creating user account %{user}...
|
22
|
+
modifying_sudo: Modifying sudoers file to remove tty requirement...
|
23
|
+
using_key: Using existing SSH key %{name}
|
24
|
+
creating_key: Creating new SSH key %{name}...
|
25
|
+
trying_rsync_install: Rsync not found, attempting to install with yum...
|
26
|
+
rsyncing: Rsyncing folder %{hostpath} => %{guestpath}...
|
27
|
+
rsync_missing: The rsync executable was not found in the current path.
|
28
|
+
config:
|
29
|
+
client_id: Client ID is required
|
30
|
+
api_key: API key is required"
|
31
|
+
private_key: SSH private key path is required
|
32
|
+
public_key: SSH public key not found %{key}
|
33
|
+
errors:
|
34
|
+
vdc_not_found: Virtual datacenter '%{vdc}' not found
|
35
|
+
template_not_found: Template %{template} not found in VDC '%{vdc}'
|
36
|
+
poweroff: Error powering off VM %{vm}. Current state is %{state}
|
37
|
+
network_error: |-
|
38
|
+
A network error has ocurred. The process of assigning the VM to the
|
39
|
+
designated networks has failed. Please review the network configuration.
|
40
|
+
public_key: |-
|
41
|
+
There was an issue reading the public key at:
|
42
|
+
|
43
|
+
Path: %{path}
|
44
|
+
|
45
|
+
Please check the file's permissions.
|
46
|
+
api_status: |-
|
47
|
+
There was an issue with the request made to Abiquo API
|
48
|
+
API at:
|
49
|
+
|
50
|
+
Path: %{path}
|
51
|
+
Headers: %{headers}
|
52
|
+
Data: %{data}
|
53
|
+
|
54
|
+
The response status from the API was:
|
55
|
+
|
56
|
+
Status: %{status}
|
57
|
+
Response: %{response}
|
58
|
+
apifind_error: |-
|
59
|
+
There was an issue when looking for:
|
60
|
+
Entity: %{entity}
|
61
|
+
Name: %{name}
|
62
|
+
|
63
|
+
Probably doesn't exist. Please check through Abiquo UI
|
64
|
+
restclient_error: |-
|
65
|
+
There was an issue with the request made to Abiquo API at:
|
66
|
+
Path: %{path}
|
67
|
+
Headers: %{headers}
|
68
|
+
Data: %{data}
|
69
|
+
|
70
|
+
The response status from the API was:
|
71
|
+
Response: %{response}
|
72
|
+
rsync: |-
|
73
|
+
There was an error when attemping to rsync a share folder.
|
74
|
+
Please inspect the error message below for more info.
|
75
|
+
|
76
|
+
Host path: %{hostpath}
|
77
|
+
Guest path: %{guestpath}
|
78
|
+
Error: %{stderr}
|
79
|
+
json: |-
|
80
|
+
There was an issue with the JSON response from the Digital Ocean
|
81
|
+
API at:
|
82
|
+
|
83
|
+
Path: %{path}
|
84
|
+
URI Params: %{params}
|
85
|
+
|
86
|
+
The response JSON from the API was:
|
87
|
+
|
88
|
+
Response: %{response}
|
89
|
+
result_match: |-
|
90
|
+
The result collection for %{collection_name}:
|
91
|
+
|
92
|
+
%{sub_obj}
|
93
|
+
|
94
|
+
Contained no object with the value "%{value}" for the the
|
95
|
+
key "%{key}".
|
96
|
+
|
97
|
+
Please ensure that the configured value exists in the collection.
|
98
|
+
certificate: |-
|
99
|
+
The secure connection to the Digital Ocean API has failed. Please
|
100
|
+
ensure that your local certificates directory is defined in the
|
101
|
+
provider config.
|
102
|
+
|
103
|
+
config.vm.provider :digital_ocean do |vm|
|
104
|
+
vm.ca_path = "/path/to/ssl/ca/cert.crt"
|
105
|
+
end
|
106
|
+
|
107
|
+
This is generally caused by the OpenSSL configuration associated
|
108
|
+
with the Ruby install being unaware of the system specific ca
|
109
|
+
certs.
|
110
|
+
local_ip: |-
|
111
|
+
The Digital Ocean provider was unable to determine the host's IP.
|
data/test/Vagrantfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Vagrant.configure('2') do |config|
|
2
|
+
config.ssh.username = 'root'
|
3
|
+
config.ssh.password = 'Temporal1!'
|
4
|
+
|
5
|
+
config.vm.synced_folder ".", "/vagrant",type: "rsync"
|
6
|
+
config.vm.provider :abiquo do |provider, override|
|
7
|
+
override.vm.box = 'abiquo'
|
8
|
+
override.vm.box_url = "https://github.com/abiquo/vagrant-abiquo/raw/master/box/abiquo.box"
|
9
|
+
provider.abiquo_connection_data = {
|
10
|
+
abiquo_api_url: ENV['ABQ_URL'],
|
11
|
+
abiquo_username: ENV['ABQ_USER'],
|
12
|
+
abiquo_password: ENV['ABQ_PASS']
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
config.vm.provision :shell, :path => 'scripts/provision.sh'
|
17
|
+
|
18
|
+
config.vm.define :virtualmachine do |virtualmachine|
|
19
|
+
virtualmachine.vm.provider :abiquo do |provider|
|
20
|
+
provider.virtualdatacenter = ENV['ABQ_VDC']
|
21
|
+
provider.virtualappliance = ENV['ABQ_VAPP'] || 'testing'
|
22
|
+
provider.template = ENV['ABQ_TMPL'] || 'Core'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/test/test.sh
ADDED
@@ -0,0 +1,20 @@
|
|
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", "Marc Cirauqui"]
|
10
|
+
gem.email = ["daniel.beneyto@abiquo.com", "marc.cirauqui@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 "abiquo-api", "~> 0.1.1"
|
19
|
+
gem.add_dependency "log4r"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant_abiquo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Beneyto
|
8
|
+
- Marc Cirauqui
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: abiquo-api
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.1.1
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.1.1
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: log4r
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: Enables Vagrant to manage Abiquo instances
|
43
|
+
email:
|
44
|
+
- daniel.beneyto@abiquo.com
|
45
|
+
- marc.cirauqui@abiquo.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- ".ruby-gemset"
|
52
|
+
- ".ruby-version"
|
53
|
+
- CHANGELOG.md
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- Vagrantfile
|
60
|
+
- box/abiquo.box
|
61
|
+
- box/metadata.json
|
62
|
+
- lib/vagrant_abiquo.rb
|
63
|
+
- lib/vagrant_abiquo/actions.rb
|
64
|
+
- lib/vagrant_abiquo/actions/check_state.rb
|
65
|
+
- lib/vagrant_abiquo/actions/create.rb
|
66
|
+
- lib/vagrant_abiquo/actions/create_vapp.rb
|
67
|
+
- lib/vagrant_abiquo/actions/destroy.rb
|
68
|
+
- lib/vagrant_abiquo/actions/power_off.rb
|
69
|
+
- lib/vagrant_abiquo/actions/power_on.rb
|
70
|
+
- lib/vagrant_abiquo/actions/reset.rb
|
71
|
+
- lib/vagrant_abiquo/config.rb
|
72
|
+
- lib/vagrant_abiquo/errors.rb
|
73
|
+
- lib/vagrant_abiquo/helpers/abiquo.rb
|
74
|
+
- lib/vagrant_abiquo/helpers/client.rb
|
75
|
+
- lib/vagrant_abiquo/helpers/result.rb
|
76
|
+
- lib/vagrant_abiquo/plugin.rb
|
77
|
+
- lib/vagrant_abiquo/provider.rb
|
78
|
+
- lib/vagrant_abiquo/version.rb
|
79
|
+
- locales/en.yml
|
80
|
+
- test/Vagrantfile
|
81
|
+
- test/scripts/provision.sh
|
82
|
+
- test/test.sh
|
83
|
+
- vagrant_abiquo.gemspec
|
84
|
+
homepage:
|
85
|
+
licenses: []
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.6.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Enables Vagrant to manage Abiquo instances
|
107
|
+
test_files:
|
108
|
+
- test/Vagrantfile
|
109
|
+
- test/scripts/provision.sh
|
110
|
+
- test/test.sh
|