vagrant-arubacloud 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 +0 -1
- data/README.md +893 -21
- data/Vagrantfile_base +23 -0
- data/Vagrantfile_multi_machine +108 -0
- data/Vagrantfile_only_arubacloud_tmpl_srv +22 -0
- data/Vagrantfile_pro +32 -0
- data/Vagrantfile_syncing_and_sample_provision +27 -0
- data/cloud1.png +0 -0
- data/lib/vagrant-arubacloud/action.rb +48 -7
- data/lib/vagrant-arubacloud/action/connect_arubacloud.rb +3 -2
- data/lib/vagrant-arubacloud/action/create_server.rb +27 -16
- data/lib/vagrant-arubacloud/action/delete_server.rb +3 -1
- data/lib/vagrant-arubacloud/action/halt_server.rb +10 -4
- data/lib/vagrant-arubacloud/action/list_servers.rb +37 -8
- data/lib/vagrant-arubacloud/action/list_templates.rb +4 -2
- data/lib/vagrant-arubacloud/action/read_ssh_info.rb +2 -2
- data/lib/vagrant-arubacloud/action/read_state.rb +0 -3
- data/lib/vagrant-arubacloud/action/start_server.rb +59 -0
- data/lib/vagrant-arubacloud/command/root.rb +0 -1
- data/lib/vagrant-arubacloud/command/servers.rb +31 -3
- data/lib/vagrant-arubacloud/command/snapshot.rb +175 -0
- data/lib/vagrant-arubacloud/config.rb +58 -15
- data/lib/vagrant-arubacloud/plugin.rb +9 -1
- data/lib/vagrant-arubacloud/provider.rb +1 -1
- data/lib/vagrant-arubacloud/version.rb +1 -1
- data/locales/en.yml +45 -3
- data/spec/vagrant-arubacloud/action_spec.rb +148 -7
- data/spec/vagrant-arubacloud/config_spec.rb +65 -72
- data/vagrant-arubacloud.gemspec +4 -5
- metadata +26 -12
- data/Vagrantfile.server_no_smart +0 -41
@@ -17,17 +17,21 @@ module VagrantPlugins
|
|
17
17
|
|
18
18
|
def call(env)
|
19
19
|
if env[:machine].id
|
20
|
-
env[:
|
20
|
+
config = env[:machine].provider_config
|
21
|
+
arubacloud_dc = config.endpoint
|
22
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.halting_server'))
|
21
23
|
server = env[:arubacloud_compute].servers.get(env[:machine].id)
|
22
24
|
|
23
25
|
# Check if the vm is already powered off
|
24
26
|
@logger.debug("VM stopped?: #{server.stopped?}")
|
25
27
|
if server.stopped?
|
26
28
|
# continue the middleware
|
29
|
+
@logger.debug("VM is stopped ...")
|
27
30
|
@app.call(env)
|
28
31
|
else
|
29
32
|
# Try to poweroff the VM.
|
30
33
|
begin
|
34
|
+
@logger.debug("before make do power_off ...")
|
31
35
|
server.power_off
|
32
36
|
rescue Fog::ArubaCloud::Errors::VmStatus
|
33
37
|
env[:ui].warn(I18n.t('vagrant_arubacloud.bad_state'))
|
@@ -40,10 +44,12 @@ module VagrantPlugins
|
|
40
44
|
end
|
41
45
|
|
42
46
|
# Wait for the server to be proper shut down
|
43
|
-
|
44
|
-
|
47
|
+
@logger.debug("after do power_off wait status stopped .......")
|
48
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.waiting_server_powered_off'))
|
49
|
+
retryable(:tries => 30, :sleep => 2) do
|
50
|
+
server.wait_for(2) { stopped? }
|
45
51
|
end
|
46
|
-
env[:ui].info(I18n.t('vagrant_arubacloud.server_powered_off'))
|
52
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.server_powered_off'))
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
@@ -2,19 +2,48 @@ module VagrantPlugins
|
|
2
2
|
module ArubaCloud
|
3
3
|
module Action
|
4
4
|
class ListServers
|
5
|
-
|
5
|
+
|
6
|
+
def initialize(app, env)
|
6
7
|
@app = app
|
7
|
-
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
+
def call(env )
|
11
|
+
config = env[:machine].provider_config
|
12
|
+
arubacloud_dc = config.endpoint
|
10
13
|
compute_service = env[:arubacloud_compute]
|
11
|
-
|
12
|
-
compute_service.servers
|
13
|
-
|
14
|
+
|
15
|
+
vm_in_dc = compute_service.servers
|
16
|
+
server_fnd = vm_in_dc.select{ |s| (s.id).to_i == (env[:machine].id).to_i }
|
17
|
+
|
18
|
+
if server_fnd && server_fnd.length == 1
|
19
|
+
server = server_fnd[0]
|
14
20
|
server.get_server_details
|
15
|
-
|
16
|
-
env[:ui].info ('%-20s %-20s %s' % [server.name, server.state, server.smart_ipv4])
|
21
|
+
env[:machine].ui.info('%-6s %-20s %-8s %-12s %-14s %s' % [arubacloud_dc, server.name, server.id, server.state, Fog::ArubaCloud::Compute::Server::STATE_DES[server.state], server.smart_ipv4] )
|
17
22
|
end
|
23
|
+
|
24
|
+
if config.reserved_status == "other"
|
25
|
+
#
|
26
|
+
# output all info relate VM found in current DC , but not found in '.vagrant' directory
|
27
|
+
#
|
28
|
+
ll = env[:machine].name.length
|
29
|
+
ui_ext = Vagrant::UI::Prefixed.new( Vagrant::UI::Colored.new, "-".center(ll) )
|
30
|
+
if server && server.name
|
31
|
+
config.reserved_list_owned << server.name
|
32
|
+
end
|
33
|
+
server_xs = vm_in_dc.select{ |s| not (config.reserved_list_owned.include? s.name)}
|
34
|
+
server_xs.sort_by(&:name).each do |server|
|
35
|
+
server.get_server_details
|
36
|
+
ui_ext.detail('%-6s %-20s %-8s %-12s %-14s %s' % [arubacloud_dc, server.name, server.id, server.state, Fog::ArubaCloud::Compute::Server::STATE_DES[server.state], server.smart_ipv4] )
|
37
|
+
end
|
38
|
+
config.reserved_list_owned = []
|
39
|
+
else
|
40
|
+
if server && server.name
|
41
|
+
config.reserved_list_owned = server.name
|
42
|
+
else
|
43
|
+
config.reserver_list_owned = ""
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
18
47
|
@app.call(env)
|
19
48
|
end
|
20
49
|
end
|
@@ -7,10 +7,12 @@ module VagrantPlugins
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
config = env[:machine].provider_config
|
11
|
+
arubacloud_dc = config.endpoint
|
10
12
|
compute_service = env[:arubacloud_compute]
|
11
|
-
env[:ui].info ('%-40s %-60s %-20s %s' % ['Template Name', 'Description', 'ID', 'Hypervisor ID'])
|
13
|
+
env[:ui].info ('%-5s %-40s %-60s %-20s %s' % ['DC', 'Template Name', 'Description', 'ID', 'Hypervisor ID'])
|
12
14
|
compute_service.templates.sort_by(&:hypervisor).each do |template|
|
13
|
-
|
15
|
+
env[:ui].info ('%-5s %-40s %-60s %-20s %s' % [arubacloud_dc, template.name,
|
14
16
|
template.description,
|
15
17
|
template.id,
|
16
18
|
enum_hypervisor_id(template.hypervisor)])
|
@@ -24,7 +24,7 @@ module VagrantPlugins
|
|
24
24
|
server = arubacloud.servers.get(machine.id)
|
25
25
|
if server.nil?
|
26
26
|
# The machine can't be found
|
27
|
-
@logger.info("
|
27
|
+
@logger.info("Machine couldn't be found, assuming it got destroyed.")
|
28
28
|
machine.id = nil
|
29
29
|
nil
|
30
30
|
else
|
@@ -40,4 +40,4 @@ module VagrantPlugins
|
|
40
40
|
end # ReadSSHInfo
|
41
41
|
end # Action
|
42
42
|
end # ArubaCloud
|
43
|
-
end # VagrantPlugins
|
43
|
+
end # VagrantPlugins
|
@@ -13,9 +13,6 @@ module VagrantPlugins
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
16
|
-
# env[:ui].output(":machine_state_id: #{env[:machine_state_id]}")
|
17
|
-
# env[:ui].output(":arubacloud_compute: #{env[:arubacloud_compute]}")
|
18
|
-
# env[:ui].output(":machine: #{env[:machine]}")
|
19
16
|
env[:machine_state_id] = read_state(env[:arubacloud_compute], env[:machine])
|
20
17
|
@app.call(env)
|
21
18
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'vagrant/util/retryable'
|
3
|
+
require 'fog/arubacloud/error'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module ArubaCloud
|
8
|
+
module Action
|
9
|
+
# This stop a server, if it exists
|
10
|
+
class StartServer
|
11
|
+
include Vagrant::Util::Retryable
|
12
|
+
|
13
|
+
def initialize(app, env)
|
14
|
+
@app = app
|
15
|
+
@env = env
|
16
|
+
@logger = Log4r::Logger.new('vagrant_arubacloud::action::start_server')
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
if env[:machine].id
|
21
|
+
config = env[:machine].provider_config
|
22
|
+
arubacloud_dc = config.endpoint
|
23
|
+
|
24
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.starting_server'))
|
25
|
+
server = env[:arubacloud_compute].servers.get(env[:machine].id)
|
26
|
+
# Check if the vm is already powered on
|
27
|
+
@logger.debug("VM ready?: #{server.ready?}")
|
28
|
+
if server.ready?
|
29
|
+
# continue the middleware
|
30
|
+
@app.call(env)
|
31
|
+
else
|
32
|
+
# Try to power-on the VM.
|
33
|
+
begin
|
34
|
+
server.power_on
|
35
|
+
rescue Fog::ArubaCloud::Errors::VmStatus
|
36
|
+
env[:ui].warn(I18n.t('vagrant_arubacloud.bad_state'))
|
37
|
+
return
|
38
|
+
rescue Fog::ArubaCloud::Errors::RequestError => e
|
39
|
+
if e.response['ResultCode'].eql? 17
|
40
|
+
env[:ui].warn(I18n.t('vagrant_arubacloud.operation_already_in_queue'))
|
41
|
+
return
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Wait for the server to be proper started and up
|
46
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.waiting_server_powered_on'))
|
47
|
+
retryable(:tries => 40, :sleep => 2) do
|
48
|
+
server.wait_for(1) { ready? }
|
49
|
+
end
|
50
|
+
env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.server_powered_on'))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
@app.call(env)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module ArubaCloud
|
3
5
|
module Command
|
@@ -5,14 +7,40 @@ module VagrantPlugins
|
|
5
7
|
def execute
|
6
8
|
options = {}
|
7
9
|
opts = OptionParser.new do |o|
|
8
|
-
o.banner = 'Usage: vagrant arubacloud
|
10
|
+
o.banner = 'Usage: vagrant arubacloud servers [options]'
|
9
11
|
end
|
10
|
-
|
11
12
|
argv = parse_options(opts)
|
12
13
|
return unless argv
|
13
14
|
|
14
|
-
|
15
|
+
vm_count = 1
|
16
|
+
vm_list = Array.new
|
17
|
+
vm_size = 0
|
18
|
+
|
19
|
+
with_target_vms(argv, :provider => :arubacloud , :plist => '1' ) do |machine|
|
20
|
+
if vm_count == 1
|
21
|
+
ll = machine.name.length
|
22
|
+
ui_ext = Vagrant::UI::Prefixed.new( Vagrant::UI::Colored.new, " "*ll )
|
23
|
+
ui_ext.opts = { :color => :white, :bold => true }
|
24
|
+
ui_ext.detail ('%-6s %-20s %-8s %-12s %-14s %s' % ['DC', 'Server Name', ' Id ', 'State Code', 'State meaning', 'IPv4 address'])
|
25
|
+
ui_ext.detail ("-" * 80)
|
26
|
+
# vm_size : how many vm are in .vagrant directory (is default)
|
27
|
+
# status : 'owned' all VM defined in my '.vagrant' directory
|
28
|
+
machine.provider_config.reserved_status = "owned"
|
29
|
+
vm_size = machine.config.vm.defined_vm_keys.length
|
30
|
+
end
|
31
|
+
if (vm_count == vm_size)
|
32
|
+
# if last element change 'status' to 'other' to output list of all external VM in current DC
|
33
|
+
# and send list all VM's ( server.name) founds in '.vagrant' directory
|
34
|
+
machine.provider_config.reserved_status = "other"
|
35
|
+
machine.provider_config.reserved_list_owned = vm_list
|
36
|
+
end
|
37
|
+
|
15
38
|
machine.action('list_servers')
|
39
|
+
vm_count += 1
|
40
|
+
# accum in append current server-name returned by list_server only if exist
|
41
|
+
if machine.provider_config.reserved_list_owned
|
42
|
+
vm_list << machine.provider_config.reserved_list_owned
|
43
|
+
end
|
16
44
|
end
|
17
45
|
end
|
18
46
|
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'vagrant-arubacloud/action'
|
3
|
+
require 'fog/arubacloud'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Command
|
7
|
+
class Snapshot < Vagrant.plugin('2', :command)
|
8
|
+
def self.synopsis
|
9
|
+
'implement snapshot for vagrant-arubacloud '
|
10
|
+
end
|
11
|
+
def execute
|
12
|
+
options = {:snapop => nil, :namevm => nil}
|
13
|
+
myparser = OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: vagrant snapshot -t [create|delete|restore|list] -n name_server"
|
15
|
+
opts.on('-n', '--name name', 'Name server of virtual machine') do |name|
|
16
|
+
options[:namevm] = name;
|
17
|
+
end
|
18
|
+
opts.on('-t', '--type type', 'Type of snapshot : create|delete|restore|list') do |type|
|
19
|
+
options[:snapop] = type;
|
20
|
+
end
|
21
|
+
opts.on('-h', '--help', 'Displays Help') do
|
22
|
+
puts opts
|
23
|
+
return
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
myparser.parse!
|
28
|
+
|
29
|
+
if options[:namevm] == nil
|
30
|
+
puts 'Name of VM is missing'
|
31
|
+
return
|
32
|
+
end
|
33
|
+
if options[:snapop] == nil
|
34
|
+
puts "Type of action: 'create,delete,restore,list' is missing"
|
35
|
+
return
|
36
|
+
end
|
37
|
+
ck1 = ["create", "delete", "restore", "list"].include? options[:snapop]
|
38
|
+
if !ck1
|
39
|
+
puts 'Valid option type are: create,delete,restore,list '
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
not_found = true
|
44
|
+
with_target_vms( nil, :provider => :arubacloud) do |machine|
|
45
|
+
# if not machine.id....
|
46
|
+
if machine.id == nil
|
47
|
+
next
|
48
|
+
end
|
49
|
+
config1 = machine.provider_config
|
50
|
+
#if no url in config....
|
51
|
+
unless config1.url
|
52
|
+
machine.ui.info(" [dc?] " + I18n.t('vagrant_arubacloud.wrong_dc'))
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
arubacloud_dc = config1.endpoint
|
57
|
+
myprefix = "[#{arubacloud_dc}] "
|
58
|
+
params = {
|
59
|
+
:provider => :arubacloud,
|
60
|
+
:arubacloud_username => config1.arubacloud_username,
|
61
|
+
:arubacloud_password => config1.arubacloud_password,
|
62
|
+
:url => config1.url
|
63
|
+
}
|
64
|
+
|
65
|
+
envx = Fog::Compute.new params
|
66
|
+
server = envx.servers.get(machine.id)
|
67
|
+
if server.name == options[:namevm]
|
68
|
+
|
69
|
+
machine.ui.info(myprefix + I18n.t('vagrant_arubacloud.connect_to_dc'))
|
70
|
+
machine.ui.info(myprefix + I18n.t('vagrant_arubacloud.snapshot_req_type') + " '#{options[:snapop]}'" + " target id:#{machine.id}" )
|
71
|
+
not_found = false
|
72
|
+
case options[:snapop]
|
73
|
+
# output if exist date creation and date expire for snapshot
|
74
|
+
when "list"
|
75
|
+
begin
|
76
|
+
myreq = server.list_snapshot
|
77
|
+
if myreq["Success"]
|
78
|
+
machine.ui.info(myprefix + 'snapshot ' + I18n.t('vagrant_arubacloud.snapshot_info_create') + " #{myreq['credate']} " + I18n.t('vagrant_arubacloud.snapshot_info_expired') + " #{myreq['expdate']} " )
|
79
|
+
else
|
80
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_info_not_found'))
|
81
|
+
end
|
82
|
+
rescue Fog::ArubaCloud::Errors::RequestError => e
|
83
|
+
message = ''
|
84
|
+
error = nil
|
85
|
+
@logger.debug(e.inspect.to_yaml)
|
86
|
+
machine.ui.warn(myprefix + " *ERR* list response message: #{e.response.to_yaml}")
|
87
|
+
end
|
88
|
+
# creation of snapshot ....
|
89
|
+
when "create"
|
90
|
+
if server.state == Fog::ArubaCloud::Compute::Server::RUNNING
|
91
|
+
#
|
92
|
+
# if state active and request snapshot create ...
|
93
|
+
#
|
94
|
+
begin
|
95
|
+
myreq = server.create_snapshot
|
96
|
+
if myreq
|
97
|
+
machine.ui.info(myprefix + I18n.t('vagrant_arubacloud.snapshot_created'))
|
98
|
+
else
|
99
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_create_err_fog'))
|
100
|
+
end
|
101
|
+
rescue Fog::ArubaCloud::Errors::RequestError => e
|
102
|
+
message = ''
|
103
|
+
error = nil
|
104
|
+
@logger.debug(e.inspect.to_yaml)
|
105
|
+
machine.ui.warn(myprefix + " *ERROR* response message: #{e.response.to_yaml}")
|
106
|
+
#raise error
|
107
|
+
end
|
108
|
+
#
|
109
|
+
else
|
110
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_create_err_not_on'))
|
111
|
+
end
|
112
|
+
# delete of snapshot...
|
113
|
+
when "delete"
|
114
|
+
#
|
115
|
+
# if snapshot delete ...
|
116
|
+
#
|
117
|
+
begin
|
118
|
+
myreq = server.delete_snapshot
|
119
|
+
if myreq
|
120
|
+
machine.ui.info(myprefix + I18n.t('vagrant_arubacloud.snapshot_deleted'))
|
121
|
+
else
|
122
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_delete_err_fog'))
|
123
|
+
end
|
124
|
+
rescue Fog::ArubaCloud::Errors::RequestError => e
|
125
|
+
message = ''
|
126
|
+
error = nil
|
127
|
+
@logger.debug(e.inspect.to_yaml)
|
128
|
+
machine.ui.warn(myprefix + " *ERROR* response message: #{e.response.to_yaml}")
|
129
|
+
#raise error
|
130
|
+
end
|
131
|
+
# if vm is power off and esiste a snapshot resorre vm from snapshot
|
132
|
+
# (waring : the machine is not power on after restart and snapshot image is removed)
|
133
|
+
when "restore"
|
134
|
+
if server.state == Fog::ArubaCloud::Compute::Server::STOPPED
|
135
|
+
#
|
136
|
+
# if state stopped (power off) and requets restore
|
137
|
+
# WARNING : the snapshot file is removed after restore
|
138
|
+
#
|
139
|
+
begin
|
140
|
+
myreq = server.apply_snapshot
|
141
|
+
if myreq
|
142
|
+
machine.ui.info(myprefix + I18n.t('vagrant_arubacloud.snapshot_restored'))
|
143
|
+
else
|
144
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_restore_err_fog'))
|
145
|
+
end
|
146
|
+
rescue Fog::ArubaCloud::Errors::RequestError => e
|
147
|
+
message = ''
|
148
|
+
error = nil
|
149
|
+
@logger.debug(e.inspect.to_yaml)
|
150
|
+
machine.ui.warn(myprefix + " *ERROR* response message: #{e.response.to_yaml}")
|
151
|
+
#raise error
|
152
|
+
end
|
153
|
+
else
|
154
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_restore_err_not_off'))
|
155
|
+
end
|
156
|
+
|
157
|
+
else
|
158
|
+
machine.ui.warn(myprefix + I18n.t('vagrant_arubacloud.snapshot_type_unknow') + " :#{options[:snapop]}" )
|
159
|
+
end
|
160
|
+
|
161
|
+
end # test if found machine.id
|
162
|
+
|
163
|
+
end #
|
164
|
+
|
165
|
+
if not_found
|
166
|
+
puts "==> ??? [dc?] " + I18n.t("vagrant_arubacloud.snapshot_server_unknow") + " :#{options[:namevm]}"
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
|
@@ -4,7 +4,20 @@ require 'fog'
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module ArubaCloud
|
6
6
|
|
7
|
+
DC_TABLES = {
|
8
|
+
:dc1 => "https://api.dc1.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
9
|
+
:dc2 => "https://api.dc2.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
10
|
+
:dc3 => "https://api.dc3.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
11
|
+
:dc4 => "https://api.dc4.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
12
|
+
:dc5 => "https://api.dc5.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
13
|
+
:dc6 => "https://api.dc6.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json",
|
14
|
+
:dc8 => "https://api.dc8.computing.cloud.it/WsEndUser/v2.9/WsEndUser.svc/json"
|
15
|
+
}
|
16
|
+
|
17
|
+
DC_DEFAULT = "dc2"
|
18
|
+
|
7
19
|
class Config < Vagrant.plugin('2', :config)
|
20
|
+
|
8
21
|
# ArubaCloud Username
|
9
22
|
# @return [String]
|
10
23
|
attr_accessor :arubacloud_username
|
@@ -13,11 +26,19 @@ module VagrantPlugins
|
|
13
26
|
# @return [String]
|
14
27
|
attr_accessor :arubacloud_password
|
15
28
|
|
29
|
+
# reserved for internal use
|
30
|
+
attr_accessor :reserved_status
|
31
|
+
attr_accessor :reserved_list_owned
|
32
|
+
|
16
33
|
# Ws EndPoint Url
|
17
34
|
# Expected to be the url of the web service to use
|
18
35
|
# @return [String]
|
19
36
|
attr_accessor :url
|
20
37
|
|
38
|
+
# Ws EndPoint id : can be dc2,dc2,dc3,...dc8 (dc7 is not defined at this release)
|
39
|
+
# @return [String]
|
40
|
+
attr_accessor :endpoint
|
41
|
+
|
21
42
|
# The name of the server. This defaults to the name of the machine
|
22
43
|
# defined by Vagrant (via 'config.vm.define'), but can be override here.
|
23
44
|
# @return [String]
|
@@ -28,17 +49,13 @@ module VagrantPlugins
|
|
28
49
|
# @return [Integer]
|
29
50
|
attr_accessor :template_id
|
30
51
|
|
31
|
-
# The smart vm type expressed
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# @return [Integer]
|
37
|
-
attr_accessor :package_id
|
38
|
-
|
39
|
-
# The admin password of the vm (root user) .
|
52
|
+
# The smart vm type expressed as String:
|
53
|
+
# 'small'
|
54
|
+
# 'medium'
|
55
|
+
# 'large'
|
56
|
+
# 'extra large'
|
40
57
|
# @return [String]
|
41
|
-
attr_accessor :
|
58
|
+
attr_accessor :package_id
|
42
59
|
|
43
60
|
# Service Type expressed in ID [Integer]:
|
44
61
|
# 1 = Pro Hyper-V
|
@@ -70,8 +87,10 @@ module VagrantPlugins
|
|
70
87
|
def initialize
|
71
88
|
@arubacloud_username = UNSET_VALUE
|
72
89
|
@arubacloud_password = UNSET_VALUE
|
73
|
-
@admin_password = UNSET_VALUE
|
74
90
|
@url = UNSET_VALUE
|
91
|
+
@reserved_status = UNSET_VALUE
|
92
|
+
@reserved_list_owned = UNSET_VALUE
|
93
|
+
@endpoint = UNSET_VALUE
|
75
94
|
@server_name = UNSET_VALUE
|
76
95
|
@template_id = UNSET_VALUE
|
77
96
|
@package_id = UNSET_VALUE
|
@@ -84,8 +103,10 @@ module VagrantPlugins
|
|
84
103
|
def finalize!
|
85
104
|
@arubacloud_username = nil if @arubacloud_username == UNSET_VALUE
|
86
105
|
@arubacloud_password = nil if @arubacloud_password == UNSET_VALUE
|
87
|
-
@admin_password = nil if @admin_password == UNSET_VALUE
|
88
106
|
@url = nil if @url == UNSET_VALUE
|
107
|
+
@reserved_status = nil if @reserved_status = UNSET_VALUE
|
108
|
+
@reserved_list_owned = nil if @reserved_list_owned = UNSET_VALUE
|
109
|
+
@endpoint = nil if @endpoint == UNSET_VALUE
|
89
110
|
@server_name = nil if @server_name == UNSET_VALUE
|
90
111
|
@template_id = nil if @template_id == UNSET_VALUE
|
91
112
|
@package_id = nil if @package_id == UNSET_VALUE
|
@@ -101,10 +122,32 @@ module VagrantPlugins
|
|
101
122
|
# Global configurations needed by all service types
|
102
123
|
errors << I18n.t('vagrant_arubacloud.config.arubacloud_username_required') unless @arubacloud_username
|
103
124
|
errors << I18n.t('vagrant_arubacloud.config.arubacloud_password_required') unless @arubacloud_password
|
104
|
-
errors << I18n.t('vagrant_arubacloud.config.admin_password_required') unless @admin_password
|
105
125
|
errors << I18n.t('vagrant_arubacloud.config.template_id_required') unless @template_id
|
106
126
|
errors << I18n.t('vagrant_arubacloud.config.service_type_required') unless @service_type
|
107
127
|
|
128
|
+
errors << I18n.t('vagrant_arubacloud.config.ssh_password_required') unless machine.config.ssh.password
|
129
|
+
|
130
|
+
#check if coded url or endpoint
|
131
|
+
#if url not in table or dc wrong return error
|
132
|
+
if (@url)
|
133
|
+
if (DC_TABLES.key(@url))
|
134
|
+
@endpoint = DC_TABLES.key(@url)
|
135
|
+
else
|
136
|
+
errors << I18n.t('vagrant_arubacloud.config.url_is_wrong')
|
137
|
+
end
|
138
|
+
else
|
139
|
+
if (@endpoint)
|
140
|
+
if DC_TABLES.key?(@endpoint.to_sym)
|
141
|
+
@url = DC_TABLES[@endpoint.to_sym]
|
142
|
+
else
|
143
|
+
errors << I18n.t('vagrant_arubacloud.config.endpoint_is_wrong')
|
144
|
+
end
|
145
|
+
else
|
146
|
+
@endpoint = DC_DEFAULT.to_sym
|
147
|
+
@url = DC_TABLES[DC_DEFAULT.to_sym]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
108
151
|
if @service_type.eql? 4
|
109
152
|
errors << I18n.t('vagrant_arubacloud.config.package_id_required') unless @package_id
|
110
153
|
else
|
@@ -118,7 +161,7 @@ module VagrantPlugins
|
|
118
161
|
end
|
119
162
|
{'ArubaCloud Provider' => errors}
|
120
163
|
end
|
121
|
-
|
122
164
|
end # Config
|
165
|
+
|
123
166
|
end # ArubaCloud
|
124
|
-
end # VagrantPlugins
|
167
|
+
end # VagrantPlugins
|