vagrant_abiquo 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Vagrantfile +9 -7
- data/lib/vagrant_abiquo/actions.rb +6 -0
- data/lib/vagrant_abiquo/actions/create.rb +4 -26
- data/lib/vagrant_abiquo/actions/create_vapp.rb +4 -1
- data/lib/vagrant_abiquo/actions/delete_vapp.rb +41 -0
- data/lib/vagrant_abiquo/actions/deploy.rb +70 -0
- data/lib/vagrant_abiquo/config.rb +2 -0
- data/lib/vagrant_abiquo/plugin.rb +5 -0
- data/lib/vagrant_abiquo/provider.rb +6 -4
- data/lib/vagrant_abiquo/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d52459a5932c1be97b7e5d6197e5735f1b432d6
|
4
|
+
data.tar.gz: 8acfc9a0a156761871e17abecd1b459efe643e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3272327a7463373c99f6f40bc97e5055d7a4ded18a3faa51ca747613003bca49e8d1ee4a5e5d5d32d012f43cd16257249e68238b27256ecd64fb1c1b6118c9df
|
7
|
+
data.tar.gz: 9452f08c3feb41347fca22b822b88dd07bbf0d0313345e0dd936e384692e3c17e1c284c1ff3d968e9a5ebca370dccb604b6813ecdab8d57b8f3e631a69d8765c
|
data/Gemfile.lock
CHANGED
data/Vagrantfile
CHANGED
@@ -3,8 +3,10 @@ VAGRANTFILE_API_VERSION = "2"
|
|
3
3
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
4
4
|
config.vm.synced_folder ".", "/vagrant", type: "rsync"
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
(1..10).each do |ind|
|
7
|
+
config.vm.define "abiquotesting-#{ind}"
|
8
|
+
end
|
9
|
+
|
8
10
|
config.vm.provider :abiquo do |provider, override|
|
9
11
|
override.vm.box = 'abiquo'
|
10
12
|
override.vm.box_url = "https://github.com/abiquo/vagrant_abiquo/raw/master/box/abiquo.box"
|
@@ -20,12 +22,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
20
22
|
}
|
21
23
|
}
|
22
24
|
}
|
23
|
-
|
24
|
-
|
25
|
-
provider.hwprofile = '4gb'
|
26
|
-
provider.virtualdatacenter = '
|
25
|
+
provider.cpu_cores = 1
|
26
|
+
provider.ram_mb = 512
|
27
|
+
#provider.hwprofile = '4gb'
|
28
|
+
provider.virtualdatacenter = 'esx'
|
27
29
|
provider.virtualappliance = 'Vagrant Tests'
|
28
|
-
provider.template = '
|
30
|
+
provider.template = 'Alpine'
|
29
31
|
|
30
32
|
override.ssh.private_key_path = '~/.ssh/id_rsa'
|
31
33
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'vagrant_abiquo/actions/check_state'
|
2
2
|
require 'vagrant_abiquo/actions/create'
|
3
|
+
require 'vagrant_abiquo/actions/deploy'
|
3
4
|
require 'vagrant_abiquo/actions/destroy'
|
4
5
|
require 'vagrant_abiquo/actions/power_off'
|
5
6
|
require 'vagrant_abiquo/actions/power_on'
|
@@ -42,6 +43,11 @@ module VagrantPlugins
|
|
42
43
|
b.use SyncedFolders
|
43
44
|
when :not_created
|
44
45
|
b.use Create
|
46
|
+
b.use Deploy
|
47
|
+
b.use Provision
|
48
|
+
b.use SyncedFolders
|
49
|
+
when :NOT_ALLOCATED
|
50
|
+
b.use Deploy
|
45
51
|
b.use Provision
|
46
52
|
b.use SyncedFolders
|
47
53
|
end
|
@@ -24,7 +24,7 @@ module VagrantPlugins
|
|
24
24
|
|
25
25
|
# Check if we have to use hwprofiles
|
26
26
|
lim = vdc.link(:enterprise).get.link(:limits).get.select {|l| l.link(:location).title == vdc.link(:location).title }.first
|
27
|
-
if lim.enabledHardwareProfiles
|
27
|
+
if lim.respond_to? :enabledHardwareProfiles
|
28
28
|
if @machine.provider_config.hwprofile.nil?
|
29
29
|
raise Abiquo::Errors::HWprofileEnabled, vdc: @machine.provider_config.virtualdatacenter
|
30
30
|
end
|
@@ -47,7 +47,7 @@ module VagrantPlugins
|
|
47
47
|
vm_definition = {}
|
48
48
|
|
49
49
|
# Configured CPU and RAM
|
50
|
-
if lim.enabledHardwareProfiles
|
50
|
+
if lim.respond_to? :enabledHardwareProfiles
|
51
51
|
# lookup the hwprofile link
|
52
52
|
hwprofile = vdc.link(:location).get.link(:hardwareprofiles).get
|
53
53
|
.select {|h| h.name == @machine.provider_config.hwprofile }.first
|
@@ -61,6 +61,7 @@ module VagrantPlugins
|
|
61
61
|
ram_mb = @machine.provider_config.ram_mb
|
62
62
|
vm_definition['cpu'] = cpu_cores || template.cpuRequired
|
63
63
|
vm_definition['ram'] = ram_mb || template.ramRequired
|
64
|
+
vm_definition['links'] = [ tmpl_link ]
|
64
65
|
end
|
65
66
|
|
66
67
|
vm_definition['label'] = @machine.name
|
@@ -88,30 +89,7 @@ module VagrantPlugins
|
|
88
89
|
raise Abiquo::Errors::NetworkError if vm.nil?
|
89
90
|
end
|
90
91
|
vm = vm.link(:edit).get
|
91
|
-
|
92
|
-
# Deploying VM
|
93
|
-
env[:ui].info I18n.t('vagrant_abiquo.info.deploy')
|
94
|
-
task = deploy(vm)
|
95
|
-
|
96
|
-
if task.state == 'FINISHED_SUCCESSFULLY'
|
97
|
-
# Deploy successfully completed
|
98
|
-
env[:ui].info I18n.t('vagrant_abiquo.info.deploycompleted')
|
99
|
-
|
100
|
-
# Give time to the OS to boot.
|
101
|
-
retryable(:tries => 20, :sleep => 5) do
|
102
|
-
next if env[:interrupted]
|
103
|
-
raise 'not ready' if !@machine.communicate.ready?
|
104
|
-
end
|
105
|
-
|
106
|
-
# Find its IP
|
107
|
-
vm = vm.link(:edit).get
|
108
|
-
ip = vm.link(:nic0).title
|
109
|
-
env[:ui].info I18n.t('vagrant_abiquo.info.vm_ip', :ip => ip)
|
110
|
-
@machine.id = vm.url
|
111
|
-
else
|
112
|
-
# Deploy failed
|
113
|
-
env[:ui].error I18n.t('vagrant_abiquo.info.deployfailed')
|
114
|
-
end
|
92
|
+
@machine.id = vm.url
|
115
93
|
|
116
94
|
@app.call(env)
|
117
95
|
end
|
@@ -15,7 +15,10 @@ module VagrantPlugins
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
|
-
|
18
|
+
if env[:env].vagrantfile.config.finalize![:vm].respond_to? :get_provider_config
|
19
|
+
pconfig = env[:env].vagrantfile.config.finalize![:vm].get_provider_config(:abiquo)
|
20
|
+
return if pconfig.abiquo_connection_data.nil?
|
21
|
+
end
|
19
22
|
@client ||= AbiquoAPI.new(pconfig.abiquo_connection_data)
|
20
23
|
|
21
24
|
@logger.info "Checking vApp '#{pconfig.virtualappliance}'"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'vagrant_abiquo/helpers/client'
|
2
|
+
require 'vagrant_abiquo/helpers/abiquo'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Abiquo
|
6
|
+
module Actions
|
7
|
+
class DeletevApp
|
8
|
+
include Helpers::Client
|
9
|
+
include Helpers::Abiquo
|
10
|
+
|
11
|
+
def initialize(app, env)
|
12
|
+
@app = app
|
13
|
+
@machine = env[:machine]
|
14
|
+
@logger = Log4r::Logger.new('vagrant::abiquo::delete_vapp')
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
if env[:env].vagrantfile.config.finalize![:vm].respond_to? :get_provider_config
|
19
|
+
pconfig = env[:env].vagrantfile.config.finalize![:vm].get_provider_config(:abiquo)
|
20
|
+
return if pconfig.abiquo_connection_data.nil?
|
21
|
+
end
|
22
|
+
@client ||= AbiquoAPI.new(pconfig.abiquo_connection_data)
|
23
|
+
|
24
|
+
@logger.info "Checking vApp '#{pconfig.virtualappliance}'"
|
25
|
+
|
26
|
+
@logger.info "Looking up VDC '#{pconfig.virtualdatacenter}'"
|
27
|
+
vdc = get_vdc(pconfig.virtualdatacenter)
|
28
|
+
raise Abiquo::Errors::VDCNotFound, vdc: pconfig.virtualdatacenter if vdc.nil?
|
29
|
+
|
30
|
+
vapp = get_vapp(vdc, pconfig.virtualappliance)
|
31
|
+
if vapp.link(:virtualmachines).get.count == 0
|
32
|
+
@logger.info "vApp '#{pconfig.virtualappliance}' is empty, deleting."
|
33
|
+
vapp.delete
|
34
|
+
end
|
35
|
+
|
36
|
+
@app.call(env)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'vagrant_abiquo/helpers/client'
|
2
|
+
require 'vagrant_abiquo/helpers/abiquo'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Abiquo
|
6
|
+
module Actions
|
7
|
+
class Deploy
|
8
|
+
include Helpers::Client
|
9
|
+
include Helpers::Abiquo
|
10
|
+
include Vagrant::Util::Retryable
|
11
|
+
|
12
|
+
def initialize(app, env)
|
13
|
+
@app = app
|
14
|
+
@machine = env[:machine]
|
15
|
+
@client = client
|
16
|
+
@env = env
|
17
|
+
@logger = Log4r::Logger.new('vagrant::abiquo::deploy')
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
vm = get_vm(@machine.id)
|
22
|
+
|
23
|
+
# Deploying VM
|
24
|
+
env[:ui].info I18n.t('vagrant_abiquo.info.deploy')
|
25
|
+
task = deploy(vm)
|
26
|
+
|
27
|
+
if task.state == 'FINISHED_SUCCESSFULLY'
|
28
|
+
# Deploy successfully completed
|
29
|
+
env[:ui].info I18n.t('vagrant_abiquo.info.deploycompleted')
|
30
|
+
|
31
|
+
# Give time to the OS to boot.
|
32
|
+
retryable(:tries => 20, :sleep => 5) do
|
33
|
+
next if env[:interrupted]
|
34
|
+
raise 'not ready' if !@machine.communicate.ready?
|
35
|
+
end
|
36
|
+
|
37
|
+
# Find its IP
|
38
|
+
vm = vm.link(:edit).get
|
39
|
+
ip = vm.link(:nic0).title
|
40
|
+
env[:ui].info I18n.t('vagrant_abiquo.info.vm_ip', :ip => ip)
|
41
|
+
@machine.id = vm.url
|
42
|
+
else
|
43
|
+
# Deploy failed
|
44
|
+
env[:ui].error I18n.t('vagrant_abiquo.info.deployfailed')
|
45
|
+
end
|
46
|
+
|
47
|
+
@app.call(env)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Both the recover and terminate are stolen almost verbatim from
|
51
|
+
# the Vagrant AWS provider up action
|
52
|
+
def recover(env)
|
53
|
+
return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
|
54
|
+
|
55
|
+
if @machine.state.id != :not_created
|
56
|
+
terminate(env)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def terminate(env)
|
61
|
+
destroy_env = env.dup
|
62
|
+
destroy_env.delete(:interrupted)
|
63
|
+
destroy_env[:config_validate] = false
|
64
|
+
destroy_env[:force_confirm_destroy] = true
|
65
|
+
env[:action_runner].run(Actions.destroy, destroy_env)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -24,9 +24,11 @@ module VagrantPlugins
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def finalize!
|
27
|
+
@abiquo_connection_data = {} if @abiquo_connection_data == UNSET_VALUE
|
27
28
|
@abiquo_connection_data[:abiquo_api_url] = ENV['ABQ_URL'] if @abiquo_connection_data[:abiquo_api_url].nil?
|
28
29
|
@abiquo_connection_data[:abiquo_username] = ENV['ABQ_USER'] if @abiquo_connection_data[:abiquo_username].nil?
|
29
30
|
@abiquo_connection_data[:abiquo_password] = ENV['ABQ_PASS'] if @abiquo_connection_data[:abiquo_password].nil?
|
31
|
+
@abiquo_connection_data = nil if @abiquo_connection_data[:abiquo_api_url].nil?
|
30
32
|
|
31
33
|
@virtualdatacenter = ENV['ABQ_VDC'] if @virtualdatacenter == UNSET_VALUE
|
32
34
|
@virtualappliance = ENV['ABQ_VAPP'] if @virtualappliance == UNSET_VALUE
|
@@ -21,6 +21,11 @@ module VagrantPlugins
|
|
21
21
|
require_relative 'actions/create_vapp.rb'
|
22
22
|
hook.prepend(Actions::CreatevApp)
|
23
23
|
end
|
24
|
+
|
25
|
+
action_hook(:delete_vapp, :environment_unload) do |hook|
|
26
|
+
require_relative 'actions/delete_vapp.rb'
|
27
|
+
hook.prepend(Actions::DeletevApp)
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -42,9 +42,11 @@ module VagrantPlugins
|
|
42
42
|
|
43
43
|
def ssh_info
|
44
44
|
return nil if state.id != :ON
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
begin
|
46
|
+
@ip ||= @vm.link(:nics).get.first.ip
|
47
|
+
rescue Exception
|
48
|
+
return nil
|
49
|
+
end
|
48
50
|
|
49
51
|
template = @vm.link(:virtualmachinetemplate).get unless @username
|
50
52
|
@username = template.loginUser if template.respond_to? :loginUser
|
@@ -57,7 +59,7 @@ module VagrantPlugins
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def state
|
60
|
-
@vm
|
62
|
+
@vm = Provider.virtualmachine(@machine)
|
61
63
|
state = @vm.nil? ? :not_created : @vm.state.to_sym
|
62
64
|
long = short = state.to_s
|
63
65
|
Vagrant::MachineState.new(state, short, long)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant_abiquo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Beneyto
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-03-
|
12
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abiquo-api
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- lib/vagrant_abiquo/actions/check_state.rb
|
65
65
|
- lib/vagrant_abiquo/actions/create.rb
|
66
66
|
- lib/vagrant_abiquo/actions/create_vapp.rb
|
67
|
+
- lib/vagrant_abiquo/actions/delete_vapp.rb
|
68
|
+
- lib/vagrant_abiquo/actions/deploy.rb
|
67
69
|
- lib/vagrant_abiquo/actions/destroy.rb
|
68
70
|
- lib/vagrant_abiquo/actions/power_off.rb
|
69
71
|
- lib/vagrant_abiquo/actions/power_on.rb
|