vagrant_abiquo 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b30bdcf2e2b2ca6263318614c9b5b34b377e8045
4
- data.tar.gz: 5d1c21fe38e675aed1f3fed59a5e886f921072ed
3
+ metadata.gz: e84c1cada8bf45ee196f4eff05307c2dbf2da31a
4
+ data.tar.gz: b4a7b2e211ac6b4e481b1d274e8f39a811f7a62e
5
5
  SHA512:
6
- metadata.gz: e0bfc80826dd892710b037763e4519c888bdccacc68f74c74a5cc2d6dfc2903f9aaa6c921a31f26aaea2cf1065362eb179678ecd9570b962c257a3c5add4ac00
7
- data.tar.gz: eddf98c1af5b58a3f969f26403395e79adf6f06789f7d82b837a5ab502bf25e34a616c3c170af7bc094ff057620436dccaca3b6dad12f192c8191835cc198dfb
6
+ metadata.gz: 2e93e8bf38d815fc94c4ed68669c7db0a9b48b2b397c02ed7d4e88512eb8efa4d1acf39e9dcac099cb623e58e3591693b6fe6cdc29f2c7c99d863028ef081ccf
7
+ data.tar.gz: 573c0fefd59d85790c4606511d3636760e9c2b050bbbd08f6720c7ca06c90ea89d8b2d82648e4b48fceb9eca511093205edd236a392f7ee9a0b79dfbb3ddaff8
data/Gemfile.lock CHANGED
@@ -24,7 +24,7 @@ GIT
24
24
  PATH
25
25
  remote: .
26
26
  specs:
27
- vagrant_abiquo (0.0.3)
27
+ vagrant_abiquo (0.0.4)
28
28
  abiquo-api (~> 0.1.2)
29
29
  log4r
30
30
 
data/README.md CHANGED
@@ -72,6 +72,8 @@ The following attributes are available to further configure the provider:
72
72
  - `user_data` - An optional user data script to be passed on to the VM. If not
73
73
  specified, the plugin adds a simple provision script to ensure SSH keys are
74
74
  injected to the VM.
75
+ - `hwprofile` - If the VDC where you are going to deploy uses hardware profiles,
76
+ specify the one to use by name. Either this or CPU/RAM pair is required.
75
77
 
76
78
  Run
77
79
  ---
data/Vagrantfile CHANGED
@@ -3,11 +3,7 @@ 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
- (1..5).each do |index|
7
- config.vm.define "abiquotesting#{index}" do |t|
8
- t.vm.hostname = "abiquotesting#{index}"
9
- end
10
- end
6
+ config.vm.define "abiquotesting"
11
7
 
12
8
  config.vm.provider :abiquo do |provider, override|
13
9
  override.vm.box = 'abiquo'
@@ -24,16 +20,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
24
20
  }
25
21
  }
26
22
  }
27
- provider.cpu_cores = 2
28
- provider.ram_mb = 2048
29
- provider.virtualdatacenter = 'ESX_VDC'
23
+ #provider.cpu_cores = 2
24
+ #provider.ram_mb = 2048
25
+ provider.hwprofile = '4gb'
26
+ provider.virtualdatacenter = 'VDC'
30
27
  provider.virtualappliance = 'Vagrant Tests'
31
- provider.template = 'Centos 7 x86_64'
28
+ provider.template = 'CentOS 7.3.1611 x64'
32
29
 
33
- provider.network = {
34
- 'private_dnsmasq' => nil
35
- }
36
30
  override.ssh.private_key_path = '~/.ssh/id_rsa'
37
- override.ssh.username = 'centos'
38
31
  end
39
32
  end
@@ -22,6 +22,14 @@ module VagrantPlugins
22
22
  vdc = get_vdc(@machine.provider_config.virtualdatacenter)
23
23
  raise Abiquo::Errors::VDCNotFound, vdc: @machine.provider_config.virtualdatacenter if vdc.nil?
24
24
 
25
+ # Check if we have to use hwprofiles
26
+ lim = vdc.link(:enterprise).get.link(:limits).get.select {|l| l.link(:location).title == vdc.link(:location).title }.first
27
+ if lim.enabledHardwareProfiles
28
+ if @machine.provider_config.hwprofile.nil?
29
+ raise Abiquo::Errors::HWprofileEnabled, vdc: @machine.provider_config.virtualdatacenter
30
+ end
31
+ end
32
+
25
33
  # Find for selected virtual appliance
26
34
  vname = vapp_name(@machine)
27
35
  vapp = get_vapp(vdc, vname)
@@ -35,17 +43,28 @@ module VagrantPlugins
35
43
  tmpl_link = template.link(:edit).clone.to_hash
36
44
  tmpl_link['rel'] = "virtualmachinetemplate"
37
45
 
38
- # Configured CPU and RAM
39
- cpu_cores = @machine.provider_config.cpu_cores
40
- ram_mb = @machine.provider_config.ram_mb
41
-
42
46
  # VM entity
43
47
  vm_definition = {}
44
- vm_definition['cpu'] = cpu_cores || template.cpuRequired
45
- vm_definition['ram'] = ram_mb || template.ramRequired
48
+
49
+ # Configured CPU and RAM
50
+ if lim.enabledHardwareProfiles
51
+ # lookup the hwprofile link
52
+ hwprofile = vdc.link(:location).get.link(:hardwareprofiles).get
53
+ .select {|h| h.name == @machine.provider_config.hwprofile }.first
54
+ raise Abiquo::Errors::HWProfileNotFound, hwprofile: @machine.provider_config.hwprofile, vdc: vdc.name if hwprofile.nil?
55
+ hwprofile_lnk = hwprofile.link(:self).clone.to_hash
56
+ hwprofile_lnk['rel'] = 'hardwareprofile'
57
+
58
+ vm_definition['links'] = [ tmpl_link, hwprofile_lnk ]
59
+ else
60
+ cpu_cores = @machine.provider_config.cpu_cores
61
+ ram_mb = @machine.provider_config.ram_mb
62
+ vm_definition['cpu'] = cpu_cores || template.cpuRequired
63
+ vm_definition['ram'] = ram_mb || template.ramRequired
64
+ end
65
+
46
66
  vm_definition['label'] = @machine.name
47
67
  vm_definition['vdrpEnabled'] = true
48
- vm_definition['links'] = [ tmpl_link ]
49
68
 
50
69
  # Create VM
51
70
  env[:ui].info I18n.t('vagrant_abiquo.info.create')
@@ -6,6 +6,7 @@ module VagrantPlugins
6
6
  attr_accessor :virtualappliance
7
7
  attr_accessor :cpu_cores
8
8
  attr_accessor :ram_mb
9
+ attr_accessor :hwprofile
9
10
  attr_accessor :template
10
11
  attr_accessor :network
11
12
  attr_accessor :user_data
@@ -17,6 +18,7 @@ module VagrantPlugins
17
18
  @template = UNSET_VALUE
18
19
  @cpu_cores = 0
19
20
  @ram_mb = 0
21
+ @hwprofile = UNSET_VALUE
20
22
  @network = UNSET_VALUE
21
23
  @user_data = UNSET_VALUE
22
24
  end
@@ -33,6 +35,7 @@ module VagrantPlugins
33
35
  @cpu_cores = ENV['ABQ_CPU'] if @cpu_cores == 0
34
36
  @ram_mb = ENV['ABQ_RAM'] if @ram_mb == 0
35
37
  @ram_mb = nil if @ram_mb == 0
38
+ @hwprofile = ENV['ABQ_HWPROFILE'] if @hwprofile == UNSET_VALUE
36
39
 
37
40
  @network = { ENV['ABQ_NET'] => ENV['ABQ_IP'] } if @network == UNSET_VALUE
38
41
 
@@ -47,6 +50,7 @@ module VagrantPlugins
47
50
  errors << I18n.t('vagrant_abiquo.config.abiquo_connection_data') if !@abiquo_connection_data
48
51
  errors << I18n.t('vagrant_abiquo.config.virtualdatacenter') if !@virtualdatacenter
49
52
  errors << I18n.t('vagrant_abiquo.config.template') if !@template
53
+ errors << I18n.t('vagrant_abiquo.config.cpuhwprofile') if @cpu_cores.nil? and @hwprofile.nil?
50
54
 
51
55
  { 'Abiquo Provider' => errors }
52
56
  end
@@ -21,6 +21,14 @@ module VagrantPlugins
21
21
  error_key(:network_error)
22
22
  end
23
23
 
24
+ class HWprofileEnabled < AbiquoError
25
+ error_key(:hwprofile_enabled)
26
+ end
27
+
28
+ class HWProfileNotFound < AbiquoError
29
+ error_key(:hwprofile_not_found)
30
+ end
31
+
24
32
  class APIStatusError < AbiquoError
25
33
  error_key(:api_status)
26
34
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Abiquo
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -26,10 +26,10 @@ en:
26
26
  rsyncing: Rsyncing folder %{hostpath} => %{guestpath}...
27
27
  rsync_missing: The rsync executable was not found in the current path.
28
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}
29
+ abiquo_connection_data: Abiquo connection data not found in config!
30
+ virtualdatacenter: Abiquo virtualdatacenter not found in config!
31
+ template: Abiquo template not found in config!
32
+ cpuhwprofile: Either hardware profile or cpu core count is required!
33
33
  errors:
34
34
  vdc_not_found: Virtual datacenter '%{vdc}' not found
35
35
  template_not_found: Template %{template} not found in VDC '%{vdc}'
@@ -37,6 +37,11 @@ en:
37
37
  network_error: |-
38
38
  A network error has ocurred. The process of assigning the VM to the
39
39
  designated networks has failed. Please review the network configuration.
40
+ hwprofile_enabled: |-
41
+ The virtualdatacenter '%{vdc}' requires the use of hardware profiles.
42
+ Correct the Abiquo provider config so it points to a valid hardware
43
+ profile instead of specifying CPU cores and RAM.
44
+ hwprofile_not_found: Hardware profile '%{hwprofile}' not found in VDC '%{vdc}'
40
45
  public_key: |-
41
46
  There was an issue reading the public key at:
42
47
 
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.3
4
+ version: 0.0.4
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-05 00:00:00.000000000 Z
12
+ date: 2017-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: abiquo-api